`scipy.linalg`: low-level batch support vs `numpy.linalg`
https://github.com/scipy/scipy/issues/21466 added support for batched ND arrays across scipy.linalg. This effort was mostly completed in the scipy 1.16.x timeframe.
In the 1.17 and 1.18 window, we moved several functions to low-level C code. This improves performance, esp for batches of small matrices, at a cost of more complicated code---which is worse maintenance-wise.
Therefore, we do not necessarily want to move all batch looping to native code. This issue is to prioritize which parts of scipy.linalg need looping in C, and which can stay in python.
One relevant aspect is the duplication between scipy.linalg and numpy.linalg. Typically, scipy functions have more features, and numpy functions are faster, partly because their batch support is all in C.
So a first shot at a North Start goal could be to make scipy.linalg a strict superset of numpy.linalg. This is not very realistic or even desirable. First, there are difficult backwards compatibility considerations (e.g. https://github.com/scipy/scipy/issues/4818); Second, why would we even bother implementing scipy.linalg.trace.
So an amended goal: for each function which is in both scipy.linalg and numpy.linalg, the scipy version has all features of the numpy version, may have additional features, and has a comparable performance.
With this in mind, here's a listing of https://numpy.org/doc/stable/reference/routines.linalg.html, with an opinionated prioritization (a filled checkbox means already implemented):
Matrix and vector products
dot, outer, cross, einsum etc : out of scope for scipy.linalg.
Decompositions
-
cholesky -
qr -
svd -
svdvals
Matrix eigenvalues
-
eig -
eigvals -
eigh -
eigvalsh
Solving equations and inverting matrices
-
solve -
inv -
lstsq -
pinv tensorsolve,tensorinv: out of scope
Norms and other numbers
Mostly out of scope. Potentially in-scope:
-
detdetis rather low priority. Our implementation goes to significant lengths for numerical stability (I think?), so we should check if our implementation is more stable than numpy's. If it is, maybe consider porting our improvements to numpy instead. -
norm
I think . If we ever get to it, we should introduce norm is rather low priorityvector_norm and matrix_norm, like numpy did, and only if we plan to offer some norms that numpy does not.
Other matrix operations
diagonal,matrix_transpose: out of scope
Out of unchecked boxes, the obvious high-priority item is eigh. It is frequently used, and scipy's version has quite a few bells and whistles compared to numpy's. It's not entirely clear though which of them are in common use and which ones are historical artefacts (subset_by_index?).
Source: scipy/scipy