Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / libs / eigen / doc / examples / class_CwiseBinaryOp.cpp
blob682af46de49b95dae4825daf92c8863b65c2a0c1
1 #include <Eigen/Core>
2 #include <iostream>
3 using namespace Eigen;
4 using namespace std;
6 // define a custom template binary functor
7 template<typename Scalar> struct MakeComplexOp {
8 EIGEN_EMPTY_STRUCT_CTOR(MakeComplexOp)
9 typedef complex<Scalar> result_type;
10 complex<Scalar> operator()(const Scalar& a, const Scalar& b) const { return complex<Scalar>(a,b); }
13 int main(int, char**)
15 Matrix4d m1 = Matrix4d::Random(), m2 = Matrix4d::Random();
16 cout << m1.binaryExpr(m2, MakeComplexOp<double>()) << endl;
17 return 0;