#include#include int main() { Eigen::VectorXd v(3); v << 1, 2, 3; std::cout << "Original vector:\n" << v << "\n"; Eigen::VectorXd transposed = v.transpose(); std::cout << "Transposed vector:\n" << transposed << "\n"; return 0; }
Original vector: 1 2 3 Transposed vector: 1 2 3
#include#include int main() { Eigen::VectorXd v(2); Eigen::MatrixXd m(3, 2); v << 1, 2; m << 1, 2, 3, 4, 5, 6; std::cout << "Original matrix:\n" << m << "\n"; Eigen::MatrixXd transposed = v.transpose() * m; std::cout << "Transposed matrix:\n" << transposed << "\n"; return 0; }
Original matrix: 1 2 3 4 5 6 Transposed matrix: 11 14The VectorXd transpose method is part of the Eigen library, which is a C++ template library for linear algebra.