[SciPy-dev] small bug(s) in scipy.linalg

Pearu Peterson pearu at cens.ioc.ee
Mon Feb 10 04:27:39 CST 2003


On 10 Feb 2003, Alexander Schmolck wrote:

> I think scipy.linalg.basic has a few issues with 1D vectors vs row and column
> vectors (respective shapes: (n,), (1,n), (n,1)). It would seem clear to me,
> for example that `norm` ought to produce exactly the same with a 1D vector as
> with a row vector or column vector. Currently it doesn't,

-1 for considering it as a bug.

For generality, I'd leave to users to decide whether (1,n) or
(n,1) shaped matrices should regarded as vectors. 

It is simple to call norm(ravel(x)) (even if x is (n,) shaped).
However, if norm() would automatically map x -> ravel(x) for one
row/column matrix x, as suggested, then this would make writing generic
algorithms harder (check shapes, split program flow, etc).

How about introducing a convenience function

  def vnorm(x):
      return norm(ravel(x))

?

> and the very common case of the 2 norm for a vector is, I think,
> handled inefficiently.

+1 for fixing this.

Pearu




More information about the Scipy-dev mailing list