comp.lang.ada
 help / color / mirror / Atom feed
From: AdaMagica <christ-usch.grein@t-online.de>
Subject: Re: Quick inverse square root
Date: Mon, 4 Jan 2021 03:13:52 -0800 (PST)	[thread overview]
Message-ID: <283abde6-81b9-4194-b695-1b4686634d97n@googlegroups.com> (raw)
In-Reply-To: <7fe2291a-bc12-4708-85aa-0ffbdc25b2bfn@googlegroups.com>

> 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; 
> 
> function G_QUICK_INVERSE_SQRT( a : F ) return F is 

  pragma Assert (F'Base'Size = U'Modulus);

> magic : constant U := U(1.5 * 2.0**(F'Machine_Mantissa - 1) * (F(F'Machine_Emax - 1) - 0.043));
> y : F := a; 
> i : U; 
> for i'Address use y'Address; 
> begin 
> i := magic - shift_right( i, 1 ); 
> return y * (1.5 - (0.5 * a * y * y));
> end G_QUICK_INVERSE_SQRT; 

  parent reply	other threads:[~2021-01-04 11: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 [this message]
2021-01-04 11:28       ` AdaMagica
2021-01-04 12:13         ` Dmitry A. Kazakov
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