📄 s_tanl.s
字号:
// tan(B) as T_hi + T_lo;// cot(B) as C_hi + C_lo;// 1/[sin(B)*cos(B)] as SC_inv//// T_hi, C_hi are in double-precision memory format;// T_lo, C_lo are in single-precision memory format;// SC_inv is in extended-precision memory format.//// The value of tan(x) will be approximated by a short polynomial of// the form//// tan(x) as x + x * P, where// P = x^2 * (P2_1 + x^2 * (P2_2 + x^2 * P2_3))//// Because |x| <= 2^(-7), cot(B) - x approximates cot(B) - tan(x)// to a relative accuracy better than 2^(-20). Thus, a good// initial guess of 1/( cot(B) - tan(x) ) to initiate the iterative// division is://// 1/(cot(B) - tan(x)) is approximately// 1/(cot(B) - x) is// tan(B)/(1 - x*tan(B)) is approximately// T_hi / ( 1 - T_hi * x ) is approximately//// T_hi * [ 1 + (Thi * x) + (T_hi * x)^2 ]//// The calculation of tan(r+c) therefore proceed as follows://// Tx := T_hi * x// xsq := x * x//// V_hi := T_hi*(1 + Tx*(1 + Tx))// P := xsq * (P1_1 + xsq*(P1_2 + xsq*P1_3))// ...V_hi serves as an initial guess of 1/(cot(B) - tan(x))// ...good to about 20 bits of accuracy//// tanx := x + x*P// D := C_hi - tanx// ...D is a double precision denominator: cot(B) - tan(x)//// V_hi := V_hi + V_hi*(1 - V_hi*D)// ....V_hi approximates 1/(cot(B)-tan(x)) to 40 bits//// V_lo := V_hi * ( [ (1 - V_hi*C_hi) + V_hi*tanx ]// - V_hi*C_lo ) ...observe all order// ...V_hi + V_lo approximates 1/(cot(B) - tan(x))// ...to extra accuracy//// ... SC_inv(B) * (x + x*P)// ... tan(B) + ------------------------- + CORR// ... cot(B) - (x + x*P)// ...// ... = tan(B) + SC_inv(B)*(x + x*P)*(V_hi + V_lo) + CORR// ...//// Sx := SC_inv * x// CORR := sgn_r * c * SC_inv * T_hi//// ...put the ingredients together to compute// ... SC_inv(B) * (x + x*P)// ... tan(B) + ------------------------- + CORR// ... cot(B) - (x + x*P)// ...// ... = tan(B) + SC_inv(B)*(x + x*P)*(V_hi + V_lo) + CORR// ...// ... = T_hi + T_lo + CORR +// ... Sx * V_hi + Sx * V_lo + Sx * P *(V_hi + V_lo)//// CORR := CORR + T_lo// tail := V_lo + P*(V_hi + V_lo)// tail := Sx * tail + CORR// tail := Sx * V_hi + tail// T_hi := sgn_r * T_hi//// ...T_hi + sgn_r*tail now approximate// ...sgn_r*(tan(B+x) + CORR) accurately//// Result := T_hi + sgn_r*tail ...in user-defined// ...rounding control// ...It is crucial that independent paths be fully// ...exploited for performance's sake.////// Next, we consider the computation of -cot( r + c ). As// presented in the previous section,//// -cot( r + c ) = -cot(r) + c * csc^2(r)// = sgn_r * [ -cot(B+x) + CORR ]// CORR = sgn_r * c * cot(B) * 1/[sin(B)*cos(B)]//// because csc^2(r) = csc^(|r|), and B approximate |r| to 6.5 bits.//// -cot( r + c ) =// / (1/[sin(B)*cos(B)]) * tan(x)// sgn_r * | -cot(B) + -------------------------------- +// \ tan(B) + tan(x)// \// CORR |// ///// The values of tan(B), cot(B) and 1/(sin(B)*cos(B)) are// calculated beforehand and stored in a table. Specifically,// the table values are//// tan(B) as T_hi + T_lo;// cot(B) as C_hi + C_lo;// 1/[sin(B)*cos(B)] as SC_inv//// T_hi, C_hi are in double-precision memory format;// T_lo, C_lo are in single-precision memory format;// SC_inv is in extended-precision memory format.//// The value of tan(x) will be approximated by a short polynomial of// the form//// tan(x) as x + x * P, where// P = x^2 * (P2_1 + x^2 * (P2_2 + x^2 * P2_3))//// Because |x| <= 2^(-7), tan(B) + x approximates tan(B) + tan(x)// to a relative accuracy better than 2^(-18). Thus, a good// initial guess of 1/( tan(B) + tan(x) ) to initiate the iterative// division is://// 1/(tan(B) + tan(x)) is approximately// 1/(tan(B) + x) is// cot(B)/(1 + x*cot(B)) is approximately// C_hi / ( 1 + C_hi * x ) is approximately//// C_hi * [ 1 - (C_hi * x) + (C_hi * x)^2 ]//// The calculation of -cot(r+c) therefore proceed as follows://// Cx := C_hi * x// xsq := x * x//// V_hi := C_hi*(1 - Cx*(1 - Cx))// P := xsq * (P1_1 + xsq*(P1_2 + xsq*P1_3))// ...V_hi serves as an initial guess of 1/(tan(B) + tan(x))// ...good to about 18 bits of accuracy//// tanx := x + x*P// D := T_hi + tanx// ...D is a double precision denominator: tan(B) + tan(x)//// V_hi := V_hi + V_hi*(1 - V_hi*D)// ....V_hi approximates 1/(tan(B)+tan(x)) to 40 bits//// V_lo := V_hi * ( [ (1 - V_hi*T_hi) - V_hi*tanx ]// - V_hi*T_lo ) ...observe all order// ...V_hi + V_lo approximates 1/(tan(B) + tan(x))// ...to extra accuracy//// ... SC_inv(B) * (x + x*P)// ... -cot(B) + ------------------------- + CORR// ... tan(B) + (x + x*P)// ...// ... =-cot(B) + SC_inv(B)*(x + x*P)*(V_hi + V_lo) + CORR// ...//// Sx := SC_inv * x// CORR := sgn_r * c * SC_inv * C_hi//// ...put the ingredients together to compute// ... SC_inv(B) * (x + x*P)// ... -cot(B) + ------------------------- + CORR// ... tan(B) + (x + x*P)// ...// ... =-cot(B) + SC_inv(B)*(x + x*P)*(V_hi + V_lo) + CORR// ...// ... =-C_hi - C_lo + CORR +// ... Sx * V_hi + Sx * V_lo + Sx * P *(V_hi + V_lo)//// CORR := CORR - C_lo// tail := V_lo + P*(V_hi + V_lo)// tail := Sx * tail + CORR// tail := Sx * V_hi + tail// C_hi := -sgn_r * C_hi//// ...C_hi + sgn_r*tail now approximates// ...sgn_r*(-cot(B+x) + CORR) accurately//// Result := C_hi + sgn_r*tail in user-defined rounding control// ...It is crucial that independent paths be fully// ...exploited for performance's sake.//// 3. Implementation Notes// =======================//// Table entries T_hi, T_lo; C_hi, C_lo; SC_inv//// Recall that 2^(-2) <= |r| <= pi/4;//// r = sgn_r * 2^k * 1.b_1 b_2 ... b_63//// and//// B = 2^k * 1.b_1 b_2 b_3 b_4 b_5 1//// Thus, for k = -2, possible values of B are//// B = 2^(-2) * ( 1 + index/32 + 1/64 ),// index ranges from 0 to 31//// For k = -1, however, since |r| <= pi/4 = 0.78...// possible values of B are//// B = 2^(-1) * ( 1 + index/32 + 1/64 )// index ranges from 0 to 19.////RODATA.align 16LOCAL_OBJECT_START(TANL_BASE_CONSTANTS)tanl_table_1:data8 0xA2F9836E4E44152A, 0x00003FFE // two_by_pidata8 0xC84D32B0CE81B9F1, 0x00004016 // P_0data8 0xC90FDAA22168C235, 0x00003FFF // P_1data8 0xECE675D1FC8F8CBB, 0x0000BFBD // P_2data8 0xB7ED8FBBACC19C60, 0x0000BF7C // P_3LOCAL_OBJECT_END(TANL_BASE_CONSTANTS)LOCAL_OBJECT_START(tanl_table_2)data8 0xC90FDAA22168C234, 0x00003FFE // PI_BY_4data8 0xA397E5046EC6B45A, 0x00003FE7 // Inv_P_0data8 0x8D848E89DBD171A1, 0x0000BFBF // d_1data8 0xD5394C3618A66F8E, 0x0000BF7C // d_2data4 0x3E800000 // two**-2data4 0xBE800000 // -two**-2data4 0x00000000 // paddata4 0x00000000 // padLOCAL_OBJECT_END(tanl_table_2)LOCAL_OBJECT_START(tanl_table_p1)data8 0xAAAAAAAAAAAAAABD, 0x00003FFD // P1_1data8 0x8888888888882E6A, 0x00003FFC // P1_2data8 0xDD0DD0DD0F0177B6, 0x00003FFA // P1_3data8 0xB327A440646B8C6D, 0x00003FF9 // P1_4data8 0x91371B251D5F7D20, 0x00003FF8 // P1_5data8 0xEB69A5F161C67914, 0x00003FF6 // P1_6data8 0xBEDD37BE019318D2, 0x00003FF5 // P1_7data8 0x9979B1463C794015, 0x00003FF4 // P1_8data8 0x8EBD21A38C6EB58A, 0x00003FF3 // P1_9LOCAL_OBJECT_END(tanl_table_p1)LOCAL_OBJECT_START(tanl_table_q1)data8 0xAAAAAAAAAAAAAAB4, 0x00003FFD // Q1_1data8 0xB60B60B60B5FC93E, 0x00003FF9 // Q1_2data8 0x8AB355E00C9BBFBF, 0x00003FF6 // Q1_3data8 0xDDEBBC89CBEE3D4C, 0x00003FF2 // Q1_4data8 0xB3548A685F80BBB6, 0x00003FEF // Q1_5data8 0x913625604CED5BF1, 0x00003FEC // Q1_6data8 0xF189D95A8EE92A83, 0x00003FE8 // Q1_7LOCAL_OBJECT_END(tanl_table_q1)LOCAL_OBJECT_START(tanl_table_p2)data8 0xAAAAAAAAAAAB362F, 0x00003FFD // P2_1data8 0x88888886E97A6097, 0x00003FFC // P2_2data8 0xDD108EE025E716A1, 0x00003FFA // P2_3LOCAL_OBJECT_END(tanl_table_p2)LOCAL_OBJECT_START(tanl_table_tm2)//// Entries T_hi double-precision memory format// Index = 0,1,...,31 B = 2^(-2)*(1+Index/32+1/64)// Entries T_lo single-precision memory format// Index = 0,1,...,31 B = 2^(-2)*(1+Index/32+1/64)//data8 0x3FD09BC362400794data4 0x23A05C32, 0x00000000data8 0x3FD124A9DFFBC074data4 0x240078B2, 0x00000000data8 0x3FD1AE235BD4920Fdata4 0x23826B8E, 0x00000000data8 0x3FD2383515E2701Ddata4 0x22D31154, 0x00000000data8 0x3FD2C2E463739C2Ddata4 0x2265C9E2, 0x00000000data8 0x3FD34E36AFEEA48Bdata4 0x245C05EB, 0x00000000data8 0x3FD3DA317DBB35D1data4 0x24749F2D, 0x00000000data8 0x3FD466DA67321619data4 0x2462CECE, 0x00000000data8 0x3FD4F4371F94A4D5data4 0x246D0DF1, 0x00000000data8 0x3FD5824D740C3E6Ddata4 0x240A85B5, 0x00000000data8 0x3FD611234CB1E73Ddata4 0x23F96E33, 0x00000000data8 0x3FD6A0BEAD9EA64Bdata4 0x247C5393, 0x00000000data8 0x3FD73125B804FD01data4 0x241F3B29, 0x00000000data8 0x3FD7C25EAB53EE83data4 0x2479989B, 0x00000000data8 0x3FD8546FE6640EEDdata4 0x23B343BC, 0x00000000data8 0x3FD8E75FE8AF1892data4 0x241454D1, 0x00000000data8 0x3FD97B3553928BDAdata4 0x238613D9, 0x00000000data8 0x3FDA0FF6EB9DE4DEdata4 0x22859FA7, 0x00000000data8 0x3FDAA5AB99ECF92Ddata4 0x237A6D06, 0x00000000data8 0x3FDB3C5A6D8F1796data4 0x23952F6C, 0x00000000data8 0x3FDBD40A9CFB8BE4data4 0x2280FC95, 0x00000000data8 0x3FDC6CC387943100data4 0x245D2EC0, 0x00000000data8 0x3FDD068CB736C500data4 0x23C4AD7D, 0x00000000data8 0x3FDDA16DE1DDBC31data4 0x23D076E6, 0x00000000data8 0x3FDE3D6EEB515A93data4 0x244809A6, 0x00000000data8 0x3FDEDA97E6E9E5F1data4 0x220856C8, 0x00000000data8 0x3FDF78F11963CE69data4 0x244BE993, 0x00000000data8 0x3FE00C417D635BCEdata4 0x23D21799, 0x00000000data8 0x3FE05CAB1C302CD3data4 0x248A1B1D, 0x00000000data8 0x3FE0ADB9DB6A1FA0data4 0x23D53E33, 0x00000000data8 0x3FE0FF724A20BA81data4 0x24DB9ED5, 0x00000000data8 0x3FE151D9153FA6F5data4 0x24E9E451, 0x00000000LOCAL_OBJECT_END(tanl_table_tm2)LOCAL_OBJECT_START(tanl_table_tm1)//// Entries T_hi double-precision memory format// Index = 0,1,...,19 B = 2^(-1)*(1+Index/32+1/64)// Entries T_lo single-precision memory format// Index = 0,1,...,19 B = 2^(-1)*(1+Index/32+1/64)//data8 0x3FE1CEC4BA1BE39Edata4 0x24B60F9E, 0x00000000data8 0x3FE277E45ABD9B2Ddata4 0x248C2474, 0x00000000data8 0x3FE324180272B110data4 0x247B8311, 0x00000000data8 0x3FE3D38B890E2DF0data4 0x24C55751, 0x00000000data8 0x3FE4866D46236871data4 0x24E5BC34, 0x00000000data8 0x3FE53CEE45E044B0data4 0x24001BA4, 0x00000000data8 0x3FE5F74282EC06E4data4 0x24B973DC, 0x00000000data8 0x3FE6B5A125DF43F9data4 0x24895440, 0x00000000data8 0x3FE77844CAFD348Cdata4 0x240021CA, 0x00000000data8 0x3FE83F6BCEED6B92data4 0x24C45372, 0x00000000data8 0x3FE90B58A34F3665data4 0x240DAD33, 0x00000000data8 0x3FE9DC522C1E56B4data4 0x24F846CE, 0x00000000data8 0x3FEAB2A427041578data4 0x2323FB6E, 0x00000000data8 0x3FEB8E9F9DD8C373data4 0x24B3090B, 0x00000000data8 0x3FEC709B65C9AA7Bdata4 0x2449F611, 0x00000000data8 0x3FED58F4ACCF8435data4 0x23616A7E, 0x00000000data8 0x3FEE480F97635082data4 0x24C2FEAE, 0x00000000data8 0x3FEF3E57F0ACC544data4 0x242CE964, 0x00000000data8 0x3FF01E20F7E06E4Bdata4 0x2480D3EE, 0x00000000data8 0x3FF0A1258A798A69data4 0x24DB8967, 0x00000000LOCAL_OBJECT_END(tanl_table_tm1)LOCAL_OBJECT_START(tanl_table_cm2)//// Entries C_hi double-precision memory format// Index = 0,1,...,31 B = 2^(-2)*(1+Index/32+1/64)// Entries C_lo single-precision memory format// Index = 0,1,...,31 B = 2^(-2)*(1+Index/32+1/64)//data8 0x400ED3E2E63EFBD0data4 0x259D94D4, 0x00000000data8 0x400DDDB4C515DAB5data4 0x245F0537, 0x00000000data8 0x400CF57ABE19A79Fdata4 0x25D4EA9F, 0x00000000data8 0x400C1A06D15298EDdata4 0x24AE40A0, 0x00000000data8 0x400B4A4C164B2708data4 0x25A5AAB6, 0x00000000data8 0x400A855A5285B068data4 0x25524F18, 0x00000000data8 0x4009CA5A3FFA549Fdata4 0x24C999C0, 0x00000000data8 0x4009188A646AF623data4 0x254FD801, 0x00000000data8 0x40086F3C6084D0E7data4 0x2560F5FD, 0x00000000data8 0x4007CDD2A29A76EEdata4 0x255B9D19, 0x00000000data8 0x400733BE6C8ECA95data4 0x25CB021B, 0x00000000data8 0x4006A07E1F8DDC52data4 0x24AB4722, 0x00000000data8 0x4006139BC298AD58data4 0x252764E2, 0x00000000data8 0x40058CABBAD7164Bdata4 0x24DAF5DB, 0x00000000data8 0x40050B4BAE31A5D3data4 0x25EA20F4, 0x00000000data8 0x40048F2189F85A8Adata4 0x2583A3E8, 0x00000000data8 0x400417DAA862380Ddata4 0x25DCC4CC, 0x00000000data8 0x4003A52B1088FCFEdata4 0x2430A492, 0x00000000data8 0x400336CCCD3527D5data4 0x255F77CF, 0x00000000data8 0x4002CC7F5760766Ddata4 0x25DA0BDA, 0x00000000data8 0x4002660711CE02E3data4 0x256FF4A2, 0x00000000data8 0x4002032CD37BBE04data4 0x25208AED, 0x00000000data8 0x4001A3BD7F050775data4 0x24B72DD6, 0x00000000data8 0x40014789A554848Adata4 0x24AB4DAA, 0x00000000data8 0x4000EE65323E81B7data4 0x2584C440, 0x00000000data8 0x4000982721CF1293data4 0x25C9428D, 0x00000000data8 0x400044A93D415EEBdata4 0x25DC8482, 0x00000000data8 0x3FFFE78FBD72C577data4 0x257F5070, 0x00000000data8 0x3FFF4AC375EFD28Edata4 0x23EBBF7A, 0x00000000data8 0x3FFEB2AF60B52DDEdata4 0x22EECA07, 0x00000000data8 0x3FFE1F1935204180data4 0x24191079, 0x00000000data8 0x3FFD8FCA54F7E60Adata4 0x248D3058, 0x00000000LOCAL_OBJECT_END(tanl_table_cm2)LOCAL_OBJECT_START(tanl_table_cm1)//// Entries C_hi double-precision memory format// Index = 0,1,...,19 B = 2^(-1)*(1+Index/32+1/64)// Entries C_lo single-precision memory format// Index = 0,1,...,19 B = 2^(-1)*(1+Index/32+1/64)//data8 0x3FFCC06A79F6FADEdata4 0x239C7886, 0x00000000data8 0x3FFBB91F891662A6data4 0x250BD191, 0x00000000data8 0x3FFABFB6529F155Ddata4 0x256CC3E6, 0x00000000data8 0x3FF9D3002E964AE9data4 0x250843E3, 0x00000000data8 0x3FF8F1EF89DCB383data4 0x2277C87E, 0x00000000data8 0x3FF81B937C87DBD6data4 0x256DA6CF, 0x00000000data8 0x3FF74F141042EDE4data4 0x2573D28A, 0x00000000data8 0x3FF68BAF1784B360data4 0x242E489A, 0x00000000data8 0x3FF5D0B57C923C4Cdata4 0x2532D940, 0x00000000data8 0x3FF51D88F418EF20data4 0x253C7DD6, 0x00000000data8 0x3FF4719A02F88DAEdata4 0x23DB59BF, 0x00000000data8 0x3FF3CC6649DA0788data4 0x252B4756, 0x00000000data8 0x3FF32D770B980DB8data4 0x23FE585F, 0x00000000data8 0x3FF2945FE56C987A
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -