looking at the line 2807 in the file you get:/*
multiply matrix and vector attempting to resize existing objects
What does this error message mean?
Check failed in file ...boost_1_54_0/boost/numeric/ublas/matrix_sparse.hpp at line 2807:
!preserve
libc++abi.dylib: terminate called throwing an exception
*/
void resize (size_type size1, size_type size2, bool preserve = true) { // FIXME preserve unimplemented BOOST_UBLAS_CHECK (!preserve, internal_logic ()); so you need to write resize(size1,size2,false); The default behavior of resize is to save the old values if possible. this is cumbersome to implement for sparse matrices when they are shrunk, so this is not implemented yet. But yeah, we also had fun with that issue. Default behaviour should never be to throw an exception :). But the correct way would be not to use resize when you can create the matrices with the right sizes instead.
I am not sure i understand the question.// what happens to the memory of v2 here?
noalias(*v2.at(i)) = prod(*theMatrix.at(i),*v1.at(i));
for the rest: use resize without preserve or push_back of the std::vector. Never use new/delete as long as no one forces you to. Instead of storing n vectors of same size in a std::vector use a matrix.