comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Quick inverse square root
Date: Mon, 4 Jan 2021 13:13:00 +0100	[thread overview]
Message-ID: <rsv0ob$81u$1@gioia.aioe.org> (raw)
In-Reply-To: e2f8932e-7992-4ae2-b112-6a481872ceb3n@googlegroups.com

On 2021-01-04 12:28, AdaMagica wrote:
> AdaMagica schrieb am Montag, 4. Januar 2021 um 12:13:53 UTC+1:
>>> with INTERFACES; use INTERFACES;
>>> generic
>>> type F is digits <>;
>>> type U is mod <>;
>>> with function SHIFT_RIGHT( n : U; amount : NATURAL ) return U;
>>> function G_QUICK_INVERSE_SQRT( a : F ) return F;
> 
> I haven't got the slightest idea for which range this function should be applied, but for sure not for the complete Float range.
> Thus there should be an assertion about the range of the parameter a in the body. Or even better a precondition in the spec.

It appears to be the Newton method with an heuristic used to choose the 
starting point. The descriptions is here:

    https://en.wikipedia.org/wiki/Fast_inverse_square_root

It also mentions a hack for double precision IEEE 754 floats.

P.S. The method makes no sense to implement or use on modern hardware.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2021-01-04 12:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-02 22:26 Quick inverse square root Matt Borchers
2021-01-02 23:18 ` Jeffrey R. Carter
2021-01-03 10:58 ` Dmitry A. Kazakov
2021-01-03 22:31   ` Matt Borchers
2021-01-03 23:47     ` Jeffrey R. Carter
2021-01-04  3:50       ` Matt Borchers
2021-01-04  4:28         ` Matt Borchers
2021-01-04 11:04         ` Jeffrey R. Carter
2021-01-04 11:13     ` AdaMagica
2021-01-04 11:28       ` AdaMagica
2021-01-04 12:13         ` Dmitry A. Kazakov [this message]
2021-01-04 13:39 ` Egil H H
2021-01-04 20:55   ` Matt Borchers
2021-01-04 21:06     ` Paul Rubin
2021-01-05  2:22       ` Matt Borchers
2021-01-07 17:49     ` Brian Drummond
replies disabled

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