文件名称:矩阵相加的算法
介绍说明--下载内容来自于网络,使用问题请自行百度
当稀疏矩阵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
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.