views:

301

answers:

2

Hi All, I have two dimensional matrix. My matrix is sparse. I am facing performance problem. Can any body please answer that what api or class i can use in java to handle sparse matrix to improve my program performance.

For example I want

it take 100x100 matrix
handle sparse stuff
do the multiplication
return me my matrix same as 100x100 with 0 ( mean sparse matrix )

Thanks

A: 

Have you tried using Jama? http://math.nist.gov/javanumerics/jama/ - they don't directly support sparse matrices, but it's a widely used package.

Also, princeton seems to have a sparse matrix implementation for you to take a look at http://www.cs.princeton.edu/introcs/44st/SparseMatrix.java.html

vicatcu
I am using jama for SVD. Can you point out how can I use jama for this purpose? I think jama is for dense matrix
+3  A: 

Jama is awful for large sparse matrices.

Have a look at the Colt linear algebra library.


Another possibility for sparse linear algebra is the apache commons library. Might be a little lighter-weight than Colt but the difference from the look-and-feel of Jama might be a little larger.

mobrule
@mobrule: How is Fortran for that? Because in the very link you gave it is written that Java is gaining more and more adoption and can reach 90% of the speed of Fortran. How is 90% of Fortran's speed? Is that awful? (btw I'm doing heavy number crunching in Java)
Webinator
Can't comment on performance, but +1 on API for Colt.
omerkudat
@Wizard, Fortran is a compiled language, like C. You are not going to get anything faster unless you write it in assembly.
mobrule
is there anyother solution ?? coz colt is very big and i can't use very big api for this purpose :(
@agazerboy - the part of the API you need --http://acs.lbl.gov/~hoschek/colt/api/cern/colt/matrix/package-summary.html for matrix objects and http://acs.lbl.gov/~hoschek/colt/api/cern/colt/matrix/linalg/package-summary.html for SVD/linear-algebra are not so large. Are you working on an embedded system or something?
mobrule