From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,14be6619f79b4573 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!news.glorb.com!feeder.xsnews.nl!feeder.news-service.com!proxad.net!usenet-fr.net!news.enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Marius Amado Alves Newsgroups: comp.lang.ada Subject: Re: Hashing on System.Address Date: Tue, 14 Jun 2005 11:29:50 +0100 Organization: Cuivre, Argent, Or Message-ID: References: <200506141214.14213.baldrick@free.fr> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 (Apple Message framework v622) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: melchior.cuivre.fr.eu.org 1118745239 51924 212.85.156.195 (14 Jun 2005 10:33:59 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Tue, 14 Jun 2005 10:33:59 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: In-Reply-To: <200506141214.14213.baldrick@free.fr> X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new at dcc.fc.up.pt X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:11345 Date: 2005-06-14T11:29:50+01:00 On 14 Jun 2005, at 11:14, Duncan Sands wrote: > On Tuesday 14 June 2005 12:03, Marius Amado Alves wrote: >>> ... The other thing I haven't really figured out is what to do >>> if you have a 64-bit address, and Hash_Type is only 32... >> >> I gave a general solution to this class of cases before: >> >> << >> Treat both the input and output values as bit strings X (1 .. M) and = Y >> (1 .. N) respectively. (Use representation clauses, packed arrays, = and >> unchecked conversion for this.) Make N small, say 16. Set Y bits to=20= >> the >> value of X bits as follows: >> >> if M > N, Y (J) =3D X (1 + (J - 1) * M / N), for J in 1 .. N >> >> if M =3D N, Y =3D X >> >> if M < N, initialize Y to all zeros, >> then let Y (1 + (I - 1) * N / M) =3D X (I), for I in 1 .. M >>>> > > Hi Marius, thanks for the suggestion. A few comments though: > if M > N (say M =3D 2*N) then you're skipping every second bit > in X. Why not use them - mix them in somehow? Yes, I thought of that, namely picking every slice of M / N bits of the=20= input and convert it to 1 bit. Example for M =3D 2 * N: 00 =3D> 0, 01 =3D>= 0,=20 10 =3D> 1, 11 =3D> 1. But see below. > If M < N then > you are trying to spread the bits of X evenly throughout Y. Are > there any theoretical reasons to think this is a good strategy? Intuition + experimentation. "Guess first, prove later" (Poincar=E9) I=20= tested my function against GNAT's. Dispersion was equivalent. Speed=20 also I if I remember correctly. That's proof enough for me. That's why=20= I didn't advance to the slice variant just above.