[SciPy-dev] Re: lu_solve problem -- f2py related

pearu at scipy.org pearu at scipy.org
Thu Apr 4 02:15:16 CST 2002

```Hi Travis,

On Wed, 3 Apr 2002, Travis Oliphant wrote:

> The easiest way to show the problem is to look at linalg2.solve for the
> following problem.
>
> A = rand(5,5)
> b1 = rand(5,2)
>
> x1 = linalg2.solve(A,b1)
> x2 = linalg2.solve(A,b1[:,0])
> x3 = linalg2.solve(A,b1[:,0].copy())
>
> print x1[:,0]
> print x2
> print x3

Here is what I get with f2py 2.13.175-1239 and ..-1242:
>>> from scipy_base.testing import rand
>>> import linalg2
>>> A = rand(5,5)
>>> b1 = rand(5,2)
>>> x1 = linalg2.solve(A,b1)
>>> x2 = linalg2.solve(A,b1[:,0])
>>> x3 = linalg2.solve(A,b1[:,0].copy())
>>> print x1[:,0]
[ 0.71772198  1.32782188  0.39482474 -3.19123014  1.71486623]
>>> print x2
[ 0.71772198  1.32782188  0.39482474 -3.19123014  1.71486623]
>>> print x3
[ 0.71772198  1.32782188  0.39482474 -3.19123014  1.71486623]

Looks good to me.

> Notice that x2 is not correct.  The problem I think is the fact that in
> array_from_pyobj there is a check for (rank > 1) arrays before
> lazy-transposes are done.  I think a check should be made for rank-1 arrays
> as well, to handle this case.

What version of f2py are you using? It might be an old and already
fixed problem.

Pearu

```