[SciPy-user] Scipy Sparse Library
Dinesh B Vadhia
Sat Jan 26 14:34:17 CST 2008
Our version of SciPy is 0.60.win32-py2.5.
We are solving b = Ax, where b and x are 'float' vectors, A is an MxN sparse matrix (with M != N) with binary (ie. 0 or 1) entries, and is defined as:
A = scipy.asmatrix(scipy.zeros((M, N), float)) # 'float' because byte int not supported yet
A is populated. We then use the following SciPy statement to transform into a sparse matrix in csc format:
A = scipy.sparse.csc_matrix(A) # scipy sparse csc matrix version
Next, calculate b as:
b = A * x
We don't have drastically varying values. Cheers!
Date: Sat, 26 Jan 2008 08:07:59 -0600
From: "Nathan Bell" <email@example.com>
Subject: Re: [SciPy-user] Scipy Sparse Library
To: "SciPy Users List" <firstname.lastname@example.org>
Content-Type: text/plain; charset=ISO-8859-1
On Jan 25, 2008 9:59 PM, Dinesh B Vadhia <email@example.com> wrote:
> We built a working C++ program using the SparseLib++ library last year. We
> are now creating a Python version of the program using the Scipy sparse
> library (the csc matrix format) and the results of the program are very
> different to the C++ program. It's either the Python program or the data.
> We have checked the programs and the data and cannot identify any
> Is it possible that the Scipy sparse libraries behave differently from the
> SparseLib++ library? I would have said unlikely but I guess anything is
Can you tell us what sparse functionality you are using and which
version of SciPy you have? Can you produce a short script that
demonstrates the problem?
SciPy sparse arithmetic should produce the same results as
SparseLib++. The only case when this may not be true is when the
entries of your matrix have drastically varying values (e.g. 1e-10 vs
1e10) and the lack of associativity in floating math produces
Nathan Bell firstname.lastname@example.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-user