% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/S3_factorizations.R
\name{qr.HDF5Matrix}
\alias{qr.HDF5Matrix}
\title{QR decomposition of an HDF5Matrix}
\usage{
\method{qr}{HDF5Matrix}(
  x,
  thin = FALSE,
  block_size = NULL,
  overwrite = FALSE,
  threads = -1L,
  method = "auto",
  compression = NULL,
  ...
)
}
\arguments{
\item{x}{An \code{HDF5Matrix}.}

\item{thin}{Logical. Compute thin (economy) QR.  Default \code{FALSE}.
For \code{method = "tsqr"} this is strongly recommended; full Q via TSQR
requires an expensive basis-completion step (O(m² k)).}

\item{block_size}{Integer or NULL. Row-block size hint for TSQR; ignored by
\code{method = "lapack"}.  NULL = auto.}

\item{overwrite}{Logical. Overwrite existing results.  Default \code{FALSE}.}

\item{threads}{Integer. OpenMP threads (-1 = auto, CRAN-compliant).
For \code{method = "lapack"} controls Eigen BLAS threads.
For \code{method = "tsqr"} controls the OpenMP block loop.}

\item{method}{Character. Algorithm selection:
\describe{
\item{"auto"}{Default. Selects TSQR when m > 5n AND m > 1000
(tall-skinny), LAPACK otherwise.}
\item{"lapack"}{Eigen HouseholderQR. Reliable for any matrix shape.}
\item{"tsqr"}{Parallel Tall-Skinny QR. Requires m >= n.
Efficient for big-omics tall matrices (e.g. samples × features).
The R factor is mathematically equivalent to LAPACK R (up to sign).
The Q factor is a valid orthogonal matrix but differs from LAPACK Q.}
}}

\item{compression}{Integer (0-9) or NULL. gzip compression level for the
result datasets.  NULL uses the global option set by
\code{\link{hdf5matrix_options}} (default 6).  Use \code{0} to disable
compression (faster for benchmarks).}

\item{...}{Ignored (for S3 compatibility).}
}
\value{
Named list: \code{Q} (\code{HDF5Matrix}), \code{R} (\code{HDF5Matrix}).
}
\description{
Computes A = Q R block-wise on disk and returns Q and R as
\code{HDF5Matrix} objects.
}
\note{
20260304: Added \code{method} parameter and TSQR support.
}
\examples{
\donttest{

tmp <- tempfile(fileext = ".h5")

X  <- hdf5_create_matrix(tmp, "data/A", data = matrix(rnorm(10000), 100, 100))

X   <- hdf5_matrix(tmp, "data/A")

# Default (auto method)
res <- qr(X)
dim(res$Q)   # m x m  (or m x min(m,n) if thin = TRUE)
dim(res$R)   # m x n  (or min(m,n) x n)

# Explicit TSQR for a tall-skinny matrix (recommended: thin = TRUE)

hdf5_close_all()
unlink(tmp)

}

}
