summaryrefslogtreecommitdiffhomepage
path: root/eigen/doc/snippets/TopicAliasing_mult2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'eigen/doc/snippets/TopicAliasing_mult2.cpp')
-rw-r--r--eigen/doc/snippets/TopicAliasing_mult2.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/eigen/doc/snippets/TopicAliasing_mult2.cpp b/eigen/doc/snippets/TopicAliasing_mult2.cpp
new file mode 100644
index 0000000..a3ff568
--- /dev/null
+++ b/eigen/doc/snippets/TopicAliasing_mult2.cpp
@@ -0,0 +1,10 @@
+MatrixXf matA(2,2), matB(2,2);
+matA << 2, 0, 0, 2;
+
+// Simple but not quite as efficient
+matB = matA * matA;
+cout << matB << endl << endl;
+
+// More complicated but also more efficient
+matB.noalias() = matA * matA;
+cout << matB;