[SciPy-User] scipy.linalg.solve()'s overwrite option does not work

braingateway braingateway at gmail.com
Fri Nov 5 21:21:48 EDT 2010


Hi everyone,
I believe the overwrite option is used for reduce memory usage. But I
did following test, and find out it does not work at all. Maybe I
misunderstood the purpose of overwrite option. If anybody could explain
this, I shall highly appreciate your help.

>>> a=npy.random.randn(20,20)
>>> x=npy.random.randn(20,4)
>>> a=npy.matrix(a)
>>> x=npy.matrix(x)
>>> b=a*x
>>> import scipy.linalg as sla
>>> a0=npy.matrix(a)
>>> a is a0
False
>>> b0=npy.matrix(b)
>>> b is b0
False
>>> X=sla.solve(a,b,overwrite_b=True,debug=True)
solve:overwrite_a= False
solve:overwrite_b= True
>>> X is b
False
>>> (X==b).all()
False
>>> (b0==b).all()
True
>>> sla.solve(a,b,overwrite_a=True,overwrite_b=True,debug=True)
solve:overwrite_a= True
solve:overwrite_b= True
>>> (a0==a).all()
True
>>> help(sla.solve)
Help on function solve in module scipy.linalg.basic:

solve(a, b, sym_pos=False, lower=False, overwrite_a=False,
overwrite_b=False, debug=False)
Solve the equation a x = b for x

Parameters
----------
a : array, shape (M, M)
b : array, shape (M,) or (M, N)
sym_pos : boolean
Assume a is symmetric and positive definite
lower : boolean
Use only data contained in the lower triangle of a, if sym_pos is true.
Default is to use upper triangle.
overwrite_a : boolean
Allow overwriting data in a (may enhance performance)
overwrite_b : boolean
Allow overwriting data in b (may enhance performance)

Returns
-------



More information about the SciPy-User mailing list