The matrix rank is computed as the number of singular values
(or eigenvalues in absolute value when hermitian = TRUE
)
that are greater than the specified tol
threshold.
linalg_matrix_rank(
A,
...,
atol = NULL,
rtol = NULL,
tol = NULL,
hermitian = FALSE
)
(Tensor): tensor of shape (*, m, n)
where *
is zero or more
batch dimensions.
Not currently used.
the absolute tolerance value. When NULL
it’s considered to be zero.
the relative tolerance value. See above for the value it takes when NULL
.
(float, Tensor, optional): the tolerance value. See above for
the value it takes when NULL
. Default: NULL
.
(bool, optional): indicates whether A
is Hermitian if complex
or symmetric if real. Default: FALSE
.
Supports input of float, double, cfloat and cdouble dtypes.
Also supports batches of matrices, and if A
is a batch of matrices then
the output has the same batch dimensions.
If hermitian = TRUE
, A
is assumed to be Hermitian if complex or
symmetric if real, but this is not checked internally. Instead, just the lower
triangular part of the matrix is used in the computations.
If tol
is not specified and A
is a matrix of dimensions (m, n)
,
the tolerance is set to be
torch:::math_to_rd(" tol = \\sigma_1 \\max(m, n) \\varepsilon ")
where is the largest singular value
(or eigenvalue in absolute value when hermitian = TRUE
), and
is the epsilon value for the dtype of A
(see torch_finfo()
).
If A
is a batch of matrices, tol
is computed this way for every element of
the batch.
Other linalg:
linalg_cholesky_ex()
,
linalg_cholesky()
,
linalg_det()
,
linalg_eigh()
,
linalg_eigvalsh()
,
linalg_eigvals()
,
linalg_eig()
,
linalg_householder_product()
,
linalg_inv_ex()
,
linalg_inv()
,
linalg_lstsq()
,
linalg_matrix_norm()
,
linalg_matrix_power()
,
linalg_multi_dot()
,
linalg_norm()
,
linalg_pinv()
,
linalg_qr()
,
linalg_slogdet()
,
linalg_solve()
,
linalg_svdvals()
,
linalg_svd()
,
linalg_tensorinv()
,
linalg_tensorsolve()
,
linalg_vector_norm()
if (torch_is_installed()) {
a <- torch_eye(10)
linalg_matrix_rank(a)
}
Run the code above in your browser using DataLab