Computes the singular value decomposition of a numeric matrix using the Eigen C++ template library.
The vectors
character argument determines whether to compute no left and right singular vectors ('none'
), thinned left and right singular vectors ('thin'
), or full left and right singular vectors ('full'
). For a
matrix x
with dimensions n
and p
, setting vectors = 'thin'
will does the following (quoted from eigen website):
In case of a rectangular n-by-p matrix, letting m be the smaller value among n and p, there are only m singular vectors;
the remaining columns of U and V do not correspond to actual singular vectors.
Asking for thin U or V means asking for only their m first columns to be formed.
So U is then a n-by-m matrix, and V is then a p-by-m matrix.
Notice that thin U and V are all you need for (least squares) solving.
Setting vectors = 'full'
will compute full matrices for U and V, so that U will be of size n-by-n, and V will be of size p-by-p.
In a nimbleFunction
, svd
is identical to nimSvd
.
returnType(svdNimbleList())
can be used within a link{nimbleFunction}
to specify that the function will return a nimbleList
generated by the nimSvd
function. svdNimbleList()
can also be used to define a nested nimbleList
element. See the User Manual for usage examples.