Re: [eigen] SparseView |

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

*To*: eigen <eigen@xxxxxxxxxxxxxxxxxxx>*Subject*: Re: [eigen] SparseView*From*: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>*Date*: Fri, 6 Jan 2017 18:05:55 +0100*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=azLqPaHZ0rAB4qbjWRokZq50SYXpTcb9MRidvu+ctgY=; b=hL1GZNLwRW1gmXr5EedT4DnLcSHXMZ+/EQ5AvysAJYhyLYDQ52e4K9WAMKf1lB6zUi dv9qiz7TINVDcSJiRDz6eqcp4eTnDHFf3GlI+drGBsHiDvbXGtGQMDZAjyHRw93zQ7N0 kLcMsLN9lb469akABFOKaTswZdPamBjyxmkGf5XGDnF0oY2tESSmGIx0zkHUGBfTTT5D m6X5GOJ/R0zG/wsijVYoAl0mj4P2tjSuU3LaP+9t6l9S8mxiUVOMjvlFNSp8ieq3/tNb Q1u6h5ujanEBcdXzeicCqSQ5ONUDMM+uOV8TWgsOZ/Kh9yYFxZrVGUGH7/+I2zFcpglL gJ3g==

For the record, the shortcoming is now fixed, online docs will update automatically soon...

gael

On Fri, Jan 6, 2017 at 5:47 PM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx> wrote:

indeed, it's not documented. It's use is simple:MatrixXd A(n,n);SparseMatrix<double> B = A.sparseView();you can also pass a reference non-zero and a tolerance (that default to NumTraits<Scalar>::dummy_precision()) : SparseMatrix<double> B = A.sparseView(ref,epsilon);that will consider as zero values x s..t. x<=ref*epsilon.gaelOn Fri, Jan 6, 2017 at 5:05 PM, Rob McDonald <rob.a.mcdonald@xxxxxxxxxx> wrote:I'd like to construct a sparse matrix from a dense one. I realize

this will require iterating over (and testing) all the entries of the

matrix, but I also assume Eigen has a built-in way to do this than the

naive for-loops I would write.

I've found references to SparseView online -- sometimes apparently as

a method of a dense matrix -- other times as a stand-alone class.

I've also found SparseCore/SparseView.h in the Eigen source.

Unfortunately, I haven't found anything resembling documentation or an

example of how to actually use this. The class definition for

SparseView seems to be self-referencing:

template<typename MatrixType>

class SparseView : public SparseMatrixBase<SparseView<MatrixType> >

Which was more than my feeble mind could handle...

Does anyone have any pointers on the best way to do this?

I'm currently using Eigen 3.2.8. I can update if required, but

mention it just in case it is relevant.

Thanks in advance,

Rob

**Follow-Ups**:**Re: [eigen] SparseView***From:*Rob McDonald

**References**:**[eigen] SparseView***From:*Rob McDonald

**Re: [eigen] SparseView***From:*Gael Guennebaud

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] SparseView** - Next by Date:
**Re: [eigen] SparseView** - Previous by thread:
**Re: [eigen] SparseView** - Next by thread:
**Re: [eigen] SparseView**

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