This answer offers a single element solution:
#include <cmath>
#include <iostream>
#include <Eigen/Core>
double Exp(double x) // the functor we want to apply
{
return std::exp(x);
}
int main()
{
Eigen::MatrixXd m(2, 2);
m << 0, 1, 2, 3;
std::cout << m << std::endl << "becomes: ";
std::cout << std::endl << m.unaryExpr(&Exp) << std::endl;
}
However, I want to apply a sliding window to a Matrix so I could write a function:
double foo(Eigen::Matrix2d x) // the functor we want to apply
{
// Whatever
}
Is this possible?