英特尔C ++编译器和Eigen

时间:2016-05-18 18:25:07

标签: c++ visual-studio intel eigen

我正在尝试使用intel C ++编译器编译我的代码,该代码具有矩阵乘法功能。对于矩阵乘法,我使用的是Eigen库。这是示例代码。我正在使用VS2013和最新版本的Eigen库。

#define EIGEN_USE_MKL_ALL
#include <Eigen/Dense>
using namespace Eigen;

int main()
{
  Matrix<double, 1, 200, RowMajor> y_pred;
  y_pred.setRandom(); // Eigen library function
  double learning_rate = 0.5;
  cout << learning_rate * y_pred << endl;
  return 1;
}

当我使用intel C ++编译器时,我收到以下错误:

1>error : more than one operator "*" matches these operands:
1>              function "Eigen::operator*(const double &, const Eigen::MatrixBase<Eigen::Matrix<double, 1, 200, 1, 1, 200>> &)"
1>              function "Eigen::operator*(const std::complex<double> &, const Eigen::MatrixBase<Eigen::Matrix<double, 1, 200, 1, 1, 200>> &)"
1>              function "Eigen::internal::operator*(const float &, const Eigen::Matrix<std::complex<float>, -1, -1, 0, -1, -1> &)"
1>              function "Eigen::internal::operator*(const float &, const Eigen::Matrix<std::complex<float>, -1, 1, 0, -1, 1> &)"
1>              function "Eigen::internal::operator*(const float &, const Eigen::Matrix<std::complex<float>, 1, -1, 1, 1, -1> &)"
1>              function "Eigen::internal::operator*(const float &, const Eigen::Matrix<Eigen::scomplex, -1, -1, 1, -1, -1> &)"
1>              operand types are: float * Eigen::Matrix<double, 1, 200, 1, 1, 200>
1>              y_pred = learning_rate * y_pred;

1 个答案:

答案 0 :(得分:0)

您可以显式执行标量计算:

cout << learning_rate * y_pred.array() << endl;