Re: [eigen] SparseMatrix StorageIndex issue |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
Given the following code:Hi,I am using Eigen 3.3.4, on clang 4.0I was changing the StorageIndex type and I noticed something that might be a problem with my Eigen configuration or a bug.
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE int
#include <Eigen/Eigen>
using StorageIndexType = long;
Eigen::SparseMatrix<double, Eigen::ColMajor, StorageIndexType> A(10,10);
Causes the bad_alloc throw as well on (SparseMatrix.h:829) // s << static_cast<const SparseMatrixBase<SparseMatrix>I have also noticed that printing the matrix like this:When adding for(int i=0; i<10; ++i) A.insert(i,i) = 1; or A.setIdentity(); I get a bad_alloc exception.However running:
A.resize(10, 10);
for(int i=0; i<10; ++i) A.insert(i,i) = 1;
Does not cause the throw. It will throw if using setIdentity instead of insert even with the resize though.
std::cerr << "A =\n" << A << std::endl;&>(m) The streaming with Eigen debug ON print shows the following (before crashing):
Nonzero entries:
(1,0) (1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (1,8) (1,9) (_,_) (_,_) (_,_) (_,_) (_,_) (_,_) (_,_) (_,_) (_,_) (_,_)
Outer pointers:
0 1 2 3 4 5 6 7 8 9 $
Inner non zeros:
1 1 1 1 1 1 1 1 1 1 $I have tried making all combinations of int and long of EIGEN_DEFAULT_DENSE_INDEX_TYPE and StorageIndexType, only this combination crashes.Trying to use the matrix with SPQR also crashes (which was my initial intention):
Eigen::SPQR<Eigen::SparseMatrix<double, Eigen::ColMajor, StorageIndexType> > solver;
solver.compute(A);Kind regards,Gerard
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |