Should have mentioned -- I was using numpy 0.9.4 / scipy 0.4.4.<br>Looks like it works in numpy 0.9.5 / scipy 0.4.6<br><br>But matplotlib, which I also need, hasn't been updated for numpy 0.9.5 yet. :-(<br><br>It's also still pretty weird to me that you have to do "from
scipy.linalg import 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?
<br><br>>>> import numpy as N<br>>>> import scipy as S<br>>>> <a href="http://S.linalg.lu">S.linalg.lu</a><br>Traceback (most recent call last):<br> File "<input>", line 1, in ?
<br>AttributeError: 'module' object has no attribute 'lu'<br>>>> from scipy.linalg import lu<br>>>> S.linalg.lu(N.rand(2,2))<br>(array([[ 0., 1.],<br> [ 1., 0.]]), array([[ 1. , 0. ],
<br> [ 0.18553085, 1. ]]), array([[ 0.71732168, 0.48540043],<br> [ 0. , 0.61379118]]))<br>>>> (N.__version__, S.__version__)<br>('0.9.5', '0.4.6')<br><br>--bb<br><br><div><span class="gmail_quote">
On 2/20/06, <b class="gmail_sendername">Nils Wagner</b> <<a href="mailto:nwagner@mecha.uni-stuttgart.de">nwagner@mecha.uni-stuttgart.de</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Bill Baxter wrote:<br>> Ack. I may be able to get references to lu, lu_factor, et al, but<br>> they don't actually work with numpy arrays:<br>><br>> from scipy.linalg import lu,lu_factor,lu_solve<br>> import scipy as S
<br>> A = S.rand(2,2)<br>> lu(A)<br>> Traceback (most recent call last):<br>> File "<input>", line 1, in ?<br>> File "C:\Python24\Lib\site-packages\scipy\linalg\decomp.py", line
<br>> 249, in lu<br>> flu, = get_flinalg_funcs(('lu',),(a1,))<br>> File "C:\Python24\Lib\site-packages\scipy\linalg\flinalg.py", line<br>> 30, in get_flinalg_funcs<br>> t = arrays[i].dtypechar
<br>> AttributeError: 'numpy.ndarray' object has no attribute 'dtypechar'<br>><br>><br>> Ok, so, once again, does anyone have an lu_factor / lu_solve<br>> implementation in python that I could borrow?<br>>
<br>> Apologies for the monologue.<br>><br>> --bb<br>><br>><br>> On 2/20/06, *Bill Baxter* <<a href="mailto:wbaxter@gmail.com">wbaxter@gmail.com</a><br>> <mailto:<a href="mailto:wbaxter@gmail.com">
wbaxter@gmail.com</a>>> wrote:<br>><br>> Upon further inspection I find that if I call 'from scipy import<br>> *' then <a href="http://linalg.lu">linalg.lu</a> <<a href="http://linalg.lu">http://linalg.lu
</a>> etc are defined.<br>> But if I do anything else to import scipy like 'import scipy' or<br>> 'import scipy as S' or 'from scipy import linalg', then lu, cg etc<br>> are not defined.<br>><br>
> Why is that?<br>><br>> I can get at them without importing * by doing 'from scipy.linalg<br>> import lu', but that's kind of odd to have to do that.<br>><br>> --bb<br>><br>><br>> On 2/20/06, * Bill Baxter* <
<a href="mailto:wbaxter@gmail.com">wbaxter@gmail.com</a><br>> <mailto:<a href="mailto:wbaxter@gmail.com">wbaxter@gmail.com</a>>> wrote:<br>><br>> This url <a href="http://www.rexx.com/~dkuhlman/scipy_course_01.html">
http://www.rexx.com/~dkuhlman/scipy_course_01.html</a><br>> <<a href="http://www.rexx.com/%7Edkuhlman/scipy_course_01.html">http://www.rexx.com/%7Edkuhlman/scipy_course_01.html</a>> seems<br>> to keep turning up in my searches for numpy and scipy things,
<br>> but many of the linalg operations it lists don't seem to exist<br>> in recent versions of numpy (or scipy).<br>><br>> Some of them are:<br>><br>> * norm<br>> * factorizations: lu, lu_factor, lu_solve, qr
<br>> * iterative solvers: cg, cgs, gmres etc.<br>><br>> Did these things used to exist in Numeric but they haven't<br>> been ported over? Will they be re-introduced sometime?<br>><br>
> In the short term, the one I'm after right now is LU decompose<br>> and solve functionality. Anyone have a numpy implementation?<br>><br>> --Bill Baxter<br>><br>No problem here.<br>
<br>>>> from scipy.linalg import lu,lu_factor,lu_solve<br>>>> import scipy as S<br>>>> A = S.rand(2,2)<br>>>> lu(A)<br>(array([[ 0., 1.],<br> [ 1., 0.]]), array([[ 1. , 0. ],
<br> [ 0.81367315, 1. ]]), array([[ 0.49886054, 0.57065709],<br> [ 0. , -0.30862809]]))<br>>>> S.__version__<br>'0.4.7.1614'<br><br><br>Nils<br><br></blockquote></div><br><br>