I am successfully working with Eigen and I'm trying to understand a few details with complex numbers.
This works fine (Visual Studio)
kx.real()(0, 0) = 1.0;
This throws a compiler error
kz_r.imag()(0, ii) =1.0
The error I get is:
Severity Code Description Project File Line Suppression State Error C2440 'return': cannot convert from 'double' to 'double &' \eigen\src\core\mathfunctions.h 919
Just use std::complex<double>
(or float
):
std::complex<double> c(1,1);
Eigen::MatrixXd R1; R1.setRandom(2,2);
Eigen::MatrixXcd C1 = c*R1; // multiply complex*real
Eigen::MatrixXcd C2 = c*C1; // complex scalar times complex matrix
C1(0,0) = c; // assign complex value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With