[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] SparseView
- From: Rob McDonald <rob.a.mcdonald@xxxxxxxxx>
- Date: Fri, 6 Jan 2017 09:10:31 -0800
- 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=6eeXIdgpcvQTvxZPGqhWWojbakrfXriR3xtIy8rQBFY=; b=t0ARDwW3p9dbDEZBq8j70Jo4m7zQledeKhFG+hLG1S/n4zvmk6yZn7p0n+9EE3G/wn jXjDfGgkdz4RCG9eeYyxICGvAcmlVLS/xRucXB6a2UjyQLljbuS8QrGafco6KfyROsiN K3GHFiB8s5OAi9lMLBSoEZGog79d6IhadyFYRynKXNxUFvN3/QhUsIqMilSqbHteD+UG VNk1rmwhFhq+Gt8JXNTT4w5XaZeUhlFWOFeofh7BmLC81HbM1yNsxg4/66slBwNlFqq1 X7i0hgFhj7YW7VkEuRFSmn51lkcQzcEV7D2qBevkv27RCqwHFN64qsb2o2eEKhcUYLps rPyw==
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.
On Fri, Jan 6, 2017 at 9:05 AM, Gael Guennebaud
> For the record, the shortcoming is now fixed, online docs will update
> automatically soon...
> On Fri, Jan 6, 2017 at 5:47 PM, Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
>> 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.
>> On Fri, Jan 6, 2017 at 5:05 PM, Rob McDonald <rob.a.mcdonald@xxxxxxxxx>
>>> 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,