存储稀疏矩阵的数据结构 [英] Data Structure for Storing Sparse Matrices

查看:101
本文介绍了存储稀疏矩阵的数据结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要对稀疏矩阵进行一些数学运算.我注意到使用数组可能不是利用内存的最有效方法,特别是因为矩阵可能有200多个行.我也考虑过使用链表,但不确定是否会更好.有没有适合这种情况的数据结构[方法].

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.

推荐答案

超过200行"有多少?多么稀疏? 1000x1000的Doubles矩阵仍不到8MB,除非您需要同时处理大量的内容,否则我不必担心.

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.

这篇关于存储稀疏矩阵的数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆