class_CwiseUnaryOp.cpp
Go to the documentation of this file.
1 #include <Eigen/Core>
2 #include <iostream>
3 using namespace Eigen;
4 using namespace std;
5 
6 // define a custom template unary functor
7 template<typename Scalar>
8 struct CwiseClampOp {
9  CwiseClampOp(const Scalar& inf, const Scalar& sup) : m_inf(inf), m_sup(sup) {}
10  const Scalar operator()(const Scalar& x) const { return x<m_inf ? m_inf : (x>m_sup ? m_sup : x); }
11  Scalar m_inf, m_sup;
12 };
13 
14 int main(int, char**)
15 {
16  Matrix4d m1 = Matrix4d::Random();
17  cout << m1 << endl << "becomes: " << endl << m1.unaryExpr(CwiseClampOp<double>(-0.5,0.5)) << endl;
18  return 0;
19 }
SCALAR Scalar
Definition: bench_gemm.cpp:33
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Definition: Half.h:150
Matrix3d m1
Definition: IOFormat.cpp:2
static double inf
Definition: testMatrix.cpp:30
const Scalar operator()(const Scalar &x) const
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
int main(int, char **)
CwiseClampOp(const Scalar &inf, const Scalar &sup)


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:47