[Numpy-discussion] Re: Some missing linalg things (wanted: LU decomposition)
Bill Baxter
wbaxter at gmail.com
Sun Feb 19 23:38:08 EST 2006
Should have mentioned -- I was using numpy 0.9.4 / scipy 0.4.4.
Looks like it works in numpy 0.9.5 / scipy 0.4.6
But matplotlib, which I also need, hasn't been updated for numpy 0.9.5 yet.
:-(
It's also still pretty weird to me that you have to do "from
scipy.linalgimport lu" specifically. And then after doing that one
import, then all the
other scipy.linalg.* functions magically spring into existence too. Is that
sort of hing expected behavior from Python imports?
>>> import numpy as N
>>> import scipy as S
>>> S.linalg.lu
Traceback (most recent call last):
File "<input>", line 1, in ?
AttributeError: 'module' object has no attribute 'lu'
>>> from scipy.linalg import lu
>>> S.linalg.lu(N.rand(2,2))
(array([[ 0., 1.],
[ 1., 0.]]), array([[ 1. , 0. ],
[ 0.18553085, 1. ]]), array([[ 0.71732168, 0.48540043],
[ 0. , 0.61379118]]))
>>> (N.__version__, S.__version__)
('0.9.5', '0.4.6')
--bb
On 2/20/06, Nils Wagner <nwagner at mecha.uni-stuttgart.de> wrote:
>
> Bill Baxter wrote:
> > Ack. I may be able to get references to lu, lu_factor, et al, but
> > they don't actually work with numpy arrays:
> >
> > from scipy.linalg import lu,lu_factor,lu_solve
> > import scipy as S
> > A = S.rand(2,2)
> > lu(A)
> > Traceback (most recent call last):
> > File "<input>", line 1, in ?
> > File "C:\Python24\Lib\site-packages\scipy\linalg\decomp.py", line
> > 249, in lu
> > flu, = get_flinalg_funcs(('lu',),(a1,))
> > File "C:\Python24\Lib\site-packages\scipy\linalg\flinalg.py", line
> > 30, in get_flinalg_funcs
> > t = arrays[i].dtypechar
> > AttributeError: 'numpy.ndarray' object has no attribute 'dtypechar'
> >
> >
> > Ok, so, once again, does anyone have an lu_factor / lu_solve
> > implementation in python that I could borrow?
> >
> > Apologies for the monologue.
> >
> > --bb
> >
> >
> > On 2/20/06, *Bill Baxter* <wbaxter at gmail.com
> > <mailto:wbaxter at gmail.com>> wrote:
> >
> > Upon further inspection I find that if I call 'from scipy import
> > *' then linalg.lu <http://linalg.lu> etc are defined.
> > But if I do anything else to import scipy like 'import scipy' or
> > 'import scipy as S' or 'from scipy import linalg', then lu, cg etc
> > are not defined.
> >
> > Why is that?
> >
> > I can get at them without importing * by doing 'from scipy.linalg
> > import lu', but that's kind of odd to have to do that.
> >
> > --bb
> >
> >
> > On 2/20/06, * Bill Baxter* <wbaxter at gmail.com
> > <mailto:wbaxter at gmail.com>> wrote:
> >
> > This url http://www.rexx.com/~dkuhlman/scipy_course_01.html
> > <http://www.rexx.com/%7Edkuhlman/scipy_course_01.html> seems
> > to keep turning up in my searches for numpy and scipy things,
> > but many of the linalg operations it lists don't seem to exist
> > in recent versions of numpy (or scipy).
> >
> > Some of them are:
> >
> > * norm
> > * factorizations: lu, lu_factor, lu_solve, qr
> > * iterative solvers: cg, cgs, gmres etc.
> >
> > Did these things used to exist in Numeric but they haven't
> > been ported over? Will they be re-introduced sometime?
> >
> > In the short term, the one I'm after right now is LU decompose
> > and solve functionality. Anyone have a numpy implementation?
> >
> > --Bill Baxter
> >
> No problem here.
>
> >>> from scipy.linalg import lu,lu_factor,lu_solve
> >>> import scipy as S
> >>> A = S.rand(2,2)
> >>> lu(A)
> (array([[ 0., 1.],
> [ 1., 0.]]), array([[ 1. , 0. ],
> [ 0.81367315, 1. ]]), array([[ 0.49886054, 0.57065709],
> [ 0. , -0.30862809]]))
> >>> S.__version__
> '0.4.7.1614'
>
>
> Nils
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060219/c085fd2c/attachment.html>
More information about the NumPy-Discussion
mailing list