tut_matrix_resize.cpp 489 B

123456789101112131415161718
  1. #include <iostream>
  2. #include <Eigen/Dense>
  3. using namespace Eigen;
  4. int main()
  5. {
  6. MatrixXd m(2,5);
  7. m.resize(4,3);
  8. std::cout << "The matrix m is of size "
  9. << m.rows() << "x" << m.cols() << std::endl;
  10. std::cout << "It has " << m.size() << " coefficients" << std::endl;
  11. VectorXd v(2);
  12. v.resize(5);
  13. std::cout << "The vector v is of size " << v.size() << std::endl;
  14. std::cout << "As a matrix, v is of size "
  15. << v.rows() << "x" << v.cols() << std::endl;
  16. }