DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ B T

⟦4f4c4972b⟧ TextFile

    Length: 2969 (0xb99)
    Types: TextFile
    Names: »B«

Derivation

└─⟦5f3412b64⟧ Bits:30000745 8mm tape, Rational 1000, ENVIRONMENT 12_6_5 TOOLS 
    └─ ⟦91c658230⟧ »DATA« 
        └─⟦458657fb6⟧ 
            └─⟦1472c4407⟧ 
                └─⟦this⟧ 
└─⟦d10a02448⟧ Bits:30000409 8mm tape, Rational 1000, ENVIRONMENT, D_12_7_3
    └─ ⟦fc9b38f02⟧ »DATA« 
        └─⟦9b46a407a⟧ 
            └─⟦2e03b931c⟧ 
                └─⟦this⟧ 

TextFile

separate (Generic_Elementary_Functions)

function Arctan (Y : Float_Type; X : Float_Type := 1.0) return Float_Type is

   U, V, Sign_X, Sign_Y, Buffer, Z1, Z2, Result : Common_Float;
   Swap_Flag : Boolean;

   Zero    : constant := 0.0;
   One     : constant := 1.0;
   Pi      : constant := 3.14159_26535_89793_23846_26433_83279_50288_4197;
   Pi_By_2 : constant := 1.57079_63267_94896_61923_13216_91639_75144_2098;
   Pi_By_4 : constant := 0.78539_81633_97448_30961_56608_45819_87572_1049;
   Pi_3_4  : constant := 2.35619_44901_92344_92884_69825_37459_62716_3147;

   Pi_Lead    : constant Common_Float := 16#3.243#;
   Piby2_Lead : constant Common_Float := 16#1.921#;

   Pi_Trail    : constant Common_Float :=
      16#0.F6A88_85A30_8D313_198A2_E0370_7344A_40938#E-3;
   Piby2_Trail : constant Common_Float :=
      16#0.FB544_42D18_46989_8CC51_701B8_39A25_2049C#E-3;

begin

-- Filter out exceptional cases.
   U      := Common_Float (X);
   Sign_X := Copy_Sign (One, U);
   U      := abs (U);
   V      := Common_Float (Y);
   Sign_Y := Copy_Sign (One, V);
   V      := abs (V);

   if V = Zero then
      if U = Zero then
         raise Argument_Error;
      else
         if Sign_X = One then
            return (Float_Type (Copy_Sign (Zero, Sign_Y)));
         else
            return (Float_Type (Sign_Y * Pi));
         end if;
      end if;
   end if;

   if U = Zero then
      return (Float_Type (Sign_Y * Pi_By_2));
   end if;

   if U = V then
      if Sign_X = One then
         return (Float_Type (Sign_Y * Pi_By_4));
      else
         return (Float_Type (Sign_Y * Pi_3_4));
      end if;
   end if;


-- Step 1. Argument Reduction.
   if U < V then
      Swap_Flag := True;
      Buffer    := U;
      U         := V;
      V         := Buffer;
   else
      Swap_Flag := False;
   end if;






-- Step 2. Approximation. Obtain atan(V/U). This is performed by KP_Atn
-- which returns atan(V/U) as Z1 + Z2. Moreover, whenever Z1 is non-zero,
-- it has at most 4 hex digits and satisfies |Z1| >= 1/16.

   Kp_Atn (V, U, Z1, Z2);


-- Step 3. Reconstruction. Obtain atan(Y,X) via Sign_X, Sign_Y, Swap_Flag,
-- and atan(V/U). The reconstruction is based on three relations:
--   atan(Y,X)     = sign(Y) * atan(|Y|,X),
--   atan(|Y|,X)   = pi - atan(|Y|,-X),
--   atan(|Y|,|X|) = pi/2 - atan(|X|,|Y|).

   if Swap_Flag = False then

      if Sign_X = One then
         -- atan(|Y|,X) = atan(V,U)
         Result := Z1 + Z2;
      else
         -- atan(|Y|,X) = atan(V,-U) = pi - atan(V,U)
         Result := (Pi_Lead - Z1) + (Pi_Trail - Z2);
      end if;

   else

      if Sign_X = One then
         -- atan(|Y|,X) = atan(U,V) = pi/2 - atan(V,U)
         Result := (Piby2_Lead - Z1) + (Piby2_Trail - Z2);
      else
         -- atan(|Y|,X) = atan(U,-V) = pi - atan(U,V) = pi - (pi/2 - atan(V,U))
         Result := (Piby2_Lead + Z1) + (Piby2_Trail + Z2);
      end if;

   end if;

   return (Float_Type (Copy_Sign (Result, Sign_Y)));


end Arctan;