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*: Patrick Mihelich <patrick.mihelich@xxxxxxxxx>*Date*: Wed, 1 Apr 2009 11:53:30 -0700*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; bh=U+/Jy59/wmZ4Q87PlUZIVc2y+jd7amZvXbbrvUAYb20=; b=OSgIRq4TBh5a+pNrMej0ijHQAYdTMnenADME3uAh2zXnoiXS1glpcd6OGp4s9MaPTT Kjx4VXDtrt1AoGFQUdeusCdR+GZAGxBxeX1KS7sI+2K3Wg4rXEmuz1/OFT3DKia2oVPm WPoWKT22YrtqMr/59ktBW6unE1FNtFsQBm4SM=*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; b=lObgygPZ+q38w3l1fc0aznKqugpoC+Znz5/piMec7Y7tEUi6FiShaANjznk4pAWusj +TedJzjTTzT7719iyg0CVOK81wIYOjizBcUpOW+PJCM+O/PrUsUnnNg2hmzJixqaMqS6 n1dauHnDPe/G6nUoNmlloM94Oz3GnNMqW0pMQ=

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".

I also have this use case, and not only for sparse matrices. I often use uint8 arrays, either because I'm dealing with images or when I have some floating-point feature vector that I quantize to uint8 for better time & space efficiency. It would be *awesome* if Eigen had good support (SSE, etc.) for small integer types; I already have code where I am using Eigen for manipulating float feature vectors and my own ugly hand-rolled SSE stuff for the quantized uint8 feature vectors. This does require choosing the accumulation type intelligently, and maybe the unsigned types have their own issues.

An approach that has worked nicely for me is to use a very simple metaprogram:

template<typename T> struct Accumulation { typedef T type; }

template<> struct Accumulation<unsigned char> { typedef unsigned int type; }

// etc.

Then it is very easy for the user to define an accumulated scalar type different from the custom scalar type using partial specialization, and this type can be used transparently throughout Eigen.

Patrick

**Follow-Ups**:**Re: [eigen] Overflow in sum()***From:*Benoit Jacob

**Re: [eigen] Overflow in sum()***From:*Benoit Jacob

**References**:**[eigen] Overflow in sum()***From:*Jens Mueller

**Re: [eigen] Overflow in sum()***From:*Benoit Jacob

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [eigen] Overflow in sum()** - Next by Date:
**Re: [eigen] Overflow in sum()** - Previous by thread:
**Re: [eigen] Overflow in sum()** - Next by thread:
**Re: [eigen] Overflow in sum()**

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