Re: [eigen] SparseView

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


Thanks much, it appears to be working as advertised for me now.

I made the mistake of only grepping for SparseView rather than
sparseView, so I never found the method version.

Rob


On Fri, Jan 6, 2017 at 9:05 AM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
> 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.
>>
>> gael
>>
>> On Fri, Jan 6, 2017 at 5:05 PM, Rob McDonald <rob.a.mcdonald@xxxxxxxxx>
>> 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
>>>
>>>
>>
>



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