[SciPy-user] Scipy Sparse Library
Dinesh B Vadhia
dineshbvadhia at hotmail.com
Sat Jan 26 15:34:17 EST 2008
Nathan:
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!
Dinesh
------------------------------
Message: 6
Date: Sat, 26 Jan 2008 08:07:59 -0600
From: "Nathan Bell" <wnbell at gmail.com>
Subject: Re: [SciPy-user] Scipy Sparse Library
To: "SciPy Users List" <scipy-user at scipy.org>
Message-ID:
<d05265cb0801260607w13c5c011xfd30a1ac03e3dd50 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
On Jan 25, 2008 9:59 PM, Dinesh B Vadhia <dineshbvadhia at hotmail.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
> discrepencies.
>
> Is it possible that the Scipy sparse libraries behave differently from the
> SparseLib++ library? I would have said unlikely but I guess anything is
> possible.
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
different results.
--
Nathan Bell wnbell at gmail.com
http://graphics.cs.uiuc.edu/~wnbell/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20080126/654dcd50/attachment.html>
More information about the SciPy-User
mailing list