Re: [eigen] [Sparse] element acces in a cwise unary op on an Eigen::Sparse |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] [Sparse] element acces in a cwise unary op on an Eigen::Sparse
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Thu, 25 Nov 2010 13:13:59 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=aNHtmKAtmtSomKr76TCT/aRjk39nYi8QGxHILWi2vnY=; b=ZxVw7x6IZ//Wb+b7rxLw1qoHBackj1zf3geQ/QnY5Bwag6n9+13hbRx2zKxeJcuGVG M9k0jdId+IAEQ0OerQRs/1BW//AUcKHs9v0bLFBi2CI45bO+wgWj8pQNnSzbtys+K64A RO6HauITfXkpQ2J+t+wUQinUkW8pImeltwj8E=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=ALVzvBCQbCf53guxFYPzrWKVitkgFqQ0lu/ZJhNJi8nPj6wqitM9KYarh3Rjko/dzF NH48OGHLKwmVqpbOMCdmta7n+p28uXrKn/FORI/IeVBhgAfQGm+tf45zNYFF4wIIFdNI vs4z0/GkexQIgxQ/YCPt/RK9UJmdtRh7wgifs=
Random access to a sparse matrix is inherently very inefficient, and
so I decided not to support it. Instead use iterators and/or, some
fast access function like .innerVector(i).lastCoeff() ...
SparseMatrix and DynamicSparseMatrix objects provide a coeff()
function for debug purpose only. It is not supposed to be used in
production code.
gael.
On Thu, Nov 25, 2010 at 10:11 AM, <bernard.hugueney@xxxxxxxxxx> wrote:
>
> 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
>
>
>