Skip to contents

Mirrors the C# QRDecomposition class (Householder reflections): decomposes the M x N matrix a into an M x M orthogonal matrix q and an M x N upper triangular matrix r such that q %*% r reproduces a. The C# RMatrix property is named r here (R has no naming collision in this package, unlike in the C# codebase).

Usage

qr_decomposition(a)

Arguments

a

a numeric matrix, M x N.

Value

a list with elements q (M x M) and r (M x N).

Examples

a <- matrix(c(1, 0, 2, 1, 2, 5, 1, 5, -1), nrow = 3)
qr <- qr_decomposition(a)
qr$q %*% qr$r  # reproduces a
#>              [,1] [,2] [,3]
#> [1,] 1.000000e+00    1    1
#> [2,] 1.236979e-16    2    5
#> [3,] 2.000000e+00    5   -1