dpnp.linalg.matrix_rank
- dpnp.linalg.matrix_rank(A, tol=None, hermitian=False)[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 ((...) {float, dpnp.ndarray, usm_ndarray}, optional) -- Threshold below which SVD values are considered zero. If tol is
None
, andS
is an array with singular values for M, andeps
is the epsilon value for datatype ofS
, then tol is set toS.max() * max(M.shape) * eps
. 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
.
- 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)