Re: [eigen] Checking for integer overflow in size computations |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
On 17.10.2011 00:36, Benoit Jacob wrote:
2011/10/16 Christoph Hertzberg<chtz@xxxxxxxxxxxxxxxxxxxxxxxx>:On 16.10.2011 22:21, Benoit Jacob wrote:Note that there is a small performance overhead associated with that. I tried to minimize it, but there is still 1 integer division in the size=rows*cols overflow check. I hope that's still negligible compared to the cost of malloc.I have not looked into your patch yet, but wouldn't a multiplication in int64/int128 also do the job?I don't know that all platforms have an integer type twice bigger than size_t? On x86-64 are there 128 bit integers? I didn't know that. Also I'm afraid there might exist 32bit platforms without 64bit integers.
Well, naturally I can't say that for every platform, but for x86-64 it seems to be possible:
http://stackoverflow.com/questions/1541426/computing-high-64-bits-of-a-64x64-int-product-in-cIf someone really cared, one could implement a backup solution using grid multiplication (where most parts can be ignored, and the case that both high parts are !=0 is trivial)
Christoph -- ---------------------------------------------- Dipl.-Inf. Christoph Hertzberg Cartesium 0.051 Universität Bremen Enrique-Schmidt-Straße 5 28359 Bremen Tel: (+49) 421-218-64252 ----------------------------------------------
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |