aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/examples
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2015-09-28 11:55:36 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2015-09-28 11:55:36 +0200
commit02e940fc9f55fffc69f0081781ede5949f9a37fc (patch)
tree78f379b2bd3f40b6a66099d2858306464766f0ba /doc/examples
parent8c1ee3629f845572caaba28c746bab0ef6a0084a (diff)
bug #1071: improve doc on lpNorm and add example for some operator norms
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_operatornorm.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_operatornorm.cpp b/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_operatornorm.cpp
new file mode 100644
index 000000000..62e28fc31
--- /dev/null
+++ b/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_reductions_operatornorm.cpp
@@ -0,0 +1,18 @@
+#include <Eigen/Dense>
+#include <iostream>
+
+using namespace Eigen;
+using namespace std;
+
+int main()
+{
+ MatrixXf m(2,2);
+ m << 1,-2,
+ -3,4;
+
+ cout << "1-norm(m) = " << m.cwiseAbs().colwise().sum().maxCoeff()
+ << " == " << m.colwise().lpNorm<1>().maxCoeff() << endl;
+
+ cout << "infty-norm(m) = " << m.cwiseAbs().rowwise().sum().maxCoeff()
+ << " == " << m.rowwise().lpNorm<1>().maxCoeff() << endl;
+}