qr_decomposition {GPUmatrix} | R Documentation |
The QR Decomposition of a GPUmatrix object
Description
These functions mimic the base qr
family functions to operate on gpu.matrix-class objects.
Usage
## S4 method for signature 'gpu.matrix.tensorflow'
qr(x,...)
## S4 method for signature 'gpu.matrix.torch'
qr(x,...)
## S4 method for signature 'list'
qr.Q(qr,complete,Dvec)
## S4 method for signature 'list'
qr.R(qr,complete)
## S4 method for signature 'list'
qr.X(qr,complete)
## S4 method for signature 'list'
qr.coef(qr,y)
## S4 method for signature 'list'
qr.qy(qr,y)
## S4 method for signature 'list'
qr.qty(qr,y)
## S4 method for signature 'list'
qr.resid(qr,y)
## S4 method for signature 'ANY,gpu.matrix.tensorflow'
qr.solve(a,b)
## S4 method for signature 'ANY,gpu.matrix.torch'
qr.solve(a,b)
## S4 method for signature 'gpu.matrix.tensorflow,ANY'
qr.solve(a,b)
## S4 method for signature 'gpu.matrix.tensorflow,gpu.matrix.tensorflow'
qr.solve(a,b)
## S4 method for signature 'gpu.matrix.torch,ANY'
qr.solve(a,b)
## S4 method for signature 'gpu.matrix.torch,gpu.matrix.torch'
qr.solve(a,b)
## S4 method for signature 'list,ANY'
qr.solve(a,b)
Arguments
x |
a |
y , b |
a |
... |
further arguments passed to or from other methods. |
qr |
a list resulting from the application of the function |
complete |
The same as in 'base' function |
Dvec |
The same as in 'base' function |
a |
a |
Details
The function qr
internally calls the corresponding function of the library torch or tensorflow (depending on the type of input gpu.matrix-class).
The QR decomposition can be used to solve the equation Ax=b
for a given matrix A, and a vector of observations b. In this context, the functions qr.coef
, and qr.resid
return the coefficients, and residuals values. Moreover, the functions qr.qy
, and qr.qty
returns Q %*% y
and Q %*% t(y)
.
Note that if parameter complete
is TRUE then an arbitrary orthogonal completion of the X and Q matrix or wheter the R matrix is to be completed by binding zero-value rows beneath the square upper triangle.
The function solve.qr
solves the system of equations Ax=b
via the QR decomposition. This function internally calls the corresponding function of the library torch or tensorflow (depending on the type of input gpu.matrix-class).
If the input gpu.matrix-class object(s) are stored on the GPU, then the operations will be performed on the GPU. See gpu.matrix
.
Value
The function qr
returns a list with the following items:
q |
The corresponding complete matrix |
r |
The corresponding complete matrix |
x |
The matrix |
Please note that the output returned by this function is different from the 'base' function qr
, which returns an object of the 'qr' class.
After performing a QR decomposition on a matrix A, given the resulting object, the functions qr.X
, qr.Q
, and qr.R
return the original matrix A, the matrix Q, and the matrix R respectively. The returned matrices are gpu.matrix-class objects.
The functions qr.coef
and qr.resid
return the coefficients and residuals when fitting the equation Ax=b
. In this context, the functions qr.qy
, and qr.qty
returns Q %*% y
and Q %*% t(y)
. The resulting vectors are objects of the class gpu.matrix.
The function qr.solve
returns a gpu.matrix-class object containing the coefficients of the solution of the system of equations Ax=b
by QR decomposition.
See Also
See qr
, linalg_qr
, torch_triangular_solve
Examples
## Not run:
## overdetermined system
A <- gpu.matrix(runif(12),nrow = 4)
b <- gpu.matrix(rnorm(4),ncol=1)
qr.solve(a = A, b)
qr_gpu <- qr(A)
qr.solve(a=qr_gpu,b)
qr.coef(qr = qr_gpu,b)
qr.resid(qr = qr_gpu,b)
qr.qty(qr = qr_gpu,b)
qr.qy(qr = qr_gpu,b)
qr.X(qr = qr_gpu,complete = T)
qr.Q(qr = qr_gpu,complete = T)
qr.R(qr = qr_gpu,complete = T)
## underdetermined system
A <- gpu.matrix(runif(12),nrow = 3)
b <- gpu.matrix(rnorm(3),ncol=1)
qr.solve(a = A, b)
qr_gpu <- qr(A)
qr.solve(a=qr_gpu,b)
qr.coef(qr = qr_gpu,b)
qr.resid(qr = qr_gpu,b)
qr.qty(qr = qr_gpu,b)
qr.qy(qr = qr_gpu,b)
qr.X(qr = qr_gpu,complete = T)
qr.Q(qr = qr_gpu,complete = T)
qr.R(qr = qr_gpu,complete = T)
## End(Not run)