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.
Arguments
- A
(Tensor): tensor of shape
(*, m, n)
where*
is zero or more batch dimensions.- ...
Not currently used.
- atol
the absolute tolerance value. When
NULL
it’s considered to be zero.- rtol
the relative tolerance value. See above for the value it takes when
NULL
.- tol
(float, Tensor, optional): the tolerance value. See above for the value it takes when
NULL
. Default:NULL
.- hermitian
(bool, optional): indicates whether
A
is Hermitian if complex or symmetric if real. Default:FALSE
.
Details
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
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.
See also
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_triangular()
,
linalg_solve()
,
linalg_svdvals()
,
linalg_svd()
,
linalg_tensorinv()
,
linalg_tensorsolve()
,
linalg_vector_norm()
Examples
if (torch_is_installed()) {
a <- torch_eye(10)
linalg_matrix_rank(a)
}
#> torch_tensor
#> 10
#> [ CPULongType{} ]