diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-09-28 11:55:36 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-09-28 11:55:36 +0200 |
commit | 02e940fc9f55fffc69f0081781ede5949f9a37fc (patch) | |
tree | 78f379b2bd3f40b6a66099d2858306464766f0ba /doc/examples | |
parent | 8c1ee3629f845572caaba28c746bab0ef6a0084a (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.cpp | 18 |
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; +} |