#include#include int main() { Eigen::VectorXd v1(3); v1 << 1, 2, 3; std::cout << "v1 = \n" << v1 << std::endl; Eigen::VectorXd v2(3); v2 << 4, 5, 6; std::cout << "v2 = \n" << v2 << std::endl; Eigen::VectorXd v3 = v1 + v2; std::cout << "v3 = \n" << v3 << std::endl; return 0; }
#includeIn this example, we create a VectorXd object v and initialize its values. We then compute the dot product of v with itself using the dot() method. We also compute the normalized vector of v using the normalized() method and print out its contents.#include int main() { Eigen::VectorXd v(5); v << 1, 2, 3, 4, 5; double dot = v.dot(v); std::cout << "dot product of v with itself: " << dot << std::endl; Eigen::VectorXd v_normalized = v.normalized(); std::cout << "normalized v: \n" << v_normalized << std::endl; return 0; }