[SciPy-User] scipy+lapack array copy
Skipper Seabold
jsseabold@gmail....
Mon Mar 8 12:10:32 CST 2010
On Mon, Mar 8, 2010 at 12:47 PM, Paul Anton Letnes
<paul.anton.letnes@gmail.com> wrote:
> Hi everyone.
>
> I have a numerical project where I link a fortran module to python using f2py. The fortran module basically sets up the left hand side coefficient matrix of a linear equation system. The right hand side is small, so I set that up in python. So far, everything works great.
>
> Now, when I call scipy-lapack, I am using:
> from scipy.linalg.lapack import flapack as lapack
> lu, piv, x, info = lapack.zgesv(A, b)
> A is created in the fortran part of the program. b is created from numpy.zeros(). Both report as F_CONTIGUOUS by printing A.flags and b.flags.
>
> The problem is that I'd like A to be large (>1GB), but the lapack wrapper (or lapack itself?) copies the array, doubling the memory use. Aside from being unnecessary, this also reduces the practical problem size I can solve by a factor 2, which of course is very annoying.
>
> How can I get around this problem?
>
It looks like zgesv allows you to set overwrite_a = 1. If this isn't
what you want, there might be another way to proceed.
In [5]: from scipy.linalg.lapack import flapack as lapack
In [6]: lapack.zgesv?
Type: fortran
String Form: <fortran object at 0x7fccc4f6af08>
Namespace: Interactive
Docstring:
zgesv - Function signature:
lu,piv,x,info = zgesv(a,b,[overwrite_a,overwrite_b])
Required arguments:
a : input rank-2 array('D') with bounds (n,n)
b : input rank-2 array('D') with bounds (n,nrhs)
Optional arguments:
overwrite_a := 0 input int
overwrite_b := 0 input int
Return objects:
lu : rank-2 array('D') with bounds (n,n) and a storage
piv : rank-1 array('i') with bounds (n)
x : rank-2 array('D') with bounds (n,nrhs) and b storage
info : int
Skipper
More information about the SciPy-User
mailing list