Re: [eigen] adding constructor to SparseMatrix

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


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:
>>
>>
>



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