eigen/doc/examples/class_CwiseBinaryOp.cpp
Jitse Niesen 9f1fa6ea5e Fix compilation error in doc/examples/class_CwiseBinaryOp.cpp .
This is a follow-up of 9d54783036
 (better work around for empty structs).
2009-12-21 18:16:01 +00:00

19 lines
536 B
C++

#include <Eigen/Core>
#include <Eigen/Array>
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
// define a custom template binary functor
template<typename Scalar> struct MakeComplexOp {
EIGEN_EMPTY_STRUCT_CTOR(MakeComplexOp)
typedef complex<Scalar> result_type;
complex<Scalar> operator()(const Scalar& a, const Scalar& b) const { return complex<Scalar>(a,b); }
};
int main(int, char**)
{
Matrix4d m1 = Matrix4d::Random(), m2 = Matrix4d::Random();
cout << m1.binaryExpr(m2, MakeComplexOp<double>()) << endl;
return 0;
}