Hot Search : Source embeded web remote control p2p game More...
Location : Home Search - sparse matrix in c
Search - sparse matrix in c - List
当稀疏矩阵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.
Date : 2008-10-13 Size : 2.49kb User : snow
CodeBus is one of the largest source code repositories on the Internet!
Contact us :
1999-2046 CodeBus All Rights Reserved.