Data Structure for Storing Sparse Matrices

ε祈祈猫儿з 提交于 2019-12-07 00:55:30

问题


I need to do some mathematics operations on sparse matrices. I noticed that using arrays may not be the most efficient way to utilize my memory, especially since the matrices may have over 200 rows. I have considered using a linked list too, but I'm not sure if that'll be better. Is there any suitable data structure [approach] to this situation.


回答1:


How many "over 200 rows"? How sparse? A 1000x1000 matrix of doubles is still less than 8MB, which is not something I'd worry about unless you need to work with a lot of them simultaneously.

The ideal data structure depends mainly on what kind of operations you need to perform.

Note that there are ready-to-use sparse matrix libraries for all common languages out there - you're much better off using one of those than rolling your own.




回答2:


Here are a few open source Java maths libraries that include sparse matrices. You could study the data structures used (or even just use one of them if programming in Java).

  • Colt
  • Jsci
  • Matrix Toolkits Java



回答3:


There's a new matrix library out for java that looks like it might have good Sparse Matrix support: UJMP: The Universal Java Matrix Package



来源:https://stackoverflow.com/questions/989378/data-structure-for-storing-sparse-matrices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!