Comments (8)
From what I understand, numpy should be able to use nrm2
as well as it is BLAS, not LAPACK. In the long run, would it not be best if this was fixed in numpy itself on top of our own efforts in scipy? norm
is definitely much less involved than many other linalg functions from numpy such as the matrix decompositions but a fundamentally important function in my opinion.
from scipy.
np.linalg.norm
is used whenever axis
is provided:
Lines 177 to 178 in fdf3b90
from scipy.
On top of what @lucascolley mentioned, NumPy does not use the safe norm from LAPACK but does its own unscaled dot product hence bypasses the safety guards. If you don't have too many cols/rows in the axis a for loop is an easy way out without too much of python overhead.
from scipy.
Should we fix 2-norm working with axis? I can cook up something in C or Cython and nrm2
is not complicated.
Based on what we discussed over kron deprecation, not sure what it entails in terms of array api though since this is a central function and unlike kron we should support it and make it as general as possible, in my opinion. However if I cook something up in C or Cython not sure if it is even possible to support it.
from scipy.
that sounds sensible - see data-apis/array-api#213 for the array API perspective. We'd probably rewrite scipy.linalg.norm
in terms of xp.linalg.vector_norm
and xp.linalg.matrix_norm
for the non-np
codepath.
If we can upstream all efficiency gains from the SciPy implementation to those (new) NumPy functions, we'll be able to simplify it to just one codepath (well, there'll be a codepath for if the namespace doesn't implement the linalg
extension, but that's orthogonal to the discussion here).
from scipy.
Oh my, I typed too fast probably: openblas does not support the safe scaling yet apparently: OpenMathLib/OpenBLAS#4313. Until it is available there, probably difficult to use for both numpy and scipy but I would like to be convinced of the opposite by the BLAS gurus.
Xref numpy issue numpy/numpy#19097
from scipy.
It doesn't have to use the BLAS code as all based on Anderson's work. We can write our own native version of nrm2 in C or Cython. Not sure if NumPy implements it since it is not using nrm2 even now.
from scipy.
Overall judging by the discussions oat the array api, it seems to me the linalg parts are not well thought out.
from scipy.
Related Issues (20)
- BUG/BLD: scipy-1.13.1 fails to build with msvc HOT 2
- BUG: sparse.csgraph: Test failures with sparse 0.15.1 installed. HOT 10
- DOC/BLD: Build uses python3 from wrong env HOT 2
- CI: adding a Windows CI job with MSVC + MKL + Intel Fortran (ifx) HOT 1
- MAINT: clean up `sparse._sputils.getdtype` HOT 1
- ENH: `ndimage.map_coordinates`: avoid array copy for big endian data HOT 4
- BUG: `interpolate.BSpline.basis_element` differs from `BSpline` on the last spline HOT 1
- BUG: scipy.optimize.curve_fit full_output and boundaries incompatible HOT 1
- DOC/DEV: Developer docs should mention Accelerate support HOT 5
- BUG: stats.kstest: units stripped from `astropy.unit.Quantity` objects starting with 1.12.0 HOT 1
- BUG: `zsh: abort python` after `scipy.linalg.sqrtm` on empty `np.array` on M1 Macbook via conda HOT 1
- BUG: special.lpmv(0,v,-1) returns incorrect value for non-integer v
- ENH: integrate: evaluate simultaneously a function and its jacobian for ODE integration HOT 2
- BUG: sparse.csgraph.dijkstra errors on inputs with int64 or no indices
- BUG: positional argument `DeprecationWarning` message is overly long HOT 10
- TST: TestEig.test_singular failing tolerance with generic BLAS installed HOT 2
- BUG: interpolate.griddata: memory leak in linear mode under Python 3.12 HOT 10
- DOC: Old SciPy version in embedded Jupyterlite notebooks HOT 9
- DOC: stats: wrong docstrings of `*Result` classes HOT 2
- BUG: Can't build scipy on main (1.15.0.dev0), PyObject_Vectorcall* not found HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scipy.