英特尔C++编译器和Eigen

Intel C++ Compiler and Eigen

本文关键字:Eigen 编译器 C++ 英特尔      更新时间:2023-10-16

我正试图用英特尔C++编译器编译我的代码,它具有矩阵乘法。对于矩阵乘法,我使用的是特征库。这是示例代码。我将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;
}

当我使用英特尔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;

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

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