[eigen] [Sparse] element acces in a cwise unary op on an Eigen::Sparse |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
Hi,
I'd like to have access on elements of a cwise unary op, but the
compiler
cannot find a coeff member function.
the folowing code :
#include <iostream>
#include <Eigen/Core>
#include <Eigen/Sparse>
#include <complex>
template<typename Derived>
void useCoeff( Eigen::EigenBase<Derived> const a){
std::cout<<a.coeff(0,0)<<std::endl;
}
int main(int argc, char* argv[])
{
Eigen::SparseMatrix<double> a(2,2);
std::cout<<a.coeff(0,0)<<std::endl;
useCoeff(a.cast<std::complex<double> >());
return 0;
}
gives the error :
tst-coeff.cxx: In function ‘void useCoeff(Eigen::EigenBase<Derived>)
[with Derived =
Eigen::CwiseUnaryOp<Eigen::internal::scalar_cast_op<double,
std::complex<double> >, Eigen::SparseMatrix<double> >]’:
tst-coeff.cxx:15:45: instantiated from here
tst-coeff.cxx:8:5: error: ‘const class
Eigen::CwiseUnaryOp<Eigen::internal::scalar_cast_op<double,
std::complex<double> >, Eigen::SparseMatrix<double> >’ has no member
named ‘coeff’
How am I to access elements of my cast expression ?
Any help greatly appreciated :)
Best regards,
Bernard