From 657013c9743d9774d2fbb227b16e575b2f1ac2b0 Mon Sep 17 00:00:00 2001 From: Jitse Niesen Date: Mon, 27 Dec 2010 16:35:25 +0000 Subject: Mention ptr_fun in docs for .unaryExpr() --- doc/examples/class_CwiseUnaryOp_ptrfun.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 doc/examples/class_CwiseUnaryOp_ptrfun.cpp (limited to 'doc/examples/class_CwiseUnaryOp_ptrfun.cpp') diff --git a/doc/examples/class_CwiseUnaryOp_ptrfun.cpp b/doc/examples/class_CwiseUnaryOp_ptrfun.cpp new file mode 100644 index 000000000..36706d8ed --- /dev/null +++ b/doc/examples/class_CwiseUnaryOp_ptrfun.cpp @@ -0,0 +1,20 @@ +#include +#include +using namespace Eigen; +using namespace std; + +// define function to be applied coefficient-wise +double ramp(double x) +{ + if (x > 0) + return x; + else + return 0; +} + +int main(int, char**) +{ + Matrix4d m1 = Matrix4d::Random(); + cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(ptr_fun(ramp)) << endl; + return 0; +} -- cgit v1.2.3