Re: [eigen] Overflow in sum()

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


It depends how common your use case is: if many people are going to do
the same, we could have another template parameter for sparse
matrices, the "accumulated scalar type", decoupled from the "scalar
type".

Otherwise, you might just have your own safe_sum() method (we can add
EIGEN_SPARSEMATRIX_PLUGIN and/or EIGEN_SPARSEMATRIXBASE_PLUGIN macros
if you need, so you can add methods also to sparse classes).

Benoit

2009/4/1 Jens Mueller <jens.k.mueller@xxxxxx>:
> Hi,
>
> I added a custom Scalar type to Eigen, because my sparse matrices have
> many coefficients but these are rather small integers. When using the
> sum() method, I get wrong results, because the function returns a
> Scalar. I added an assertion (see attached diff against current trunk)
> to check for possible overflows.
> I'm willing to fix this problem but I'm not sure how. Any
> recommendations how to proceed?
>
> Regards,
> Jens
>



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