|
83 | 83 | "qr",
|
84 | 84 | "solve",
|
85 | 85 | "svd",
|
| 86 | + "svdvals", |
86 | 87 | "slogdet",
|
87 | 88 | "tensorinv",
|
88 | 89 | "tensorsolve",
|
@@ -1315,6 +1316,62 @@ def svd(a, full_matrices=True, compute_uv=True, hermitian=False):
|
1315 | 1316 | return dpnp_svd(a, full_matrices, compute_uv, hermitian)
|
1316 | 1317 |
|
1317 | 1318 |
|
| 1319 | +def svdvals(x, /): |
| 1320 | + """ |
| 1321 | + Returns the singular values of a matrix (or a stack of matrices) ``x``. |
| 1322 | +
|
| 1323 | + When ``x`` is a stack of matrices, the function will compute |
| 1324 | + the singular values for each matrix in the stack. |
| 1325 | +
|
| 1326 | + Calling ``dpnp.linalg.svdvals(x)`` to get singular values is the same as |
| 1327 | + ``dpnp.linalg.svd(x, compute_uv=False, hermitian=False)``. |
| 1328 | +
|
| 1329 | + For full documentation refer to :obj:`numpy.linalg.svdvals`. |
| 1330 | +
|
| 1331 | + Parameters |
| 1332 | + ---------- |
| 1333 | + x : (..., M, N) {dpnp.ndarray, usm_ndarray} |
| 1334 | + Input array with ``x.ndim >= 2`` and whose last two dimensions |
| 1335 | + form matrices on which to perform singular value decomposition. |
| 1336 | +
|
| 1337 | + Returns |
| 1338 | + ------- |
| 1339 | + out : (..., K) dpnp.ndarray |
| 1340 | + Vector(s) of singular values of length K, where K = min(M, N). |
| 1341 | +
|
| 1342 | +
|
| 1343 | + See Also |
| 1344 | + -------- |
| 1345 | + :obj:`dpnp.linalg.svd` : Compute the singular value decomposition. |
| 1346 | +
|
| 1347 | +
|
| 1348 | + Examples |
| 1349 | + -------- |
| 1350 | + >>> import dpnp as np |
| 1351 | + >>> a = np.array([[3, 0], [0, 4]]) |
| 1352 | + >>> np.linalg.svdvals(a) |
| 1353 | + array([4., 3.]) |
| 1354 | +
|
| 1355 | + This is equivalent to calling: |
| 1356 | +
|
| 1357 | + >>> np.linalg.svd(a, compute_uv=False, hermitian=False) |
| 1358 | + array([4., 3.]) |
| 1359 | +
|
| 1360 | + Stack of matrices: |
| 1361 | +
|
| 1362 | + >>> b = np.array([[[6, 0], [0, 8]], [[9, 0], [0, 12]]]) |
| 1363 | + >>> np.linalg.svdvals(b) |
| 1364 | + array([[ 8., 6.], |
| 1365 | + [12., 9.]]) |
| 1366 | +
|
| 1367 | + """ |
| 1368 | + |
| 1369 | + dpnp.check_supported_arrays_type(x) |
| 1370 | + assert_stacked_2d(x) |
| 1371 | + |
| 1372 | + return dpnp_svd(x, full_matrices=True, compute_uv=False, hermitian=False) |
| 1373 | + |
| 1374 | + |
1318 | 1375 | def slogdet(a):
|
1319 | 1376 | """
|
1320 | 1377 | Compute the sign and (natural) logarithm of the determinant of an array.
|
|
0 commit comments