user238384
user238384

Reputation: 2466

java sparse matrix problem

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 )

Upvotes: 4

Views: 3515

Answers (4)

Ryu
Ryu

Reputation: 11

SuanShu has a large collection of sparse matrices implemented. You can simply use those instead writing your own.

They currently support these formats: CSR, DOK, LIL

Upvotes: 1

Vladimir Kostyukov
Vladimir Kostyukov

Reputation: 2552

You might look at la4j (Linear Algebra for Java). The la4j supports sparse matrices as well as dense ones. Here is the list of supported matrix types: 1D-Array (dense), 2D-Array (dense), CRS - Compressed Row Storage (sparse), CCS - Compressed Column Storage (sparse).

Upvotes: 1

mob
mob

Reputation: 118605

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.

Upvotes: 6

vicatcu
vicatcu

Reputation: 5837

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

Upvotes: 0

Related Questions