[Numpy-discussion] how to use lu decomposition in lapack library?
luszczek at cs.utk.edu
Tue Oct 4 12:41:04 EDT 2005
Then you have to dig in deeper:
import numarray.linear_algebra.lapack_lite2 as lapack_lite
piv = numarray.zeros((n,), "l")
outcome = lapack_lite.dgesv(n, nrhs, a, lda, piv, b, ldb, 0)
outcome['info'] is the 'info' parameter set by LAPACK.
You have to make sure that 'a' and 'b' are in Fortran order
because you're calling Fortran code. Here is a sample code:
>>> a=numarray.array([[1,2,3],[4,5,6]], 'd')
Call to 'transpose()' made it a Fortran array but it transposed
the array too.
meng at are.berkeley.edu wrote:
> Thanks, Piotr!
> What I actually want is the lower (L) and upper triangular matrix (U)
> from matrix 'a'. How to get it?
> At 15:14 2005-10-4 -0400, you wrote:
>> You would have to be more specific. If you just want to
>> solve a system of linear equations with matrix 'a' and
>> right-hand-side 'b':
>> import numarray.linear_algebra as LA
>> x = LA.solve_linear_equations(a, b)
>> Unlike LAPACK, the above will leave your 'a' untouched.
>> So, if you have another right hand side 'b1' and the
>> same matrix 'a' you'll have to pay the cost of factorization
>> all over again.
>> There is a way around it but I don't know what you really need.
>> meng at are.berkeley.edu wrote:
>>> Hi there-
>>> Can someone help me on this? Thanks!
>>> Xiangyi Meng
>>> Department of Agricultural and Resource Economics
>>> Room 303, Giannini Hall #3310
>>> University of California, Berkeley
>>> Berkeley, CA 94720-3310
>>> Tel: (510) 643-4124
>>> Fax: (510) 643-8911
>>> Email: meng at are.berkeley.edu
>>> This SF.Net email is sponsored by:
>>> Power Architecture Resource Center: Free content, downloads,
>>> and more. http://solutions.newsforge.com/ibmarch.tmpl
>>> Numpy-discussion mailing list
>>> Numpy-discussion at lists.sourceforge.net
> Xiangyi Meng
> Department of Agricultural and Resource Economics
> Room 303, Giannini Hall #3310
> University of California, Berkeley
> Berkeley, CA 94720-3310
> Tel: (510) 643-4124
> Fax: (510) 643-8911
> Email: meng at are.berkeley.edu
More information about the NumPy-Discussion