Sunday, August 2, 2009

What is a good way to make a sparse matrix in java?

The matrix could be large (10,000 by 10,000), but very sparse. I plan on doing a decent amount of calculations with it. What data structure/ library should I use to do this easily?

What is a good way to make a sparse matrix in java?
There is a library to do it. Usually the code that most people write won't be as efficient as the code in libraries.





http://rs.cipr.uib.no/mtj/





http://www.ii.uib.no/forskningsgrupper/o...
Reply:The easiest way is probably just to use a Hashtable. You can use an Array of Integer values as the key if you want. Then the "size" (or maximum index values) does not matter much at all, as well as the number of dimensions.





http://java.sun.com/j2se/1.3/docs/api/ja...
Reply:Well, i suggest to use the Coordinate Method Representation, in the case that you have multiple elements per row you may use the Variant Coordinate Method Representation, but anyways try to make your work done on rows not columns, since none of the previous representations is efficient if frequent colum operations are required.





For more information about Sparse Matrices representations, see this link: http://www.cs.uml.edu/~lechner/DataModel...


No comments:

Post a Comment