class_CwiseBinaryOp.cpp
Go to the documentation of this file.
1 #include <Eigen/Core>
2 #include <iostream>
3 
4 using Eigen::Matrix4d;
5 
6 // define a custom template binary functor
7 template<typename Scalar> struct MakeComplexOp {
8  typedef std::complex<Scalar> result_type;
9  result_type operator()(const Scalar& a, const Scalar& b) const { return result_type(a,b); }
10 };
11 
12 int main(int, char**)
13 {
14  Matrix4d m1 = Matrix4d::Random(), m2 = Matrix4d::Random();
15  std::cout << m1.binaryExpr(m2, MakeComplexOp<double>()) << std::endl;
16  return 0;
17 }
Array< int, 3, 1 > b
Matrix3d m1
Definition: IOFormat.cpp:2
IndexedView_or_Block operator()(const RowIndices &rowIndices, const ColIndices &colIndices)
MatrixType m2(n_dims)
int main(int, char **)
Matrix< double, 4, 4 > Matrix4d
4×4 matrix of type double.
Definition: Matrix.h:502