Re: [eigen] Overflow in sum() |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Overflow in sum()
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 1 Apr 2009 16:16:28 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=jAvqngii0U20sFV10473L8izzLhMXFMxwLQyopGm5h4=; b=xwUW3mMVn1h57/nau5WAoedzQTF59tIaXvGE6UupaOHdScj8m/51eI/u/xUqS7M+ne NfFbfJ8sX6a12Lhq6TF8WiQF18YWGgwjcIgqEYgZy5SFJL+dLX0JUObBKvUrOQKYAusk 19aeLzG2mevquDpsVPGgVS/qeqbUy/dusiIVg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=DRRAqyaC05gJUGtuiYIJvABzHwJ5EZeA/7pRe4YZnf/6uMCWCQdOCKSwROLM2oNTHR 1A53GEaAdamKoTmepCfsZEp93YcaEtffbMfW3d2ujyLB/e9UayK8kH8ncNROrMfdVs1N XWDETbWQV7tL4sSb1S2uIrK8cJnBe7RmjKHDI=
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
>