稀疏矩阵
我们如何显示稀疏矩阵?有人想帮助我说:使用链表。
我还读过一些我们应该创建这样的类的地方:
SpMatrix
{
int non_zero_value;
int i,j;
}
到底什么是稀疏矩阵,我读过维基百科和其他网站。但问题还没有解决。
提前致谢。
How can we display a sparse matrix? Someone who wanted to help me said: use linked lists.
Also I have read some where that we should create class like this :
SpMatrix
{
int non_zero_value;
int i,j;
}
Exactly what is a sparse matrix, I have read wekipedia and other sites. but the problem isn't solved yet.
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
稀疏矩阵是大多数元素等于 0 的矩阵。例如,仅对角线上具有非零元素的矩阵显然是稀疏矩阵:
显然,存储矩阵的所有元素是浪费空间,因为大多数元素为零。有多种技术可以存储此类矩阵,这实际上取决于您想要的通用程度以及手头的具体问题。
大多数时候,您最终会为想要支持的每种不同类型的稀疏矩阵(例如对角线、三角形、带对角线等)提供一个特定的类。这通常会为您提供比通用解决方案更有效的代码。
这是一个复杂的问题,没有现成的食谱。您可以使用链接列表或其他任何东西。
A sparse is a matrix with most elements equal to 0. For example a matrix that has non-zero elements only on the diagonal is clearly a sparse matrix:
Clearly it's a waste of space to store all the elements of the matrix since most are zero. There a number of techniques to store such matrices and it really depends on how generic you want to be and to the specific problem in hand.
Most times you end up having a specific class for each different kind of sparse matrix you want to support, e.g. diagonal, triangular, band diagonal, etc. That usually gives you more efficient code than a generic solution.
It's a complex problem with no ready made recipes. You can use linked lists or anything else really.