简体   繁体   English

稀疏矩阵相乘,链表

[英]Multiplication of sparse matrix, linked list

I have 2 sets of sorted linked list A and B, and i want to get product of A * B. for A it's easy since it's just a normal nested for loop. 我有2套排序的链表A和B,我想得到A * B的乘积。对于A,这很容易,因为它只是一个普通的嵌套for循环。 What about B? B呢? Initially i thought of haveing 3 nested for loop but since i'll be using pointers so it's impossible to use B[i][j]. 最初,我想到将3嵌套用于循环,但是由于我将使用指针,因此无法使用B [i] [j]。 any idea guys? 有什么主意吗?

I sort of figured out a way to do it. 我有点想办法了。

while (A != NULL)      //your first list
{                   
                       // store your row value and col in variables
   while (B != NULL)   // second list
   {
      if (colB == rowA) // you check if the b col is equals to a row, if yes you can
                        // start storing the values inside the 3rd link. 



    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM