Computes the QR decomposition of a matrix input, and returns matrices Q and R such that $input = QR$, with QQ being an orthogonal matrix and RR being an upper triangular matrix.

tch_qr(x)

Arguments

x

tensor object

Details

This returns the thin (reduced) QR factorization.

Examples

x <- tensor(matrix(runif(16), ncol = 4)) tch_qr(x)
#> [[1]] #> tensor #> -0.1476 0.7844 -0.5595 -0.2232 #> -0.7923 0.0812 0.4731 -0.3767 #> -0.5265 -0.5149 -0.6532 0.1760 #> -0.2708 0.3361 0.1909 0.8816 #> [ Variable[CPUFloatType]{4,4} ] #> #> [[2]] #> tensor #> -1.1657 -1.0536 -0.6330 -0.6298 #> 0.0000 0.8340 0.2082 -0.0984 #> 0.0000 0.0000 0.2308 -0.5939 #> 0.0000 0.0000 0.0000 0.1678 #> [ Variable[CPUFloatType]{4,4} ] #>