Re: [eigen] SparseView |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
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
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |