class_CwiseUnaryOp_ptrfun.cpp
Go to the documentation of this file.
1 #include <Eigen/Core>
2 #include <iostream>
3 
4 // define function to be applied coefficient-wise
5 double ramp(double x)
6 {
7  if (x > 0)
8  return x;
9  else
10  return 0;
11 }
12 
13 int main(int, char**)
14 {
16  std::cout << m1 << std::endl << "becomes: " << std::endl << m1.unaryExpr(std::ptr_fun(ramp)) << std::endl;
17  return 0;
18 }
Matrix3d m1
Definition: IOFormat.cpp:2
static const RandomReturnType Random()
Definition: Random.h:114
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
int main(int, char **)
double ramp(double x)