View source: R/gen-namespace.R
| torch_qr | R Documentation |
Qr
torch_qr(self, some = TRUE)
self |
(Tensor) the input tensor of size |
some |
(bool, optional) Set to |
Computes the QR decomposition of a matrix or a batch of matrices input,
and returns a namedtuple (Q, R) of tensors such that \mbox{input} = Q R
with Q being an orthogonal matrix or batch of orthogonal matrices and
R being an upper triangular matrix or batch of upper triangular matrices.
If some is TRUE, then this function returns the thin (reduced) QR factorization.
Otherwise, if some is FALSE, this function returns the complete QR factorization.
precision may be lost if the magnitudes of the elements of input
are large
While it should always give you a valid decomposition, it may not give you the same one across platforms - it will depend on your LAPACK implementation.
if (torch_is_installed()) {
a = torch_tensor(matrix(c(12., -51, 4, 6, 167, -68, -4, 24, -41), ncol = 3, byrow = TRUE))
out = torch_qr(a)
q = out[[1]]
r = out[[2]]
torch_mm(q, r)$round()
torch_mm(q$t(), q)$round()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.