/* Test program to test resize of symmetric matrix, adapted from example * provided at http://www.boost.org/libs/numeric/ublas/doc/symmetric.htm * * author: Tinne De Laet (first dot last at mech dot kuleuven dot be) */ #include #include int main () { using namespace boost::numeric::ublas; // Check resize for matrix matrix m (3, 3); for (unsigned i = 0; i < m.size1 (); ++ i) for (unsigned j = 0; j < m.size2 (); ++ j) m (i, j) = 3 * i + j; std::cout << "original m" << m << "\n" << std::endl; std::cout << "Resize m to bigger size" << std::endl; m.resize(m.size1 () +2, m.size2 () +2,true); std::cout << "m resized: " << m << " \n" << std::endl; std::cout << "Resize m to smaller size" << std::endl; m.resize(m.size1 () -1, m.size2 () -1,true); std::cout << "m resized: " << m << " \n" << std::endl; // Check resize for symmetric matrix symmetric_matrix ml (3, 3); for (unsigned i = 0; i < ml.size1 (); ++ i) for (unsigned j = 0; j <= i; ++ j) ml (i, j) = 3 * i + j; std::cout << "original ml" << ml << " \n" << std::endl; symmetric_matrix mu (3, 3); for (unsigned i = 0; i < mu.size1 (); ++ i) for (unsigned j = i; j < mu.size2 (); ++ j) mu (i, j) = 3 * i + j; std::cout << "original mu" << mu << " \n" << std::endl; std::cout << "Resize ml to bigger size" << std::endl; ml.resize(ml.size1 () +2,true); std::cout << "ml resized: " << m << " \n" << std::endl; std::cout << "Resize ml to smaller size" << std::endl; ml.resize(ml.size1 () -1,true); std::cout << "ml resized: " << m << " \n" << std::endl; std::cout << "Resize mu to smaller size" << std::endl; mu.resize(mu.size1 () -1,true); std::cout << "mu resized: " << m << " \n" << std::endl; std::cout << "Resize mu to bigger size" << std::endl; mu.resize(mu.size1 () +1,true); std::cout << "mu resized: " << m << " \n" << std::endl; }