Re: [eigen] [Sparse] cwise op |

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

*To*: <eigen@xxxxxxxxxxxxxxxxxxx>*Subject*: Re: [eigen] [Sparse] cwise op*From*: <bernard.hugueney@xxxxxxxxxx>*Date*: Fri, 19 Nov 2010 16:33:20 +0100

Hi,

Hi, this is already the default behavior, otherwise the result would be dense, and that would make no sense to use a sparse representation. That's also why there are currently only a very few cwise binary operator exposed.There is also one exception for coeff wise operator* for which weskipeach pair of elements where one is a zero. Currently, this isspecificto operator*, but using traits, we could extend it to operator &&forboolean matrices and perhaps a few others... gael

Yes, I understand that you provide the cwiseXXX with the right

Traits could give the cancellation property giving the best traversal.

another sparse (as in block() of dense matrices) as in [0] Any enlightenment welcome :) Best Regards, Bernard #include <iostream> #include <Eigen/Core> #include <Eigen/Sparse> // write src into dest from pos (r,c) template<typename Scalar1, typename Scalar2>

{

typedef Eigen::SparseMatrix<Scalar2> dest_t; for (std::size_t k=0; k != src.outerSize(); ++k) { for (srcIt_t it(src,k); it; ++it) { dest.insert( it.row()+r, it.col()+c)= it.value(); } } dest.finalize(); } int main(int argc, char* argv[]) {

ac.insert(0,1)=1.; ac.insert(2,9)=3.; ac.insert(3,4)= 2; ac.finalize(); Eigen::SparseMatrix<double> dest(4,20); std::cerr<<"write:\n"<<ac<<std::endl; doWrite(ac, 0, 0, dest); std::cout<<dest<<std::endl; doWrite(ac, 0, 10, dest); std::cout<<dest<<std::endl; return 0; } outputs : write: Nonzero entries: (1,0) (2,3) (3,2) Column pointers: 0 0 1 1 1 2 2 2 2 2 $ Nonzero entries: (1,1) (3,9) (2,4) Column pointers: 0 1 1 2 $ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 2 0 0 0 0 0 Nonzero entries: (1,0) (2,3) (3,2) Column pointers: 0 0 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 $ Nonzero entries: (1,1) (3,9) (2,4) Column pointers: 0 1 1 2 $ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Nonzero entries: (1,0) (2,3) (3,2) (2,3) (3,2) (0,0) Column pointers: 0 0 1 1 1 2 2 2 2 2 3 3 4 3 3 4 4 4 4 4 $ Nonzero entries: (1,1) (3,9) (3,19) (2,4) (2,11) (2,14) Column pointers: 0 1 1 3 $ 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 3 0 0 0 0 2 0 0 0 0 0 0 2 0 0 2 0 0 0 0 0 ←fail ☹

**Follow-Ups**:**Re: [eigen] [Sparse] cwise op***From:*Gael Guennebaud

**References**:**[eigen] [Sparse] cwise op***From:*bernard.hugueney

**Re: [eigen] [Sparse] cwise op***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] new API for Cholmod** - Next by Date:
**Re: [eigen] [Sparse] cwise op** - Previous by thread:
**Re: [eigen] [Sparse] cwise op** - Next by thread:
**Re: [eigen] [Sparse] cwise op**

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