You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
469 B

  1. #include <unsupported/Eigen/MatrixFunctions>
  2. #include <iostream>
  3. using namespace Eigen;
  4. std::complex<double> expfn(std::complex<double> x, int)
  5. {
  6. return std::exp(x);
  7. }
  8. int main()
  9. {
  10. const double pi = std::acos(-1.0);
  11. MatrixXd A(3,3);
  12. A << 0, -pi/4, 0,
  13. pi/4, 0, 0,
  14. 0, 0, 0;
  15. std::cout << "The matrix A is:\n" << A << "\n\n";
  16. std::cout << "The matrix exponential of A is:\n"
  17. << A.matrixFunction(expfn) << "\n\n";
  18. }