#include#include int main() { Eigen::MatrixXd A(3,5); // fill A with some values here... Eigen::VectorXd sub = A.col(0); sub.conservativeResize(3); sub << A.col(0), A.col(1); std::cout << "Sub-matrix with first two columns:\n" << sub << std::endl; return 0; }
#includeIn this code, we use the tail() method to extract the last three elements of v and store them in a VectorXd called sub. We then print sub to the console to display the sub-vector.#include int main() { Eigen::VectorXd v(10); // fill v with some values here... Eigen::VectorXd sub = v.tail(3); std::cout << "Sub-vector with last three columns:\n" << sub << std::endl; return 0; }