9999]
100100
101101
102- def cholesky (a , upper = False ):
102+ def cholesky (a , / , * , upper = False ):
103103 """
104104 Cholesky decomposition.
105105
@@ -1062,7 +1062,7 @@ def matrix_power(a, n):
10621062 return dpnp_matrix_power (a , n )
10631063
10641064
1065- def matrix_rank (A , tol = None , hermitian = False ):
1065+ def matrix_rank (A , tol = None , hermitian = False , * , rtol = None ):
10661066 """
10671067 Return matrix rank of array using SVD method.
10681068
@@ -1073,21 +1073,27 @@ def matrix_rank(A, tol=None, hermitian=False):
10731073 ----------
10741074 A : {(M,), (..., M, N)} {dpnp.ndarray, usm_ndarray}
10751075 Input vector or stack of matrices.
1076- tol : (...) {float, dpnp.ndarray, usm_ndarray}, optional
1077- Threshold below which SVD values are considered zero. If `tol` is
1078- ``None``, and ``S`` is an array with singular values for `M`, and
1079- ``eps`` is the epsilon value for datatype of ``S``, then `tol ` is
1080- set to ``S.max() * max(M.shape) * eps` `.
1076+ tol : (...) {None, float, dpnp.ndarray, usm_ndarray}, optional
1077+ Threshold below which SVD values are considered zero. Only `tol` or
1078+ `rtol` can be set at a time. If none of them are provided, defaults
1079+ to ``S.max() * max(M, N) * eps`` where `S ` is an array with singular
1080+ values for `A`, and `eps` is the epsilon value for datatype of `S `.
10811081 Default: ``None``.
10821082 hermitian : bool, optional
10831083 If ``True``, `A` is assumed to be Hermitian (symmetric if real-valued),
10841084 enabling a more efficient method for finding singular values.
10851085 Default: ``False``.
1086+ rtol : (...) {None, float, dpnp.ndarray, usm_ndarray}, optional
1087+ Parameter for the relative tolerance component. Only `tol` or `rtol`
1088+ can be set at a time. If none of them are provided, defaults to
1089+ ``max(M, N) * eps`` where `eps` is the epsilon value for datatype
1090+ of `S` (an array with singular values for `A`).
1091+ Default: ``None``.
10861092
10871093 Returns
10881094 -------
10891095 rank : (...) dpnp.ndarray
1090- Rank of A .
1096+ Rank of `A` .
10911097
10921098 See Also
10931099 --------
@@ -1114,8 +1120,12 @@ def matrix_rank(A, tol=None, hermitian=False):
11141120 dpnp .check_supported_arrays_type (
11151121 tol , scalar_type = True , all_scalars = True
11161122 )
1123+ if rtol is not None :
1124+ dpnp .check_supported_arrays_type (
1125+ rtol , scalar_type = True , all_scalars = True
1126+ )
11171127
1118- return dpnp_matrix_rank (A , tol = tol , hermitian = hermitian )
1128+ return dpnp_matrix_rank (A , tol = tol , hermitian = hermitian , rtol = rtol )
11191129
11201130
11211131def matrix_transpose (x , / ):
@@ -1456,7 +1466,7 @@ def outer(x1, x2, /):
14561466 return dpnp .outer (x1 , x2 )
14571467
14581468
1459- def pinv (a , rcond = 1e-15 , hermitian = False ):
1469+ def pinv (a , rcond = None , hermitian = False , * , rtol = None ):
14601470 """
14611471 Compute the (Moore-Penrose) pseudo-inverse of a matrix.
14621472
@@ -1469,20 +1479,27 @@ def pinv(a, rcond=1e-15, hermitian=False):
14691479 ----------
14701480 a : (..., M, N) {dpnp.ndarray, usm_ndarray}
14711481 Matrix or stack of matrices to be pseudo-inverted.
1472- rcond : { float, dpnp.ndarray, usm_ndarray}, optional
1482+ rcond : (...) {None, float, dpnp.ndarray, usm_ndarray}, optional
14731483 Cutoff for small singular values.
14741484 Singular values less than or equal to ``rcond * largest_singular_value``
14751485 are set to zero. Broadcasts against the stack of matrices.
1476- Default: ``1e-15``.
1486+ Only `rcond` or `rtol` can be set at a time. If none of them are
1487+ provided, defaults to ``max(M, N) * dpnp.finfo(a.dtype).eps``.
1488+ Default: ``None``.
14771489 hermitian : bool, optional
14781490 If ``True``, a is assumed to be Hermitian (symmetric if real-valued),
14791491 enabling a more efficient method for finding singular values.
14801492 Default: ``False``.
1493+ rtol : (...) {None, float, dpnp.ndarray, usm_ndarray}, optional
1494+ Same as `rcond`, but it's an Array API compatible parameter name.
1495+ Only `rcond` or `rtol` can be set at a time. If none of them are
1496+ provided, defaults to ``max(M, N) * dpnp.finfo(a.dtype).eps``.
1497+ Default: ``None``.
14811498
14821499 Returns
14831500 -------
14841501 out : (..., N, M) dpnp.ndarray
1485- The pseudo-inverse of a .
1502+ The pseudo-inverse of `a` .
14861503
14871504 Examples
14881505 --------
@@ -1493,17 +1510,24 @@ def pinv(a, rcond=1e-15, hermitian=False):
14931510 >>> a = np.random.randn(9, 6)
14941511 >>> B = np.linalg.pinv(a)
14951512 >>> np.allclose(a, np.dot(a, np.dot(B, a)))
1496- array([ True] )
1513+ array(True)
14971514 >>> np.allclose(B, np.dot(B, np.dot(a, B)))
1498- array([ True] )
1515+ array(True)
14991516
15001517 """
15011518
15021519 dpnp .check_supported_arrays_type (a )
1503- dpnp .check_supported_arrays_type (rcond , scalar_type = True , all_scalars = True )
1520+ if rcond is not None :
1521+ dpnp .check_supported_arrays_type (
1522+ rcond , scalar_type = True , all_scalars = True
1523+ )
1524+ if rtol is not None :
1525+ dpnp .check_supported_arrays_type (
1526+ rtol , scalar_type = True , all_scalars = True
1527+ )
15041528 assert_stacked_2d (a )
15051529
1506- return dpnp_pinv (a , rcond = rcond , hermitian = hermitian )
1530+ return dpnp_pinv (a , rcond = rcond , hermitian = hermitian , rtol = rtol )
15071531
15081532
15091533def qr (a , mode = "reduced" ):
0 commit comments