Re: [eigen] adding constructor to SparseMatrix |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] adding constructor to SparseMatrix
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Mon, 14 Jun 2010 13:37:36 +0200
- Cc: Daniel Lowengrub <lowdanie@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=/RWo9PpwOvlmv5DRFBXljHM9zNOqeyDH4xIVomQ6mmk=; b=FG+ugoay4UQmByX1+03nswUa3CR+H9QvalMGO35sSWg609zhaOjpGx/BGBC0AyS5qy OaygS2zQ/AWSUcy7PeA642Tpb/g0mhg02eYjvQ/ztu0O5AOdRpuHkUUM2wP8/WRLrVrD hVBDyrRk0wlYTl2ScWhX472Fq2lPGgIQ6h0hw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=anXkul7cUR2W9Kikv8DMWjaRNmeyOxcNuQEUBO8PZKHH6GDoc8EI5PD+2tH1L730y5 cRp8s4g8vP0K+aVh9SDFHGGnSK8wn2NIwimJaJxt8RiMwxNK4mg2aJ1P8InRP8GcIsU+ Rq32higdNdfh8lK0h46xlBg+9CJ9YPc7sFUoQ=
Hi list,
sorry I did not realized I replied to Daniel privately, and so we had
a long discussion about that topic privately. My bad.
To summarize, Daniel just pushed a set changes adding a SparseView
sparse expression allowing to view a dense expression as a sparse one
removing small value. The API is as follow:
MatrixBase::sparseView(Scalar reference=0, RealScalar epsilon =
<default epsilon>);
e.g.:
MatrixXd a, b;
SparseMatrix<double> mat = (a + b).sparseView(); // skip all zero
SparseMatrix<double> mat = (a + b).sparseView(1); // skip small values
compared to 1
This is very useful for debugging purpose.
Actually, this SparseView class is implemented in such a way that it
can also be used to filter small values of a sparse expression too.
However, it still remains the question of the respective
SparseMatrixBase method since here sparseView does not fit !!
Of course you are still welcome to comment on the above API :)
cheers,
gael
On Mon, Jun 7, 2010 at 12:11 AM, Daniel Lowengrub <lowdanie@xxxxxxxxx> wrote:
> Sorry about the previous mis-post.
> I think that it'd be useful to be able to quickly cast a regular
> Matrix type into a SparseMatrix. I have two questions about the
> implementation:
> 1) Would it be better to implement a new SparseMatrix ctor that
> accepts a Matrix as an argument, or to implement a function like
> sparseView in the Matrix class which returns a SparseMatrix?
> 2) At what level would it make sense for this to work? In the first
> direction, a general MatrixBase shouldn't be able to be turned into a
> SparseMatrix because this doesn't make sense for some subtypes of
> MatrixBases such as expressions. In the other direction, if the
> answer to the first question is to add a ctor, then should it be added
> to SparseMatrixBase and be available to all of it's children, or
> should it be specific to SparseMatrix? Casting a DenseMatrix to a
> SparseMatrix is probably most useful when a DenseMatrix is constructed
> as part of an algorithm but the algorithm requires operations like
> factorization and linear system solving which are more efficient when
> performed on a SparseMatrix [if the matrix is truly sparse]. Because
> of this, casting a Matrix to a DynamicSparseMatrix doesn't seem too
> helpful.
>
> What do you think?
> Daniel
>
> On 6/7/10, Daniel Lowengrub <lowdanie@xxxxxxxxx> wrote:
>>
>>
>