c++ - 英特尔 C++ 编译器和 Eigen

标签 c++ visual-studio intel eigen

我正在尝试使用英特尔 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;
}

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

关于c++ - 英特尔 C++ 编译器和 Eigen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37307428/

相关文章:

c++ - Windows Messaging - 捕获来自另一个 API 的调用

c++ - Rcpp 调试- fatal error : Datetime. h : No such file or directory; xtsAPI. h: 没有这样的文件或目录

c++ - 在包含 Eigen 类型的类上使用 ` Eigen::aligned_allocator` on `std::vector`

python - anaconda中intel python和intel环境的区别?

android - 在 Windows 10 上为 Android Studio 安装 HAXM

java - 如何获取完整的十六进制文件(英特尔和摩托罗拉十六进制文件)的总长度?

c++ - Windows 中的 pthread_cond_timedwait()

c++ - 关于标准中虚函数描述的一个问题

ios - Visual Studio iOS 部署失败,因为 "The edge module has not been pre-compiled"

visual-studio - 在 .NET Core 2.0 中查看项目属性时出错