📄 e_acoshl.s
字号:
.file "acoshl.s"// Copyright (c) 2000 - 2005, Intel Corporation// All rights reserved.//// Contributed 2000 by the Intel Numerics Group, Intel Corporation//// Redistribution and use in source and binary forms, with or without// modification, are permitted provided that the following conditions are// met://// * Redistributions of source code must retain the above copyright// notice, this list of conditions and the following disclaimer.//// * Redistributions in binary form must reproduce the above copyright// notice, this list of conditions and the following disclaimer in the// documentation and/or other materials provided with the distribution.//// * The name of Intel Corporation may not be used to endorse or promote// products derived from this software without specific prior written// permission.// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Intel Corporation is the author of this code, and requests that all// problem reports or change requests be submitted to it directly at // http://www.intel.com/software/products/opensource/libraries/num.htm.////*********************************************************************//// History: // 10/01/01 Initial version// 10/10/01 Performance inproved// 12/11/01 Changed huges_logp to not be global// 01/02/02 Corrected .restore syntax// 05/20/02 Cleaned up namespace and sf0 syntax// 08/14/02 Changed mli templates to mlx// 02/06/03 Reorganized data tables// 03/31/05 Reformatted delimiters between data tables////*********************************************************************//// API//==============================================================// long double acoshl(long double);//// Overview of operation//==============================================================// // There are 6 paths:// 1. x = 1// Return acoshl(x) = 0;//// 2. x < 1// Return acoshl(x) = Nan (Domain error, error handler call with tag 135);//// 3. x = [S,Q]Nan or +INF// Return acoshl(x) = x + x;// // 4. 'Near 1': 1 < x < 1+1/8// Return acoshl(x) = sqrtl(2*y)*(1-P(y)/Q(y)), // where y = 1, P(y)/Q(y) - rational approximation//// 5. 'Huges': x > 0.5*2^64// Return acoshl(x) = (logl(2*x-1));// // 6. 'Main path': 1+1/8 < x < 0.5*2^64// b_hi + b_lo = x + sqrt(x^2 - 1);// acoshl(x) = logl_special(b_hi, b_lo);// // Algorithm description //==============================================================//// I. Near 1 path algorithm// **************************************************************// The formula is acoshl(x) = sqrtl(2*y)*(1-P(y)/Q(y)), // where y = 1, P(y)/Q(y) - rational approximation//// 1) y = x - 1, y2 = 2 * y//// 2) Compute in parallel sqrtl(2*y) and P(y)/Q(y)// a) sqrtl computation method described below (main path algorithm, item 2))// As result we obtain (gg+gl) - multiprecision result // as pair of double extended values// b) P(y) and Q(y) calculated without any extra precision manipulations// c) P/Q division:// y = frcpa(Q) initial approximation of 1/Q// z = P*y initial approximation of P/Q// // e = 1 - b*y// e2 = e + e^2// e1 = e^2// y1 = y + y*e2 = y + y*(e+e^2)//// e3 = e + e1^2// y2 = y + y1*e3 = y + y*(e+e^2+..+e^6)//// r = P - Q*z// e = 1 - Q*y2// xx = z + r*y2 high part of a/b//// y3 = y2 + y2*e4// r1 = P - Q*xx// xl = r1*y3 low part of a/b//// 3) res = sqrt(2*y) - sqrt(2*y)*(P(y)/Q(y)) =// = (gg+gl) - (gg + gl)*(xx+xl);//// a) hh = gg*xx; hl = gg*xl; lh = gl*xx; ll = gl*xl;// b) res = ((((gl + ll) + lh) + hl) + hh) + gg;// (exactly in this order)//// II. Main path algorithm // ( thanks to Peter Markstein for the idea of sqrt(x^2+1) computation! )// **********************************************************************//// There are 3 parts of x+sqrt(x^2-1) computation://// 1) m2 = (m2_hi+m2_lo) = x^2-1 obtaining// ------------------------------------// m2_hi = x2_hi - 1, where x2_hi = x * x;// m2_lo = x2_lo + p1_lo, where // x2_lo = FMS(x*x-x2_hi), // p1_lo = (1 + m2_hi) - x2_hi;//// 2) g = (g_hi+g_lo) = sqrt(m2) = sqrt(m2_hi+m2_lo)// ----------------------------------------------// r = invsqrt(m2_hi) (8-bit reciprocal square root approximation);// g = m2_hi * r (first 8 bit-approximation of sqrt);// // h = 0.5 * r;// e = 0.5 - g * h;// g = g * e + g (second 16 bit-approximation of sqrt);// // h = h * e + h;// e = 0.5 - g * h;// g = g * e + g (third 32 bit-approximation of sqrt);//// h = h * e + h;// e = 0.5 - g * h;// g_hi = g * e + g (fourth 64 bit-approximation of sqrt);// // Remainder computation:// h = h * e + h;// d = (m2_hi - g_hi * g_hi) + m2_lo;// g_lo = d * h;//// 3) b = (b_hi + b_lo) = x + g, where g = (g_hi + g_lo) = sqrt(x^2-1)// -------------------------------------------------------------------// b_hi = (g_hi + x) + gl;// b_lo = (x - b_hi) + g_hi + gl;// // Now we pass b presented as sum b_hi + b_lo to special version// of logl function which accept a pair of arguments as// mutiprecision value. // // Special log algorithm overview// ================================// Here we use a table lookup method. The basic idea is that in// order to compute logl(Arg) for an argument Arg in [1,2), // we construct a value G such that G*Arg is close to 1 and that// logl(1/G) is obtainable easily from a table of values calculated// beforehand. Thus//// logl(Arg) = logl(1/G) + logl((G*Arg - 1))//// Because |G*Arg - 1| is small, the second term on the right hand// side can be approximated by a short polynomial. We elaborate// this method in four steps.//// Step 0: Initialization//// We need to calculate logl( X+1 ). Obtain N, S_hi such that//// X = 2^N * ( S_hi + S_lo ) exactly//// where S_hi in [1,2) and S_lo is a correction to S_hi in the sense// that |S_lo| <= ulp(S_hi).//// For the special version of logl: S_lo = b_lo// !-----------------------------------------------!//// Step 1: Argument Reduction//// Based on S_hi, obtain G_1, G_2, G_3 from a table and calculate//// G := G_1 * G_2 * G_3// r := (G * S_hi - 1) + G * S_lo//// These G_j's have the property that the product is exactly // representable and that |r| < 2^(-12) as a result.//// Step 2: Approximation//// logl(1 + r) is approximated by a short polynomial poly(r).//// Step 3: Reconstruction//// Finally, logl( X ) = logl( X+1 ) is given by//// logl( X ) = logl( 2^N * (S_hi + S_lo) )// ~=~ N*logl(2) + logl(1/G) + logl(1 + r)// ~=~ N*logl(2) + logl(1/G) + poly(r).//// For detailed description see logl or log1pl function, regular path.//// Registers used//==============================================================// Floating Point registers used: // f8, input// f32 -> f95 (64 registers)// General registers used: // r32 -> r67 (36 registers)// Predicate registers used:// p7 -> p11// p7 for 'NaNs, Inf' path// p8 for 'near 1' path// p9 for 'huges' path// p10 for x = 1 // p11 for x < 1////*********************************************************************// IEEE Special Conditions://// acoshl(+inf) = +inf// acoshl(-inf) = QNaN // acoshl(1) = 0 // acoshl(x<1) = QNaN// acoshl(SNaN) = QNaN// acoshl(QNaN) = QNaN//// Data tables//============================================================== RODATA.align 64// Near 1 path rational aproximation coefficientsLOCAL_OBJECT_START(Poly_P)data8 0xB0978143F695D40F, 0x3FF1 // .84205539791447100108478906277453574946e-4 data8 0xB9800D841A8CAD29, 0x3FF6 // .28305085180397409672905983082168721069e-2 data8 0xC889F455758C1725, 0x3FF9 // .24479844297887530847660233111267222945e-1 data8 0x9BE1DFF006F45F12, 0x3FFB // .76114415657565879842941751209926938306e-1 data8 0x9E34AF4D372861E0, 0x3FFB // .77248925727776366270605984806795850504e-1 data8 0xF3DC502AEE14C4AE, 0x3FA6 // .3077953476682583606615438814166025592e-26 LOCAL_OBJECT_END(Poly_P)//LOCAL_OBJECT_START(Poly_Q)data8 0xF76E3FD3C7680357, 0x3FF1 // .11798413344703621030038719253730708525e-3 data8 0xD107D2E7273263AE, 0x3FF7 // .63791065024872525660782716786703188820e-2 data8 0xB609BE5CDE206AEF, 0x3FFB // .88885771950814004376363335821980079985e-1 data8 0xF7DEACAC28067C8A, 0x3FFD // .48412074662702495416825113623936037072302 data8 0x8F9BE5890CEC7E38, 0x3FFF // 1.1219450873557867470217771071068369729526 data8 0xED4F06F3D2BC92D1, 0x3FFE // .92698710873331639524734537734804056798748 LOCAL_OBJECT_END(Poly_Q)// Q coeffs LOCAL_OBJECT_START(Constants_Q)data4 0x00000000,0xB1721800,0x00003FFE,0x00000000 data4 0x4361C4C6,0x82E30865,0x0000BFE2,0x00000000data4 0x328833CB,0xCCCCCAF2,0x00003FFC,0x00000000data4 0xA9D4BAFB,0x80000077,0x0000BFFD,0x00000000data4 0xAAABE3D2,0xAAAAAAAA,0x00003FFD,0x00000000data4 0xFFFFDAB7,0xFFFFFFFF,0x0000BFFD,0x00000000 LOCAL_OBJECT_END(Constants_Q)// Z1 - 16 bit fixedLOCAL_OBJECT_START(Constants_Z_1)data4 0x00008000data4 0x00007879data4 0x000071C8data4 0x00006BCBdata4 0x00006667data4 0x00006187data4 0x00005D18data4 0x0000590Cdata4 0x00005556data4 0x000051ECdata4 0x00004EC5data4 0x00004BDBdata4 0x00004925data4 0x0000469Fdata4 0x00004445data4 0x00004211LOCAL_OBJECT_END(Constants_Z_1)// G1 and H1 - IEEE single and h1 - IEEE doubleLOCAL_OBJECT_START(Constants_G_H_h1)data4 0x3F800000,0x00000000data8 0x0000000000000000data4 0x3F70F0F0,0x3D785196data8 0x3DA163A6617D741Cdata4 0x3F638E38,0x3DF13843data8 0x3E2C55E6CBD3D5BBdata4 0x3F579430,0x3E2FF9A0data8 0xBE3EB0BFD86EA5E7data4 0x3F4CCCC8,0x3E647FD6data8 0x3E2E6A8C86B12760data4 0x3F430C30,0x3E8B3AE7data8 0x3E47574C5C0739BAdata4 0x3F3A2E88,0x3EA30C68data8 0x3E20E30F13E8AF2Fdata4 0x3F321640,0x3EB9CEC8data8 0xBE42885BF2C630BDdata4 0x3F2AAAA8,0x3ECF9927data8 0x3E497F3497E577C6data4 0x3F23D708,0x3EE47FC5data8 0x3E3E6A6EA6B0A5ABdata4 0x3F1D89D8,0x3EF8947Ddata8 0xBDF43E3CD328D9BEdata4 0x3F17B420,0x3F05F3A1data8 0x3E4094C30ADB090Adata4 0x3F124920,0x3F0F4303data8 0xBE28FBB2FC1FE510data4 0x3F0D3DC8,0x3F183EBFdata8 0x3E3A789510FDE3FAdata4 0x3F088888,0x3F20EC80data8 0x3E508CE57CC8C98Fdata4 0x3F042108,0x3F29516Adata8 0xBE534874A223106CLOCAL_OBJECT_END(Constants_G_H_h1)// Z2 - 16 bit fixedLOCAL_OBJECT_START(Constants_Z_2)data4 0x00008000data4 0x00007F81data4 0x00007F02data4 0x00007E85data4 0x00007E08data4 0x00007D8Ddata4 0x00007D12data4 0x00007C98data4 0x00007C20data4 0x00007BA8data4 0x00007B31data4 0x00007ABBdata4 0x00007A45data4 0x000079D1data4 0x0000795Ddata4 0x000078EBLOCAL_OBJECT_END(Constants_Z_2)// G2 and H2 - IEEE single and h2 - IEEE doubleLOCAL_OBJECT_START(Constants_G_H_h2)data4 0x3F800000,0x00000000data8 0x0000000000000000data4 0x3F7F00F8,0x3B7F875Ddata8 0x3DB5A11622C42273data4 0x3F7E03F8,0x3BFF015Bdata8 0x3DE620CF21F86ED3data4 0x3F7D08E0,0x3C3EE393data8 0xBDAFA07E484F34EDdata4 0x3F7C0FC0,0x3C7E0586data8 0xBDFE07F03860BCF6data4 0x3F7B1880,0x3C9E75D2data8 0x3DEA370FA78093D6data4 0x3F7A2328,0x3CBDC97Adata8 0x3DFF579172A753D0data4 0x3F792FB0,0x3CDCFE47data8 0x3DFEBE6CA7EF896Bdata4 0x3F783E08,0x3CFC15D0data8 0x3E0CF156409ECB43data4 0x3F774E38,0x3D0D874Ddata8 0xBE0B6F97FFEF71DFdata4 0x3F766038,0x3D1CF49Bdata8 0xBE0804835D59EEE8data4 0x3F757400,0x3D2C531Ddata8 0x3E1F91E9A9192A74data4 0x3F748988,0x3D3BA322data8 0xBE139A06BF72A8CDdata4 0x3F73A0D0,0x3D4AE46Fdata8 0x3E1D9202F8FBA6CFdata4 0x3F72B9D0,0x3D5A1756data8 0xBE1DCCC4BA796223data4 0x3F71D488,0x3D693B9Ddata8 0xBE049391B6B7C239LOCAL_OBJECT_END(Constants_G_H_h2)// G3 and H3 - IEEE single and h3 - IEEE double LOCAL_OBJECT_START(Constants_G_H_h3)data4 0x3F7FFC00,0x38800100data8 0x3D355595562224CDdata4 0x3F7FF400,0x39400480data8 0x3D8200A206136FF6data4 0x3F7FEC00,0x39A00640data8 0x3DA4D68DE8DE9AF0data4 0x3F7FE400,0x39E00C41data8 0xBD8B4291B10238DCdata4 0x3F7FDC00,0x3A100A21data8 0xBD89CCB83B1952CAdata4 0x3F7FD400,0x3A300F22data8 0xBDB107071DC46826data4 0x3F7FCC08,0x3A4FF51Cdata8 0x3DB6FCB9F43307DBdata4 0x3F7FC408,0x3A6FFC1Ddata8 0xBD9B7C4762DC7872data4 0x3F7FBC10,0x3A87F20Bdata8 0xBDC3725E3F89154Adata4 0x3F7FB410,0x3A97F68Bdata8 0xBD93519D62B9D392data4 0x3F7FAC18,0x3AA7EB86data8 0x3DC184410F21BD9Ddata4 0x3F7FA420,0x3AB7E101data8 0xBDA64B952245E0A6data4 0x3F7F9C20,0x3AC7E701data8 0x3DB4B0ECAABB34B8data4 0x3F7F9428,0x3AD7DD7Bdata8 0x3D9923376DC40A7Edata4 0x3F7F8C30,0x3AE7D474data8 0x3DC6E17B4F2083D3data4 0x3F7F8438,0x3AF7CBEDdata8 0x3DAE314B811D4394data4 0x3F7F7C40,0x3B03E1F3data8 0xBDD46F21B08F2DB1data4 0x3F7F7448,0x3B0BDE2Fdata8 0xBDDC30A46D34522Bdata4 0x3F7F6C50,0x3B13DAAAdata8 0x3DCB0070B1F473DBdata4 0x3F7F6458,0x3B1BD766data8 0xBDD65DDC6AD282FDdata4 0x3F7F5C68,0x3B23CC5Cdata8 0xBDCDAB83F153761Adata4 0x3F7F5470,0x3B2BC997data8 0xBDDADA40341D0F8Fdata4 0x3F7F4C78,0x3B33C711data8 0x3DCD1BD7EBC394E8data4 0x3F7F4488,0x3B3BBCC6data8 0xBDC3532B52E3E695data4 0x3F7F3C90,0x3B43BAC0data8 0xBDA3961EE846B3DEdata4 0x3F7F34A0,0x3B4BB0F4data8 0xBDDADF06785778D4data4 0x3F7F2CA8,0x3B53AF6Ddata8 0x3DCC3ED1E55CE212data4 0x3F7F24B8,0x3B5BA620data8 0xBDBA31039E382C15data4 0x3F7F1CC8,0x3B639D12data8 0x3D635A0B5C5AF197data4 0x3F7F14D8,0x3B6B9444data8 0xBDDCCB1971D34EFCdata4 0x3F7F0CE0,0x3B7393BCdata8 0x3DC7450252CD7ADAdata4 0x3F7F04F0,0x3B7B8B6Ddata8 0xBDB68F177D7F2A42LOCAL_OBJECT_END(Constants_G_H_h3)// Assembly macros//==============================================================// Floating Point RegistersFR_Arg = f8FR_Res = f8FR_PP0 = f32FR_PP1 = f33FR_PP2 = f34FR_PP3 = f35FR_PP4 = f36FR_PP5 = f37FR_QQ0 = f38FR_QQ1 = f39FR_QQ2 = f40FR_QQ3 = f41FR_QQ4 = f42FR_QQ5 = f43FR_Q1 = f44 FR_Q2 = f45 FR_Q3 = f46 FR_Q4 = f47 FR_Half = f48FR_Two = f49FR_log2_hi = f50 FR_log2_lo = f51 FR_X2 = f52FR_M2 = f53FR_M2L = f54FR_Rcp = f55FR_GG = f56FR_HH = f57FR_EE = f58FR_DD = f59FR_GL = f60FR_Tmp = f61FR_XM1 = f62FR_2XM1 = f63FR_XM12 = f64 // Special logl registersFR_XLog_Hi = f65 FR_XLog_Lo = f66 FR_Y_hi = f67 FR_Y_lo = f68FR_S_hi = f69 FR_S_lo = f70 FR_poly_lo = f71FR_poly_hi = f72FR_G = f73FR_H = f74FR_h = f75FR_G2 = f76FR_H2 = f77FR_h2 = f78 FR_r = f79 FR_rsq = f80 FR_rcub = f81 FR_float_N = f82 FR_G3 = f83 FR_H3 = f84 FR_h3 = f85 FR_2_to_minus_N = f86 // Near 1 registersFR_PP = f65FR_QQ = f66FR_PV6 = f69FR_PV4 = f70FR_PV3 = f71FR_PV2 = f72FR_QV6 = f73FR_QV4 = f74FR_QV3 = f75FR_QV2 = f76FR_Y0 = f77FR_Q0 = f78 FR_E0 = f79FR_E2 = f80FR_E1 = f81FR_Y1 = f82FR_E3 = f83FR_Y2 = f84FR_R0 = f85FR_E4 = f86FR_Y3 = f87
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -