These functions mimic the functions eigen
,svd
,chol
to operate on gpu.matrix-class objects:
'eigen'
mimics the base function 'eigen'
that "computes the eigenvalues and eigenvectors of a numeric (double, integer, logical) or complex matrix."
'svd'
mimics the base function 'svd'
that "computes the singular-value decomposition of a rectangular matrix."
'chol'
mimics the base function 'chol'
that "computes Compute the Cholesky factorization of a real symmetric positive-definite square matrix."
# S4 method for gpu.matrix.tensorflow
eigen(x)
# S4 method for gpu.matrix.torch
eigen(x)# S4 method for gpu.matrix.tensorflow
svd(x)
# S4 method for gpu.matrix.torch
svd(x)
# S4 method for gpu.matrix.tensorflow
chol(x)
# S4 method for gpu.matrix.torch
chol(x)
The output of these functions correspond to their equivalent base functions:
eigen
mimics the base function eigen
that computes the eigenvalues and eigenvectors of a numeric (double, integer, logical) or complex matrix. It returns a list with the following items:
a vector with the P
eigenvalues of x
the eigenvectors of x
svd
mimics the base function svd
that computes the singular-value decomposition of a rectangular matrix. It returns a list with the following items:
a vector containing the singular values of x
a matrix whose columns contain the left singular vectors of x
a matrix whose columns contain the right singular vectors of x
chol
mimics the base function chol
that computes Compute the Cholesky factorization of a real symmetric positive-definite square matrix. It returns a gpu.matrix-class object with The upper triangular factor of the Cholesky decomposition, i.e., the matrix \(R\) such that \(R'R = X\).
a gpu.matrix
. X
must fulfil certain characteristics depending on the function to be called (see details).
These functions mimic the behaviour of their respective 'base' functions.
In the case of the eigen
function, the input value can be a numeric or complex gpu.matrix class.
For svd
function, the input value could be a numeric or complex gpu.matrix-class object.
For chol
function, the input must be a positive-definite squere matrix.
Internally, these functions call its corresponding function of the tensorflow or torch library 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
.
# \donttest{
if (FALSE) {
a <- gpu.matrix(rnorm(9),3,3)
ein <- eigen(a) #eigenvalues and eigenvectors
svd_return <- svd(a) #svd of gpu.matrix a
ata <- tcrossprod(a)
#ata is a real symmetric positive-definite square matrix.
chol(ata) #cholesky decomposition.
}
# }
Run the code above in your browser using DataLab