Registered Member
|
I have tried to construct a sparse matrix using set_from_triplets method but when I tried with large data I get this error :
a.out: /usr/local/include/eigen3/Eigen/src/SparseCore/SparseMatrix.h:952: void Eigen::internal::set_from_triplets(const InputIterator&, const InputIterator&, SparseMatrixType&, int) [with InputIterator = __gnu_cxx::__normal_iterator<Eigen::Triplet<long int>*, std::vector<Eigen::Triplet<long int> > >; SparseMatrixType = Eigen::SparseMatrix<long int, 1>]: Assertion `it->row()>=0 && it->row()<mat.rows() && it->col()>=0 && it->col()<mat.cols()' failed. Aborted actually I read a data form file and push them to triplet Could you help me ? thanks, Mohammad |
Moderator
|
you have to resize the sparse matrix (rows/cols) before inserting the elements
|
Registered Member
|
I still get this error It is my code :
|
Moderator
|
maybe your file format is not 0-based indexed...
|
Registered Member
|
what is 0-based indexed file ? |
Moderator
|
many file formats assume that the index of the first row/column is 1 while in C++/Eigen it's 0.
|
Registered Member
|
But when i run this code for small lines it worked
|
Moderator
|
This assert is telling you that at least one of the coefficient in the triplet list is outside the range you specified. You can check that in your while loop:
txid < Nx && userid < Ny |
Registered Member
|
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]