Re: [eigen] add SparseView

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


2010/6/14 Daniel Lowengrub <lowdanie@xxxxxxxxx>:
> Hi,
> I just added a SparseView class to the Sparse module.
> Usage:
> If d_mat is a DenseStorage matrix or expression then the sparseView
> method makes it compatible with Sparse types.  For example:
> Matrix3d m3,m4;
> Eigen::SparseMatrix<double> smat(3,3);
>
> m3 << 1, 0, 0, 2, 0, 0, 7, 2, 0;
> m4 << 0, 6, 0, 0, 0, 5, 0, 0, 4;
> smat = (m3*m4 + m3).sparseView();
> std::cout << smat;
>
> outputs:
> Nonzero entries:
> (1,0) (2,1) (7,2) (6,0) (12,1) (44,2) (10,2)
>
> Column pointers:
> 0 3 6  $
>
> [and other sparse info]
>
> In addition, a reference variable and an epsilon variable may be
> passed which determine the threshold for which values will be ignored
> by the sparse matrix:
> smat = (m3*m4 + m3).sparseView(reference);
> and:
> smat = (m3*m4 + m3).sparseView(reference, epsilon);

I like this API!

Thanks Daniel!

Benoit

>
>
>



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