You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
376 B

  1. #include <Eigen/Core>
  2. #include <iostream>
  3. using namespace StormEigen;
  4. using namespace std;
  5. // define function to be applied coefficient-wise
  6. double ramp(double x)
  7. {
  8. if (x > 0)
  9. return x;
  10. else
  11. return 0;
  12. }
  13. int main(int, char**)
  14. {
  15. Matrix4d m1 = Matrix4d::Random();
  16. cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(ptr_fun(ramp)) << endl;
  17. return 0;
  18. }