将函数应用于特征矩阵的重复子矩阵

时间:2018-04-26 05:33:52

标签: c++ eigen

这个答案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;
}

但是,我想将一个滑动窗口应用于Matrix,以便我可以编写一个函数:

double foo(Eigen::Matrix2d x) // the functor we want to apply
{
    // Whatever
}

这可能吗?

0 个答案:

没有答案