summaryrefslogtreecommitdiff
path: root/numpy/linalg/linalg.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/linalg/linalg.py')
-rw-r--r--numpy/linalg/linalg.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index a7e12aa08..e5d13efc8 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -1763,7 +1763,7 @@ def lstsq(a, b, rcond=-1):
residuals : {(), (1,), (K,)} ndarray
Sums of residuals; squared Euclidean 2-norm for each column in
``b - a*x``.
- If the rank of `a` is < N or > M, this is an empty array.
+ If the rank of `a` is < N or M <= N, this is an empty array.
If `b` is 1-dimensional, this is a (1,) shape array.
Otherwise the shape is (K,).
rank : int
@@ -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