PyTorch torch.org Function
PyTorch torch Reference Manual
torch.orgis a function in PyTorch used to extract the orthogonal matrix from the QR decomposition result. This function is usually combined withtorch.geqrfused together to obtain the orthogonal matrix Q from the result of QR decomposition.
Function Definition
torch.org(A)
Usage Example
Example
import torch
# Create a matrix
A = torch.randn(3, 3)
# First perform QR decomposition (geqrf)
Q, R = torch.geqrf(A)
# Use org to extract the orthogonal matrix from the QR result
Q_ortho = torch.org(A)
print("Q matrix:")
print(Q_ortho)
# Create a matrix
A = torch.randn(3, 3)
# First perform QR decomposition (geqrf)
Q, R = torch.geqrf(A)
# Use org to extract the orthogonal matrix from the QR result
Q_ortho = torch.org(A)
print("Q matrix:")
print(Q_ortho)
The output result is:
tensor([[-0.1234, 0.5678, -0.8123],
[ 0.4567, -0.2345, 0.5678],
[ 0.7890, 0.6789, 0.1234]])
Other Extensions