Skip to content

Commit d1dbf8e

Browse files
committed
Merge pull request numpy#3895 from larsmans/norm-dot
ENH: use dot in linalg.norm
2 parents 42c8ced + 45ec18e commit d1dbf8e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

numpy/linalg/linalg.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,12 @@ def norm(x, ord=None, axis=None):
20532053

20542054
# Check the default case first and handle it immediately.
20552055
if ord is None and axis is None:
2056-
return sqrt(add.reduce((x.conj() * x).real, axis=None))
2056+
x = x.ravel(order='K')
2057+
if isComplexType(x.dtype.type):
2058+
sqnorm = dot(x.real, x.real) + dot(x.imag, x.imag)
2059+
else:
2060+
sqnorm = dot(x, x)
2061+
return sqrt(sqnorm)
20572062

20582063
# Normalize the `axis` argument to a tuple.
20592064
nd = x.ndim

0 commit comments

Comments
 (0)