A bug in scipy.linalg.lu_factor?
Hello, I am trying to write some unit tests to my new "Automatic matrix" code and I think I bumped into a bug in scipy.linalg.lu_factor. If you give a matrix to it, it doesn't honor the overwrite_a option: In [1]:import numpy as num In [2]:M = num.mat(num.random.rand(2,2)) In [3]:print M [[ 0.33267781 0.2100424 ] [ 0.61852696 0.32244386]] In [4]:import scipy.linalg as la In [5]:LU, P = la.lu_factor(M, overwrite_a=0); print M [[ 0.33267781 0.63136882] [ 0.61852696 -0.06807478]] In [6]:LU, P = la.lu_factor(M, overwrite_a=0); print M [[ 0.63136882 0.52691517] [-0.06807478 0.6543966 ]] As you can see the matrix is changed by calling the function. can anyone confirm this? I am running numpy 1.0.1 and scipy 0.5.2. Best, Paulo
On Thu, 25 Jan 2007 16:06:23 -0200 "Paulo J. S. Silva" <pjssilva@ime.usp.br> wrote:
Hello,
I am trying to write some unit tests to my new "Automatic matrix" code and I think I bumped into a bug in scipy.linalg.lu_factor. If you give a matrix to it, it doesn't honor the overwrite_a option:
In [1]:import numpy as num
In [2]:M = num.mat(num.random.rand(2,2))
In [3]:print M [[ 0.33267781 0.2100424 ] [ 0.61852696 0.32244386]]
In [4]:import scipy.linalg as la
In [5]:LU, P = la.lu_factor(M, overwrite_a=0); print M [[ 0.33267781 0.63136882] [ 0.61852696 -0.06807478]]
In [6]:LU, P = la.lu_factor(M, overwrite_a=0); print M [[ 0.63136882 0.52691517] [-0.06807478 0.6543966 ]]
As you can see the matrix is changed by calling the function.
can anyone confirm this? I am running numpy 1.0.1 and scipy 0.5.2.
Best,
Paulo
Hi Paulo, I can confirm this bug. 1.0.2.dev3511 0.5.3.dev2560 Nils
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
On Thu, 25 Jan 2007 16:06:23 -0200 "Paulo J. S. Silva" <pjssilva@ime.usp.br> wrote:
Hello,
I am trying to write some unit tests to my new "Automatic matrix" code and I think I bumped into a bug in scipy.linalg.lu_factor. If you give a matrix to it, it doesn't honor the overwrite_a option:
In [1]:import numpy as num
In [2]:M = num.mat( )
In [3]:print M [[ 0.33267781 0.2100424 ] [ 0.61852696 0.32244386]]
In [4]:import scipy.linalg as la
In [5]:LU, P = la.lu_factor(M, overwrite_a=0); print M [[ 0.33267781 0.63136882] [ 0.61852696 -0.06807478]]
In [6]:LU, P = la.lu_factor(M, overwrite_a=0); print M [[ 0.63136882 0.52691517] [-0.06807478 0.6543966 ]]
As you can see the matrix is changed by calling the function.
can anyone confirm this? I am running numpy 1.0.1 and scipy 0.5.2.
Best,
Paulo
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
It works if you use M=num.random.rand(2,2) Nils I have filed a ticket.
On Thu, 25 Jan 2007 16:56:54 -0200 "Paulo J. S. Silva" <pjssilva@ime.usp.br> wrote:
Em Qui, 2007-01-25 às 19:46 +0100, Nils Wagner escreveu:
It works if you use M=num.random.rand(2,2)
Nils
Yes, it works for arrays but not for matrices. I thought that scipy.linalg functions were supposed to work with matrices.
Paulo
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
linalg.solve works with matrix input In [1]: import numpy as num In [2]: import scipy.linalg as la In [3]: M = num.mat(num.random.rand(2,2)) In [4]: b = num.random.rand(2) In [5]: x = la.solve(M,b) In [6]: print M*x [[ 0.29508067 0.17152755]] In [7]: b Out[7]: array([ 0.29508067, 0.17152755]) Nils
participants (2)
-
Nils Wagner -
Paulo J. S. Silva