文件名称:矩阵相加的算法
介绍说明--下载内容均来自于网络,请自行研究使用
当稀疏矩阵A和B均以三元组表作为存储结构时,试写出矩阵相加的算法,其结果存放在三元组表C中。
解:这个算法有点繁,要考虑到两个稀疏矩阵的非零元素不是一一对应的,在建立新的三元组表C时,为了使三元组元素仍按行优先排列,所以每次插入的三元组不一定是A的,按照矩阵元素的行列去找A中的三元组,若有,则加入C,同时,这个元素如果在B中也有,则加上B的这个元素值,否则这个值就不变 如果A中没有,则找B,有则插入C,无则查找下一个矩阵元素。
-sparse matrix A and B were 3 groups, as a storage structure and try to write together the matrix algorithm, results stored in ternary Group C table. Solution : This is a bit complicated algorithm, taking into account the two nonzero sparse matrix element is not one-to-one. the establishment of a new ternary Group C table, in order to enable groups of elements remaining three yuan prioritize OK, So inserted three yuan each group is not necessarily A, in accordance with the matrix elements ranks to find a group of three yuan, and if so, C is added, and if this element is B, plus the B value of the element, Otherwise, the value on the same if not A, then B to find, then insert C, no one will find under the matrix elements.
解:这个算法有点繁,要考虑到两个稀疏矩阵的非零元素不是一一对应的,在建立新的三元组表C时,为了使三元组元素仍按行优先排列,所以每次插入的三元组不一定是A的,按照矩阵元素的行列去找A中的三元组,若有,则加入C,同时,这个元素如果在B中也有,则加上B的这个元素值,否则这个值就不变 如果A中没有,则找B,有则插入C,无则查找下一个矩阵元素。
-sparse matrix A and B were 3 groups, as a storage structure and try to write together the matrix algorithm, results stored in ternary Group C table. Solution : This is a bit complicated algorithm, taking into account the two nonzero sparse matrix element is not one-to-one. the establishment of a new ternary Group C table, in order to enable groups of elements remaining three yuan prioritize OK, So inserted three yuan each group is not necessarily A, in accordance with the matrix elements ranks to find a group of three yuan, and if so, C is added, and if this element is B, plus the B value of the element, Otherwise, the value on the same if not A, then B to find, then insert C, no one will find under the matrix elements.
相关搜索: 稀疏矩阵
(系统自动生成,下载前可以参看下载内容)
下载文件列表
文档.rtf