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*: <bernard.hugueney@xxxxxxxxxx>*Date*: Thu, 25 Nov 2010 15:50:43 +0100

Hi Gael, Thanks for your answer.

Random access to a sparse matrix is inherently very inefficient, and so I decided not to support it. Instead use iterators and/or, some

I am fully aware that is dumb to iterate over the whole virtual matrix however, the decision was not mine to make. Give that I had to enable some operations that result in a dense matrix (e.g. "or equal" logical ops between sparse matrices where 0. <= 0.

to iterate over it.

fast access function like .innerVector(i).lastCoeff() ...

#include <iostream> #include <Eigen/Core> #include <Eigen/Sparse> #include <complex> template<typename Derived> void useLastCoeff( Eigen::EigenBase<Derived> const a){ std::cout<<a.derived().innerVector(0).lastCoeff()<<std::endl; } int main(int argc, char* argv[]) { Eigen::SparseMatrix<double> a(2,5); a.insert(1,0)=555.; a.insert(2,0)=777.; a.insert(0,1)=666.; a.finalize(); useLastCoeff(a.cast<std::complex<double> >()); return 0; } fails with :

tst-coeff.cxx:20:49: instantiated from here

SparseMatrix and DynamicSparseMatrix objects provide a coeff() function for debug purpose only. It is not supposed to be used in production code.

every virtual element of the matrix (even the "0."), I'm stuck :( Btw, à propos Eigen::Sparse<bool> : - it would be nice to be able to set the default value to «true».

Thanks Best Regards, Bernard

**Follow-Ups**:**[eigen] [sparse] bool isMuchSmallerThan<OtherScalar>***From:*bernard.hugueney

**Re: [eigen] [Sparse] element acces in a cwise unary op on an Eigen::Sparse***From:*Gael Guennebaud

**References**:**[eigen] [Sparse] element acces in a cwise unary op on an Eigen::Sparse***From:*bernard.hugueney

**Re: [eigen] [Sparse] element acces in a cwise unary op on an Eigen::Sparse***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] [Sparse] element acces in a cwise unary op on an Eigen::Sparse** - Next by Date:
**[eigen] [sparse] bool isMuchSmallerThan<OtherScalar>** - Previous by thread:
**Re: [eigen] [Sparse] element acces in a cwise unary op on an Eigen::Sparse** - Next by thread:
**[eigen] [sparse] bool isMuchSmallerThan<OtherScalar>**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |