matrix_rank¶
- matrix_rank(x: array, /, *, rtol: float | array | None = None) array ¶
Returns the rank (i.e., number of non-zero singular values) of a matrix (or a stack of matrices).
- Parameters:
x (array) – input array having shape
(..., M, N)
and whose innermost two dimensions formMxN
matrices. Should have a floating-point data type.rtol (Optional[Union[float, array]]) – relative tolerance for small singular values. Singular values approximately less than or equal to
rtol * largest_singular_value
are set to zero. If afloat
, the value is equivalent to a zero-dimensional array having a floating-point data type determined by Type Promotion Rules (as applied tox
) and must be broadcast against each matrix. If anarray
, must have a floating-point data type and must be compatible withshape(x)[:-2]
(see Broadcasting). IfNone
, the default value ismax(M, N) * eps
, whereeps
must be the machine epsilon associated with the floating-point data type determined by Type Promotion Rules (as applied tox
). Default:None
.
- Returns:
out (array) – an array containing the ranks. The returned array must have a floating-point data type determined by Type Promotion Rules and must have shape
(...)
(i.e., must have a shape equal toshape(x)[:-2]
).