This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Eigen Sparse matrix problem with nonZeros and OuterStarts

Tags: None
(comma "," separated)
lucaverzeroli
Registered Member
Posts
1
Karma
0
Hi, i'm not sure that it's correct write here but i want to ask you these things about the sparse matrix;
1- Using InnerIterator sometimes it.value() is equal to zero! Is it related to mekeCompressed? In that case could you explain me how to use it?
2- I would like to use OuterStarts vector in order to implement an elimination tree. Is it possible to obtain it directly from the sparse matrix without any loop?


Code: Select all
typedef SparseMatrix<double> SMd;
SMd A;
// A is filled in a function
       A.makeCompressed();
   n = A.cols();

   VectorXi Ci(n + 1); //this is something like OuterStarts
   VectorXi Ri(A.nonZeros()); // i check nonZeros in Matlab and the value is not correct
   
   int j = 0;
   int count = 0;
   int z = 1;
   Ci(0) = 0;
   for (int k = 0; k < A.outerSize(); ++k)
   {
      count = 0;
      for (SparseMatrix<double>::InnerIterator it(A, k); it; ++it)
      {
         if (it.value()!=0) // I have put this because it.value() sometimes is zero!!! is it related to
                                                     makeCompressed?
         {
            Ri(j) = it.row();   // row index
                     j++;
                     count++;  // number of non zeros in a colomn
         }

      }
      Ci(z) = Ci(z - 1) + count;   // col index ---- This build a vector with number that should be inside
                                                                OuterStarts
      z++;
   }


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]