dimanche 14 août 2022

Error passing Eigen matrix to a function in C++: "no instance of overloaded function matches the argument list"

I have a script that is working fine, but when I try to write a function with the same script I get the error "no instance of overloaded function "aapx" matches the argument list".

I know that an Eigen::Matrix should always be passed by reference to a function so I did and I thought maybe the issue is I am initializing a Eigen::Matrix<std::complex<double> and passing a Eigen::MatrixXcd but that doesn't seem to fix the error either.

The function

void aapx(const Eigen::Ref<const Eigen::MatrixXcd>& uh, Eigen::Ref<const Eigen::MatrixXcd>& vh, Eigen::Ref<const Eigen::MatrixXcd>& ph){ 
//some calculations

}

The main code looks like:

static const int nx = 10;
static const int ny = 10; 

Eigen::Matrix<std::complex<double>, (ny+1), (nx)> uh;
uh.setZero();

Eigen::Matrix<std::complex<double>, (ny+1), (nx)> vh;
vh.setZero();

Eigen::Matrix<std::complex<double>, (ny+1), nx> ph;  
ph.setZero();

aapx(uh,vh,ph); //ERROR

I can post the full code if necessary. The full error:

no instance of overloaded function "aapx" matches the argument list
argument types are: (Eigen::Matrix<std::_Complex<double>, 11, 10, 0, 11, 10>, Eigen::Matrix<std::_Complex<double>, 11, 10, 0, 11, 10>, Eigen::Matrix<std::_Complex<double>, 11, 10, 0, 11, 10>)

Aucun commentaire:

Enregistrer un commentaire