I'm using Eigen to perform some matrix manipulations in C++. In it, I have a line schematically of the form
MatrixXcd A = MatrixXcd::Zeros(10,10);
A(0,0) += 2.0*1i;
Compiling this on my local computer gives no problems. However, compiling it on a different computer using the same CMake file gives the following error:
error: no match for ‘operator+=’ (operand types are ‘Eigen::DenseCoeffsBase<Eigen::Matrix<std::complex<double>, -1, -1>, 1>::Scalar {aka std::complex<double>}’ and ‘__complex__ double’)
so somehow the types std::comple<double>
and __complex__ double
are different, and the computer is unable to resolve the difference. Can someone explain to me what these differences are, and how to remove the discrepancy? I could try figuring out how the two computers are configured differently, but that seems like a more difficult problem to get help with online.
Ensure you add the line
using namespace std::complex_literals;
at beginning of your main() function.
Also check that probably you want to do A(0,0) += 2.0 + 1i;
instead of A(0,0) += 2.0*1i;