dpnp.linalg.matrix_rank
- dpnp.linalg.matrix_rank(A, tol=None, hermitian=False, *, rtol=None)[source]
Return matrix rank of array using SVD method.
Rank of the array is the number of singular values of the array that are greater than tol.
- Parameters:
A ({(M,), (..., M, N)} {dpnp.ndarray, usm_ndarray}) -- Input vector or stack of matrices.
tol ((...) {None, float, dpnp.ndarray, usm_ndarray}, optional) -- Threshold below which SVD values are considered zero. Only tol or rtol can be set at a time. If none of them are provided, defaults to
S.max() * max(M, N) * eps
where S is an array with singular values for A, and eps is the epsilon value for datatype of S. Default:None
.hermitian (bool, optional) -- If
True
, A is assumed to be Hermitian (symmetric if real-valued), enabling a more efficient method for finding singular values. Default:False
.rtol ((...) {None, float, dpnp.ndarray, usm_ndarray}, optional) -- Parameter for the relative tolerance component. Only tol or rtol can be set at a time. If none of them are provided, defaults to
max(M, N) * eps
where eps is the epsilon value for datatype of S (an array with singular values for A). Default:None
.
- Returns:
rank -- Rank of A.
- Return type:
(...) dpnp.ndarray
See also
dpnp.linalg.svd
Singular Value Decomposition.
Examples
>>> import dpnp as np >>> from dpnp.linalg import matrix_rank >>> matrix_rank(np.eye(4)) # Full rank matrix array(4) >>> I=np.eye(4); I[-1,-1] = 0. # rank deficient matrix >>> matrix_rank(I) array(3) >>> matrix_rank(np.ones((4,))) # 1 dimension - rank 1 unless all 0 array(1) >>> matrix_rank(np.zeros((4,))) array(0)