#include <Eigen/Sparse> #include <complex> int main() { Eigen::SparseMatrix<std::complex<double>> mat(177858, 177858); std::complex<double> val; mat.coeffRef(0, 0) = val; mat.coeffRef(1, 1) = val; mat.coeffRef(2, 2) = val; mat.coeffRef(3, 0) = val; // bad_alloc! } Above code throws std::bad_alloc in Memory.h:666. Culprit seems to be SparseMatrix.h:1183: this->reserveInnerVectors(Array<StorageIndex,Dynamic,1>::Constant(2*m_outerSize, convert_index(m_outerSize))); This leads to a count(SparseMatrix.h:340) of 1568874950 and finaly to a new T[1568874950] // T being std::complex<double>? in Memory.h. Changing SparseMatrix.h:1183: to this->reserveInnerVectors(Array<StorageIndex,Dynamic,1>::Constant(2*m_outerSize, 2)); seemingly solved my Problem. ------------------------------------- eigen 3.3-alpha1 (eigen-09a8e2186610) VS2015 Win7x64 16GB -------------------------------------
ooch, that line was twice wrong! (2*m_outerSize instead of 2, and wrong parameter order) https://bitbucket.org/eigen/eigen/commits/536061d9bbbc/ Summary: Bug 1105: fix default preallocation when moving from compressed to uncompressed mode
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1105.