diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2014-01-09 16:00:15 -0800 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2014-01-09 16:00:15 -0800 |
commit | d1dbf8e796ab6bcdc4f3b71252f3921ab2a62269 (patch) | |
tree | 4d748835c41e7a06b4caa82042bf75d56f9616ca /numpy/linalg/linalg.py | |
parent | 42c8ced9257869a3897d84e2d5da570ddbb5fc59 (diff) | |
parent | 45ec18e2153613642dffd8cb52278e4ca4c3605c (diff) | |
download | numpy-d1dbf8e796ab6bcdc4f3b71252f3921ab2a62269.tar.gz |
Merge pull request #3895 from larsmans/norm-dot
ENH: use dot in linalg.norm
Diffstat (limited to 'numpy/linalg/linalg.py')
-rw-r--r-- | numpy/linalg/linalg.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index a7e12aa08..102c6aec2 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -2053,7 +2053,12 @@ def norm(x, ord=None, axis=None): # Check the default case first and handle it immediately. if ord is None and axis is None: - return sqrt(add.reduce((x.conj() * x).real, axis=None)) + x = x.ravel(order='K') + if isComplexType(x.dtype.type): + sqnorm = dot(x.real, x.real) + dot(x.imag, x.imag) + else: + sqnorm = dot(x, x) + return sqrt(sqnorm) # Normalize the `axis` argument to a tuple. nd = x.ndim |