Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,17 +0,0 @@
with Ada.Numerics.Generic_Real_Arrays;
generic
type Real is digits <>;
package Thiele is
package Real_Arrays is new Ada.Numerics.Generic_Real_Arrays (Real);
subtype Real_Array is Real_Arrays.Real_Vector;
type Thiele_Interpolation (Length : Natural) is private;
function Create (X, Y : Real_Array) return Thiele_Interpolation;
function Inverse (T : Thiele_Interpolation; X : Real) return Real;
private
type Thiele_Interpolation (Length : Natural) is record
X, Y, RhoX : Real_Array (1 .. Length);
end record;
end Thiele;

View file

@ -1,56 +0,0 @@
package body Thiele is
use type Real_Array;
function "/" (Left, Right : Real_Array) return Real_Array is
Result : Real_Array (Left'Range);
begin
if Left'Length /= Right'Length then
raise Constraint_Error with "arrays not same size";
end if;
for I in Result'Range loop
Result (I) := Left (I) / Right (I);
end loop;
return Result;
end "/";
function Rho (X, Y : Real_Array) return Real_Array is
N : constant Natural := X'Length;
P : array (1 .. N) of Real_Array (1 .. N) :=
(others => (others => 9.9));
Result : Real_Array (1 .. N);
begin
P (1) (1 .. N) := Y (1 .. N);
P (2) (1 .. N - 1) := (X (1 .. N - 1) - X (2 .. N)) /
(P (1) (1 .. N - 1) - P (1) (2 .. N));
for I in 3 .. N loop
P (I) (1 .. N - I + 1) := P (I - 2) (2 .. N - I + 2) +
(X (1 .. N - I + 1) - X (I .. N)) /
(P (I - 1) (1 .. N - I + 1) - P (I - 1) (2 .. N - I + 2));
end loop;
for I in X'Range loop
Result (I) := P (I) (1);
end loop;
return Result;
end Rho;
function Create (X, Y : Real_Array) return Thiele_Interpolation is
begin
if X'Length < 3 then
raise Constraint_Error with "at least 3 values";
end if;
if X'Length /= Y'Length then
raise Constraint_Error with "input arrays not same size";
end if;
return (Length => X'Length, X => X, Y => Y, RhoX => Rho (X, Y));
end Create;
function Inverse (T : Thiele_Interpolation; X : Real) return Real is
A : Real := 0.0;
begin
for I in reverse 3 .. T.Length loop
A := (X - T.X (I - 1)) / (T.RhoX (I) - T.RhoX (I - 2) + A);
end loop;
return T.Y (1) + (X - T.X (1)) / (T.RhoX (2) + A);
end Inverse;
end Thiele;

View file

@ -1,43 +0,0 @@
with Ada.Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
with Thiele;
procedure Main is
package Math is new Ada.Numerics.Generic_Elementary_Functions
(Long_Float);
package Float_Thiele is new Thiele (Long_Float);
use Float_Thiele;
Row_Count : Natural := 32;
X_Values : Real_Array (1 .. Row_Count);
Sin_Values : Real_Array (1 .. Row_Count);
Cos_Values : Real_Array (1 .. Row_Count);
Tan_Values : Real_Array (1 .. Row_Count);
begin
-- build table
for I in 1 .. Row_Count loop
X_Values (I) := Long_Float (I) * 0.05 - 0.05;
Sin_Values (I) := Math.Sin (X_Values (I));
Cos_Values (I) := Math.Cos (X_Values (I));
Tan_Values (I) := Math.Tan (X_Values (I));
end loop;
declare
Sin : Thiele_Interpolation := Create (Sin_Values, X_Values);
Cos : Thiele_Interpolation := Create (Cos_Values, X_Values);
Tan : Thiele_Interpolation := Create (Tan_Values, X_Values);
begin
Ada.Text_IO.Put_Line
("Internal Math.Pi: " &
Long_Float'Image (Ada.Numerics.Pi));
Ada.Text_IO.Put_Line
("Thiele 6*InvSin(0.5):" &
Long_Float'Image (6.0 * Inverse (Sin, 0.5)));
Ada.Text_IO.Put_Line
("Thiele 3*InvCos(0.5):" &
Long_Float'Image (3.0 * Inverse (Cos, 0.5)));
Ada.Text_IO.Put_Line
("Thiele 4*InvTan(1): " &
Long_Float'Image (4.0 * Inverse (Tan, 1.0)));
end;
end Main;

View file

@ -1,69 +0,0 @@
Function Reciprocal-Difference( [Double[][]] $function )
{
$rho=@()
$rho+=0
$funcl = $function.length
if( $funcl -gt 0 )
{
-2..($funcl-1) | ForEach-Object {
$i=$_
#Write-Host "$($i+1) - $($rho[$i+1]) - $($rho[$i+1].GetType())"
$rho[$i+2] = $( 0..($funcl-$i-1) | Where-Object {$_ -lt $funcl} | ForEach-Object {
$j=$_
switch ($i) {
{$_ -lt 0 } { 0 }
{$_ -eq 0 } { $function[$j][1] }
{$_ -gt 0 } { ( $function[$j][0] - $function[$j+$i][0] ) / ( $rho[$i+1][$j] - $rho[$i+1][$j+1] ) + $rho[$i][$j+1] }
}
if( $_ -lt $funcl )
{
$rho += 0
}
})
}
}
$rho
}
Function Thiele-Interpolation ( [Double[][]] $function )
{
$funcl = $function.length
$invoke = "{`n`tparam([Double] `$x)`n"
if($funcl -gt 1)
{
$rho = Reciprocal-Difference $function
($funcl-1)..0 | ForEach-Object {
$invoke += "`t"
$invoke += '$x{0} = {1} - {2}' -f $_, @($rho[$_+2])[0], @($rho[$_])[0]
if($_ -lt ($funcl-1))
{
$invoke += ' + ( $x - {0} ) / $x{1} ' -f $function[$_][0], ($_+1)
}
$invoke += "`n"
}
$invoke+="`t`$x0`n}"
} else {
$invoke += "`t`$x`n}"
}
invoke-expression $invoke
}
$sint=@{}; 0..31 | ForEach-Object { $_ * 0.05 } | ForEach-Object { $sint[$_] = [Math]::sin($_) }
$cost=@{}; 0..31 | ForEach-Object { $_ * 0.05 } | ForEach-Object { $cost[$_] = [Math]::cos($_) }
$tant=@{}; 0..31 | ForEach-Object { $_ * 0.05 } | ForEach-Object { $tant[$_] = [Math]::tan($_) }
$asint=New-Object 'Double[][]' 32,2; $sint.GetEnumerator() | Sort-Object Value | ForEach-Object {$i=0}{ $asint[$i][0] = $_.Value; $asint[$i][1] = $_.Name; $i++ }
$acost=New-Object 'Double[][]' 32,2; $cost.GetEnumerator() | Sort-Object Value | ForEach-Object { $i=0 }{ $acost[$i][0] = $_.Value; $acost[$i][1] = $_.Name; $i++ }
$atant=New-Object 'Double[][]' 32,2; $tant.GetEnumerator() | Sort-Object Value | ForEach-Object {$i=0}{ $atant[$i][0] = $_.Value; $atant[$i][1] = $_.Name; $i++ }
$asin = (Thiele-Interpolation $asint)
#uncomment to see the function
#"{$asin}"
6*$asin.InvokeReturnAsIs(.5)
$acos = (Thiele-Interpolation $acost)
#uncomment to see the function
#"{$acos}"
3*$acos.InvokeReturnAsIs(.5)
$atan = (Thiele-Interpolation $atant)
#uncomment to see the function
#"{$atan}"
4*$atan.InvokeReturnAsIs(1)