Compute a function of the singular values of the 2-D matrices in `x`. This is a private utility function used by `numpy.linalg.norm()`. Parameters ---------- x : ndarray row_axis, col_axis : int The axes of `x` that hold the 2-D matrices. op : callable This
(x, row_axis, col_axis, op)
| 2349 | |
| 2350 | |
| 2351 | def _multi_svd_norm(x, row_axis, col_axis, op): |
| 2352 | """Compute a function of the singular values of the 2-D matrices in `x`. |
| 2353 | |
| 2354 | This is a private utility function used by `numpy.linalg.norm()`. |
| 2355 | |
| 2356 | Parameters |
| 2357 | ---------- |
| 2358 | x : ndarray |
| 2359 | row_axis, col_axis : int |
| 2360 | The axes of `x` that hold the 2-D matrices. |
| 2361 | op : callable |
| 2362 | This should be either numpy.amin or `numpy.amax` or `numpy.sum`. |
| 2363 | |
| 2364 | Returns |
| 2365 | ------- |
| 2366 | result : float or ndarray |
| 2367 | If `x` is 2-D, the return values is a float. |
| 2368 | Otherwise, it is an array with ``x.ndim - 2`` dimensions. |
| 2369 | The return values are either the minimum or maximum or sum of the |
| 2370 | singular values of the matrices, depending on whether `op` |
| 2371 | is `numpy.amin` or `numpy.amax` or `numpy.sum`. |
| 2372 | |
| 2373 | """ |
| 2374 | y = moveaxis(x, (row_axis, col_axis), (-2, -1)) |
| 2375 | result = op(svd(y, compute_uv=False), axis=-1) |
| 2376 | return result |
| 2377 | |
| 2378 | |
| 2379 | def _norm_dispatcher(x, ord=None, axis=None, keepdims=None): |