aboutsummaryrefslogtreecommitdiff
path: root/unsupported/doc/examples/MatrixSine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unsupported/doc/examples/MatrixSine.cpp')
-rw-r--r--unsupported/doc/examples/MatrixSine.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/unsupported/doc/examples/MatrixSine.cpp b/unsupported/doc/examples/MatrixSine.cpp
new file mode 100644
index 000000000..9eea9a081
--- /dev/null
+++ b/unsupported/doc/examples/MatrixSine.cpp
@@ -0,0 +1,20 @@
+#include <unsupported/Eigen/MatrixFunctions>
+#include <iostream>
+
+using namespace Eigen;
+
+int main()
+{
+ MatrixXd A = MatrixXd::Random(3,3);
+ std::cout << "A = \n" << A << "\n\n";
+
+ MatrixXd sinA = A.sin();
+ std::cout << "sin(A) = \n" << sinA << "\n\n";
+
+ MatrixXd cosA = A.cos();
+ 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";
+}