From 65cd1c7639e6dab0416ecc440b01e7257554dfc0 Mon Sep 17 00:00:00 2001 From: Jitse Niesen Date: Mon, 11 Jan 2010 18:05:30 +0000 Subject: Add support for matrix sine, cosine, sinh and cosh. --- unsupported/doc/examples/MatrixSine.cpp | 21 +++++++++++++++++++++ unsupported/doc/examples/MatrixSinh.cpp | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 unsupported/doc/examples/MatrixSine.cpp create mode 100644 unsupported/doc/examples/MatrixSinh.cpp (limited to 'unsupported/doc') diff --git a/unsupported/doc/examples/MatrixSine.cpp b/unsupported/doc/examples/MatrixSine.cpp new file mode 100644 index 000000000..f8780ac92 --- /dev/null +++ b/unsupported/doc/examples/MatrixSine.cpp @@ -0,0 +1,21 @@ +#include + +using namespace Eigen; + +int main() +{ + MatrixXd A = MatrixXd::Random(3,3); + std::cout << "A = \n" << A << "\n\n"; + + MatrixXd sinA; + ei_matrix_sin(A, &sinA); + std::cout << "sin(A) = \n" << sinA << "\n\n"; + + MatrixXd cosA; + ei_matrix_cos(A, &cosA); + std::cout << "cos(A) = \n" << cosA << "\n\n"; + + // The matrix functions satisfy sin^2(A) + cos^2(A) = I, + // like the scalar functions. + std::cout << "sin^2(A) + cos^2(A) = \n" << sinA*sinA + cosA*cosA << "\n\n"; +} diff --git a/unsupported/doc/examples/MatrixSinh.cpp b/unsupported/doc/examples/MatrixSinh.cpp new file mode 100644 index 000000000..488d95652 --- /dev/null +++ b/unsupported/doc/examples/MatrixSinh.cpp @@ -0,0 +1,21 @@ +#include + +using namespace Eigen; + +int main() +{ + MatrixXf A = MatrixXf::Random(3,3); + std::cout << "A = \n" << A << "\n\n"; + + MatrixXf sinhA; + ei_matrix_sinh(A, &sinhA); + std::cout << "sinh(A) = \n" << sinhA << "\n\n"; + + MatrixXf coshA; + ei_matrix_cosh(A, &coshA); + std::cout << "cosh(A) = \n" << coshA << "\n\n"; + + // The matrix functions satisfy cosh^2(A) - sinh^2(A) = I, + // like the scalar functions. + std::cout << "cosh^2(A) - sinh^2(A) = \n" << coshA*coshA - sinhA*sinhA << "\n\n"; +} -- cgit v1.2.3