comp.lang.ada
 help / color / mirror / Atom feed
From: vincent.diemunsch@gmail.com
Subject: Re: Efficient Bit Vector Manipulation.
Date: Sat, 16 May 2015 04:58:01 -0700 (PDT)
Date: 2015-05-16T04:58:01-07:00	[thread overview]
Message-ID: <adc96dc3-0328-45c4-9ac9-3ec8141df64e@googlegroups.com> (raw)
In-Reply-To: <crml0kFpmvdU1@mid.individual.net>

Le vendredi 15 mai 2015 18:25:59 UTC+2, Niklas Holsti a écrit :

> Very well-known problem... see
> http://en.wikipedia.org/wiki/Find_first_set
> and
> http://graphics.stanford.edu/~seander/bithacks.html
> 
> The latter page gives C code, which should be easy to translate to Ada 
> using the modular types from Interfaces and their shift operations.

Thank you very much Niklas, there is all I need here for finding the first 1 bit !
 
> Same suggestion for the rest of your questions: use modular types, 
> shifts and masks.
> 
> I doubt that any compiler provides good optimization of such operations 
> on Boolean arrays, even if packed to one bit per element. Anyway, the 
> Ada RM does not define in which order the bits are indexed, so code 
> using Boolean arrays would be unportable if it uses Unchecked_Conversion 
> to converts between integers and arrays.

So there is a need for an optimized Bit Vector package based on packed 
boolean arrays, and implemented both as shifts for portability and as
assembly instructions for the most common machines.

Kind regards,

Vincent


  reply	other threads:[~2015-05-16 11:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-15 12:07 Efficient Bit Vector Manipulation Vincent
2015-05-15 12:48 ` Colin Paul de Gloucester
2015-05-16 17:12   ` Dennis Lee Bieber
2015-05-15 16:26 ` Niklas Holsti
2015-05-16 11:58   ` vincent.diemunsch [this message]
2015-05-15 16:58 ` Jeffrey R. Carter
2015-05-16 12:06   ` vincent.diemunsch
2015-05-17 13:55 ` robin.vowels
2015-05-18  7:53 ` Stefan.Lucks
2015-05-18 11:43   ` vincent.diemunsch
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox