with Test_Type_Definitions; use Test_Type_Definitions; with Test_Utilities; use Test_Utilities; with Test_Function_Definitions; use Test_Function_Definitions; package body Test_Log_Family is J_Left : constant Int_Type := 0; J_Right : constant Int_Type := 127; K_Left : constant Int_Type := 0; K_Right : constant Int_Type := 15; L_Left : constant Int_Type := 0; L_Right : constant Int_Type := 15; M_Left : constant Int_Type := 0; M_Right : constant Int_Type := 127; Base_Eps_Inv, Mach_Eps_Inv, PM1 : Float_Type; N_Taylor_Atanh, N_Taylor_AtanhMx, N_Limit, Radix : Int_Type; Log_of_Two, Log_of_Ten : Value_Table; Log2_Pieces : constant array( Int_Type range 1..4 ) of Float_Type := ( 16#0.B17#, 16#0.217#E-3, 16#0.F7D#E-6, 16#0.1CF79_ABC9E_3B398_03F2F_6AF40_F3432_67298_B#E-9 ); PM : constant array (Int_Type range 0..1) of Float_Type := (1.0,-1.0); A_K : array (Int_Type range K_Left..K_Right) of Float_Type; B_L : array (Int_Type range L_Left..L_Right) of Float_Type; C_M : array (Int_Type range M_Left..M_Right) of Float_Type; W_M : array (Int_Type range M_Left..M_Right, Int_Type range 0..1, Position) of Float_Type; V_L : array (Int_Type range L_Left..L_Right, Int_Type range 0..1, Position) of Float_Type; U_K : array (Int_Type range K_Left..K_Right, Int_Type range 0..1, Position) of Float_Type := ( ((16#0.0000#, 16#0.00000#), (-16#0.0000#, -16#0.00000#)), ((16#0.07E0#, 16#0.A6C39_E0CC0_133E3_F04F1_EF229_FAEAE_FAE14_CD#E-4), (-16#0.0820#, -16#0.AEC4F_3A222_380B9_E3AEA_6C444_EF070_6133B_C2#E-4)), ((16#0.0F85#, 16#0.18600_8B153_30BE6_4B8B7_75997_898D3_474D3_37#E-4), (-16#0.1085#, -16#0.98B59_E3A06_88A3F_D9BF5_03372_C12FC_6C58F_F1#E-4)), ((16#0.16F0#, 16#0.D28AE_56B4B_9BE49_9B9ED_19B64_0CE50_C1EF6_50#E-4), (-16#0.1933#, -16#0.5E5D5_94988_AE1D5_EA3EC_CD250_89735_832FF_2F#E-4)), ((16#0.1E27#, 16#0.076E2_AF2E5_E9EA8_7FFE1_FE9E1_55DB9_4EBC4_01#E-4), (-16#0.222F#, -16#0.1D044_FC8F7_BC671_683F8_E5BD0_3C776_A3FB0_F0#E-4)), ((16#0.252A#, 16#0.A5F03_FEA46_980BB_8E203_EDF4D_109FB_C9070_F7#E-4), (-16#0.2B7E#, -16#0.80D6A_87B63_F7052_5D9F9_040C5_B4B0A_83873_31#E-4)), ((16#0.2BFE#, 16#0.60E14_F27A7_90E7C_4140E_42477_5FCD5_5C735_5F#E-4), (-16#0.3527#, -16#0.DA791_5B3C6_DE57D_4EF4B_901B9_9B9DC_622BE_3D#E-4)), ((16#0.32A4#, 16#0.B539E_8AD68_EC826_0EA71_712CE_C4CA0_BED3C_F7#E-4), (-16#0.3F32#, -16#0.38D96_766F2_FB328_337CC_050C6_D83B2_276E3_E4#E-4)), ((16#0.391F#, 16#0.EF8F3_53443_584BB_03DE5_FF734_495C7_65EA7_40#E-4), (-16#0.49A5#, -16#0.8844D_36E49_E0EFA_DD9DB_02AA7_0A8C3_D2437_32#E-4)), ((16#0.3F72#, 16#0.30DAB_C7C55_1AAA8_CD86F_29A59_41240_58445_5B#E-4), (-16#0.548A#, -16#0.B81CE_28F5F_3840B_263AC_B4351_10463_12355_7C#E-4)), ((16#0.459D#, 16#0.72AEA_E9838_0E731_F55C4_1B8B8_23F06_7D04A_43#E-4), (-16#0.5FEB#, -16#0.E8EF6_0546F_B79BF_6D4CB_1225E_657CE_261E6_66#E-4)), ((16#0.4BA3#, 16#0.8AEB8_474C2_70B32_46A14_206CF_37B77_AD6FB_22#E-4), (-16#0.6BD4#, -16#0.A5492_33741_9D56C_45DD3_E8677_4703A_763E8_23#E-4)), ((16#0.5186#, 16#0.2F087_17B09_F42DE_CDECC_F1CD1_05772_CD24C_00#E-4), (-16#0.7852#, -16#0.28689_C9B36_537E3_375B2_047FB_21979_8D58B_25#E-4)), ((16#0.5746#, 16#0.F6FD6_02729_42363_83DC7_FE115_9F380_B4A6B_42#E-4), (-16#0.8573#, -16#0.B7168_2A7D2_1AE21_F9F89_C1AB8_0B26B_96CFD_07#E-4)), ((16#0.5CE7#, 16#0.5FDAE_F401A_73893_14FEB_4FBDE_5AADD_E10DC_EA#E-4), (-16#0.934B#, -16#0.1089A_6DC93_C1DF5_BB3B6_0554E_15187_A486E_65#E-4)), ((16#0.6268#, 16#0.CE1B0_5096A_D69C6_20440_F055B_3FFC6_3281B_40#E-4), (-16#0.A1EC#, -16#0.FF97C_91E26_7B0B7_EFAE0_8E597_E166D_ABF5F_2F#E-4)) ); function AtanhMx_Taylor( R : Float_Type ) return Float_Type is separate; function Atanh_Taylor( R : Float_Type ) return Float_Type is separate; procedure Core_Test_Log( N : in Int_Type; NLog2_Lead, NLog2_Trail : in Float_Type; J, K, L, M : in Int_Type; Arg, Log_of_Arg : out Value_Table ) is separate; procedure Test_Log_Interval( N, N_Arguments : in Int_Type; MRE_Base, MRE_Mach, Bad_Arg, Bad_Val : out Float_Type; Outcome : out Status ) is separate; procedure Test_LogB_Interval( N, N_Arguments, Base_Flag : in Int_Type; MRE_Base, MRE_Mach, Bad_Arg, Bad_Base, Bad_Val : out Float_Type; Outcome : out Status ) is separate; procedure Test_Log ( N_Intervals, N_Arguments : in Int_Type ) is separate; procedure Test_LogB( N_Intervals, N_Arguments, Base_Flag : in Int_Type ) is separate; procedure Test_Log2( N_Intervals, N_Arguments : in Int_Type ) is begin Test_LogB( N_Intervals, N_Arguments, 2 ); end Test_Log2; procedure Test_Log10( N_Intervals, N_Arguments : in Int_Type ) is begin Test_LogB( N_Intervals, N_Arguments, 10 ); end Test_Log10; procedure Test_LogBase( N_Intervals, N_Arguments : in Int_Type ) is begin Test_LogB( N_Intervals, N_Arguments, 0 ); end Test_LogBase; begin --Decide on the number of terms needed in the two Taylor series expansions -- case Float_Type'Base'Digits is when 1..6 => N_Taylor_AtanhMx := 4; when 7..18 => N_Taylor_AtanhMx := 7; when 19..33 => N_Taylor_AtanhMx := 10; when others => raise Program_Error; end case; case Float_Type'Base'Digits is when 1..6 => N_Taylor_Atanh := 2; when 7..18 => N_Taylor_Atanh := 3; when 19..33 => N_Taylor_Atanh := 5; when others => raise Program_Error; end case; --Initialize the extreme test interval Nlog2 + [-log2/2, log2/2] if Int_Type'Last >= Float_Type'Safe_Emax then N_Limit := Float_Type'Safe_Emax - 1; else N_Limit := Int_Type'Last - 1; end if; --Initialize scales for computing errors in Epsilon Radix := Float_Type'Machine_Radix; Mach_Eps_Inv := Float_Type(Radix)**Integer(Float_Type'Machine_Mantissa-1); Base_Eps_Inv := Float_Type(1.0 / Float_Type'Base'Epsilon); if ( Float_Type'Base'Digits > 33 or Float_Type'Base'Digits < 6 ) then raise Program_Error; end if; if ( Float_Type'Machine_Radix /= 2 and Float_Type'Machine_Radix /= 16 ) then raise Program_Error; end if; -- Initialize the values of A_K, B_M, and C_N for K in K_Left..K_Right loop A_K(K) := Float_Type(K) * 2#1.0#E-5; end loop; for L in L_Left..L_Right loop B_L(L) := Float_Type(L) * 2#1.0#E-9; end loop; for M in M_Left..M_Right loop C_M(M) := Float_Type(M) * 2#1.0#E-16; end loop; -- Initialize the values of log( 1 + B_L ) and log( 1 - B_L ) for L in L_Left..L_Right loop for S in Int_Type'(0)..1 loop V_L(L, S, Lead) := PM(S)*B_L(L) - B_L(L)*B_L(L)*0.5; PM1 := 1.0; V_L(L, S, Trail) := PM1 / 27.0; for I in reverse Int_Type'(3)..26 loop PM1 := -PM1; V_L(L, S, Trail) := V_L(L, S, Trail) * PM(S)*B_L(L) + (PM1/Float_Type(I)); end loop; V_L(L, S, Trail) := PM(S)*B_L(L)*B_L(L)*B_L(L)*V_L(L, S, Trail); end loop; end loop; --end of loop for initializing V_L's -- Initialize the values of log( 1 + C_M ) and log( 1 - C_M ) for M in M_Left..M_Right loop for S in Int_Type'(0)..1 loop W_M(M, S, Lead) := PM(S)*C_M(M); PM1 := 1.0; W_M(M, S, Trail) := PM1 / 15.0; for K in reverse Int_Type'(2)..14 loop PM1 := -PM1; W_M(M, S, Trail) := W_M(M, S, Trail) * PM(S)*C_M(M) + (PM1/Float_Type(K)); end loop; W_M(M, S, Trail) := C_M(M)*C_M(M)*W_M(M, S, Trail); end loop; end loop; declare Buffer : Value_Table; begin for Index in 1..Value_Table_Size loop Buffer(Index, Lead ) := 16#0.B1721#; Buffer(Index, Trail) := 16#0.7F7D1_CF79A_BC9E3_B3980_3F2F6_AF40F#E-5; end loop; Normalize( Val_In => Buffer, Val_Out => Log_of_Two ); for Index in 1..Value_Table_Size loop Buffer(Index, Lead ) := 16#2.4D76#; Buffer(Index, Trail) := 16#0.3776A_AA2B0_5BA95_B58AE_0B4C2_8A38A#E-4; end loop; Normalize( Val_In => Buffer, Val_Out => Log_of_Ten ); end; end Test_Log_Family;