#include #include #include #include int main() { //using namespace boost::numeric::ublas; //using namespace std; int size = 4; // matrix A(4, 4), B(identity_matrix(4)); // OK with 1, 2, 3, 4. Crash with 5, 6, ... (Floating exception) //matrix A(size, size), B(identity_matrix(size)); // I will get a compile time error here ***, even if size is a const int boost::numeric::ublas::matrix A(size, size); boost::numeric::ublas::vector B(boost::numeric::ublas::scalar_vector(size, 1)); for (int i = 0; i < size; ++i) for (int j = 0; j < size; ++j) A(i,j) = std::rand() % 10; boost::numeric::ublas::permutation_matrix<> pm(size); int result = boost::numeric::ublas::lu_factorize, boost::numeric::ublas::permutation_matrix<> >(A, pm); if ( 0 == result ) { boost::numeric::ublas::lu_substitute(A, pm, B); // *** Here is where the error is generated } else std::cout << "Error at row " << result << std::endl; }