Code
# Create a random 100x50 matrix
X <- matrix(rnorm(5000), 100, 50)
# Compute thin QR decomposition
result <- bdQR(X, thin = TRUE)
# Verify the decomposition
# Should be approximately zero
max(abs(X - result$Q %*% result$R))LINEAR_ALGEBRA
Computes the QR decomposition (also called QR factorization) of a matrix A into a product A = QR where Q is an orthogonal matrix and R is an upper triangular matrix. This function operates on in-memory matrices.
| Parameter | Description |
|---|---|
X |
A real matrix or vector to be decomposed |
thin |
Logical. If TRUE, returns the reduced (thin) Q matrix. If FALSE (default), returns the full Q matrix. The thin decomposition is more memory efficient. |
block_size |
Integer. Optional block size for blocked computation. Larger blocks may improve performance but require more memory. |
threads |
Integer. Optional number of threads for parallel computation. If NULL, uses all available threads. |
A list containing: * Q: The orthogonal matrix Q * R: The upper triangular matrix R
The QR decomposition is a fundamental matrix factorization that decomposes a matrix into an orthogonal matrix Q and an upper triangular matrix R. This implementation: - Supports both thin and full QR decomposition - Can utilize parallel computation for better performance - Handles both matrix and vector inputs
bdQR_hdf5 for QR decomposition of HDF5-stored matrices
---
title: "bdQR"
subtitle: "bdQR"
---
<span class="category-badge linear_algebra">LINEAR_ALGEBRA</span>
## Description
Computes the QR decomposition (also called QR factorization) of a matrix A into
a product A = QR where Q is an orthogonal matrix and R is an upper triangular matrix.
This function operates on in-memory matrices.
## Usage
```r
bdQR(X, thin = NULL, block_size = NULL, threads = NULL)
```
## Arguments
::: {.param-table}
| Parameter | Description |
|-----------|-------------|
| `X` | A real matrix or vector to be decomposed |
| `thin` | Logical. If TRUE, returns the reduced (thin) Q matrix. If FALSE (default), returns the full Q matrix. The thin decomposition is more memory efficient. |
| `block_size` | Integer. Optional block size for blocked computation. Larger blocks may improve performance but require more memory. |
| `threads` | Integer. Optional number of threads for parallel computation. If NULL, uses all available threads. |
:::
## Value
::: {.return-value}
A list containing:
* Q: The orthogonal matrix Q
* R: The upper triangular matrix R
:::
## Details
The QR decomposition is a fundamental matrix factorization that decomposes a matrix
into an orthogonal matrix Q and an upper triangular matrix R. This implementation:
- Supports both thin and full QR decomposition
- Can utilize parallel computation for better performance
- Handles both matrix and vector inputs
## Examples
```{r}
#| eval: false
#| code-fold: show
# Create a random 100x50 matrix
X <- matrix(rnorm(5000), 100, 50)
# Compute thin QR decomposition
result <- bdQR(X, thin = TRUE)
# Verify the decomposition
# Should be approximately zero
max(abs(X - result$Q %*% result$R))
```
## See Also
::: {.see-also}
[bdQR_hdf5](../hdf5_algebra/bdQR_hdf5.html) for QR decomposition of HDF5-stored matrices
:::