Skip to contents

Computes the reduced QR decomposition of a matrix operand: $$A = Q R,$$ where \(Q\) has orthonormal columns (\(Q^\top Q = I\)) and \(R\) is upper triangular. For an \(m \times n\) input with \(k = \min(m, n)\), \(Q\) has shape \(m \times k\) and \(R\) has shape \(k \times n\).

Usage

nv_qr(operand)

# S3 method for class 'AnvlArray'
qr(x, ...)

Arguments

operand

(arrayish)
Matrix of data type floating-point with exactly 2 dimensions.

x

(arrayish)
Same as operand; this is the name used by the base R S3 generic.

...

No additional arguments.

Value

Named list with elements Q (shape (m, k)) and R (shape (k, n)), where (m, n) = shape(operand) and k = min(m, n). Both have the same data type as operand.

See also

Examples

x <- nv_matrix(c(1, 2, 3, 4, 5, 6), nrow = 3, dtype = "f32")
nv_qr(x)
#> $Q
#> AnvlArray
#>  -0.2673  0.8729
#>  -0.5345  0.2182
#>  -0.8018 -0.4364
#> [ CPUf32{3,2} ] 
#> 
#> $R
#> AnvlArray
#>  -3.7417 -8.5524
#>   0.0000  1.9640
#> [ CPUf32{2,2} ] 
#>