Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Optimization 我在这里使用什么特征类型进行最佳优化?_Optimization_Eigen - Fatal编程技术网

Optimization 我在这里使用什么特征类型进行最佳优化?

Optimization 我在这里使用什么特征类型进行最佳优化?,optimization,eigen,Optimization,Eigen,下面的代码(使用Eigen库)是我需要的简化版本 什么类型的名称代替了这里的\u struct ABC { virtual _HERE_ f(const MatrixXd& x) const = 0; }; struct Sub : ABC { _HERE_ f(const MatrixXd& x) const { return 1 - x.array(); } }; struct Pow : ABC { _HERE_ f(co

下面的代码(使用Eigen库)是我需要的简化版本

什么类型的名称代替了这里的
\u

struct ABC {
    virtual _HERE_ f(const MatrixXd& x) const = 0;
};

struct Sub : ABC {
    _HERE_ f(const MatrixXd& x) const {
        return 1 - x.array();
    }
};

struct Pow : ABC {
    _HERE_ f(const MatrixXd& x) const {
        return m.array().pow(5);
    }
};
问题是什么是最佳优化

这两个操作都返回某种类型的
CwiseBinaryOp
,但不是相同类型的
CwiseBinaryOp

我知道我可以在这里用
MatrixXd
代替
\u,但我怀疑这并不能实现最佳优化

对于函数的每次使用,是否必须将
CwiseBinaryOp
转换为
MatrixXd


我还想知道如果我需要
CwiseBinaryOp
CwiseUnaryOp
只需返回
MatrixXd
——如果你想利用表达式模板,你需要使用静态多态性。