diff options
Diffstat (limited to 'usr/src/lib/libm/common/Q')
70 files changed, 10828 insertions, 0 deletions
diff --git a/usr/src/lib/libm/common/Q/_TBL_atanl.c b/usr/src/lib/libm/common/Q/_TBL_atanl.c new file mode 100644 index 0000000000..bf152db99f --- /dev/null +++ b/usr/src/lib/libm/common/Q/_TBL_atanl.c @@ -0,0 +1,235 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Table of constants for atanl. + * By K.C. Ng, March 9, 1989 + */ + +#include "libm.h" + +const long double _TBL_atanl_hi[] = { + +1.243549945467614350313548491638710241657e-0001L, + +1.320397616146387492746844065265695322625e-0001L, + +1.397088742891636451833677767390950568161e-0001L, + +1.473614810886516356098027603968455182107e-0001L, + +1.549967419239409823037143749334921913337e-0001L, + +1.626138285979485753736415637615578006202e-0001L, + +1.702119252854744044904966070997617136954e-0001L, + +1.777902289926760707966247992158246889946e-0001L, + +1.853479499956947648860259612285446466726e-0001L, + +1.928843122579746641970587106902273034988e-0001L, + +2.003985538258785146539457850343783844615e-0001L, + +2.078899272022629936053349831029943247563e-0001L, + +2.153576996977380480244596271664896416574e-0001L, + +2.228011537593945157710321221404325552502e-0001L, + +2.302195872768437302401709596798029906555e-0001L, + +2.376123138654712524738836343256377791989e-0001L, + +2.449786631268641541720824812112758064196e-0001L, + +2.596296294082575310299464431839719056011e-0001L, + +2.741674511196587975993718983421757859244e-0001L, + +2.885873618940773956236114199582183450433e-0001L, + +3.028848683749714055605560945055582181228e-0001L, + +3.170557532091470098090155766744673297585e-0001L, + +3.310960767041320949443387877569445542126e-0001L, + +3.450021772071051088676812869000516840829e-0001L, + +3.587706702705722203959200639264605221536e-0001L, + +3.723984466767542219236550382837018264141e-0001L, + +3.858826693980737758976954846072313963819e-0001L, + +3.992207695752525656147166961588647649110e-0001L, + +4.124104415973873068997912896671269426092e-0001L, + +4.254496373700422895422636051807923301382e-0001L, + +4.383365598579578054456160492147713089588e-0001L, + +4.510696559885234763756392572821934407380e-0001L, + +4.636476090008061162142562314612143971334e-0001L, + +4.883339510564055238671649607470648445964e-0001L, + +5.123894603107377066666010205842592380556e-0001L, + +5.358112379604637002690850687076914469847e-0001L, + +5.585993153435624359715082164016612287587e-0001L, + +5.807563535676703992032744750015008237512e-0001L, + +6.022873461349641816821226942042329192246e-0001L, + +6.231993299340659309924753490603745936779e-0001L, + +6.435011087932843868028092287173226044727e-0001L, + +6.632029927060932553632543102382758341723e-0001L, + +6.823165548747480782564299817111529878473e-0001L, + +7.008544078844501724579512817867512731862e-0001L, + +7.188299996216245054170141515259046989104e-0001L, + +7.362574289814281317428352710891466247927e-0001L, + +7.531512809621943895247393702690288860057e-0001L, + +7.695264804056582604068200359856540172660e-0001L, + +7.853981633974483096156608458198756993698e-0001L, + +8.156919233162234110214608387456458267228e-0001L, + +8.441539861131710025178441482716474673863e-0001L, + +8.709034570756529531401731125978140729165e-0001L, + +8.960553845713439561748007180299377954660e-0001L, + +9.197196053504168172286034548210894096931e-0001L, + +9.420000403794636647379371705345936211589e-0001L, + +9.629943306809362018151958359970998967730e-0001L, + +9.827937232473290679857106110146660376257e-0001L, + +1.001483135694234732918329595301437489634e+0000L, + +1.019141344266349734638342917023063621235e+0000L, + +1.035841253008800176584694470325444073548e+0000L, + +1.051650212548373667459867312086299902692e+0000L, + +1.066630365315743563079176347420279908601e+0000L, + +1.080839000541168310887156729217199785900e+0000L, + +1.094328907321189919892788314610235276303e+0000L, + +1.107148717794090503017065460178537049754e+0000L, + +1.130953743979160446470933515536327756003e+0000L, + +1.152571997215667518040149862612751467283e+0000L, + +1.172273881128476386600594944133704600686e+0000L, + +1.190289949682531732927733774829318280338e+0000L, + +1.206817370285252530395511580056557662568e+0000L, + +1.222025323210989637041741743922570412029e+0000L, + +1.236059489478081941909451971109078614621e+0000L, + +1.249045772398254425829917077281090048355e+0000L, + +1.261093382252440419313940881247335764012e+0000L, + +1.272297395208717341296193749822480574646e+0000L, + +1.282740879744270747362885251136495516407e+0000L, + +1.292496667789785267903091421407081672353e+0000L, + +1.301628834009196143804785850366685502445e+0000L, + +1.310193935047555634256437689171905343754e+0000L, + +1.318242051016837049859330202327136304043e+0000L, + +1.325817663668032465059239210428475688616e+0000L, + +1.339705659598999539328303752589555785024e+0000L, + +1.352127380920954657189147941389812759877e+0000L, + +1.363300100359693954289298527825099156027e+0000L, + +1.373400766945015860861271926444961060484e+0000L, + +1.382574821490125858059967417768568516395e+0000L, + +1.390942827002418348642768694383643239549e+0000L, + +1.398605512271957595012670081611428272786e+0000L, + +1.405647649380269780952193401995808066441e+0000L, + +1.412141064608495215367613671858489085282e+0000L, + +1.418146998399631459403860303970098863261e+0000L, + +1.423717971406494118901819046610729710890e+0000L, + +1.428899272190732696418470074537198400139e+0000L, + +1.433730152484708986640471909669887388026e+0000L, + +1.438244794498222597961404247935481603967e+0000L, + +1.442473099109101820025292059937729181035e+0000L, + +1.446441332248135184199966842475880386611e+0000L, +}; + +const long double _TBL_atanl_lo[] = { + +1.407486919762806380231720282041430859065e-0036L, + -4.959696159473992555573043943799966949987e-0036L, + +8.952774562519464887393121344636183788152e-0036L, + +1.188043742320789571818076584354496443030e-0035L, + -2.781027811204514537842537512823435451463e-0037L, + +1.479722037702380032729553623431514726239e-0036L, + -4.216956140054819873287038480184963406819e-0036L, + +7.243122966691348464993032365631602349468e-0036L, + -2.157343008983917029989567935379065159119e-0036L, + -9.951574540512672355445236729812860518631e-0036L, + -3.906555899232483818161756973039787656743e-0036L, + +5.526029227179372681321198066466113031444e-0036L, + +8.841572221591432180768225431803645204369e-0036L, + -8.176772879158617925419332362828558820944e-0036L, + -1.334412303465614224379711382302833876421e-0036L, + -4.492733120781338290893073392468132589219e-0036L, + +4.494551147181249039320182433676250148336e-0036L, + -1.668808150427922355577672445964844056727e-0035L, + +1.562975758610795576946108656893732968411e-0035L, + -2.238983556330807855250797038533151084811e-0035L, + -4.831232174554731155187045067118216295832e-0036L, + -1.433617235290583287695892661098069884431e-0035L, + -8.744018199889993280298917417096058172481e-0036L, + +5.928463600852983744578036078546455593865e-0036L, + -2.237665124843624127606105529504351499363e-0035L, + +6.074583759933610541428031075667744213648e-0036L, + +1.537218711045194967779234476202996702309e-0035L, + +2.097606805675115624165712158247879024716e-0035L, + -5.562395640549543806072686220262281911497e-0036L, + +1.969736670783247184185841193489735190152e-0035L, + +2.107031196447948850903473363942488754370e-0035L, + -2.302735636298200160225651851085422984456e-0035L, + +4.895096422573334926686184352202977056848e-0036L, + -7.238014347779445821387272305082026475766e-0036L, + +1.636564886570361403163744339604956885811e-0035L, + -3.988581195823453079372912991980323419740e-0035L, + +4.158772212091261351041778392322742597344e-0035L, + +3.834742145455647215368468737733713502739e-0035L, + -9.225117893363872172351589646548899090659e-0036L, + +1.409461969045598952617573674185465039654e-0036L, + +3.356885780547223527061285142581080367945e-0035L, + +3.909099105552255239501810680323211880340e-0035L, + +5.295641697965420814052186270729703965359e-0036L, + -5.096084681994551436784706392366250713672e-0036L, + -4.495901442527761585832968039391831520500e-0035L, + +3.803922654455163426656685761596261429034e-0035L, + -4.405652287289551210830864219661168965762e-0036L, + +1.602502419248216107622380775342561907695e-0036L, + +2.167952532530945256199261006510838063526e-0035L, + +1.984403801351542212571536292573675410407e-0035L, + +3.913961947179974683450522735356843245724e-0035L, + +2.111344380797545350551845343679956185473e-0035L, + +3.155855727744469275503981694439277018543e-0035L, + +1.629504452035546140826558561950023833561e-0035L, + -3.508724520927030585615123035617120894580e-0035L, + +2.904104186428285567959105527094611730009e-0035L, + -2.312884345381835659093199520980662723328e-0035L, + -7.712492318147157843996797382071597987481e-0035L, + +2.753902782988692242909206359044995381933e-0035L, + -9.450089945318130895108454599083752773445e-0035L, + -7.306175530203209233759494600164318159101e-0035L, + -4.173614481395375219395277015740431906643e-0035L, + +3.436994835625640704534485526286425749647e-0035L, + -6.379024349229809090730208492427563489748e-0035L, + -9.684294381635326129100412786609400488464e-0036L, + +4.874675753913887090927595832669806057728e-0035L, + -8.753388647708419088451160136858547852751e-0035L, + +1.428474399232791889269255113808220484160e-0035L, + +5.726277621107338954256562569347449057228e-0035L, + -3.225488314878041124559482227075035491317e-0035L, + +7.885354819060987732596552525237673513561e-0035L, + +8.408173673903719409751503836536882928318e-0035L, + +7.472287035756368381507824298193454239425e-0035L, + +7.997720282579343528943481360087007043974e-0036L, + -8.057784077336213905484849234629395332153e-0035L, + +1.421774675367058306549004020905308580426e-0035L, + +1.223248691422120500410974356032312699327e-0035L, + +8.969605507083003644736195721794664042146e-0035L, + -3.148039443508188441068606673984936704609e-0035L, + -5.092714604071534501324064251761157116236e-0035L, + -5.743199771592413656813385943270585886166e-0035L, + -4.392045140508377027909976608047950844300e-0035L, + +9.110675398490771556301866677631321964372e-0035L, + -3.703256901427284100951240077306435653503e-0035L, + +8.816741942974671427690982540513176913907e-0035L, + -3.838934169602835250375231286170331051923e-0036L, + -3.346295934196089154634089550801425121335e-0035L, + -3.921262677678607438391618849895555508099e-0035L, + -7.834039739637786725586449456859141775022e-0035L, + +7.468101863245698652060064034062436100558e-0035L, + +8.911091861895691845113559487616548179839e-0035L, + +3.941816063227189053043179714566870857491e-0035L, + -4.104811408858010482019343563832718161219e-0035L, + -2.316541945158215332638394475622094450115e-0035L, + -1.842831258152531940939933020370545982007e-0035L, + +7.147731654670948234541171201790940212220e-0035L, + +2.991450157843587466215363770701953452571e-0035L, +}; diff --git a/usr/src/lib/libm/common/Q/_TBL_cosl.c b/usr/src/lib/libm/common/Q/_TBL_cosl.c new file mode 100644 index 0000000000..58f7468f70 --- /dev/null +++ b/usr/src/lib/libm/common/Q/_TBL_cosl.c @@ -0,0 +1,192 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * table of cosl(x) where x is 0.15625 + i*0.03125, i=0,1,...,74. + * {0x3ffc4000,0,0,0} --> (inc 0x800) --> {0x3ffe9000,0,0,0} + * 0.15625 0.03125 0.78125 (pi/4 = 0.785395663...) + */ + +#include "libm.h" + +const long double _TBL_cosl_hi[] = { + +9.878177838164719441005030343632113165093e-0001L, + +9.872023778548304903960885335116224443952e-0001L, + +9.865719083994975887573374074953084086015e-0001L, + +9.859263850706614357470592528694354441508e-0001L, + +9.852658177182138162042947097595789939359e-0001L, + +9.845902164215998060143951077820687364441e-0001L, + +9.838995914896639721783093514164872453367e-0001L, + +9.831939534604930725278757612989684275134e-0001L, + +9.824733131012552574873276832436224950147e-0001L, + +9.817376814080357763345961479047090031971e-0001L, + +9.809870696056691904693298964353096645569e-0001L, + +9.802214891475680962478518674217420182872e-0001L, + +9.794409517155483599985309545029874933258e-0001L, + +9.786454692196508678842676797432752842534e-0001L, + +9.778350537979597933319715729444545493330e-0001L, + +9.770097178164173848020456902145767884624e-0001L, + +9.761694738686352767239890354351355336967e-0001L, + +9.753143347757023264772798556222610938601e-0001L, + +9.744443135859889803497110560454343440501e-0001L, + +9.735594235749481714583125145098981012012e-0001L, + +9.726596782449127526709130582675652597851e-0001L, + +9.717450913248894676192664941325029643211e-0001L, + +9.708156767703494629474905457850460270255e-0001L, + +9.698714487630153449923440459169307761267e-0001L, + +9.689124217106447841445954494941892053405e-0001L, + +9.669500292306778220083416236105315034050e-0001L, + +9.649286191047710095810746653157483714001e-0001L, + +9.628483147093796998997010934802143646862e-0001L, + +9.607092430155619030666593505813134717046e-0001L, + +9.585115345812286273019694081549198217856e-0001L, + +9.562553235431752969755999422630283611690e-0001L, + +9.539407476088947339813247959876116228319e-0001L, + +9.515679480481722021454882173642709621657e-0001L, + +9.491370696844630276658474217621056230077e-0001L, + +9.466482608860533218460995072955329761108e-0001L, + +9.441016735570043456300176912531248599600e-0001L, + +9.414974631278810686445112360536708146537e-0001L, + +9.388357885462654886325783059847125541586e-0001L, + +9.361168122670552902942374110195085880318e-0001L, + +9.333407002425484356552992294699955265909e-0001L, + +9.305076219123142911494767922295554806411e-0001L, + +9.276177501928519096280307987999613501918e-0001L, + +9.246712614670360985021130145601387709996e-0001L, + +9.216683355733519181754113682027127142383e-0001L, + +9.186091557949182678378249777185498625801e-0001L, + +9.154939088483012285639177321802218816645e-0001L, + +9.123227848721178464920295420473417337577e-0001L, + +9.090959774154310516503817356844764174905e-0001L, + +9.058136834259364207445166606527002577088e-0001L, + +9.024761032379415049251832726758959994948e-0001L, + +8.990834405601384562165449292093793065380e-0001L, + +8.956359024631706989005700004462563503448e-0001L, + +8.921336993669944047239002537237885750767e-0001L, + +8.885770450280355433176090231160209800973e-0001L, + +8.849661565261432916972965369666479264236e-0001L, + +8.813012542513405991401619082981001728813e-0001L, + +8.775825618903727161162815826038296809401e-0001L, + +8.699847180584173888289155999014662429887e-0001L, + +8.621744799348805043671625102533242741250e-0001L, + +8.541537542773853851434517851051031764412e-0001L, + +8.459244992310679544597230785974932624246e-0001L, + +8.374887238505236853153533489172406171513e-0001L, + +8.288484876093257348101717901191166381510e-0001L, + +8.200058998972340082555506338765560425268e-0001L, + +8.109631195052179021895348039410807243520e-0001L, + +8.017223540984184506074926056529642078277e-0001L, + +7.922858596771785431415013237817093985302e-0001L, + +7.826559400262727969307874474281390259485e-0001L, + +7.728349461524715448108518459134251775639e-0001L, + +7.628252757105762505070987536254297918621e-0001L, + +7.526293724180664760545413248471431159893e-0001L, + +7.422497254585013069913472534496105367206e-0001L, + +7.316888688738208863118387530000845290150e-0001L, + +7.209493809456964180438127841484476879092e-0001L, + +7.100338835660796749741216439594902194333e-0001L, +}; + +const long double _TBL_cosl_lo[] = { + +4.742713078367058978924681076205264183648e-0035L, + -3.400922580038153352909034207677181560093e-0035L, + -2.473279499369853624762524012127207246323e-0035L, + -3.902320877004518000716232064546238578734e-0035L, + +2.265680295058180661415174977785279521173e-0035L, + -2.254772246444203259170588302104662991085e-0036L, + +2.734143189480662078104863307237612648780e-0035L, + -3.701912560693446438656202168446355677822e-0035L, + -1.649243588915575846254638680142303422320e-0035L, + +2.725042655698714891044457001868653187367e-0035L, + -1.908992594100964198869963315362783449712e-0036L, + -1.465547554627127716918860559012698704471e-0035L, + +4.428780565915607570668447972900679899952e-0035L, + +1.439313657623768907227720140857454695843e-0035L, + -3.792074229051804169372108537791927020038e-0035L, + -2.610779485320152706286660129045188117210e-0036L, + -2.877279742494815830479448606269854599891e-0035L, + +3.991065835589256680020290949615723238476e-0035L, + +3.099479059550534193045145385925483327991e-0035L, + +1.146611686911982702287167679510021879695e-0035L, + -3.917592318193149049660769585602527582231e-0035L, + -1.951971321999985008371800682574139933978e-0035L, + +2.974588209723938591252776820212028367960e-0035L, + -2.038390756570426530537115267786908745116e-0036L, + -5.536347061134619893988732877493263844943e-0036L, + -4.389722144327924120620880599904805370946e-0035L, + -3.666858326708207750024755456027611364938e-0035L, + +4.889869663833434507994220130518213362272e-0036L, + -5.870115582315839607120133516012219562069e-0036L, + +2.507707793716364811457350893931543805685e-0035L, + +3.216165721908659970511036451358372071749e-0035L, + +2.880756890524786020083959729246571876109e-0035L, + +6.368426285981156583087492887998846060579e-0036L, + +6.844339659916371522503091904688601360028e-0037L, + -4.329063396630008909415294204988246215817e-0035L, + +1.038125352401202296098224611721455839121e-0035L, + +3.207093666031656020715902410548849578474e-0036L, + -3.987580687739740313485850727522454807713e-0035L, + +3.404815912367106584354098624390321615909e-0035L, + -4.752557072516798311248008988313821999362e-0035L, + +2.745410885517329825733352856854160918801e-0035L, + +7.585203719163457562812011671268547121453e-0036L, + -4.141871248600318251086493472511758380472e-0035L, + -1.835879954339576229487102635414793218992e-0035L, + +2.976082827782744334600577457984098492775e-0035L, + -3.507755179553069548150909011683056358498e-0035L, + +7.869038865563736742679481321788455681309e-0036L, + +1.208860140284441557337760250856779527931e-0035L, + -3.609503076059411697756765630044671398302e-0035L, + +2.262828995013444190183062956802106020046e-0035L, + -2.067726154909043706666702751547519756391e-0035L, + +3.735937416598668830886204955423117851511e-0035L, + -1.107719376025673147326930792646924920884e-0035L, + +4.123542789546647314438136551770221119198e-0036L, + +4.533705702883256304420378263134621416396e-0035L, + -1.434191923121166877839456190096294453634e-0035L, + -2.894849601813639248551925385406988512004e-0035L, + -4.681686383005756267827413197921838600437e-0035L, + -3.715568183175335822345624718357717998947e-0035L, + -1.687075340130951528732220617225731715663e-0035L, + +1.980549471419898781791643429252740528544e-0035L, + +2.727619978720845330457777186773261559081e-0035L, + +1.430825081004965817190481755062397701422e-0035L, + -1.720088119552308234167243322979912469421e-0035L, + +1.104812928567944364260514024188043464704e-0035L, + +6.094878513052330893256279394589637408556e-0036L, + +2.475195582284731678792488916738076213891e-0035L, + +1.693320456792379194278077712885062541662e-0035L, + +3.949752293412116642372415347411469162440e-0035L, + +4.220674118886015050047489393823250795070e-0035L, + +3.713069586576631896654508643111045710544e-0035L, + -3.789252700498009135399234738712875263543e-0035L, + +1.482556375489316971849917102931986196306e-0035L, + +4.786912857336733794995363260508118324272e-0035L, + -4.096232247636924432208967529079024417475e-0035L, +}; diff --git a/usr/src/lib/libm/common/Q/_TBL_expl.c b/usr/src/lib/libm/common/Q/_TBL_expl.c new file mode 100644 index 0000000000..aac2030240 --- /dev/null +++ b/usr/src/lib/libm/common/Q/_TBL_expl.c @@ -0,0 +1,105 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Table of constants for expl. + * By K.C. Ng, March 9, 1989 + */ + +#include "libm.h" + +const long double _TBL_expl_hi[] = { + +1.000000000000000000000000000000000000000e+0000L, + +1.021897148654116678234480134783299439782e+0000L, + +1.044273782427413840321966478739929008785e+0000L, + +1.067140400676823618169521120992809162607e+0000L, + +1.090507732665257659207010655760707978993e+0000L, + +1.114386742595892536308812956919603067800e+0000L, + +1.138788634756691653703830283841511254720e+0000L, + +1.163724858777577513813573599092185312343e+0000L, + +1.189207115002721066717499970560475915293e+0000L, + +1.215247359980468878116520251338798457624e+0000L, + +1.241857812073484048593677468726595605511e+0000L, + +1.269050957191733222554419081032338004715e+0000L, + +1.296839554651009665933754117792451159835e+0000L, + +1.325236643159741294629537095498721674113e+0000L, + +1.354255546936892728298014740140702804343e+0000L, + +1.383909881963831954872659527265192818002e+0000L, + +1.414213562373095048801688724209698078570e+0000L, + +1.445180806977046620037006241471670905678e+0000L, + +1.476826145939499311386907480374049923924e+0000L, + +1.509164427593422739766019551033193531420e+0000L, + +1.542210825407940823612291862090734841307e+0000L, + +1.575980845107886486455270160181905008906e+0000L, + +1.610490331949254308179520667357400583459e+0000L, + +1.645755478153964844518756724725822445667e+0000L, + +1.681792830507429086062250952466429790080e+0000L, + +1.718619298122477915629344376456312504516e+0000L, + +1.756252160373299483112160619375313221294e+0000L, + +1.794709075003107186427703242127781814354e+0000L, + +1.834008086409342463487083189588288856077e+0000L, + +1.874167634110299901329998949954446534439e+0000L, + +1.915206561397147293872611270295830887850e+0000L, + +1.957144124175400269018322251626871491190e+0000L, +}; + +const long double _TBL_expl_lo[] = { + +0.000000000000000000000000000000000000000e+0000L, + +1.805067874203309547455733330545737864651e-0035L, + -9.374520292280427421957567419730832143843e-0035L, + -1.596968447292758770712909630231499971233e-0035L, + +9.112493410125022978511686101672486662119e-0035L, + -6.504228206978548287230374775259388710985e-0035L, + -8.148468844525851137325691767488155323605e-0035L, + -5.066214576721800313372330745142903350963e-0035L, + -1.359830974688816973749875638245919118924e-0035L, + +9.497427635563196470307710566433246597109e-0035L, + -3.283170523176998601615065965333915261932e-0036L, + -5.017235709387190410290186530458428950862e-0035L, + -2.391474797689109171622834301602640139258e-0035L, + -8.350571357633908815298890737944083853080e-0036L, + +7.036756889073265042421737190671876440729e-0035L, + -5.182484853064646457536893018566956189817e-0035L, + +9.422242548621832065692116736394064879758e-0035L, + -3.967500825398862309167306130216418281103e-0035L, + +7.143528991563300614523273615092767243521e-0035L, + +1.159871252867985124246517834100444327747e-0035L, + +4.696933478358115495309739213201874466685e-0035L, + -3.386513175995004710799241984999819165197e-0035L, + -8.587318774298247068868655935103874453522e-0035L, + -9.605951548749350503185499362246069088835e-0035L, + +9.609733932128012784507558697141785813655e-0035L, + +6.378397921440028439244761449780848545957e-0035L, + +7.792430785695864249456461125169277701177e-0035L, + +7.361337767588456524131930836633932195088e-0035L, + -6.472995147913347230035214575612170525266e-0035L, + +8.587474417953698694278798062295229624207e-0035L, + +2.371815422825174835691651228302690977951e-0035L, + -3.026891682096118773004597373421900314256e-0037L, +}; diff --git a/usr/src/lib/libm/common/Q/_TBL_expm1l.c b/usr/src/lib/libm/common/Q/_TBL_expm1l.c new file mode 100644 index 0000000000..54044fe87c --- /dev/null +++ b/usr/src/lib/libm/common/Q/_TBL_expm1l.c @@ -0,0 +1,368 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Table of constants for expm1l. + * By K.C. Ng, June 30, 1995 + */ + +#include "libm.h" + +const long double _TBL_expm1lx[] = { + +7.8124999999999999999999999999995004619e-03L, + +2.3437499999999999999999999999998790275e-02L, + +3.9062499999999999999999999999981095794e-02L, + +5.4687500000000000000000000000007637516e-02L, + +7.0312500000000000000000000000001673152e-02L, + +8.5937500000000000000000000000004285194e-02L, + +1.0156249999999999999999999999997969348e-01L, + +1.1718749999999999999999999999998630182e-01L, + +1.3281249999999999999999999999999246480e-01L, + +1.4843750000000000000000000000000096296e-01L, + +1.6406249999999999999999999999999947037e-01L, + +1.7968750000000000000000000000007190941e-01L, + +1.9531249999999999999999999999999874815e-01L, + +2.1093749999999999999999999999999877222e-01L, + +2.2656250000000000000000000000000019259e-01L, + +2.4218749999999999999999999999999800185e-01L, + +2.5781249999999999999999999999996335918e-01L, + +2.7343749999999999999999999999999903704e-01L, + +2.8906249999999999999999999999998362960e-01L, + +3.0468750000000000000000000000000240741e-01L, + +3.2031249999999999999999999999999542592e-01L, + +3.3593749999999999999999999999999619629e-01L, + +3.5156250000000000000000000000001040002e-01L, + +3.6718749999999999999999999999999316295e-01L, + +3.8281250000000000000000000000000871483e-01L, + +3.9843750000000000000000000000000385186e-01L, + +4.1406249999999999999999999999999975926e-01L, + +4.2968750000000000000000000000000385186e-01L, + +4.4531250000000000000000000000032119697e-01L, + +4.6093749999999999999999999999999956667e-01L, + +4.7656250000000000000000000000000134815e-01L, + +4.9218749999999999999999999999999388517e-01L, + +5.0781249999999999999999999999999778518e-01L, + +5.2343749999999999999999999999999325925e-01L, + +5.3906249999999999999999999999990649610e-01L, + +5.5468750000000000000000000000000452594e-01L, + +5.7031250000000000000000000000000645187e-01L, + +5.8593749999999999999999999999999807407e-01L, + +6.0156250000000000000000000000000182963e-01L, + +6.1718750000000000000000000000000048148e-01L, + +6.3281250000000000000000000000000943706e-01L, + +6.4843749999999999999999999999999470369e-01L, + +6.6406250000000000000000000000000192593e-01L, + +6.7968750000000000000000000000000693335e-01L, + +6.9531250000000000000000000000001482966e-01L, + +7.1093750000000000000000000000000154074e-01L, + +7.2656250000000000000000000000000385186e-01L, + +7.4218750000000000000000000000000115556e-01L, + +7.5781250000000000000000000000000048148e-01L, + +7.7343749999999999999999999999999942222e-01L, + +7.8906249999999999999999999999999720740e-01L, + +8.0468749999999999999999999999999634073e-01L, + +8.2031249999999999999999999999999797777e-01L, + +8.3593750000000000000000000000000828150e-01L, + +8.5156249999999999999999999999999865185e-01L, + +8.6718749999999999999999999999999682222e-01L, + +8.8281249999999999999999999999999749629e-01L, + +8.9843749999999999999999999999999836296e-01L, + +9.1406249999999999999999999999999229628e-01L, + +9.2968750000000000000000000000000462223e-01L, + +9.4531249999999999999999999999999499258e-01L, + +9.6093749999999999999999999999999894074e-01L, + +9.7656249999999999999999999999999855555e-01L, + +9.9218750000000000000000000000000028889e-01L, + +1.0078124999999999999999999999999870963e+00L, + +1.0234375000000000000000000000000003852e+00L, + +1.0390624999999999999999999999999998074e+00L, + +1.0546874999999999999999999999999801629e+00L, + +1.0703125000000000000000000000000182963e+00L, + +1.0859375000000000000000000000000021185e+00L, + +1.1015624999999999999999999999999978815e+00L, + +1.1171874999999999999999999999999986518e+00L, + +1.1328124999999999999999999999999984593e+00L, + +1.1484374999999999999999999999999980741e+00L, + +1.1640625000000000000000000000000000000e+00L, + +1.1796874999999999999999999999999998074e+00L, + +1.1953125000000000000000000000000196445e+00L, + +1.2109374999999999999999999999999976889e+00L, + +1.2265625000000000000000000000000017333e+00L, + +1.2421874999999999999999999999999976889e+00L, + +1.2578124999999999999999999999999980741e+00L, + +1.2734374999999999999999999999999951852e+00L, + -7.8125000000000000000000000000074012886e-03L, + -2.3437499999999999999999999999997418050e-02L, + -3.9062499999999999999999999999998134255e-02L, + -5.4687500000000000000000000000006361587e-02L, + -7.0312500000000000000000000000006271309e-02L, + -8.5937500000000000000000000000001721300e-02L, + -1.0156250000000000000000000000000020463e-01L, + -1.1718750000000000000000000000000290093e-01L, + -1.3281249999999999999999999999999987963e-01L, + -1.4843749999999999999999999999999942222e-01L, + -1.6406250000000000000000000000000026482e-01L, + -1.7968750000000000000000000000000052963e-01L, + -1.9531249999999999999999999999999867592e-01L, + -2.1093750000000000000000000000000081852e-01L, + -2.2656250000000000000000000000000250371e-01L, + -2.4218749999999999999999999999999718333e-01L, + -2.5781250000000000000000000000001059261e-01L, + -2.7343749999999999999999999999999557036e-01L, + -2.8906250000000000000000000000000520001e-01L, + -3.0468749999999999999999999999999792963e-01L, + -3.2031250000000000000000000000000231112e-01L, + -3.3593749999999999999999999999999383702e-01L, + -3.5156249999999999999999999999999903704e-01L, + -3.6718749999999999999999999999999634073e-01L, + -3.8281249999999999999999999999999956667e-01L, + -3.9843750000000000000000000000000004815e-01L, + -4.1406249999999999999999999999999870000e-01L, + -4.2968750000000000000000000000000216667e-01L, + -4.4531250000000000000000000000000072222e-01L, + -4.6093749999999999999999999999999513703e-01L, + -4.7656250000000000000000000000000539260e-01L, + -4.9218749999999999999999999999999759259e-01L, + -5.0781250000000000000000000000000067408e-01L, + -5.2343750000000000000000000000001386670e-01L, + -5.3906249999999999999999999999996427400e-01L, + -5.5468750000000000000000000000000404445e-01L, + -5.7031249999999999999999999999998536293e-01L, + -5.8593749999999999999999999999999634073e-01L, + -6.0156250000000000000000000000000028889e-01L, + -6.1718749999999999999999999999998468886e-01L, + -6.3281249999999999999999999999999335554e-01L, + -6.4843750000000000000000000000000356297e-01L, + -6.6406250000000000000000000000000019259e-01L, + -6.7968750000000000000000000000000067408e-01L, + -6.9531249999999999999999999999998439997e-01L, + -7.1093750000000000000000000000000009630e-01L, + -7.2656250000000000000000000000000414075e-01L, + -7.4218749999999999999999999999998738516e-01L, + -7.5781250000000000000000000000000019259e-01L, + -7.7343750000000000000000000000000808891e-01L, + -7.8906250000000000000000000000000028889e-01L, + -8.0468750000000000000000000000000096296e-01L, + -8.2031249999999999999999999999999634073e-01L, + -8.3593750000000000000000000000000086667e-01L, + -8.5156250000000000000000000000000115556e-01L, + -8.6718750000000000000000000000000028889e-01L, + -8.8281250000000000000000000000000577779e-01L, + -8.9843750000000000000000000000000587409e-01L, + -9.1406250000000000000000000000000654816e-01L, + -9.2968749999999999999999999999999210369e-01L, + -9.4531250000000000000000000000000115556e-01L, + -9.6093749999999999999999999999999682222e-01L, + -9.7656250000000000000000000000000298519e-01L, + -9.9218749999999999999999999999999711111e-01L, + -1.0078124999999999999999999999999953778e+00L, + -1.0234375000000000000000000000000279260e+00L, + -1.0390625000000000000000000000000000000e+00L, + -1.0546875000000000000000000000000042370e+00L, + -1.0703124999999999999999999999999969185e+00L, + -1.0859374999999999999999999999999965333e+00L, + -1.1015625000000000000000000000000144445e+00L, + -1.1171875000000000000000000000000007704e+00L, + -1.1328125000000000000000000000000052000e+00L, + -1.1484375000000000000000000000000021185e+00L, + -1.1640625000000000000000000000000188741e+00L, + -1.1796874999999999999999999999999915259e+00L, + -1.1953125000000000000000000000000196445e+00L, + -1.2109374999999999999999999999999965333e+00L, + -1.2265624999999999999999999999999940296e+00L, + -1.2421874999999999999999999999999955704e+00L, + -1.2578125000000000000000000000000036593e+00L, + -1.2734375000000000000000000000000005778e+00L, +}; +const long double _TBL_expm1l[] = { + +7.8430972064479776934535597601230757455e-03L, + +2.3714316602357916968850532165767719684e-02L, + +3.9835471336230000576622009875172135295e-02L, + +5.6210497316931971181336703768137839969e-02L, + +7.2843392434877444411300095010815562014e-02L, + +8.9738217538093231018282025418516874073e-02L, + +1.0689909742365748278760239374175648642e-01L, + +1.2433022184475071745173290544494115241e-01L, + +1.4203584653356558967616143134879189360e-01L, + +1.6002029424032514702921521389409692713e-01L, + +1.7828795578866324266314330819585528511e-01L, + +1.9684329114762477118219685277015441058e-01L, + +2.1569083052054745183001825454039531082e-01L, + +2.3483517545109100468401611087600122614e-01L, + +2.5428099994668375200482125309068587301e-01L, + +2.7403305161966092927649653871633746915e-01L, + +2.9409615284637330982611062681002354822e-01L, + +3.1447520194454913428413492197987169290e-01L, + +3.3517517436919679261104091066359163835e-01L, + +3.5620112392734023305848825938576026618e-01L, + +3.7755818401188367036076223788924855083e-01L, + +3.9925156885490683578620594549518425777e-01L, + +4.2128657480069675555953993770759156716e-01L, + +4.4366858159882686275236684344276542291e-01L, + +4.6640305371759914220725806222619001343e-01L, + +4.8949554167816997960557644740137111180e-01L, + +5.1295168340968543562438375411433268970e-01L, + +5.3677720562575679548630956319776281677e-01L, + +5.6097792522261245434042965895343734385e-01L, + +5.8555975069926749109404773234379454282e-01L, + +6.1052868360005765883685767151390117210e-01L, + +6.3589081997988998017269448860547030419e-01L, + +6.6165235189256768193303746403901387346e-01L, + +6.8781956890255283724467962874956344875e-01L, + +7.1439885962053580513691701731111144172e-01L, + +7.4139671326318637019829227657113109938e-01L, + +7.6881972123746738864840365608134114398e-01L, + +7.9667457874989774401796242919906293119e-01L, + +8.2496808644115750689424843988747369733e-01L, + +8.5370715204643438037652998773947217833e-01L, + +8.8289879208191679750745518776052322714e-01L, + +9.1255013355784542053624989476899678486e-01L, + +9.4266841571854127598629758313676072782e-01L, + +9.7326099180983534572639774176307759762e-01L, + +1.0043353308743311241896996041635484486e+00L, + +1.0358990195749384471803078942778539846e+00L, + +1.0679597640471238000138982954032239149e+00L, + +1.1005253917803293237405302109843095228e+00L, + +1.1336038535290198596069082796475886372e+00L, + +1.1672032252538246054702826653026856058e+00L, + +1.2013317100932473053430319197695098859e+00L, + +1.2359976403664263564195928556324051853e+00L, + +1.2712094796074337986378900692396989892e+00L, + +1.3069758246316098519065681271390426992e+00L, + +1.3433054076344374874670823571053750423e+00L, + +1.3802070983234694643656048039370676504e+00L, + +1.4176899060838283316233663173665695732e+00L, + +1.4557629821778080933856445408266366139e+00L, + +1.4944356219791145601003068865880283870e+00L, + +1.5337172672422898656593276319684411587e+00L, + +1.5736175084078752204957296405891018055e+00L, + +1.6141460869438746959611789503655886752e+00L, + +1.6553128977240916980462361132966809382e+00L, + +1.6971279914439187908098398388318058200e+00L, + +1.7396015770741706739548391625061335312e+00L, + +1.7827440243535594070547844776995992896e+00L, + +1.8265658663204204072713762882878497127e+00L, + +1.8710778018843073303053045700866748054e+00L, + +1.9162906984380836781353147778063807290e+00L, + +1.9622155945111488641976761209920359164e+00L, + +2.0088637024644465094546949911966296733e+00L, + +2.0562464112279129437484158431835361592e+00L, + +2.1043752890810342484246997824723919209e+00L, + +2.1532620864771907009732038831535016010e+00L, + +2.2029187389124781729299756967091584890e+00L, + +2.2533573698397068911414662577557965622e+00L, + +2.3045902936282890023428920188543322512e+00L, + +2.3566300185707375845529318204056188573e+00L, + +2.4094892499365111287660263409108200844e+00L, + +2.4631808930739490736114262571853290077e+00L, + +2.5177180565610557168667363422785819682e+00L, + +2.5731140554059017538295927080989585090e+00L, + -7.7820617397564878940627738863895136168e-03L, + -2.3164975049937966141654020345517900132e-02L, + -3.8309398394574704340244721980137502162e-02L, + -5.3219029217871103345945692892173875140e-02L, + -6.7897507640472422098597150880870814431e-02L, + -8.2348417348184187852664478898998721220e-02L, + -9.6575286466913289047103004903893595054e-02L, + -1.1058158842404436382535801893754083366e-01L, + -1.2437074279646178545389116639858446817e-01L, + -1.3794611614542428546897208319214646321e-01L, + -1.5131102283849604551092782942638950286e-01L, + -1.6446872585873492869892658849405193342e-01L, + -1.7742243760133541028616024893906020644e-01L, + -1.9017532065792070445541830028432254804e-01L, + -2.0273048858867556872072433107848955384e-01L, + -2.1509100668250829875574108587424583890e-01L, + -2.2725989270542750384925893490015094814e-01L, + -2.3924011763731637587872084997993792064e-01L, + -2.5103460639728433199192216502316397159e-01L, + -2.6264623855777312240316411149867979990e-01L, + -2.7407784904759174916236707216223561007e-01L, + -2.8533222884405183877364930326430409924e-01L, + -2.9641212565437245046372839566093886675e-01L, + -3.0732024458652068208051596680746383072e-01L, + -3.1805924880965185639883349668276001738e-01L, + -3.2863176020431053139357768964876694788e-01L, + -3.3904036000255107819096872094974754682e-01L, + -3.4928758941813410931539692705947339063e-01L, + -3.5937595026695261691197788694876862518e-01L, + -3.6930790557783929525168292907013160482e-01L, + -3.7908588019390417343445352368401927192e-01L, + -3.8871226136454937222268435896035706784e-01L, + -3.9818939932830552279841068785563696096e-01L, + -4.0751960788663214438675145523141552015e-01L, + -4.1670516496882207157854692957232201487e-01L, + -4.2574831318814785027807613334156070311e-01L, + -4.3465126038938588296698375694570623290e-01L, + -4.4341618018785199889104786302733041801e-01L, + -4.5204521250008005232823143909224611574e-01L, + -4.6054046406627311177860364731167719334e-01L, + -4.6890400896465479423105583940253757841e-01L, + -4.7713788911784632111786130180348641941e-01L, + -4.8524411479139292568322765140558720714e-01L, + -4.9322466508456132479074344820321183415e-01L, + -5.0108148841352808120907176750144850100e-01L, + -5.0881650298707682468469397665961648404e-01L, + -5.1643159727492047118140006480748942245e-01L, + -5.2392863046876277909203259884139061144e-01L, + -5.3130943293621180856911747373956708600e-01L, + -5.3857580666765610494466923948125161529e-01L, + -5.4572952571621270908956480845806990458e-01L, + -5.5277233663085440607996537742519552762e-01L, + -5.5970595888282195827936433920573211501e-01L, + -5.6653208528542542950338319090135722295e-01L, + -5.7325238240733709291016556235278458118e-01L, + -5.7986849097947682625807457952262425338e-01L, + -5.8638202629558933380643321697780798620e-01L, + -5.9279457860661099402232802681583606392e-01L, + -5.9910771350892261602101192647121362362e-01L, + -6.0532297232658289493900937468812013977e-01L, + -6.1144187248763588685320419660027392238e-01L, + -6.1746590789458437705718363441235796711e-01L, + -6.2339654928911959113469156706514092208e-01L, + -6.2923524461119629598145525663487507890e-01L, + -6.3498341935254095737853086332102468069e-01L, + -6.4064247690467926157560858675744165996e-01L, + -6.4621379890156797026959945044832806294e-01L, + -6.5169874555691476103560779451668832748e-01L, + -6.5709865599626840836245660190447925603e-01L, + -6.6241484858396038364664323096343822726e-01L, + -6.6764862124497769549523628863318702845e-01L, + -6.7280125178184555417288842186006604551e-01L, + -6.7787399818659722569870081614203949644e-01L, + -6.8286809894790724165768340684449330930e-01L, + -6.8778477335346294994617200009875163606e-01L, + -6.9262522178764822913249147051072428209e-01L, + -6.9739062602461204459956440664519817754e-01L, + -7.0208214951679339786562882012396622127e-01L, + -7.0670093767897311117765076057926938575e-01L, + -7.1124811816792179736856679611852620191e-01L, + -7.1572480115771228979753508374143873445e-01L, + -7.2013207961076374868941367244540733250e-01L, +}; diff --git a/usr/src/lib/libm/common/Q/_TBL_ipio2l.c b/usr/src/lib/libm/common/Q/_TBL_ipio2l.c new file mode 100644 index 0000000000..27655109b6 --- /dev/null +++ b/usr/src/lib/libm/common/Q/_TBL_ipio2l.c @@ -0,0 +1,504 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Table of constants for 2/pi, used in __rem_pio2l (trigl) function. + * By K.C. Ng, April 25, 1989 + */ + +#include "libm.h" + +const int _TBL_ipio2l_inf[] = { /* by DHBailey MP package */ + 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, + 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, + 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, + 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, + 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, + 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, + 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, + 0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, + 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, + 0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, + 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, + 0x47C419, 0xC367CD, 0xDCE809, 0x2A8359, 0xC4768B, 0x961CA6, + 0xDDAF44, 0xD15719, 0x053EA5, 0xFF0705, 0x3F7E33, 0xE832C2, + 0xDE4F98, 0x327DBB, 0xC33D26, 0xEF6B1E, 0x5EF89F, 0x3A1F35, + 0xCAF27F, 0x1D87F1, 0x21907C, 0x7C246A, 0xFA6ED5, 0x772D30, + 0x433B15, 0xC614B5, 0x9D19C3, 0xC2C4AD, 0x414D2C, 0x5D000C, + 0x467D86, 0x2D71E3, 0x9AC69B, 0x006233, 0x7CD2B4, 0x97A7B4, + 0xD55537, 0xF63ED7, 0x1810A3, 0xFC764D, 0x2A9D64, 0xABD770, + 0xF87C63, 0x57B07A, 0xE71517, 0x5649C0, 0xD9D63B, 0x3884A7, + 0xCB2324, 0x778AD6, 0x23545A, 0xB91F00, 0x1B0AF1, 0xDFCE19, + 0xFF319F, 0x6A1E66, 0x615799, 0x47FBAC, 0xD87F7E, 0xB76522, + 0x89E832, 0x60BFE6, 0xCDC4EF, 0x09366C, 0xD43F5D, 0xD7DE16, + 0xDE3B58, 0x929BDE, 0x2822D2, 0xE88628, 0x4D58E2, 0x32CAC6, + 0x16E308, 0xCB7DE0, 0x50C017, 0xA71DF3, 0x5BE018, 0x34132E, + 0x621283, 0x014883, 0x5B8EF5, 0x7FB0AD, 0xF2E91E, 0x434A48, + 0xD36710, 0xD8DDAA, 0x425FAE, 0xCE616A, 0xA4280A, 0xB499D3, + 0xF2A606, 0x7F775C, 0x83C2A3, 0x883C61, 0x78738A, 0x5A8CAF, + 0xBDD76F, 0x63A62D, 0xCBBFF4, 0xEF818D, 0x67C126, 0x45CA55, + 0x36D9CA, 0xD2A828, 0x8D61C2, 0x77C912, 0x142604, 0x9B4612, + 0xC459C4, 0x44C5C8, 0x91B24D, 0xF31700, 0xAD43D4, 0xE54929, + 0x10D5FD, 0xFCBE00, 0xCC941E, 0xEECE70, 0xF53E13, 0x80F1EC, + 0xC3E7B3, 0x28F8C7, 0x940593, 0x3E71C1, 0xB3092E, 0xF3450B, + 0x9C1288, 0x7B20AB, 0x9FB52E, 0xC29247, 0x2F327B, 0x6D550C, + 0x90A772, 0x1FE76B, 0x96CB31, 0x4A1679, 0xE27941, 0x89DFF4, + 0x9794E8, 0x84E6E2, 0x973199, 0x6BED88, 0x365F5F, 0x0EFDBB, + 0xB49A48, 0x6CA467, 0x427271, 0x325D8D, 0xB8159F, 0x09E5BC, + 0x25318D, 0x3974F7, 0x1C0530, 0x010C0D, 0x68084B, 0x58EE2C, + 0x90AA47, 0x02E774, 0x24D6BD, 0xA67DF7, 0x72486E, 0xEF169F, + 0xA6948E, 0xF691B4, 0x5153D1, 0xF20ACF, 0x339820, 0x7E4BF5, + 0x6863B2, 0x5F3EDD, 0x035D40, 0x7F8985, 0x295255, 0xC06437, + 0x10D86D, 0x324832, 0x754C5B, 0xD4714E, 0x6E5445, 0xC1090B, + 0x69F52A, 0xD56614, 0x9D0727, 0x50045D, 0xDB3BB4, 0xC576EA, + 0x17F987, 0x7D6B49, 0xBA271D, 0x296996, 0xACCCC6, 0x5414AD, + 0x6AE290, 0x89D988, 0x50722C, 0xBEA404, 0x940777, 0x7030F3, + 0x27FC00, 0xA871EA, 0x49C266, 0x3DE064, 0x83DD97, 0x973FA3, + 0xFD9443, 0x8C860D, 0xDE4131, 0x9D3992, 0x8C70DD, 0xE7B717, + 0x3BDF08, 0x2B3715, 0xA0805C, 0x93805A, 0x921110, 0xD8E80F, + 0xAF806C, 0x4BFFDB, 0x0F9038, 0x761859, 0x15A562, 0xBBCB61, + 0xB989C7, 0xBD4010, 0x04F2D2, 0x277549, 0xF6B6EB, 0xBB22DB, + 0xAA140A, 0x2F2689, 0x768364, 0x333B09, 0x1A940E, 0xAA3A51, + 0xC2A31D, 0xAEEDAF, 0x12265C, 0x4DC26D, 0x9C7A2D, 0x9756C0, + 0x833F03, 0xF6F009, 0x8C402B, 0x99316D, 0x07B439, 0x15200C, + 0x5BC3D8, 0xC492F5, 0x4BADC6, 0xA5CA4E, 0xCD37A7, 0x36A9E6, + 0x9492AB, 0x6842DD, 0xDE6319, 0xEF8C76, 0x528B68, 0x37DBFC, + 0xABA1AE, 0x3115DF, 0xA1AE00, 0xDAFB0C, 0x664D64, 0xB705ED, + 0x306529, 0xBF5657, 0x3AFF47, 0xB9F96A, 0xF3BE75, 0xDF9328, + 0x3080AB, 0xF68C66, 0x15CB04, 0x0622FA, 0x1DE4D9, 0xA4B33D, + 0x8F1B57, 0x09CD36, 0xE9424E, 0xA4BE13, 0xB52333, 0x1AAAF0, + 0xA8654F, 0xA5C1D2, 0x0F3F0B, 0xCD785B, 0x76F923, 0x048B7B, + 0x721789, 0x53A6C6, 0xE26E6F, 0x00EBEF, 0x584A9B, 0xB7DAC4, + 0xBA66AA, 0xCFCF76, 0x1D02D1, 0x2DF1B1, 0xC1998C, 0x77ADC3, + 0xDA4886, 0xA05DF7, 0xF480C6, 0x2FF0AC, 0x9AECDD, 0xBC5C3F, + 0x6DDED0, 0x1FC790, 0xB6DB2A, 0x3A25A3, 0x9AAF00, 0x9353AD, + 0x0457B6, 0xB42D29, 0x7E804B, 0xA707DA, 0x0EAA76, 0xA1597B, + 0x2A1216, 0x2DB7DC, 0xFDE5FA, 0xFEDB89, 0xFDBE89, 0x6C76E4, + 0xFCA906, 0x70803E, 0x156E85, 0xFF87FD, 0x073E28, 0x336761, + 0x86182A, 0xEABD4D, 0xAFE7B3, 0x6E6D8F, 0x396795, 0x5BBF31, + 0x48D784, 0x16DF30, 0x432DC7, 0x356125, 0xCE70C9, 0xB8CB30, + 0xFD6CBF, 0xA200A4, 0xE46C05, 0xA0DD5A, 0x476F21, 0xD21262, + 0x845CB9, 0x496170, 0xE0566B, 0x015299, 0x375550, 0xB7D51E, + 0xC4F133, 0x5F6E13, 0xE4305D, 0xA92E85, 0xC3B21D, 0x3632A1, + 0xA4B708, 0xD4B1EA, 0x21F716, 0xE4698F, 0x77FF27, 0x80030C, + 0x2D408D, 0xA0CD4F, 0x99A520, 0xD3A2B3, 0x0A5D2F, 0x42F9B4, + 0xCBDA11, 0xD0BE7D, 0xC1DB9B, 0xBD17AB, 0x81A2CA, 0x5C6A08, + 0x17552E, 0x550027, 0xF0147F, 0x8607E1, 0x640B14, 0x8D4196, + 0xDEBE87, 0x2AFDDA, 0xB6256B, 0x34897B, 0xFEF305, 0x9EBFB9, + 0x4F6A68, 0xA82A4A, 0x5AC44F, 0xBCF82D, 0x985AD7, 0x95C7F4, + 0x8D4D0D, 0xA63A20, 0x5F57A4, 0xB13F14, 0x953880, 0x0120CC, + 0x86DD71, 0xB6DEC9, 0xF560BF, 0x11654D, 0x6B0701, 0xACB08C, + 0xD0C0B2, 0x485551, 0x0EFB1E, 0xC37295, 0x3B06A3, 0x3540C0, + 0x7BDC06, 0xCC45E0, 0xFA294E, 0xC8CAD6, 0x41F3E8, 0xDE647C, + 0xD8649B, 0x31BED9, 0xC397A4, 0xD45877, 0xC5E369, 0x13DAF0, + 0x3C3ABA, 0x461846, 0x5F7555, 0xF5BDD2, 0xC6926E, 0x5D2EAC, + 0xED440E, 0x423E1C, 0x87C461, 0xE9FD29, 0xF3D6E7, 0xCA7C22, + 0x35916F, 0xC5E008, 0x8DD7FF, 0xE26A6E, 0xC6FDB0, 0xC10893, + 0x745D7C, 0xB2AD6B, 0x9D6ECD, 0x7B723E, 0x6A11C6, 0xA9CFF7, + 0xDF7329, 0xBAC9B5, 0x5100B7, 0x0DB2E2, 0x24BA74, 0x607DE5, + 0x8AD874, 0x2C150D, 0x0C1881, 0x94667E, 0x162901, 0x767A9F, + 0xBEFDFD, 0xEF4556, 0x367ED9, 0x13D9EC, 0xB9BA8B, 0xFC97C4, + 0x27A831, 0xC36EF1, 0x36C594, 0x56A8D8, 0xB5A8B4, 0x0ECCCF, + 0x2D8912, 0x34576F, 0x89562C, 0xE3CE99, 0xB920D6, 0xAA5E6B, + 0x9C2A3E, 0xCC5F11, 0x4A0BFD, 0xFBF4E1, 0x6D3B8E, 0x2C86E2, + 0x84D4E9, 0xA9B4FC, 0xD1EEEF, 0xC9352E, 0x61392F, 0x442138, + 0xC8D91B, 0x0AFC81, 0x6A4AFB, 0xD81C2F, 0x84B453, 0x8C994E, + 0xCC2254, 0xDC552A, 0xD6C6C0, 0x96190B, 0xB8701A, 0x649569, + 0x605A26, 0xEE523F, 0x0F117F, 0x11B5F4, 0xF5CBFC, 0x2DBC34, + 0xEEBC34, 0xCC5DE8, 0x605EDD, 0x9B8E67, 0xEF3392, 0xB817C9, + 0x9B5861, 0xBC57E1, 0xC68351, 0x103ED8, 0x4871DD, 0xDD1C2D, + 0xA118AF, 0x462C21, 0xD7F359, 0x987AD9, 0xC0549E, 0xFA864F, + 0xFC0656, 0xAE79E5, 0x362289, 0x22AD38, 0xDC9367, 0xAAE855, + 0x382682, 0x9BE7CA, 0xA40D51, 0xB13399, 0x0ED7A9, 0x480569, + 0xF0B265, 0xA7887F, 0x974C88, 0x36D1F9, 0xB39221, 0x4A827B, + 0x21CF98, 0xDC9F40, 0x5547DC, 0x3A74E1, 0x42EB67, 0xDF9DFE, + 0x5FD45E, 0xA4677B, 0x7AACBA, 0xA2F655, 0x23882B, 0x55BA41, + 0x086E59, 0x862A21, 0x834739, 0xE6E389, 0xD49EE5, 0x40FB49, + 0xE956FF, 0xCA0F1C, 0x8A59C5, 0x2BFA94, 0xC5C1D3, 0xCFC50F, + 0xAE5ADB, 0x86C547, 0x624385, 0x3B8621, 0x94792C, 0x876110, + 0x7B4C2A, 0x1A2C80, 0x12BF43, 0x902688, 0x893C78, 0xE4C4A8, + 0x7BDBE5, 0xC23AC4, 0xEAF426, 0x8A67F7, 0xBF920D, 0x2BA365, + 0xB1933D, 0x0B7CBD, 0xDC51A4, 0x63DD27, 0xDDE169, 0x19949A, + 0x9529A8, 0x28CE68, 0xB4ED09, 0x209F44, 0xCA984E, 0x638270, + 0x237C7E, 0x32B90F, 0x8EF5A7, 0xE75614, 0x08F121, 0x2A9DB5, + 0x4D7E6F, 0x5119A5, 0xABF9B5, 0xD6DF82, 0x61DD96, 0x023616, + 0x9F3AC4, 0xA1A283, 0x6DED72, 0x7A8D39, 0xA9B882, 0x5C326B, + 0x5B2746, 0xED3400, 0x7700D2, 0x55F4FC, 0x4D5901, 0x8071E0, + 0xE13F89, 0xB295F3, 0x64A8F1, 0xAEA74B, 0x38FC4C, 0xEAB2BB, + 0x47270B, 0xABC3A7, 0x34BA60, 0x52DD34, 0xF8563A, 0xEB7E8A, + 0x31BB36, 0x5895B7, 0x47F7A9, 0x94C3AA, 0xD39225, 0x1E7F3E, + 0xD8974E, 0xBBA94F, 0xD8AE01, 0xE661B4, 0x393D8E, 0xA523AA, + 0x33068E, 0x1633B5, 0x3BB188, 0x1D3A9D, 0x4013D0, 0xCC1BE5, + 0xF862E7, 0x3BF28F, 0x39B5BF, 0x0BC235, 0x22747E, 0xA247C0, + 0xD52D1F, 0x19ADD3, 0x9094DF, 0x9311D0, 0xB42B25, 0x496DB2, + 0xE264B2, 0x5EF135, 0x3BC6A4, 0x1A4AD0, 0xAAC92E, 0x64E886, + 0x573091, 0x982CFB, 0x311B1A, 0x08728B, 0xBDCEE1, 0x60E142, + 0xEB641D, 0xD0BBA3, 0xE559D4, 0x597B8C, 0x2A4483, 0xF332BA, + 0xF84867, 0x2C8D1B, 0x2FA9B0, 0x50F3DD, 0xF9F573, 0xDB61B4, + 0xFE233E, 0x6C41A6, 0xEEA318, 0x775A26, 0xBC5E5C, 0xCEA708, + 0x94DC57, 0xE20196, 0xF1E839, 0xBE4851, 0x5D2D2F, 0x4E9555, + 0xD96EC2, 0xE7D755, 0x6304E0, 0xC02E0E, 0xFC40A0, 0xBBF9B3, + 0x7125A7, 0x222DFB, 0xF619D8, 0x838C1C, 0x6619E6, 0xB20D55, + 0xBB5137, 0x79E809, 0xAF9149, 0x0D73DE, 0x0B0DA5, 0xCE7F58, + 0xAC1934, 0x724667, 0x7A1A13, 0x9E26BC, 0x4555E7, 0x585CB5, + 0x711D14, 0x486991, 0x480D60, 0x56ADAB, 0xD62F64, 0x96EE0C, + 0x212FF3, 0x5D6D88, 0xA67684, 0x95651E, 0xAB9E0A, 0x4DDEFE, + 0x571010, 0x836A39, 0xF8EA31, 0x9E381D, 0xEAC8B1, 0xCAC96B, + 0x37F21E, 0xD505E9, 0x984743, 0x9FC56C, 0x0331B7, 0x3B8BF8, + 0x86E56A, 0x8DC343, 0x6230E7, 0x93CFD5, 0x6A8F2D, 0x733005, + 0x1AF021, 0xA09FCB, 0x7415A1, 0xD56B23, 0x6FF725, 0x2F4BC7, + 0xB8A591, 0x7FAC59, 0x5C55DE, 0x212C38, 0xB13296, 0x5CFF50, + 0x366262, 0xFA7B16, 0xF4D9A6, 0x2ACFE7, 0xF07403, 0xD4D604, + 0x6FD916, 0x31B1BF, 0xCBB450, 0x5BD7C8, 0x0CE194, 0x6BD643, + 0x4FD91C, 0xDF4543, 0x5F3453, 0xE2B5AA, 0xC9AEC8, 0x131485, + 0xF9D2BF, 0xBADB9E, 0x76F5B9, 0xAF15CF, 0xCA3182, 0x14B56D, + 0xE9FE4D, 0x50FC35, 0xF5AED5, 0xA2D0C1, 0xC96057, 0x192EB6, + 0xE91D92, 0x07D144, 0xAEA3C6, 0x343566, 0x26D5B4, 0x3161E2, + 0x37F1A2, 0x209EFF, 0x958E23, 0x493798, 0x35F4A6, 0x4BDC02, + 0xC2BE13, 0xBE80A0, 0x0B72A3, 0x115C5F, 0x1E1BD1, 0x0DB4D3, + 0x869E85, 0x96976B, 0x2AC91F, 0x8A26C2, 0x3070F0, 0x041412, + 0xFC9FA5, 0xF72A38, 0x9C6878, 0xE2AA76, 0x50CFE1, 0x559274, + 0x934E38, 0x0A92F7, 0x5533F0, 0xA63DB4, 0x399971, 0xE2B755, + 0xA98A7C, 0x008F19, 0xAC54D2, 0x2EA0B4, 0xF5F3E0, 0x60C849, + 0xFFD269, 0xAE52CE, 0x7A5FDD, 0xE9CE06, 0xFB0AE8, 0xA50CCE, + 0xEA9D3E, 0x3766DD, 0xB834F5, 0x0DA090, +}; + +#if 0 +const int _TBL_ipio2l_66[] = { + 0xA2F983, 0x6E4E44, 0x152A00, 0x062BC4, 0x0DA276, 0xBED4C1, + 0xFDF905, 0x5CD5BA, 0x767CEC, 0x1F80D6, 0xC26053, 0x3A0070, + 0x107C2A, 0xF68EE9, 0x687B7A, 0xB990AA, 0x38DE4B, 0x96CFF3, + 0x92735E, 0x8B34F6, 0x195BFC, 0x27F88E, 0xA93EC5, 0x3958A5, + 0x3E5D13, 0x1C55A8, 0x5B4A8B, 0xA42E04, 0x12D105, 0x35580D, + 0xF62347, 0x450900, 0xB98BCA, 0xF7E8A4, 0xA2E5D5, 0x69BC52, + 0xF0381D, 0x1A0A88, 0xFE8714, 0x7F6735, 0xBB7D4D, 0xC6F642, + 0xB27E80, 0x6191BF, 0xB6B750, 0x52776E, 0xD60FD0, 0x607DCC, + 0x68BFAF, 0xED69FC, 0x6EB305, 0xD2557D, 0x25BDFB, 0x3E4AA1, + 0x84472D, 0x8B0376, 0xF77740, 0xD290DF, 0x15EC8C, 0x45A5C3, + 0x6181EF, 0xC5E7E8, 0xD8909C, 0xF62144, 0x298428, 0x6E5D9D, + 0xF9A9B4, 0xCDBD2F, 0xC083E7, 0x0D3957, 0xECA3B2, 0x96223C, + 0xC1080D, 0x087D47, 0x7D7576, 0xA614B1, 0x42A4B6, 0xAA173C, + 0xE217E5, 0xFDCD34, 0x279D5F, 0x39AACA, 0x1CA8DF, 0x8B6633, + 0x5C49E4, 0xB56803, 0x1E7938, 0x741FDC, 0x4CB19B, 0xCECC3B, + 0x921EB7, 0x7C0FC3, 0x361F23, 0xF9EE22, 0xBA4235, 0xA5FCA3, + 0xBD4680, 0xFCDF65, 0xFC96AD, 0x31C90C, 0x919EEB, 0xFE0FB7, + 0x75B4B0, 0x693961, 0x75BCAA, 0xEB6F39, 0xA343C0, 0xD16FF2, + 0x33DAD0, 0xC1E095, 0x053182, 0x11E4A1, 0x40F943, 0x32D314, + 0xAF1B98, 0xE1B05A, 0xE5F3AD, 0x6E633F, 0x363D14, 0xA3777C, + 0xC8C6EE, 0x001E18, 0x0D180C, 0xAA1369, 0xEDFBA2, 0x998A9D, + 0x16E799, 0x693B75, 0x90EF50, 0x938DD4, 0xFB7ACD, 0x67CEEB, + 0x249DE3, 0x9B9B52, 0xD8CDAC, 0xC31A54, 0x855FBF, 0x848591, + 0x0954B0, 0x946B8C, 0xA4C7B4, 0x9A9E51, 0xF20425, 0xAA2637, + 0xFC6657, 0x7D8625, 0x620B74, 0x8B578D, 0xEC9A05, 0xDEF24F, + 0x7F19B0, 0xFC2544, 0x1DA0F1, 0x23790C, 0xC4294D, 0x6D3C32, + 0x66FE56, 0xD45562, 0x66264F, 0xA24162, 0x13E930, 0xB0E7C0, + 0xFA0E97, 0xBFC62C, 0x0E663F, 0x90F33B, 0x55E73C, 0xD791F7, + 0xD3F00D, 0xAB01C7, 0x40CF8F, 0xA593BA, 0xE627D5, 0x4A8308, + 0x32DC06, 0x80C876, 0x1C3DB5, 0xB5489F, 0x632CDF, 0xB02517, + 0xD17EFA, 0x92570F, 0xFAED44, 0x8F8536, 0x27069B, 0xC014DC, + 0x997D48, 0x961D61, 0x7A960B, 0x31B622, 0xD3C425, 0xA69520, + 0x98D29E, 0xF1C973, 0x5483D7, 0x99611E, 0xEAFF5F, 0x7DEFF1, + 0x98475C, 0x91C787, 0x537E17, 0x068C65, 0xF05E52, 0x942F04, + 0x37CF92, 0xEF4223, 0xC4C52F, 0x521DAA, 0xBAAF97, 0x972236, + 0xA2B3D3, 0x62C921, 0x8D3A8B, 0x2B3302, 0x6061B9, 0x0CBE94, + 0x75F451, 0xBD06DE, 0x86042D, 0xFB61ED, 0x4C8869, 0x590232, + 0x479963, 0x23518D, 0xAF5D28, 0x60C9DE, 0x473DB0, 0x9DE009, + 0xD8FC4C, 0xE96991, 0x9CA455, 0x800BC8, 0x977CE0, 0xDCBFA6, + 0x19D249, 0xA0F76D, 0x5F9B2F, 0x452BB3, 0x77E091, 0xB6383A, + 0x7BE9C2, 0x4BF7C1, 0x8A5EBF, 0xEB0D55, 0x9AF4DC, 0x275CA0, + 0xED09D0, 0xE50A7F, 0xBEF42C, 0x4803AF, 0x56139F, 0xD58848, + 0x797D96, 0xB8352E, 0x49D90D, 0x7607E0, 0xC99256, 0x75F530, + 0xB72237, 0x1AF080, 0xC2E813, 0x06CFA9, 0xB9DF8E, 0x919C38, + 0x89D97E, 0x0464D5, 0xB12EEF, 0xD14165, 0x365A72, 0x550D35, + 0x3772D8, 0xF41B58, 0x0378A7, 0x2D5D7D, 0xD6E433, 0xDD2018, + 0x139FD7, 0x1B5621, 0x94E046, 0x97A323, 0x693176, 0x28DF59, + 0xD24273, 0x0E4E26, 0xA9A8F6, 0xF15B41, 0x450EE3, 0x57EA61, + 0x7DADA6, 0xF21086, 0x394BEE, 0x8F4813, 0x3FDEE9, 0xF3A53D, + 0xAB2F40, 0x8B1E2B, 0xA07FD4, 0x992CC4, 0x63532D, 0x9F35A2, + 0x6FA290, 0x0094DE, 0xD2A24D, 0x755B81, 0x79F9E1, 0xFE1D35, + 0xFEE8CC, 0x9224C5, 0x54E2CE, 0x41F31C, 0xF45138, 0xED6D10, + 0x6B439D, 0xD2BE46, 0xC327D4, 0x68BFB0, 0x46D5A5, 0x79B285, + 0x776D7C, 0xE18647, 0x00E32F, 0xEBB7F2, 0x5DE307, 0x5A8EA0, + 0x06CEFE, 0x20923C, 0x354CE1, 0xAD09C5, 0x56996D, 0xCFB124, + 0xEF7BC1, 0x76BF72, 0xF20753, 0x5BBAFA, 0xB8A2B2, 0x5914F2, + 0x5D834F, 0xE64A08, 0x14C3AB, 0x07796B, 0xF2212D, 0xC74049, + 0xB61C6A, 0x282CFC, 0x25070C, 0x315BF1, 0x6FEAD3, 0x2CD2E5, + 0xD10F9C, 0x1972BB, 0x908073, 0x0F368C, 0x69BE97, 0xA242B0, + 0x722DFE, 0xAFE6A2, 0x143D8B, 0x5C5699, 0x48232B, 0xFF49AC, + 0xB5FA62, 0x6AD778, 0x7A844D, 0x258AA0, 0x8EDE3D, 0x9A9496, + 0x49924E, 0xA33E97, 0x4F43FA, 0xC40741, 0x2F764A, 0x8EB2B1, + 0x8E67D3, 0x9FF324, 0x51B11B, 0x5D6E09, 0xE9AD3E, 0xFFA902, + 0xF48653, 0x0845D3, 0xDED33E, 0x32D30E, 0x6247CA, 0x7C586D, + 0x2EAF9E, 0x323A35, 0xAD11FB, 0x0F420C, 0x0E0685, 0x401B60, + 0xBB3D43, 0xF4D489, 0xBCDC4C, 0x40FFBA, 0x18AB08, 0x7AC72D, + 0x5E76DB, 0xE8344E, 0x3975A2, 0xF9611B, 0x1121F3, 0x3A429C, + 0x9B18EC, 0xF298B1, 0x8AEC78, 0x1C248B, 0x69108F, 0xDB2D37, + 0xA1A613, 0x910359, 0x521451, 0xD4441F, 0x0BB3B6, 0x50D9DB, + 0xBD589F, 0x62A62E, 0xA9B903, 0x935F63, 0x058BEC, 0x78BCB5, + 0x2CB460, 0x3A9037, 0x0291C4, 0x1FABC1, 0xBE7D05, 0xF948E7, + 0x6BA5CD, 0xF62A0A, 0x9AEA19, 0x2257AB, 0x2E0D7D, 0x9EB93F, + 0x5E3F77, 0xD4A13F, 0x08E3DB, 0xDFD689, 0x2B9B4E, 0xB58427, + 0x25424B, 0x1197FD, 0xCF298A, 0x314008, 0xD5687F, 0x0F0EAC, + 0x13C485, 0xF684B2, 0xED7EC7, 0x6E636D, 0x28C933, 0xE19058, + 0x688B6A, 0xC88905, 0xFB2F31, 0x61304C, 0xC19765, 0x60D81A, + 0x57F276, 0xC6EFC4, 0x048954, 0x303470, 0xDA6F6F, 0x93901A, + 0x911439, 0x363D12, 0x59E72B, 0x6F9F1E, 0x57C584, 0xDF0D23, + 0xBB743F, 0xADE99C, 0x546097, 0xFCC820, 0xCBB968, 0xDA9B5F, + 0x0DC271, 0x563337, 0x9ED662, 0xE7C44F, 0x3129F8, 0xF5EAF9, + 0xDAF7F2, 0xCD09FF, 0xA92535, 0x441C29, 0x7DF436, 0xE2B00A, + 0x36746F, 0xF1DC61, 0x9D3C9C, 0x63AB71, 0xB8F3BB, 0x1C80F6, + 0x62FF65, 0x5FFE5F, 0x3B2814, 0xBADE27, 0x1B384B, 0x268AA9, + 0xBD91EF, 0xCA436B, 0xABE107, 0x88DCA6, 0xC3AFC0, 0x85D155, + 0x464A48, 0xBFDAEB, 0xC6F389, 0x907C11, 0x0D3E41, 0xCD2197, + 0x549008, 0x817E4E, 0x8C7154, 0x1DC37F, 0x5E897E, 0xA9A2FE, + 0xEC6060, 0xCC0728, 0x430D3B, 0x62471C, 0xD3A4D3, 0x2BA57B, + 0xE5D15A, 0xD632F3, 0xF2B76F, 0xEC8498, 0xAE41C2, 0xAAF413, + 0xEAF5C0, 0xDD1B07, 0xB9A2A0, 0x59F230, 0xA3F61B, 0x8F8643, + 0x05DE6B, 0x1B5B8E, 0x63ECC5, 0xBFF01D, 0x8F1440, 0x3F8ADF, + 0x2E6539, 0xF3DB7A, 0x293FE5, 0x7EE714, 0x88E6D8, 0x2B2A6A, + 0xDF6E34, 0x8D4604, 0x4F6594, 0x639063, 0x6B51CC, 0x0D05CD, + 0x009607, 0xE7BF70, 0xC9A0EA, 0x0D80DD, 0xA1A065, 0x0DCB8F, + 0xA48430, 0x715934, 0x6FC8E4, 0x6FFC52, 0xEF8B05, 0xDE506A, + 0xE62BBC, 0x31480F, 0xEA64EA, 0x51E6FB, 0x9AE773, 0x21C54D, + 0xBFA080, 0x273D1E, 0x9FFD4E, 0x0C2CA8, 0x0690A5, 0xF8773B, + 0x4B2680, 0x6E3F56, 0xC8B89F, 0x0B7BD0, 0x71C8BF, 0x5AABD3, + 0x2BA93E, 0x9D2EE1, 0xCDF2FA, 0xEE57BE, 0x84A116, 0xDA756D, + 0x8FD6C0, 0x927153, 0xFF5EF3, 0x9F8331, 0x713411, 0xF945F3, + 0x0382B2, 0x8BAE30, 0xBC45A4, 0x630101, 0x5C9C3A, 0x643CFD, + 0x48115C, 0x17F03E, 0xB5F55E, 0x288DAF, 0x725660, 0xFB58E0, + 0xFC189E, 0x1ECA69, 0xFB19A6, 0xFA7A92, 0x7CC48E, 0x869372, + 0x58089A, 0x16DB5C, 0xADC0CD, 0x09D3D4, 0xD1108E, 0xDC64ED, + 0x3A999C, 0xAA8716, 0x5A3D8E, 0x7037FB, 0x1976AD, 0xE477D7, + 0x23782B, 0xC51F39, 0x4A5E9A, 0xDAD9DA, 0xE5B559, 0x08EF06, + 0x76E24F, 0x7361AD, 0x5F42A3, 0x9B70E5, 0xCE96C4, 0x552E99, + 0x6D7A6F, 0x804474, 0x4FA45B, 0x1D115B, 0x6D109E, 0x0A1A63, + 0x1084A6, 0xE18E5D, 0x2D8589, 0x203345, 0x4851AF, 0xA71EDC, + 0x03B6B1, 0x267970, 0xDEC908, 0x795BED, 0x7099B9, 0x209321, + 0x7FC2E7, 0x0F3E5E, 0xC7A4F4, 0x088129, 0x59AE63, 0x4E3251, + 0x344268, 0x79285D, 0x2B9494, 0xF1E2A2, 0xF7DA20, 0xDF6756, + 0xCA3BA3, 0x422489, 0xA2239C, 0x38724D, 0x2AC767, 0x601E9D, + 0xB47C6C, 0xA22481, 0xBBB655, 0x1EC0C4, 0xD84A97, 0xD449EE, + 0x162C9D, 0x782F29, 0xCEB4FA, 0xE317BC, 0x2FFDBD, 0xB342D2, + 0xB2CB19, 0x323AB9, 0x1AFF93, 0x13A8DF, 0x86B5A5, 0x5741D6, + 0xC54342, 0x3CAC29, 0xF7517C, 0x129A7A, 0xB2B8B4, 0x9B709F, + 0x3923C5, 0xEAFA6E, 0xDB9077, 0x29EEA0, 0x702D8C, 0x4DC14F, + 0xE46933, 0xA764E4, 0x754266, 0xFA4F98, 0x643DA5, 0xCA775C, + 0x7F1632, 0xE671A3, 0x4BF4C6, 0xA82378, 0xEFD317, 0xE62D38, + 0xD461C9, 0x8EEC80, 0xC89882, 0x4CC73C, 0x830F3F, 0xE4B200, + 0x582615, 0x6CD558, 0xA66727, 0xEF7975, 0xFEA5CE, 0x147A40, + 0x4796E4, 0xC07761, 0xF5D5B3, 0x6B65FB, 0xE4F14D, 0xA837CA, + 0x9A152A, 0x554E94, 0x83EC5F, 0xA62174, 0x85E2ED, 0xCCE71C, + 0x3540FF, 0x088A84, 0xBA2816, 0x293610, 0x4C3EE7, 0x8E55A9, + 0x49E5E5, 0x782178, 0x45D2AA, 0x9BB449, 0x00D282, 0xF61E67, + 0xE2F7DE, 0xCC6AA1, 0xCD1979, 0x52FEDB, 0x9A8776, 0x70A018, + 0x500271, 0x1273BA, 0xDE648E, 0x7AC7F7, 0x767725, 0xD0A457, + 0xF17250, 0xBC578C, 0x2DFD3A, 0x97F988, 0xA576C8, 0x8129BB, + 0x22D9C3, 0x0436ED, 0x650791, 0xA314EC, 0x42A0B3, 0x37A521, + 0x4BFB2B, 0x8C1B7F, 0x115E17, 0xF7C27F, 0xC1D5EB, 0x060487, + 0x8A28D6, 0x41330F, 0xBFAE67, 0x7774E8, 0x4CCC3C, 0x6B2F80, + 0x628BF2, 0x1E41A6, 0x8D0B22, 0xBC85BA, 0xCCF461, 0xBEC69C, + 0xDF8A10, 0x3C5E71, 0x2F8D5F, 0x63D3DA, 0x5934D1, 0x2CA35D, + 0xC687A2, 0x24E9B4, 0x1843D3, 0x5C9B97, 0x9B580C, 0x780B2C, + 0x59943D, 0x0744D0, 0x8DA6E3, 0x07AAF6, 0x2214D0, 0x72E8D7, + 0x54151B, 0x514DE9, 0x8DCC3B, 0x0CEB00, 0x2C4DE3, 0x5012AE, + 0xD7B72E, 0xB7DE9A, 0x641B2F, 0xF9CF17, 0x8BD282, 0x9F31A3, + 0xDED846, 0x467E05, 0x26CCEA, 0xF8E404, 0x65572E, 0x82C594, + 0xE572A9, 0x895653, 0xA1AA94, 0x8DD876, 0x5E9A61, 0x69EB1C, + 0x0385A9, 0x5BC844, 0x95B2DF, 0x6678F6, 0xFA7033, 0xE4F434, + 0x5584A9, 0x32C099, 0x9AD846, 0xB3FFD1, 0xA81C56, 0x4E54EF, + 0x54D173, 0xF191B4, 0x49B2A2, 0xB309D9, 0x546D8D, 0xC0A51E, + 0xCAFFC0, 0x785400, 0x05F69D, 0x894056, 0xC33098, 0xDFF6C2, + 0x908D97, 0x05CC96, 0x46484B, 0xBD7B9D, 0xB152F5, 0x5A7461, + 0x59CA20, 0x8F8EF5, 0xC9FF05, 0xF6F398, 0x856C97, 0x81E07C, + 0xAE5EDA, 0x51BDC9, 0xF26437, 0xBBC8CE, 0x091B52, 0x68B6A5, + 0x90750E, 0x925EF9, 0x3D9CB3, 0x46EA96, 0x97D648, 0x78BCC7, + 0xF4B488, 0x05275E, 0x6619DF, 0x56D4A0, 0x8C5C41, 0xDB345A, + 0x0B79DA, 0x496369, 0x96109B, 0x667664, 0xC40CF9, 0x91D7CA, + 0x119F1A, 0xA99272, 0xCBB529, 0xBB033E, 0x8F91C0, 0x570045, + 0xB845C2, 0x2B8E52, 0x687AFB, 0x0D0AA3, 0x200863, 0x043B83, + 0xF129DE, 0x49C2D6, 0x9641D2, 0xC4747C, 0x220804, 0x503F05, + 0x7E274F, 0xCA83D9, 0x9D6495, 0x0E5039, +}; +const int _TBL_ipio2l_53[] = { + 0xA2F983, 0x6E4E44, 0x16F3C4, 0xEA69B5, 0xD3E131, 0x60E1D2, + 0xD7982A, 0xC031F5, 0xD67BCC, 0xFD1375, 0x60919B, 0x3FA0BB, + 0x612ABB, 0x714F9B, 0x03DA8A, 0xC05948, 0xD023F4, 0x5AFA37, + 0x51631D, 0xCD7A90, 0xC0474A, 0xF6A6F3, 0x1A52E1, 0x5C3927, + 0x3ADA45, 0x4E2DB5, 0x64E8C4, 0x274A5B, 0xB74ADC, 0x1E6591, + 0x2822BE, 0x4771F5, 0x12A63F, 0x83BD35, 0x2488CA, 0x1FE1BE, + 0x42C21A, 0x682569, 0x2AFB91, 0x68ADE1, 0x4A42E5, 0x9BE357, + 0xB79675, 0xCE998A, 0x83AF8B, 0xE645E6, 0xDF0789, 0x9E9747, + 0xAA15FF, 0x358C3F, 0xAF3141, 0x72A3F7, 0x2BF1D4, 0xF3AD96, + 0x7D759F, 0x257FCE, 0x29FB69, 0xB1B42C, 0xC32DE1, 0x8C0BBD, + 0x31EC2F, 0x942026, 0x85DCE7, 0x653FF3, 0x136FA7, 0x0D7A5F, + 0x93FC61, 0x035287, 0xC77FCA, 0x73530A, 0xC6BC15, 0x0E4B0F, + 0x568FCE, 0x2D3456, 0x4D7FE1, 0xA12CD1, 0xB2CEA2, 0x531C62, + 0x70B4D2, 0x1BCE9A, 0x87704D, 0x6B83D7, 0xAA8121, 0x2530EA, + 0x2074BF, 0x28A071, 0x9D69C3, 0x406DD8, 0xF58783, 0x115D89, + 0x5E85F3, 0xAACDCC, 0x8C0B57, 0xD7DFFE, 0x550D96, 0xC43EB4, + 0x89ABA7, 0x94F595, 0x56F260, 0x06A4CD, 0x7FD2E2, 0x6FDFA8, + 0x3E9C98, 0xBFD682, 0xAD3A12, 0x23A8A6, 0x173A89, 0x5DE9BD, + 0x95A978, 0x28E484, 0x5964F3, 0x496AF0, 0x4B1DA9, 0x989061, + 0xBD2BF2, 0xE01A90, 0x0905B7, 0xAC39AC, 0x52D5B7, 0x109F25, + 0x3AE1DC, 0xF90A7C, 0x33F4E5, 0xF5DFDF, 0x1522D0, 0x562CE6, + 0x392CFF, 0xEB9032, 0x10A08E, 0x0B1D7F, 0x42B80A, 0x366DD2, + 0xC24F89, 0x02222E, 0x21494C, 0x985287, 0x87FD07, 0x2EE361, + 0xAD8D68, 0xE72273, 0x9E8D59, 0xD09999, 0x10F4A1, 0x1079A3, + 0xE9BEAF, 0x9C0887, 0x09C622, 0xEBCF06, 0x974532, 0x086A8F, + 0x6CEA05, 0x388C00, 0x74969E, 0xC85B16, 0x385A38, 0x9A2F35, + 0x670531, 0xABA6D0, 0xEFD3C1, 0x27AD92, 0xF4203E, 0x3D619F, + 0x4D05F4, 0x9AE7CC, 0x03B592, 0x41FF55, 0xCAFCA5, 0x1A0987, + 0x88AB79, 0x3627D4, 0x25B12A, 0x52594A, 0xA2BEB0, 0x25C3F2, + 0x4489DA, 0x7959A7, 0xEAEC89, 0xB34714, 0x960196, 0x1FC33A, + 0x7F0275, 0x32EF92, 0x0111CE, 0x8E4685, 0x6F5B34, 0xF6123A, + 0x5543B2, 0xE9A02A, 0x74E03F, 0x54D5A8, 0x086A2C, 0x4A9CD3, + 0x921191, 0x229764, 0x0A1A84, 0x9B45AE, 0xC653A5, 0xB15F33, + 0x100FD1, 0x7DD740, 0xB20CD3, 0x0A0786, 0xF506C3, 0x25EBF4, + 0x3AB39E, 0xE3BB24, 0x27646F, 0xEECE57, 0x706BFE, 0xC7A869, + 0x57ED51, 0x118C82, 0x2B0FF5, 0xC8E545, 0xC43D80, 0x2A3183, + 0x4C1BB9, 0xBC108A, 0x099779, 0xF9ECC8, 0x2A1063, 0x5D2F6A, + 0x8F2675, 0x12FF6D, 0x32EED9, 0xE4A245, 0x7392CF, 0x5C240B, + 0xC476FF, 0x97AFC7, 0xB76131, 0x665E05, 0x67BD57, 0x19E998, + 0x3A5863, 0x23B8AA, 0x5B5608, 0x8A66C6, 0x5F2AD3, 0x78BAFA, + 0x3516CE, 0xCBEA16, 0x6E40D4, 0xB463D4, 0xA6C12F, 0xABD3D7, + 0x32650A, 0x579D10, 0x3CB9E2, 0x1A02A7, 0xDF2FFA, 0x28C991, + 0xB2264C, 0x027870, 0x47BDD4, 0xF243B1, 0x39AE2C, 0x282EA4, + 0xAF1D98, 0x2AFD16, 0xABE7AF, 0x17CB67, 0x8FF93E, 0x793167, + 0x435F6B, 0x48058B, 0x417DA0, 0xE01217, 0x085A69, 0xB50E36, + 0x79A4CD, 0xD74907, 0x26C4B5, 0xB90054, 0x06C3AD, 0x5AB38F, + 0x585E91, 0xD04E4F, 0x2938CE, 0xD4EAA7, 0xA06DE5, 0x40BFE5, + 0xDE6849, 0xEF65F0, 0xF1D4BB, 0x94C21E, 0x66E978, 0x1B9B94, + 0x961043, 0x5961B8, 0xBAAA74, 0xD662EE, 0x9DABF6, 0x0AFE28, + 0x9587A4, 0xA632BC, 0x09149F, 0xDEA996, 0x2CAFD7, 0xBDE29B, + 0x7159E6, 0x1F7C49, 0xF2E2ED, 0xBFA992, 0x7C77EF, 0xC245D0, + 0xB2D129, 0x993E75, 0xAB4C0C, 0x5C84B6, 0x17F542, 0x45314E, + 0x1DEF1B, 0xE3BDCC, 0xB3AE86, 0x24522F, 0x918FC6, 0x2138D5, + 0x883646, 0x6858B6, 0x032762, 0x5170F8, 0x4974EA, 0x76BF77, + 0xECDA8A, 0x9EADDD, 0x2404EF, 0xC52A5D, 0xF2E858, 0xC42D60, + 0xD18C08, 0xDE59B2, 0x4CC3A6, 0x94D888, 0x4C4AF0, 0xCF1F8C, + 0xBF2F6F, 0x7B4535, 0x98B0DB, 0x2BE0CF, 0x4616A7, 0xA8D9FB, + 0x88CA7A, 0x5087E1, 0x18DD8A, 0x1A9F4F, 0x1DCECE, 0xF8609E, + 0xE2F0C8, 0x9AD7D4, 0xE3CDFE, 0xC6FDD5, 0x8FF3CD, 0x7D45AA, + 0xD34957, 0x7C1963, 0x6CE098, 0xB70215, 0x326BBF, 0x47B3A6, + 0xF9235D, 0x6F66F5, 0xC6E40C, 0xE7F50B, 0xFF2FDD, 0x5A1251, + 0xE95EF1, 0xDE8E67, 0xECEE9B, 0xC9F98E, 0x722224, 0x6DF750, + 0x81D08F, 0x2BFCF0, 0xDDC10D, 0x775314, 0xDB1D87, 0x41626B, + 0x9EDF31, 0x7738D9, 0x8D9EB4, 0x4F1C2A, 0xF3E795, 0xB69699, + 0xD9A56D, 0x31BB1B, 0x542975, 0xAB917B, 0x63927C, 0x9BB764, + 0x84A598, 0x0A0C51, 0x5E48C4, 0x7780E3, 0x87E156, 0x155972, + 0xE406F8, 0x48AB9E, 0x3CCDDA, 0x010F87, 0x683B70, 0x400CAD, + 0x5DE5C5, 0x7262FA, 0xFA248D, 0x013AF2, 0xE2E8B5, 0x995F7D, + 0x7F8C4B, 0x0E8B59, 0x1006F1, 0x40B6E9, 0x760654, 0xCBCC8C, + 0x086F40, 0xDC7F6F, 0xFCD0D4, 0xA47ADE, 0x5204FA, 0xF38A9D, + 0xE76C7C, 0x575207, 0x499BF1, 0x0DB01C, 0x09098E, 0x957A71, + 0xD53E0E, 0x61DF1D, 0xE6EF34, 0x5821EC, 0x96BCC0, 0xDC96CE, + 0xA9C0AE, 0x130B2C, 0xCCC589, 0x829BB9, 0x2A75BA, 0x97611C, + 0x0CEAB8, 0x165D9D, 0x35AD41, 0x82A805, 0x975628, 0x5601A6, + 0x074F08, 0x80A27D, 0xEFA64E, 0xD7BB4B, 0x5E6397, 0xC92FFC, + 0x4F3F7A, 0xBEA764, 0x0C9B7D, 0xC5DC74, 0xEAD216, 0x6DBBC0, + 0x913E3E, 0xABF50B, 0x95B24A, 0x3FC9C5, 0xE7BA15, 0x8C7F70, + 0xF81358, 0x774606, 0xCE8C0D, 0xB6B268, 0xB85BA6, 0xAC9B2E, + 0x1AAB05, 0x0C6C82, 0x6EC2AE, 0x606874, 0x8F60BF, 0x1FBC7B, + 0x58C97A, 0x448794, 0xBA48A0, 0x72E882, 0x6D3568, 0xE131FD, + 0x4745D0, 0x0BFA1E, 0x07B01D, 0x474D43, 0x59387E, 0x5B0AD5, + 0xC37A8C, 0x0474E8, 0x13D99D, 0x68A13C, 0xB69118, 0x89228C, + 0x6F7D83, 0x86D665, 0x5C7744, 0xDD183E, 0x1C2E17, 0x712F5E, + 0x4AACCB, 0xB69B68, 0xA1201F, 0x743C2B, 0xF6AD70, 0x92E024, + 0xF34FD8, 0x33712E, 0xFE1D73, 0x4471F0, 0x7D0526, 0x58AF47, + 0x7B11FE, 0x1FCE4F, 0x1356C9, 0x9CE3CA, 0xA843C0, 0x8EEA3C, + 0xABEEE4, 0xA5D495, 0xA407A4, 0x31BB4B, 0x0AA1E3, 0x518E7C, + 0xAA4A66, 0xD82CD8, 0x6EF8D2, 0x6F32E6, 0x1DC26B, 0x17AE59, + 0x4B683B, 0x8D48F7, 0xF4FBD8, 0xD4FE0A, 0xE961DE, 0x87BD37, + 0xE6CCD6, 0xCBD76D, 0x3E99DE, 0xB72E21, 0x54EB90, 0x6AB45D, + 0x600AFB, 0xA17B2F, 0xDA0421, 0xE6CA95, 0x35AAA2, 0x7D8FB1, + 0x3207BB, 0xBF82EE, 0x71F55F, 0xC661CB, 0xBD72A1, 0xBF5A64, + 0x6E39E8, 0x6C6DE2, 0x2BD178, 0xAF62A5, 0xA7D86E, 0xE7D0FE, + 0x84DB03, 0x67FDA2, 0x2D6809, 0x0F8B8F, 0x1B50E3, 0x234EF5, + 0x7325ED, 0x8F8F4C, 0xC1E426, 0x3066AD, 0x0759A4, 0xE03390, + 0x70CC9A, 0x524F77, 0xCDD489, 0x97DD24, 0xA81858, 0xF24513, + 0xA9C18E, 0x2A2F82, 0xC2C014, 0xB8E7F0, 0x934036, 0xD36E51, + 0xD9A089, 0xDBC587, 0xB30418, 0x969192, 0x0A5213, 0xE21841, + 0x2881EC, 0x9A293F, 0x0DF705, 0x85B497, 0xE430B9, 0xE90ECF, + 0xC15FDC, 0x9E8A7E, 0xC5472D, 0xB54FBD, 0x456AF2, 0xCA80B6, + 0xAE25FE, 0xA03B46, 0x6C6CFD, 0x78382A, 0x0E7877, 0x7F2D31, + 0x03C827, 0x61CF52, 0x339A2F, 0x2286A9, 0xE41DF0, 0x640F5C, + 0xBEF364, 0x010506, 0x6D2C21, 0x841EFF, 0x7F3B5D, 0xD98DC8, + 0x0F9421, 0xA25B0C, 0x4C2C44, 0x922392, 0xB98A8A, 0x6179B9, + 0xF7B419, 0x289AAF, 0xE92F47, 0x5E47A2, 0x82927F, 0xC7290E, + 0x6C925C, 0xBA5A3C, 0x8FB7F6, 0x9C4BEE, 0x02C529, 0x0CFCD7, + 0x5EBD8C, 0x7196E0, 0x4B917E, 0x6B9780, 0x6A1731, 0xA617FF, + 0x27A20D, 0x5A56A3, 0x43C4DB, 0xC62EA4, 0x637A84, 0x1C46F9, + 0x33C780, 0x61A278, 0x4915C9, 0xD6C776, 0x6A7C66, 0xD8DD0C, + 0xF87EB1, 0x124C43, 0x5B87E7, 0x097456, 0x3C2FA7, 0x307C4A, + 0x54267A, 0x30E34E, 0xC0CF98, 0xD75B19, 0xFADEDB, 0x12CBE8, + 0x29F24C, 0x579C7E, 0xBF3682, 0xDCB460, 0xAE08B3, 0xA524BC, + 0xC181C2, 0x5DAB90, 0x466602, 0x55345B, 0xA13941, 0x47D820, + 0x278066, 0x81B089, 0x165EFB, 0x4D27FD, 0x2BF9F4, 0x2E2FFB, + 0x6106B5, 0xE76806, 0x445A84, 0x0BDA0D, 0x49D7A4, 0x72650D, + 0xCDC55B, 0x3E16BC, 0x132F6F, 0x29E8FD, 0xE58428, 0x621E41, + 0x7D2AC4, 0xAB5697, 0xAC61EB, 0xE5DAF0, 0x654ED6, 0x8E77E3, + 0x0B2FBC, 0x2E63A3, 0xC8296A, 0x8B631F, 0x4ECCA6, 0x91859C, + 0x9E3E45, 0x0E3CC7, 0xC12454, 0xCCBCB6, 0x17979E, 0xD0D374, + 0xA489A2, 0xC6258F, 0xE8EF9E, 0x12EE26, 0xC614C2, 0x62E23E, + 0xCA8C5C, 0x409AC9, 0x511D05, 0xA88CE0, 0x195500, 0xF7144F, + 0x913BB7, 0x17D064, 0xF6C9CE, 0xAC5D11, 0xD0C313, 0xBCCCB6, + 0xAAD4FC, 0xE47B2C, 0xFE4362, 0xF2E712, 0x2D5EFF, 0x833822, + 0x58A1D7, 0x68377C, 0xE49B25, 0x22B179, 0x048796, 0x069400, + 0xE670D3, 0xD2CB85, 0x55FBE6, 0x67F281, 0xFE2DE0, 0x8CFAF2, + 0x9865BC, 0x210CD3, 0x86DD70, 0x43D00F, 0x55E279, 0x679252, + 0x8D4F58, 0xE17AC5, 0x6A6127, 0x1B0876, 0x5D8ED0, 0x701330, + 0xD5BD25, 0xC9A126, 0x57C571, 0xDC5C3F, 0xB6D34E, 0xB72383, + 0x001A9E, 0x7D36C0, 0x8151F6, 0x65D7C1, 0xE1F513, 0xCD372A, + 0xE69B0C, 0xD02685, 0x23C3EB, 0x3544CB, 0xF0BE31, 0x83F399, + 0xCB93F8, 0xFFC693, 0x908EC6, 0x8E5DE1, 0x315B7E, 0x67CE7B, + 0x40AAF7, 0x7FD285, 0x069B36, 0x03C00A, 0x13C7D5, 0x0DA14C, + 0x1EAAD4, 0x2B777F, 0x8E05C1, 0x5AD1AE, 0x60C398, 0xA4EA59, + 0x10BEED, 0x88F2FA, 0x69B941, 0xA54E70, 0xA817C3, 0xB96246, + 0xE8EEDC, 0x56D570, 0xBBEBB5, 0xD8F235, 0x201AB9, 0x9CC747, + 0x5BC2FB, 0xC877F3, 0x428CF6, 0x4EEF84, 0xBF85FD, 0xEE6D34, + 0x84C2DE, 0xC42F4C, 0x1A513B, 0x9AC41F, 0x87FFFA, 0x1CA431, + 0x714252, 0xC73FB9, 0x662D89, 0x3D83BA, 0xBDF046, 0x2E4F62, + 0x76B7C0, 0x81336C, 0xBE80A9, 0x4C9D72, 0x739A15, 0x47972C, + 0xA36A1B, 0xD31731, 0x54BA46, 0x2E8C72, 0xFEA5A5, 0x9A7E5F, + 0xC359ED, 0x8F0FFB, 0x1270DA, 0x5E9B08, 0xB0BFCB, 0x36974C, + 0x6CD8F9, 0xD02E1F, 0x1C3F2F, 0xFCF8F0, 0x4C2C6D, 0x0B2169, + 0x48B9CE, 0x42737D, 0xA8E974, 0x64062D, 0xA86C59, 0xEEC419, + 0x047C83, 0x996A23, 0xF2A4C8, 0x4BE1B8, 0x348286, 0xE84240, + 0x8337CB, 0xE55A2F, 0xC17750, 0xA4DA06, 0x64347F, 0x59A5A1, + 0xDFF53D, 0x62A571, 0xEECF3A, 0x886700, 0xC06DAF, 0x4E161F, + 0x12670E, 0xBDFE1A, 0xA72B38, 0x5BA22C, 0xFED227, 0x3FC814, + 0x150E5A, 0xE99B3A, 0x8EE9FC, 0xBC1845, 0x32373A, 0xBDA476, + 0xCEB88F, 0x7FAED3, 0xDB9116, 0x31CF72, 0x1A5136, 0xC4F362, + 0xDE4799, 0x768043, 0x386207, 0x8E5497, 0xB0EF6D, 0x6C57FB, + 0xF56664, 0xD24F05, 0xE0F702, 0x8A41EF, 0xA2EC53, 0x09731C, + 0x6157FE, 0xC5731C, 0xEF1A2E, 0x60EC10, 0xA67EFE, 0x486A73, + 0x8004F6, 0xC3F482, 0x63BA28, 0x107282, +}; +#endif diff --git a/usr/src/lib/libm/common/Q/_TBL_logl.c b/usr/src/lib/libm/common/Q/_TBL_logl.c new file mode 100644 index 0000000000..b4b5b44ea5 --- /dev/null +++ b/usr/src/lib/libm/common/Q/_TBL_logl.c @@ -0,0 +1,169 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Table of constants for logl. + * By K.C. Ng, March 9, 1989 + */ + +#include "libm.h" + +const long double _TBL_logl_hi[] = { + +0.000000000000000000000000000000000000000e+0000L, + +1.550418653596525415085404409320395875274e-0002L, + +3.077165866675368837102820454313423549427e-0002L, + +4.580953603129420316667926449525231301634e-0002L, + +6.062462181643484258060612972483742997442e-0002L, + +7.522342123758752569860532039086827578824e-0002L, + +8.961215868968713261995143730528787027578e-0002L, + +1.037967936816435648260617694803438348244e-0001L, + +1.177830356563834545387940581504548168563e-0001L, + +1.315763577887192725887160624312135596698e-0001L, + +1.451820098444978972819350572286183123887e-0001L, + +1.586050301766385840933711683530052981349e-0001L, + +1.718502569266592223400988812516892523599e-0001L, + +1.849223384940119926639035059723077314615e-0001L, + +1.978257433299198803625720374533782925763e-0001L, + +2.105647691073496376695527531626088702497e-0001L, + +2.231435513142097557662949937027997104032e-0001L, + +2.355660713127669090775881163009096337126e-0001L, + +2.478361639045812567806026867952720081699e-0001L, + +2.599575244369260669720794933085231739065e-0001L, + +2.719337154836417588316694242031136685288e-0001L, + +2.837681731306445983469010458794547135312e-0001L, + +2.954642128938358763866817700916107535002e-0001L, + +3.070250352949118620751243666552419834311e-0001L, + +3.184537311185346158102471140686078561531e-0001L, + +3.297532863724679818144228014362478784488e-0001L, + +3.409265869705932103050890001544662426952e-0001L, + +3.519764231571781846554474552048254288130e-0001L, + +3.629054936893684531378242945398272521523e-0001L, + +3.737164097935840808210167331226757525499e-0001L, + +3.844116989103320397347900487369508110320e-0001L, + +3.949938082408689781063939783520655318915e-0001L, + +4.054651081081643819780130322994137932204e-0001L, + +4.158278951437109656133288259511744826605e-0001L, + +4.260843953109000631245447385569842356371e-0001L, + +4.362367667749180703490412239178509575736e-0001L, + +4.462871026284195115325899874055994208063e-0001L, + +4.562374334815875943808053840818705719756e-0001L, + +4.660897299245992245586191878736453654769e-0001L, + +4.758459048699639142652093893677655824436e-0001L, + +4.855078157817008078017910633011255535046e-0001L, + +4.950772667978515145979645213034899480604e-0001L, + +5.045560107523952870583081828817948816463e-0001L, + +5.139457511022343168010058668287669524912e-0001L, + +5.232481437645478365168069353535037563840e-0001L, + +5.324647988694718438739234379583263151144e-0001L, + +5.415972824327443715765422111689841356847e-0001L, + +5.506471179526622792599479861304555364807e-0001L, + +5.596157879354226862708883466532843603287e-0001L, + +5.685047353526687120787385804082945993734e-0001L, + +5.773153650348236043181117067559499073234e-0001L, + +5.860490450035782089041193916402035316840e-0001L, + +5.947071077466927895143434959005658134879e-0001L, + +6.032908514380842623405849663552155166682e-0001L, + +6.118015411059929035298897608882125523626e-0001L, + +6.202404097518575288514942954323627943283e-0001L, + +6.286086594223741377443081293997900727520e-0001L, + +6.369074622370692316204942281372157123062e-0001L, + +6.451379613735847016652282983340864160916e-0001L, + +6.533012720127456387586157190946858013903e-0001L, + +6.613984822453650082602354487776933060928e-0001L, + +6.694306539426292672988850845059757003379e-0001L, + +6.773988235918061408096824565025274617492e-0001L, + +6.853040030989194165440476699956951850629e-0001L, +}; + +const long double _TBL_logl_lo[] = { + +0.000000000000000000000000000000000000000e+0000L, + +1.949242877125126389030374148355277037360e-0027L, + +3.053637928597425156289800058830629052349e-0027L, + +3.119411029097592549724599219796579698355e-0027L, + +2.315582833311779694729302029874044004747e-0027L, + +1.959279413884862919696230642481001644914e-0026L, + +3.207319665850940689112590931321584585232e-0026L, + +3.428363085348215886901240200560690191423e-0026L, + +5.132006688821218644279793035639158591104e-0026L, + +6.625826960278191623061313902987136675670e-0026L, + +6.511946011133829904478213998927380817716e-0027L, + +6.272836277110805877048126233548710095828e-0027L, + +6.480345801257546326311423010001184801374e-0026L, + +8.668694188954430256018491855337005516255e-0026L, + +3.374358317649896753533582921130800923337e-0026L, + +5.956974264347082186429247944518667757530e-0026L, + +9.660703479297144864941461785565180191497e-0026L, + +1.026401337764243728855958607127831718221e-0025L, + +7.895125273982903351541822547625351974082e-0026L, + +1.233787870669833985274611329531652753861e-0027L, + +7.032988549345377674736424478296516377526e-0026L, + +1.764708000531295728633384847670848625081e-0025L, + +1.359633534416813878749988462341486606257e-0025L, + +1.738801359182578816100029030519562527565e-0025L, + +9.952199173944211463901058384143333287734e-0026L, + +1.048454193250289008158931842356333139861e-0026L, + +1.996258899657478647716755914664160562170e-0025L, + +1.054613497176328160439100383508915283893e-0027L, + +5.143766259398803158035428613944687700657e-0026L, + +9.959314775409457843445608446369116918733e-0026L, + +1.374434005748650164937032849496159512584e-0026L, + +5.801291623641845255360276144691829323298e-0026L, + +8.316493534335158882618991007102844149005e-0026L, + +6.700372782269538472749252935215499311080e-0026L, + +1.410384923832595967313936024639114199873e-0025L, + +9.914327034309007140234547094345224044051e-0026L, + +1.932140695859428972988292357113036038299e-0025L, + +1.540820591764623257530922632028001952748e-0025L, + +5.963112403438125368118769047371614538741e-0026L, + +1.969366158297316138140115855981754471320e-0025L, + +1.388966334707414023926476567157219393213e-0026L, + +6.353934371729676603785277612987160899450e-0026L, + +3.488563800483361999633395030516586696799e-0025L, + +2.214454506406188993139159148705861598088e-0025L, + +2.895813670852564643073769701905380524878e-0025L, + +2.855018159274929532107406110765900047355e-0025L, + +9.273144996328510392949911518833977809658e-0026L, + +1.930744579236138780895942105787011752697e-0025L, + +1.538735422331574088102192677519746877453e-0025L, + +1.844586676642028985383989272409206538468e-0025L, + +3.547635464941839708071563131885310128521e-0025L, + +4.464712081783102087084281748635332222581e-0026L, + +5.062863951970459495500575300347508324877e-0026L, + +2.203060950889790157204518257910818074191e-0025L, + +5.540602231323196163388428517126435254723e-0027L, + +3.371348840624439923830692211721531149909e-0025L, + +7.637439356719457811667844141793488670929e-0026L, + +1.990439834788842292780211676828666657547e-0025L, + +1.978006454898465493718923085569873769719e-0025L, + +1.621161880831806223416081355472819612309e-0025L, + +3.899319576320551292151632804501913965920e-0025L, + +1.864235278097858865893177670582100390924e-0025L, + +1.534948208368053655735541548539936152221e-0025L, + +4.089715378013580174759550633443176148182e-0025L, +}; diff --git a/usr/src/lib/libm/common/Q/_TBL_sinl.c b/usr/src/lib/libm/common/Q/_TBL_sinl.c new file mode 100644 index 0000000000..766d15014c --- /dev/null +++ b/usr/src/lib/libm/common/Q/_TBL_sinl.c @@ -0,0 +1,192 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * table of sinl(x) where x is 0.15625 + i*0.03125, i=0,1,...,74. + * {0x3ffc4000,0,0,0} --> (inc 0x800) --> {0x3ffe9000,0,0,0} + * 0.15625 0.03125 0.78125 (pi/4 = 0.785395663...) + */ + +#include "libm.h" + +const long double _TBL_sinl_hi[] = { + +1.556149927735560412099206432035162581492e-0001L, + +1.594724589318434199425963881130908091043e-0001L, + +1.633274917366128508468661724543543700180e-0001L, + +1.671800323648067343709660282007512722777e-0001L, + +1.710300220313950192813479692398343312832e-0001L, + +1.748774019902721898956853691085201901772e-0001L, + +1.787221135351536593753562418641807235164e-0001L, + +1.825640980004715553995456513594130154574e-0001L, + +1.864032967622698845523799831032052611919e-0001L, + +1.902396512390990617639858876307573287214e-0001L, + +1.940731028929097911560552002141454036336e-0001L, + +1.979035932299462846523939109918127853182e-0001L, + +2.017310638016388047250381511640009707423e-0001L, + +2.055554562054955176568330206054936963632e-0001L, + +2.093767120859936437118907527248816522107e-0001L, + +2.131947731354698906160730331184784624987e-0001L, + +2.170095810950101567605780958260553963420e-0001L, + +2.208210777553384905528563479277490523429e-0001L, + +2.246292049577052923504285497964248198189e-0001L, + +2.284339045947747454247378313461956799859e-0001L, + +2.322351186115114624139308777462358722636e-0001L, + +2.360327890060663337354342917945180835158e-0001L, + +2.398268578306615644413692518108865737937e-0001L, + +2.436172671924748860122309477052146367777e-0001L, + +2.474039592545229295968487048493892032583e-0001L, + +2.549659604158784674875565748648726276685e-0001L, + +2.625123997691532814509496263956929310415e-0001L, + +2.700428167185850315527550636188270542366e-0001L, + +2.775567516463363259220234468281285678680e-0001L, + +2.850537459405474245877630333232525606110e-0001L, + +2.925333420233275436247023264939134225079e-0001L, + +2.999950833786830511632482820116999437532e-0001L, + +3.074385145803808506705029582019820907725e-0001L, + +3.148631813197452508650363151269390156066e-0001L, + +3.222686304333866256877459198931880313050e-0001L, + +3.296544099308601719143177251264631756945e-0001L, + +3.370200690222530762612817541738100244419e-0001L, + +3.443651581456984082071720464722237468910e-0001L, + +3.516892289948140592225848969555470155541e-0001L, + +3.589918345460650536777102991528689411936e-0001L, + +3.662725290860475613729093517162641768533e-0001L, + +3.735308682386929464168397526608481120900e-0001L, + +3.807664089923901920572007033888966750813e-0001L, + +3.879787097270250460510796908137419597834e-0001L, + +3.951673302409342362448326404196536570776e-0001L, + +4.023318317777731112171055988809823868862e-0001L, + +4.094717770532950661226940270114522362676e-0001L, + +4.165867302820411192591124488310696565000e-0001L, + +4.236762572039380103616839880311024798208e-0001L, + +4.307399251108031972163215178508491897943e-0001L, + +4.377773028727551328616189747027966801523e-0001L, + +4.447879609645272114330560125295252111499e-0001L, + +4.517714714916837765816887501340628695303e-0001L, + +4.587274082167365923772950289728747732442e-0001L, + +4.656553465851601826811995125075467791328e-0001L, + +4.725548637513044511465513178085169418350e-0001L, + +4.794255386042030002732879352155714019245e-0001L, + +4.930786857539230572651365527534871205832e-0001L, + +5.066114548142573676422960008938671919466e-0001L, + +5.200205419537270047602136998746747297451e-0001L, + +5.333026735360201733291311033081615288994e-0001L, + +5.464546069192035644033495537494110008818e-0001L, + +5.594731312473668773848440060031166884132e-0001L, + +5.723550682345072403849537068245036075406e-0001L, + +5.850972729404621548053993141500804585059e-0001L, + +5.976966345387015312386476189673343370299e-0001L, + +6.101500770757913712737423935661832200218e-0001L, + +6.224545602223436830419267050904433302049e-0001L, + +6.346070800152692968503099142036714364826e-0001L, + +6.466046695911523705240421598828007629792e-0001L, + +6.584443999105675415895839548840419894459e-0001L, + +6.701233804731628946545315835006484946172e-0001L, + +6.816387600233341667332419527798939078545e-0001L, + +6.929877272463179102818154908230482095679e-0001L, + +7.041675114545336727800595099739428438828e-0001L, +}; + +const long double _TBL_sinl_lo[] = { + -7.839895634192879801217180506294972695887e-0036L, + -7.579278167533093253112813720340914585189e-0036L, + +1.813803443011554857703679023007542917336e-0036L, + -5.685040200337201343842157163322014327778e-0036L, + +7.013958751874876088754160302032414326691e-0036L, + +9.101164084055805006113433827277389417722e-0036L, + -1.529069265172651032025475612605940319203e-0036L, + -5.873100812266872079952884219254900231461e-0036L, + +1.764603048068267800105867159753318395454e-0036L, + +1.747799267790272859521729635868399475234e-0036L, + -9.673047410519982672089452429449289994858e-0036L, + -7.666827750837122707923169727244402427704e-0036L, + -4.275134347549669784351512906173841196088e-0036L, + -1.826904072780322152815985026139121969706e-0036L, + -1.594702873443294499653146384825158092559e-0036L, + -7.180615084240582786256765419723871383233e-0036L, + +1.073564887942168318128295491982011935257e-0035L, + +6.166267602604185314123111207543917974633e-0036L, + +2.420615108492974698446957518700585915995e-0036L, + +1.864291640707538541155008952901532832506e-0036L, + -4.969304833641910200750246243329289676583e-0036L, + +7.191910920600591837788283739445222790835e-0036L, + +2.398670365698962872409384444450714480056e-0036L, + +2.625717623049256499265563616201152710192e-0036L, + -7.364870011085995329435971152758116180239e-0036L, + +2.202803779185347210050716883280741537850e-0035L, + +3.249236770720310646731771785718217268891e-0036L, + +2.438735936561976529428558055804286674772e-0035L, + -1.358485954689981282143446687700830546868e-0036L, + +2.042693258859029188027001236804037487674e-0035L, + +1.935394086687044503080036879506851279569e-0035L, + +1.351742655356978501392833614755710504356e-0035L, + +1.065151724232046458392410994534171402266e-0035L, + +1.924312402124329269930577050628341603064e-0035L, + -1.495058978047592634838539083355002279867e-0035L, + -1.226069967847432149730821922942328537678e-0035L, + -2.214357561488394736777775450498906642993e-0035L, + -3.197918850054809249377584675940519273161e-0036L, + +1.752934334182702105675254128020832940341e-0035L, + -2.067723892627233681394169702571120887364e-0035L, + -1.967684335349365926758978182531089889151e-0035L, + -1.480234947789865560488791134115171284680e-0035L, + -2.020095411752086363369245333724961071903e-0035L, + +8.019047838709350758444432786175864173856e-0036L, + +7.575600313883125509400401940426278198665e-0036L, + -1.956787228828481747235699165048715626458e-0035L, + +2.239452414684575979216557857298213538383e-0035L, + -2.004881068319988136754382697969636119420e-0035L, + +1.404844563886544703294730965793125947043e-0035L, + +1.540967800016293988508912183967615475673e-0035L, + +9.627943645034426124771174260339225827341e-0036L, + -1.671879365114936780075083716139548989818e-0035L, + -1.193872230164722958937943872752845047434e-0035L, + -4.709469941941829089292517195754317215227e-0036L, + -1.562825989789718724786197721553059612264e-0035L, + +9.313247749577680188502242676253713195205e-0036L, + -1.384269776167183189501758486393819264119e-0035L, + +7.064986931125350563523011010886249504328e-0036L, + -3.109636998242741557027060430659670849804e-0035L, + -3.324150213308849248337118428668967104680e-0035L, + -3.427152913195516159969937952267551337396e-0035L, + -2.118702307301603154209365237718648576399e-0035L, + -1.289226205241639223068869521009917813361e-0037L, + +2.125722734799331239445801994645145285587e-0035L, + -1.781645762780561951365253354033804640300e-0035L, + -2.495276089408737145274279413504615537138e-0035L, + +1.338422379299389637809694183691505317685e-0035L, + +1.919747869211470727176212361922698586017e-0035L, + +4.330259169399683693260601564559270596091e-0036L, + -3.417429818162194124156743659460798263758e-0035L, + -4.544129440843003305237213918657872189520e-0035L, + -1.331658529527437298976340693936847286647e-0036L, + +2.748387759350275490242241143386673942983e-0035L, + +4.500898710776635571808492195291899181897e-0035L, + -2.872593727403933486766336102755986165044e-0035L, +}; diff --git a/usr/src/lib/libm/common/Q/_TBL_tanl.c b/usr/src/lib/libm/common/Q/_TBL_tanl.c new file mode 100644 index 0000000000..b207c0cbfa --- /dev/null +++ b/usr/src/lib/libm/common/Q/_TBL_tanl.c @@ -0,0 +1,192 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * table of tanl(x) where x is 0.15625 + i*0.03125, i=0,1,...,74. + * {0x3ffc4000,0,0,0} --> (inc 0x800) --> {0x3ffe9000,0,0,0} + * 0.15625 0.03125 0.78125 (pi/4 = 0.785395663...) + */ + +#include "libm.h" + +const long double _TBL_tanl_hi[] = { + +1.575341073252716106852257741724104864870e-0001L, + +1.615397840495214763092752400110463977418e-0001L, + +1.655505192739339762139309125850523900470e-0001L, + +1.695664452197665101509706065437500194264e-0001L, + +1.735876947679815208446734114353616329985e-0001L, + +1.776144014774467276317429269586882243819e-0001L, + +1.816466996033214276582758961743535864882e-0001L, + +1.856847241156344116266612278649865067149e-0001L, + +1.897286107180591328910833700730338069829e-0001L, + +1.937784958668918635160223977682694780440e-0001L, + +1.978345167902386688084063751239797409303e-0001L, + +2.018968115074171328840689933657666757769e-0001L, + +2.059655188485788721087393288030358608878e-0001L, + +2.100407784745589808415175232245911862545e-0001L, + +2.141227308969586648860666814158624683863e-0001L, + +2.182115174984674325058820481495796084382e-0001L, + +2.223072805534313308722888175879995829692e-0001L, + +2.264101632486738374776714045035595099974e-0001L, + +2.305203097045761414554475155379181753938e-0001L, + +2.346378649964236789993677105610770268268e-0001L, + +2.387629751760259202681510637409399276566e-0001L, + +2.428957872936165424010859430156609881174e-0001L, + +2.470364494200412646634947325158035272170e-0001L, + +2.511851106692407673991038906774344215246e-0001L, + +2.553419212210362665044822364904736907938e-0001L, + +2.636805964199967998548259948794679989658e-0001L, + +2.720536986587708834265643667712727220498e-0001L, + +2.804624701452514031696042891852650256007e-0001L, + +2.889081724405147260015884454642448163630e-0001L, + +2.973920872690245894671940160246554900716e-0001L, + +3.059155173530592641072389231969929579942e-0001L, + +3.144797872725715161734382202256272257022e-0001L, + +3.230862443517455201183006557179619867007e-0001L, + +3.317362595735727673394297030105334375685e-0001L, + +3.404312285238303874282274418902587687499e-0001L, + +3.491725723659103522547129636843912210518e-0001L, + +3.579617388480169983883959631794471179752e-0001L, + +3.668002033443234227206048185537661359712e-0001L, + +3.756894699317548404092457756875977254806e-0001L, + +3.846310725041492230408562796582816506283e-0001L, + +3.936265759256327582294137871012180779893e-0001L, + +4.026775772251402117785937359900067250949e-0001L, + +4.117857068341084757888498763848712415895e-0001L, + +4.209526298694758220747941414506739471850e-0001L, + +4.301800474642300490203296054472752443302e-0001L, + +4.394696981478662404836631484799309510327e-0001L, + +4.488233592792397088405555239245740331672e-0001L, + +4.582428485344323669591891965241567184790e-0001L, + +4.677300254523917999213427069619926229670e-0001L, + +4.772867930412522617224042590104237355391e-0001L, + +4.869150994484063244987175035683195875449e-0001L, + +4.966169396975656257105605790725693200164e-0001L, + +5.063943574962298120708227547071771601970e-0001L, + +5.162494471171751444917753379369286911420e-0001L, + +5.261843553577791441706134379510093677744e-0001L, + +5.362012835812160313475789292393083126826e-0001L, + +5.463024898437905132551794657802853544147e-0001L, + +5.667670655805864456801779441354759990792e-0001L, + +5.875973675914432213941588631578976895206e-0001L, + +6.088137403243807214124939743963768234939e-0001L, + +6.304376738358847668526114292997751740101e-0001L, + +6.524918979288079927238977365516267472227e-0001L, + +6.750004851442429076631779494777228720541e-0001L, + +6.979889636235992551497657233900136516119e-0001L, + +7.214844409909044199895178832795946639042e-0001L, + +7.455157405593919951361301646778137804617e-0001L, + +7.701135513442087050059836600527731975210e-0001L, + +7.953105935686741856456016917474183548089e-0001L, + +8.211418015898941219114239653747117425236e-0001L, + +8.476445264465526540907883088076187235513e-0001L, + +8.748587605544823495396719079321555572147e-0001L, + +9.028273874526735021961743652539763208464e-0001L, + +9.315964599440724611652027565739364074620e-0001L, + +9.612155104943704161853006259468735267385e-0001L, + +9.917378983632686802568573899299023560595e-0001L, +}; + +const long double _TBL_tanl_lo[] = { + +4.179214385976688849250979202972663542033e-0036L, + +1.201528446191025246839024650298397902579e-0035L, + +1.129323489449537738080901788756231977300e-0035L, + +2.140135278964936125815581758267649033136e-0037L, + +4.432205749300185001040819456988862684951e-0036L, + +6.136100978120132271332684207100740679906e-0036L, + -1.032553059579180849987395832156976613765e-0035L, + -3.160024259922437001215851404196652376871e-0037L, + +9.288062528988428190963791818336024913881e-0036L, + -7.446971695790644707546943119354167721612e-0036L, + -3.194115406765633171232961214385101074252e-0036L, + +8.636824101000271295925487212833770093090e-0036L, + +3.102272236726159152985822088441358430350e-0036L, + -5.851906473589368694487202441718008909753e-0036L, + +4.010022070137306925338504597897336002613e-0036L, + +1.037727706884673933875970874373462194321e-0035L, + -7.373234860421060505099033319601658081963e-0037L, + +1.012564187615243178899324943342662908733e-0035L, + -1.409372712725876553601555574139438939044e-0036L, + +8.378827024922767151362882309834645448153e-0036L, + +2.973824478467770877677465646013477493211e-0037L, + +5.400099398783906370270919848839276575083e-0036L, + -6.462512242458415498262723324973388658384e-0036L, + -2.322762023061318925750503642571013465985e-0035L, + -1.258955887171193954556521579215259847692e-0035L, + -2.320447955805179154521333495999564905899e-0035L, + -1.149012552345329193834437558081484346041e-0035L, + +1.452751817871169833623945031311944393871e-0035L, + +1.233520419884672519188849688498814953115e-0035L, + -2.801716058919562991500189219464456618491e-0036L, + -8.652310551710608096633992612270187537921e-0036L, + +1.247172716748407772564831128401880847054e-0035L, + -1.239704249638930213583929247314024560861e-0035L, + +5.184462988068616168233816296529150644737e-0036L, + -6.856476723415391305857531095744442523549e-0039L, + -9.739553531295433673398454344315039002245e-0036L, + +2.266233016492660661638292126777401538348e-0035L, + +2.301502770052376628347923621704562121797e-0035L, + +1.948845747336057051538318007442114995744e-0035L, + -1.940750389335608259363326370556914475278e-0035L, + +2.019644660873458215118483163076314703163e-0035L, + +1.602015812156905914821208807083062984550e-0035L, + -3.292416392515743374743236507806546284438e-0036L, + +8.663813942351672490328381271391704283086e-0036L, + +2.366609581506599084093910217277994736871e-0035L, + -1.408950063101056644039900854057776596620e-0035L, + -1.514769920962849077013113923603803573445e-0035L, + -2.261973795598615105449462443044330073903e-0035L, + -2.553211882172402068866429390071980923144e-0036L, + +1.416627029437126089675998257335033382140e-0035L, + +2.342724931714249133589230079809850869266e-0035L, + +1.710557978782419482731492281155256146438e-0036L, + -2.148837714938406737587489024152464642738e-0035L, + -4.273007541330408144086077695573950943351e-0035L, + -1.187512317830147119742251549090183099823e-0035L, + +4.828271743385077560204615670566277021463e-0036L, + +2.888285131340709127656514948635349311805e-0035L, + -4.505233085580329558684272075904471228864e-0035L, + +2.931630895327838681946984510160883959332e-0036L, + +2.647698485118630114484469975939947791390e-0035L, + +3.589320320845381187254017736531618320153e-0035L, + +3.109409548262590459351847474032415851843e-0035L, + +4.083234910839125531016836269706248922707e-0035L, + +2.617081426185972174278972738311427223003e-0035L, + +1.685638883876736468625598871602567025329e-0035L, + +3.340709007044122362174996515517070074049e-0035L, + +4.272448967674769643335827331513513914893e-0035L, + -1.016337077502454982949287784426587554312e-0035L, + -4.164820472415940877265629374001265181061e-0035L, + -1.266702907529482683855413412028523879313e-0035L, + -2.498295523749676738976415773050309926889e-0035L, + -2.240244888035701528565322302010524216607e-0035L, + +2.072673676633052237512344957839713494538e-0035L, + -5.635620575073849011607547314084511148918e-0036L, + +1.289773398786324444403985925780591709915e-0035L, +}; diff --git a/usr/src/lib/libm/common/Q/__cosl.c b/usr/src/lib/libm/common/Q/__cosl.c new file mode 100644 index 0000000000..58a268f7dc --- /dev/null +++ b/usr/src/lib/libm/common/Q/__cosl.c @@ -0,0 +1,138 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * __k_cosl(long double x, long double y) + * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * + * Table look up algorithm + * 1. by cos(-x) = cos(x), we may replace x by |x| + * 2. if x < 25/128 = [0x3ffc4000, 0] = 0.15625 , then + * if x < 2^-57 (hx < 0x3fc60000 0), return 1.0 with inexact if x != 0 + * z = x*x; + * if x <= 1/128 = 2**-7 = 0.0078125 + * cos(x)=1.0+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))) + * else + * cos(x)=1.0+z*(q1+ ... z*q8) + * 3. else + * ht = (hx + 0x400)&0x7ffff800 (round x to a break point t) + * lt = 0 + * i = (hy-0x3ffc4000)>>11; (i<=64) + * x' = (x - t)+y (|x'| ~<= 2^-7 + * By + * cos(t+x') + * = cos(t)cos(x')-sin(t)sin(x') + * = cos(t)(1+z*(qq1+z*qq2))-[sin(t)]*x*(1+z*(pp1+z*pp2)) + * = cos(t) + [cos(t)]*(z*(qq1+z*qq2))- + * [sin(t)]*x*(1+z*(pp1+z*pp2)) + * + * Thus, + * let a= _TBL_cos_hi[i], b = _TBL_cos_lo[i], c= _TBL_sin_hi[i], + * x = (x-t)+y + * z = x*x; + * cos(t+x) = a+(b+ (-c*x*(1+z*(pp1+z*pp2))+a*(z*(qq1+z*qq2))) + */ + +#include "libm.h" + +extern const long double _TBL_cosl_hi[], _TBL_cosl_lo[], _TBL_sinl_hi[]; +static const long double + one = 1.0L, +/* + * 3 11 -122.32 + * |sin(x) - (x+pp1*x +...+ pp5*x )| <= 2 for |x|<1/64 + */ + pp1 = -1.666666666666666666666666666586782940810e-0001L, + pp2 = +8.333333333333333333333003723660929317540e-0003L, + pp3 = -1.984126984126984076045903483778337804470e-0004L, + pp4 = +2.755731922361906641319723106210900949413e-0006L, + pp5 = -2.505198398570947019093998469135012057673e-0008L, +/* + * 2 16 -117.11 + * |cos(x) - (1+q1*x + ... + q8*x )| <= 2 for |x|<= 0.15625 + */ + q1 = -4.999999999999999999999999999999756416975e-0001L, + q2 = +4.166666666666666666666666664006066577258e-0002L, + q3 = -1.388888888888888888888877700363937169637e-0003L, + q4 = +2.480158730158730158494468463031814083559e-0005L, + q5 = -2.755731922398586276322819250356005542871e-0007L, + q6 = +2.087675698767424261441959760729854017855e-0009L, + q7 = -1.147074481239662089072452129010790774761e-0011L, + q8 = +4.777761647399651599730663422263531034782e-0014L, +/* + * 2 10 -123.84 + * |cos(x) - (1+qq1*x +...+ qq5*x )| <= 2 for |x|<=1/128 + */ + qq1 = -4.999999999999999999999999999999378373641e-0001L, + qq2 = +4.166666666666666666666665478399327703130e-0002L, + qq3 = -1.388888888888888888058211230618051613494e-0003L, + qq4 = +2.480158730156105377771585658905303111866e-0005L, + qq5 = -2.755728099762526325736488376695157008736e-0007L; + +#define i0 0 + +long double +__k_cosl(long double x, long double y) { + long double a, t, z, w; + int *pt = (int *) &t, *px = (int *) &x; + int i, j, hx, ix; + + t = 1.0L; + hx = px[i0]; + ix = hx & 0x7fffffff; + if (ix < 0x3ffc4000) { + if (ix < 0x3fc60000) + if ((i = (int) x) == 0) + return (one); /* generate inexact */ + z = x * x; + + if (ix < 0x3ff80000) /* 0.0078125 */ + return one + z * (qq1 + z * (qq2 + z * (qq3 + + z * (qq4 + z * qq5)))); + else + return one + z * (q1 + z * (q2 + z * (q3 + + z * (q4 + z * (q5 + z * (q6 + z * (q7 + + z * q8))))))); + } + j = (ix + 0x400) & 0x7ffff800; + i = (j - 0x3ffc4000) >> 11; + pt[i0] = j; + if (hx > 0) + x = y - (t - x); + else + x = (-y) - (t + x); + a = _TBL_cosl_hi[i]; + z = x * x; + t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); + w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * pp5))))); + t = _TBL_cosl_lo[i] - (_TBL_sinl_hi[i] * w - a * t); + return (a + t); +} diff --git a/usr/src/lib/libm/common/Q/__lgammal.c b/usr/src/lib/libm/common/Q/__lgammal.c new file mode 100644 index 0000000000..3b1f8eff75 --- /dev/null +++ b/usr/src/lib/libm/common/Q/__lgammal.c @@ -0,0 +1,397 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * long double __k_lgammal(long double x, int *signgamlp); + * K.C. Ng, August, 1989. + * + * We choose [1.5,2.5] to be the primary interval. Our algorithms + * are mainly derived from + * + * + * zeta(2)-1 2 zeta(3)-1 3 + * lgamma(2+s) = s*(1-euler) + --------- * s - --------- * s + ... + * 2 3 + * + * + * Note 1. Since gamma(1+s)=s*gamma(s), hence + * lgamma(1+s) = log(s) + lgamma(s), or + * lgamma(s) = lgamma(1+s) - log(s). + * When s is really tiny (like roundoff), lgamma(1+s) ~ s(1-enler) + * Hence lgamma(s) ~ -log(s) for tiny s + * + */ + +#include "libm.h" +#include "longdouble.h" + +static long double neg(long double, int *); +static long double poly(long double, const long double *, int); +static long double polytail(long double); +static long double primary(long double); + +static const long double +c0 = 0.0L, +ch = 0.5L, +c1 = 1.0L, +c2 = 2.0L, +c3 = 3.0L, +c4 = 4.0L, +c5 = 5.0L, +c6 = 6.0L, +pi = 3.1415926535897932384626433832795028841971L, +tiny = 1.0e-40L; + +long double +__k_lgammal(long double x, int *signgamlp) { + long double t,y; + int i; + + /* purge off +-inf, NaN and negative arguments */ + if (!finitel(x)) return x*x; + *signgamlp = 1; + if (signbitl(x)) return (neg(x,signgamlp)); + + /* for x < 8.0 */ + if (x<8.0L) { + y = anintl(x); + i = (int) y; + switch(i) { + case 0: + if (x<1.0e-40L) return -logl(x); else + return (primary(x)-log1pl(x))-logl(x); + case 1: + return primary(x-y)-logl(x); + case 2: + return primary(x-y); + case 3: + return primary(x-y)+logl(x-c1); + case 4: + return primary(x-y)+logl((x-c1)*(x-c2)); + case 5: + return primary(x-y)+logl((x-c1)*(x-c2)*(x-c3)); + case 6: + return primary(x-y)+logl((x-c1)*(x-c2)*(x-c3)*(x-c4)); + case 7: + return primary(x-y)+logl((x-c1)*(x-c2)*(x-c3)*(x-c4)*(x-c5)); + case 8: + return primary(x-y)+ + logl((x-c1)*(x-c2)*(x-c3)*(x-c4)*(x-c5)*(x-c6)); + } + } + + /* 8.0 <= x < 1.0e40 */ + if (x < 1.0e40L) { + t = logl(x); + return x*(t-c1)-(ch*t-polytail(c1/x)); + } + + /* 1.0e40 <= x <= inf */ + return x*(logl(x)-c1); +} + +static const long double an1[] = { /* 20 terms */ + -0.0772156649015328606065120900824024309741L, + 3.224670334241132182362075833230130289059e-0001L, + -6.735230105319809513324605383668929964120e-0002L, + 2.058080842778454787900092432928910226297e-0002L, + -7.385551028673985266273054086081102125704e-0003L, + 2.890510330741523285758867304409628648727e-0003L, + -1.192753911703260976581414338096267498555e-0003L, + 5.096695247430424562831956662855697824035e-0004L, + -2.231547584535777978926798502084300123638e-0004L, + 9.945751278186384670278268034322157947635e-0005L, + -4.492623673665547726647838474125147631082e-0005L, + 2.050721280617796810096993154281561168706e-0005L, + -9.439487785617396552092393234044767313568e-0006L, + 4.374872903516051510689234173139793159340e-0006L, + -2.039156676413643091040459825776029327487e-0006L, + 9.555777181318621470466563543806211523634e-0007L, + -4.468344919709630637558538313482398989638e-0007L, + 2.216738086090045781773004477831059444178e-0007L, + -7.472783403418388455860445842543843485916e-0008L, + 8.777317930927149922056782132706238921648e-0008L, +}; + +static const long double an2[] = { /* 20 terms */ + -.0772156649015328606062692723698127607018L, + 3.224670334241132182635552349060279118047e-0001L, + -6.735230105319809367555642883133994818325e-0002L, + 2.058080842778459676880822202762143671813e-0002L, + -7.385551028672828216011343150077846918930e-0003L, + 2.890510330762060607399561536905727853178e-0003L, + -1.192753911419623262328187532759756368041e-0003L, + 5.096695278636456678258091134532258618614e-0004L, + -2.231547306817535743052975194022893369135e-0004L, + 9.945771461633313282744264853986643877087e-0005L, + -4.492503279458972037926876061257489481619e-0005L, + 2.051311416812082875492678651369394595613e-0005L, + -9.415778282365955203915850761537462941165e-0006L, + 4.452428829045147098722932981088650055919e-0006L, + -1.835024727987632579886951760650722695781e-0006L, + 1.379783080658545009579060714946381462565e-0006L, + 2.282637532109775156769736768748402175238e-0007L, + 1.002577375515900191362119718128149880168e-0006L, + 5.177028794262638311939991106423220002463e-0007L, + 3.127947245174847104122426445937830555755e-0007L, +}; + +static const long double an3[] = { /* 20 terms */ + -.0772156649015328227870646417729220690875L, + 3.224670334241156699881788955959915250365e-0001L, + -6.735230105312273571375431059744975563170e-0002L, + 2.058080842924464587662846071337083809005e-0002L, + -7.385551008677271654723604653956131791619e-0003L, + 2.890510536479782086197110272583833176602e-0003L, + -1.192752262076857692740571567808259138697e-0003L, + 5.096800771149805289371135155128380707889e-0004L, + -2.231000836682831335505058492409860123647e-0004L, + 9.968912171073936803871803966360595275047e-0005L, + -4.412020779327746243544387946167256187258e-0005L, + 2.281374113541454151067016632998630209049e-0005L, + -4.028361291428629491824694655287954266830e-0006L, + 1.470694920619518924598956849226530750139e-0005L, + 1.381686137617987197975289545582377713772e-0005L, + 2.012493539265777728944759982054970441601e-0005L, + 1.723917864208965490251560644681933675799e-0005L, + 1.202954035243788300138608765425123713395e-0005L, + 5.079851887558623092776296577030850938146e-0006L, + 1.220657945824153751555138592006604026282e-0006L, +}; + +static const long double an4[] = { /* 21 terms */ + -.0772156649015732285350261816697540392371L, + 3.224670334221752060691751340365212226097e-0001L, + -6.735230109744009693977755991488196368279e-0002L, + 2.058080778913037626909954141611580783216e-0002L, + -7.385557567931505621170483708950557506819e-0003L, + 2.890459838416254326340844289785254883436e-0003L, + -1.193059036207136762877351596966718455737e-0003L, + 5.081914708100372836613371356529568937869e-0004L, + -2.289855016133600313131553005982542045338e-0004L, + 8.053454537980585879620331053833498511491e-0005L, + -9.574620532104845821243493405855672438998e-0005L, + -9.269085628207107155601445001196317715686e-0005L, + -2.183276779859490461716196344776208220180e-0004L, + -3.134834305597571096452454999737269668868e-0004L, + -3.973878894951937437018305986901392888619e-0004L, + -3.953352414899222799161275564386488057119e-0004L, + -3.136740932204038779362660900621212816511e-0004L, + -1.884502253819634073946130825196078627664e-0004L, + -8.192655799958926853585332542123631379301e-0005L, + -2.292183750010571062891605074281744854436e-0005L, + -3.223980628729716864927724265781406614294e-0006L, +}; + +static const long double ap1[] = { /* 19 terms */ + -0.0772156649015328606065120900824024296961L, + 3.224670334241132182362075833230047956465e-0001L, + -6.735230105319809513324605382963943777301e-0002L, + 2.058080842778454787900092126606252375465e-0002L, + -7.385551028673985266272518231365020063941e-0003L, + 2.890510330741523285681704570797770736423e-0003L, + -1.192753911703260971285304221165990244515e-0003L, + 5.096695247430420878696018188830886972245e-0004L, + -2.231547584535654004647639737841526025095e-0004L, + 9.945751278137201960636098805852315982919e-0005L, + -4.492623672777606053587919463929044226280e-0005L, + 2.050721258703289487603702670753053765201e-0005L, + -9.439485626565616989352750672499008021041e-0006L, + 4.374838162403994645138200419356844574219e-0006L, + -2.038979492862555348577006944451002161496e-0006L, + 9.536763152382263548086981191378885102802e-0007L, + -4.426111214332434049863595231916564014913e-0007L, + 1.911148847512947464234633846270287546882e-0007L, + -5.788673944861923038157839080272303519671e-0008L, +}; + +static const long double ap2[] = { /* 19 terms */ + -0.077215664901532860606428624449354836087L, + 3.224670334241132182271948744265855440139e-0001L, + -6.735230105319809467356126599005051676203e-0002L, + 2.058080842778453315716389815213496002588e-0002L, + -7.385551028673653323064118422580096222959e-0003L, + 2.890510330735923572088003424849289006039e-0003L, + -1.192753911629952368606185543945790688144e-0003L, + 5.096695239806718875364547587043220998766e-0004L, + -2.231547520600616108991867127392089144886e-0004L, + 9.945746913898151120612322833059416008973e-0005L, + -4.492599307461977003570224943054585729684e-0005L, + 2.050609891889165453592046505651759999090e-0005L, + -9.435329866734193796540515247917165988579e-0006L, + 4.362267138522223236241016136585565144581e-0006L, + -2.008556356653246579300491601497510230557e-0006L, + 8.961498103387207161105347118042844354395e-0007L, + -3.614187228330216282235692806488341157741e-0007L, + 1.136978988247816860500420915014777753153e-0007L, + -2.000532786387196664019286514899782691776e-0008L, +}; + +static const long double ap3[] = { /* 19 terms */ + -0.077215664901532859888521470795348856446L, + 3.224670334241131733364048614484228443077e-0001L, + -6.735230105319676541660495145259038151576e-0002L, + 2.058080842775975461837768839015444273830e-0002L, + -7.385551028347615729728618066663566606906e-0003L, + 2.890510327517954083379032008643080256676e-0003L, + -1.192753886919470728001821137439430882603e-0003L, + 5.096693728898932234814903769146577482912e-0004L, + -2.231540055048827662528594010961874258037e-0004L, + 9.945446210018649311491619999438833843723e-0005L, + -4.491608206598064519190236245753867697750e-0005L, + 2.047939071322271016498065052853746466669e-0005L, + -9.376824046522786006677541036631536790762e-0006L, + 4.259329829498149111582277209189150127347e-0006L, + -1.866064770421594266702176289764212873428e-0006L, + 7.462066721137579592928128104534957135669e-0007L, + -2.483546217529077735074007138457678727371e-0007L, + 5.915166576378161473299324673649144297574e-0008L, + -7.334139641706988966966252333759604701905e-0009L, +}; + +static const long double ap4[] = { /* 19 terms */ + -0.0772156649015326785569313252637238673675L, + 3.224670334241051435008842685722468344822e-0001L, + -6.735230105302832007479431772160948499254e-0002L, + 2.058080842553481183648529360967441889912e-0002L, + -7.385551007602909242024706804659879199244e-0003L, + 2.890510182473907253939821312248303471206e-0003L, + -1.192753098427856770847894497586825614450e-0003L, + 5.096659636418811568063339214203693550804e-0004L, + -2.231421144004355691166194259675004483639e-0004L, + 9.942073842343832132754332881883387625136e-0005L, + -4.483809261973204531263252655050701205397e-0005L, + 2.033260142610284888319116654931994447173e-0005L, + -9.153539544026646699870528191410440585796e-0006L, + 3.988460469925482725894144688699584997971e-0006L, + -1.609692980087029172567957221850825977621e-0006L, + 5.634916377249975825399706694496688803488e-0007L, + -1.560065465929518563549083208482591437696e-0007L, + 2.961350193868935325526962209019387821584e-0008L, + -2.834602215195368130104649234505033159842e-0009L, +}; + +static long double +primary(long double s) { /* assume |s|<=0.5 */ + int i; + + i = (int) (8.0L * (s + 0.5L)); + switch(i) { + case 0: return ch*s+s*poly(s,an4,21); + case 1: return ch*s+s*poly(s,an3,20); + case 2: return ch*s+s*poly(s,an2,20); + case 3: return ch*s+s*poly(s,an1,20); + case 4: return ch*s+s*poly(s,ap1,19); + case 5: return ch*s+s*poly(s,ap2,19); + case 6: return ch*s+s*poly(s,ap3,19); + case 7: return ch*s+s*poly(s,ap4,19); + } + /* NOTREACHED */ + return 0.0L; +} + +static long double +poly(long double s, const long double *p, int n) { + long double y; + int i; + y = p[n-1]; + for (i=n-2;i>=0;i--) y = p[i]+s*y; + return y; +} + +static const long double pt[] = { + 9.189385332046727417803297364056176804663e-0001L, + 8.333333333333333333333333333331286969123e-0002L, + -2.777777777777777777777777553194796036402e-0003L, + 7.936507936507936507927283071433584248176e-0004L, + -5.952380952380952362351042163192634108297e-0004L, + 8.417508417508395661774286645578379460131e-0004L, + -1.917526917525263651186066417934685675649e-0003L, + 6.410256409395203164659292973142293199083e-0003L, + -2.955065327248303301763594514012418438188e-0002L, + 1.796442830099067542945998615411893822886e-0001L, + -1.392413465829723742489974310411118662919e+0000L, + 1.339984238037267658352656597960492029261e+0001L, + -1.564707657605373662425785904278645727813e+0002L, + 2.156323807499211356127813962223067079300e+0003L, + -3.330486427626223184647299834137041307569e+0004L, + 5.235535072011889213611369254140123518699e+0005L, + -7.258160984602220710491988573430212593080e+0006L, + 7.316526934569686459641438882340322673357e+0007L, + -3.806450279064900548836571789284896711473e+0008L, +}; + +static long double +polytail(long double s) { + long double t,z; + int i; + z = s*s; + t = pt[18]; + for (i=17;i>=1;i--) t = pt[i]+z*t; + return pt[0]+s*t; +} + +static long double +neg(long double z, int *signgamlp) { + long double t,p; + + /* + * written by K.C. Ng, Feb 2, 1989. + * + * Since + * -z*G(-z)*G(z) = pi/sin(pi*z), + * we have + * G(-z) = -pi/(sin(pi*z)*G(z)*z) + * = pi/(sin(pi*(-z))*G(z)*z) + * Algorithm + * z = |z| + * t = sinpi(z); ...note that when z>2**112, z is an int + * and hence t=0. + * + * if (t == 0.0) return 1.0/0.0; + * if (t< 0.0) *signgamlp = -1; else t= -t; + * if (z<1.0e-40) ...tiny z + * return -log(z); + * else + * return log(pi/(t*z))-lgamma(z); + * + */ + + t = sinpil(z); /* t := sin(pi*z) */ + if (t == c0) /* return 1.0/0.0 = +INF */ + return c1/c0; + + z = -z; + if (z<=tiny) + p = -logl(z); + else + p = logl(pi/(fabsl(t)*z))-__k_lgammal(z,signgamlp); + if (t<c0) *signgamlp = -1; + return p; +} diff --git a/usr/src/lib/libm/common/Q/__poly_libmq.c b/usr/src/lib/libm/common/Q/__poly_libmq.c new file mode 100644 index 0000000000..a2492754e8 --- /dev/null +++ b/usr/src/lib/libm/common/Q/__poly_libmq.c @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include "libm.h" + +long double +__poly_libmq(long double x, int n, const long double p[]) { + long double t; + int i; + + t = p[n - 1]; + for (i = n - 2; i >= 0; i--) + t = p[i] + x * t; + return (t); +} diff --git a/usr/src/lib/libm/common/Q/__rem_pio2l.c b/usr/src/lib/libm/common/Q/__rem_pio2l.c new file mode 100644 index 0000000000..1ac009edcc --- /dev/null +++ b/usr/src/lib/libm/common/Q/__rem_pio2l.c @@ -0,0 +1,87 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * __rem_pio2l(x,y) + * + * return the remainder of x rem pi/2 in y[0]+y[1] by calling __rem_pio2m + */ + +#ifndef FDLIBM_BASED +#include "libm.h" +extern int __rem_pio2m(double *, double *, int, int, int, const int *); +#else /* FDLIBM_BASED */ +#include "fdlibm.h" +#define __rem_pio2m __kernel_rem_pio2 +#endif /* FDLIBM_BASED */ + +#include "longdouble.h" + +extern const int _TBL_ipio2l_inf[]; + +static const long double + two24l = 16777216.0L, + pio4 = 0.7853981633974483096156608458198757210495L; + +int +__rem_pio2l(long double x, long double *y) { + long double z, w; + double t[5], v[5]; + int e0, i, nx, n, sign; + const int *ipio2; + + sign = signbitl(x); + z = fabsl(x); + if (z <= pio4) { + y[0] = x; + y[1] = 0; + return (0); + } + e0 = ilogbl(z) - 23; + z = scalbnl(z, -e0); + for (i = 0; i < 5; i++) { + t[i] = (double) ((int) (z)); + z = (z - (long double) t[i]) * two24l; + } + nx = 5; + while (t[nx - 1] == 0.0) + nx--; /* skip zero term */ + ipio2 = _TBL_ipio2l_inf; + n = __rem_pio2m(t, v, e0, nx, 3, (const int *) ipio2); + z = (long double) v[2] + (long double) v[1]; + w = (long double) v[0]; + y[0] = z + w; + y[1] = z - (y[0] - w); + if (sign == 1) { + y[0] = -y[0]; + y[1] = -y[1]; + return (-n); + } + return (n); +} diff --git a/usr/src/lib/libm/common/Q/__sincosl.c b/usr/src/lib/libm/common/Q/__sincosl.c new file mode 100644 index 0000000000..f1c72af2db --- /dev/null +++ b/usr/src/lib/libm/common/Q/__sincosl.c @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * long double __k_sincos(long double x, long double y, long double *c); + * kernel sincosl function on [-pi/4, pi/4], pi/4 ~ 0.785398164 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * return sinl(x) with *c = cosl(x) + * + * Table look up algorithm + * see __k_sinl and __k_cosl + */ + +#include "libm.h" + +extern const long double _TBL_sinl_hi[], _TBL_sinl_lo[], + _TBL_cosl_hi[], _TBL_cosl_lo[]; +static const long double + one = 1.0L, +/* + * 3 11 -122.32 + * |sin(x) - (x+pp1*x +...+ pp5*x )| <= 2 for |x|<1/64 + */ + pp1 = -1.666666666666666666666666666586782940810e-0001L, + pp2 = +8.333333333333333333333003723660929317540e-0003L, + pp3 = -1.984126984126984076045903483778337804470e-0004L, + pp4 = +2.755731922361906641319723106210900949413e-0006L, + pp5 = -2.505198398570947019093998469135012057673e-0008L, +/* + * |(sin(x) - (x+p1*x^3+...+p8*x^17)| + * |------------------------------- | <= 2^-116.17 for |x|<0.1953125 + * | x | + */ + p1 = -1.666666666666666666666666666666211262297e-0001L, + p2 = +8.333333333333333333333333301497876908541e-0003L, + p3 = -1.984126984126984126984041302881180621922e-0004L, + p4 = +2.755731922398589064100587351307269621093e-0006L, + p5 = -2.505210838544163129378906953765595393873e-0008L, + p6 = +1.605904383643244375050998243778534074273e-0010L, + p7 = -7.647162722800685516901456114270824622699e-0013L, + p8 = +2.810046428661902961725428841068844462603e-0015L, +/* + * 2 10 -123.84 + * |cos(x) - (1+qq1*x +...+ qq5*x )| <= 2 for |x|<=1/128 + */ + qq1 = -4.999999999999999999999999999999378373641e-0001L, + qq2 = +4.166666666666666666666665478399327703130e-0002L, + qq3 = -1.388888888888888888058211230618051613494e-0003L, + qq4 = +2.480158730156105377771585658905303111866e-0005L, + qq5 = -2.755728099762526325736488376695157008736e-0007L, +/* + * 2 16 -117.11 + * |cos(x) - (1+q1*x + ... + q8*x )| <= 2 for |x|<= 0.15625 + */ + q1 = -4.999999999999999999999999999999756416975e-0001L, + q2 = +4.166666666666666666666666664006066577258e-0002L, + q3 = -1.388888888888888888888877700363937169637e-0003L, + q4 = +2.480158730158730158494468463031814083559e-0005L, + q5 = -2.755731922398586276322819250356005542871e-0007L, + q6 = +2.087675698767424261441959760729854017855e-0009L, + q7 = -1.147074481239662089072452129010790774761e-0011L, + q8 = +4.777761647399651599730663422263531034782e-0014L; + +#define i0 0 + +long double +__k_sincosl(long double x, long double y, long double *c) { + long double a1, a2, t, t1, t2, z, w; + int *pt = (int *) &t, *px = (int *) &x; + int i, j, hx, ix; + + t = 1.0L; + hx = px[i0]; + ix = hx & 0x7fffffff; + if (ix < 0x3ffc4000) { + if (ix < 0x3fc60000) + if (((int) x) == 0) { + *c = one; + return (x); + } /* generate inexact */ + z = x * x; + + if (ix < 0x3ff80000) { + *c = one + z * (qq1 + z * (qq2 + z * (qq3 + + z * (qq4 + z * qq5)))); + t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + + z * (p5 + z * p6))))); + } else { + *c = one + z * (q1 + z * (q2 + z * (q3 + z * (q4 + + z * (q5 + z * (q6 + z * (q7 + z * q8))))))); + t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 + + z * (p6 + z * (p7 + z * p8))))))); + } + + t = y + x * t; + return (x + t); + } + j = (ix + 0x400) & 0x7ffff800; + i = (j - 0x3ffc4000) >> 11; + pt[i0] = j; + if (hx > 0) + x = y - (t - x); + else + x = (-y) - (t + x); + a1 = _TBL_sinl_hi[i]; + z = x * x; + t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); + w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * pp5))))); + a2 = _TBL_cosl_hi[i]; + t2 = _TBL_cosl_lo[i] - (a1 * w - a2 * t); + *c = a2 + t2; + t1 = a2 * w + a1 * t; + t1 += _TBL_sinl_lo[i]; + if (hx < 0) + return (-a1 - t1); + else + return (a1 + t1); +} diff --git a/usr/src/lib/libm/common/Q/__sinl.c b/usr/src/lib/libm/common/Q/__sinl.c new file mode 100644 index 0000000000..de6df8c79c --- /dev/null +++ b/usr/src/lib/libm/common/Q/__sinl.c @@ -0,0 +1,143 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * long double __k_sinl(long double x, long double y); + * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.785398164 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * + * Table look up algorithm + * 1. by sin(-x) = -sin(x), need only to consider positive x + * 2. if x < 25/128 = [0x3ffc9000,0,0,0] = 0.1953125 , then + * if x < 2^-57 (hx < 0x3fc60000,0,0,0), return x (inexact if x != 0) + * z = x*x; + * if x <= 1/64 = 2**-6 + * sin(x) = x + (y+(x*z)*(p1 + z*p2)) + * else + * sin(x) = x + (y+(x*z)*(p1 + z*(p2 + z*(p3 + z*p4)))) + * 3. else + * ht = (hx + 0x400)&0x7ffff800 (round x to a break point t) + * lt = 0 + * i = (hy-0x3ffc4000)>>11; (i<=64) + * x' = (x - t)+y (|x'| ~<= 2^-7 + * By + * sin(t+x') + * = sin(t)cos(x')+cos(t)sin(x') + * = sin(t)(1+z*(qq1+z*qq2))+[cos(t)]*x*(1+z*(pp1+z*pp2)) + * = sin(t) + [sin(t)]*(z*(qq1+z*qq2))+ + * [cos(t)]*x*(1+z*(pp1+z*pp2)) + * + * Thus, + * let a= _TBL_sin_hi[i], b = _TBL_sin_lo[i], c= _TBL_cos_hi[i], + * x = (x-t)+y + * z = x*x; + * sin(t+x) = a+(b+ ((c*x)*(1+z*(pp1+z*pp2))+a*(z*(qq1+z*qq2))) + */ + +#include "libm.h" + +extern const long double _TBL_sinl_hi[], _TBL_sinl_lo[], _TBL_cosl_hi[]; +static const long double +one = 1.0L, +/* + * 3 11 -122.32 + * |sin(x) - (x+pp1*x +...+ pp5*x )| <= 2 for |x|<1/64 + */ + pp1 = -1.666666666666666666666666666586782940810e-0001L, + pp2 = +8.333333333333333333333003723660929317540e-0003L, + pp3 = -1.984126984126984076045903483778337804470e-0004L, + pp4 = +2.755731922361906641319723106210900949413e-0006L, + pp5 = -2.505198398570947019093998469135012057673e-0008L, +/* + * |(sin(x) - (x+p1*x^3+...+p8*x^17)| + * |------------------------------- | <= 2^-116.17 for |x|<0.1953125 + * | x | + */ + p1 = -1.666666666666666666666666666666211262297e-0001L, + p2 = +8.333333333333333333333333301497876908541e-0003L, + p3 = -1.984126984126984126984041302881180621922e-0004L, + p4 = +2.755731922398589064100587351307269621093e-0006L, + p5 = -2.505210838544163129378906953765595393873e-0008L, + p6 = +1.605904383643244375050998243778534074273e-0010L, + p7 = -7.647162722800685516901456114270824622699e-0013L, + p8 = +2.810046428661902961725428841068844462603e-0015L, +/* + * 2 10 -123.84 + * |cos(x) - (1+qq1*x +...+ qq5*x )| <= 2 for |x|<=1/128 + */ + qq1 = -4.999999999999999999999999999999378373641e-0001L, + qq2 = +4.166666666666666666666665478399327703130e-0002L, + qq3 = -1.388888888888888888058211230618051613494e-0003L, + qq4 = +2.480158730156105377771585658905303111866e-0005L, + qq5 = -2.755728099762526325736488376695157008736e-0007L; + +#define i0 0 + +long double +__k_sinl(long double x, long double y) { + long double a, t, z, w; + int *pt = (int *) &t, *px = (int *) &x; + int i, j, hx, ix; + + t = 1.0L; + hx = px[i0]; + ix = hx & 0x7fffffff; + if (ix < 0x3ffc9000) { + *(3 - i0 + (int *) &t) = -1; /* one-ulp */ + *(2 + (int *) &t) = -1; /* one-ulp */ + *(1 + (int *) &t) = -1; /* one-ulp */ + *(i0 + (int *) &t) -= 1; /* one-ulp */ + if (ix < 0x3fc60000) + if (((int) (x * t)) < 1) + return (x); /* inexact and underflow */ + z = x * x; + t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 + + z * (p6 + z * (p7 + z * p8))))))); + t = y + x * t; + return (x + t); + } + j = (ix + 0x400) & 0x7ffff800; + i = (j - 0x3ffc4000) >> 11; + pt[i0] = j; + if (hx > 0) + x = y - (t - x); + else + x = (-y) - (t + x); + a = _TBL_sinl_hi[i]; + z = x * x; + t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); + w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * pp5))))); + t = _TBL_cosl_hi[i] * w + a * t; + t += _TBL_sinl_lo[i]; + if (hx < 0) + return (-a - t); + else + return (a + t); +} diff --git a/usr/src/lib/libm/common/Q/__tanl.c b/usr/src/lib/libm/common/Q/__tanl.c new file mode 100644 index 0000000000..7c80162e2e --- /dev/null +++ b/usr/src/lib/libm/common/Q/__tanl.c @@ -0,0 +1,163 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * long double __k_tanl(long double x; long double y, int k); + * kernel tan/cotan function on [-pi/4, pi/4], pi/4 ~ 0.785398164 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * Input k indicate -- tan if k=0; else -1/tan + * + * Table look up algorithm + * 1. by tan(-x) = -tan(x), need only to consider positive x + * 2. if x < 5/32 = [0x3ffc4000, 0] = 0.15625 , then + * if x < 2^-57 (hx < 0x3fc40000 0), set w=x with inexact if x != 0 + * else + * z = x*x; + * w = x + (y+(x*z)*(t1+z*(t2+z*(t3+z*(t4+z*(t5+z*t6)))))) + * return (k == 0)? w: 1/w; + * 3. else + * ht = (hx + 0x400)&0x7ffff800 (round x to a break point t) + * lt = 0 + * i = (hy-0x3ffc4000)>>11; (i<=64) + * x' = (x - t)+y (|x'| ~<= 2^-7) + * By + * tan(t+x') + * = (tan(t)+tan(x'))/(1-tan(x')tan(t)) + * We have + * sin(x')+tan(t)*(tan(t)*sin(x')) + * = tan(t) + ------------------------------- for k=0 + * cos(x') - tan(t)*sin(x') + * + * cos(x') - tan(t)*sin(x') + * = - -------------------------------------- for k=1 + * tan(t) + tan(t)*(cos(x')-1) + sin(x') + * + * + * where tan(t) is from the table, + * sin(x') = x + pp1*x^3 + ...+ pp5*x^11 + * cos(x') = 1 + qq1*x^2 + ...+ qq5*x^10 + */ + +#include "libm.h" + +extern const long double _TBL_tanl_hi[], _TBL_tanl_lo[]; +static const long double + one = 1.0L, +/* + * 3 11 -122.32 + * |sin(x) - (x+pp1*x +...+ pp5*x )| <= 2 for |x|<1/64 + */ + pp1 = -1.666666666666666666666666666586782940810e-0001L, + pp2 = +8.333333333333333333333003723660929317540e-0003L, + pp3 = -1.984126984126984076045903483778337804470e-0004L, + pp4 = +2.755731922361906641319723106210900949413e-0006L, + pp5 = -2.505198398570947019093998469135012057673e-0008L, +/* + * 2 10 -123.84 + * |cos(x) - (1+qq1*x +...+ qq5*x )| <= 2 for |x|<=1/128 + */ + qq1 = -4.999999999999999999999999999999378373641e-0001L, + qq2 = +4.166666666666666666666665478399327703130e-0002L, + qq3 = -1.388888888888888888058211230618051613494e-0003L, + qq4 = +2.480158730156105377771585658905303111866e-0005L, + qq5 = -2.755728099762526325736488376695157008736e-0007L, +/* + * |tan(x) - (x+t1*x^3+...+t6*x^13)| + * |------------------------------ | <= 2^-59.73 for |x|<0.15625 + * | x | + */ + t1 = +3.333333333333333333333333333333423342490e-0001L, + t2 = +1.333333333333333333333333333093838744537e-0001L, + t3 = +5.396825396825396825396827906318682662250e-0002L, + t4 = +2.186948853615520282185576976994418486911e-0002L, + t5 = +8.863235529902196573354554519991152936246e-0003L, + t6 = +3.592128036572480064652191427543994878790e-0003L, + t7 = +1.455834387051455257856833807581901305474e-0003L, + t8 = +5.900274409318599857829983256201725587477e-0004L, + t9 = +2.391291152117265181501116961901122362937e-0004L, + t10 = +9.691533169382729742394024173194981882375e-0005L, + t11 = +3.927994733186415603228178184225780859951e-0005L, + t12 = +1.588300018848323824227640064883334101288e-0005L, + t13 = +6.916271223396808311166202285131722231723e-0006L; + +#define i0 0 + +long double +__k_tanl(long double x, long double y, int k) { + long double a, t, z, w = 0, s, c; + int *pt = (int *) &t, *px = (int *) &x; + int i, j, hx, ix; + + t = 1.0L; + hx = px[i0]; + ix = hx & 0x7fffffff; + if (ix < 0x3ffc4000) { + *(3 - i0 + (int *) &t) = 1; /* make t = one+ulp */ + if (ix < 0x3fc60000) { + if (((int) (x * t)) < 1) /* generate inexact */ + w = x; /* generate underflow if subnormal */ + } else { + z = x * x; + if (ix < 0x3ff30000) /* 2**-12 */ + t = z * (t1 + z * (t2 + z * (t3 + z * t4))); + else + t = z * (t1 + z * (t2 + z * (t3 + z * (t4 + + z * (t5 + z * (t6 + z * (t7 + z * (t8 + + z * (t9 + z * (t10 + z * (t11 + + z * (t12 + z * t13)))))))))))); + t = y + x * t; + w = x + t; + } + return (k == 0 ? w : -one / w); + } + j = (ix + 0x400) & 0x7ffff800; + i = (j - 0x3ffc4000) >> 11; + pt[i0] = j; + if (hx > 0) + x = y - (t - x); + else + x = (-y) - (t + x); + a = _TBL_tanl_hi[i]; + z = x * x; + /* cos(x)-1 */ + t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); + /* sin(x) */ + s = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * pp5))))); + if (k == 0) { + w = a * s; + t = _TBL_tanl_lo[i] + (s + a * w) / (one - (w - t)); + return (hx < 0 ? -a - t : a + t); + } else { + w = s + a * t; + c = w + _TBL_tanl_lo[i]; + z = one - (a * s - t); + return (hx >= 0 ? z / (-a - c) : z / (a + c)); + } +} diff --git a/usr/src/lib/libm/common/Q/acoshl.c b/usr/src/lib/libm/common/Q/acoshl.c new file mode 100644 index 0000000000..8f6d155fae --- /dev/null +++ b/usr/src/lib/libm/common/Q/acoshl.c @@ -0,0 +1,57 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak acoshl = __acoshl +#endif + +#include "libm.h" + +static const long double + zero = 0.0L, + ln2 = 6.931471805599453094172321214581765680755e-0001L, + one = 1.0L, + big = 1.e+20L; + +long double +acoshl(long double x) { + long double t; + + if (isnanl(x)) + return (x + x); + else if (x > big) + return (logl(x) + ln2); + else if (x > one) { + t = sqrtl(x - one); + return (log1pl(t * (t + sqrtl(x + one)))); + } else if (x == one) + return (zero); + else + return ((x - x) / (x - x)); +} diff --git a/usr/src/lib/libm/common/Q/acosl.c b/usr/src/lib/libm/common/Q/acosl.c new file mode 100644 index 0000000000..b4d77ff4e3 --- /dev/null +++ b/usr/src/lib/libm/common/Q/acosl.c @@ -0,0 +1,67 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * arccosin function + * ________ + * / 1 - x + * acos(x) = 2*atan2( / -------- , 1 ) + * \/ 1 + x + * + * ________ + * / 1 - x + * = 2*atan ( / -------- ) for non-exceptional x. + * \/ 1 + x + * + * Special cases: + * if x is NaN, return x itself; + * if |x|>1, return NaN with invalid signal. + */ + +#pragma weak acosl = __acosl + +#include "libm.h" + +static const long double zero = 0.0L, one = 1.0L; + +long double +acosl(long double x) { + if (isnanl(x)) + return (x + x); + else if (fabsl(x) < one) + x = atanl(sqrtl((one - x) / (one + x))); + else if (x == -one) + x = atan2l(one, zero); /* x <- PI */ + else if (x == one) + x = zero; + else { /* |x| > 1 create invalid signal */ + return (zero / zero); + } + return (x + x); +} diff --git a/usr/src/lib/libm/common/Q/asinhl.c b/usr/src/lib/libm/common/Q/asinhl.c new file mode 100644 index 0000000000..32f9d4b086 --- /dev/null +++ b/usr/src/lib/libm/common/Q/asinhl.c @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak asinhl = __asinhl +#endif + +#include "libm.h" + +static const long double + ln2 = 6.931471805599453094172321214581765680755e-0001L, + one = 1.0L, + big = 1.0e+20L, + tiny = 1.0e-20L; + +long double +asinhl(long double x) { + long double t, w; + volatile long double dummy; + + w = fabsl(x); + if (isnanl(x)) + return (x + x); /* x is NaN */ + if (w < tiny) { +#ifndef lint + dummy = x + big; /* inexact if x != 0 */ +#endif + return (x); /* tiny x */ + } else if (w < big) { + t = one / w; + return (copysignl(log1pl(w + w / (t + sqrtl(one + t * t))), x)); + } else + return (copysignl(logl(w) + ln2, x)); +} diff --git a/usr/src/lib/libm/common/Q/asinl.c b/usr/src/lib/libm/common/Q/asinl.c new file mode 100644 index 0000000000..8594a2195b --- /dev/null +++ b/usr/src/lib/libm/common/Q/asinl.c @@ -0,0 +1,78 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak asinl = __asinl +#endif + +/* + * asinl(x) = atan2l(x,sqrt(1-x*x)); + * + * For better accuracy, 1-x*x is computed as follows + * 1-x*x if x < 0.5, + * 2*(1-|x|)-(1-|x|)*(1-|x|) if x >= 0.5. + * + * Special cases: + * if x is NaN, return x itself; + * if |x|>1, return NaN with invalid signal. + */ + +#include "libm.h" + +static const long double zero = 0.0L, small = 1.0e-20L, half = 0.5L, one = 1.0L; +#ifndef lint +static const long double big = 1.0e+20L; +#endif + +long double +asinl(long double x) { + long double t, w; + volatile long double dummy; + + w = fabsl(x); + if (isnanl(x)) + return (x + x); + else if (w <= half) { + if (w < small) { +#ifndef lint + dummy = w + big; + /* inexact if w != 0 */ +#endif + return (x); + } else + return (atanl(x / sqrtl(one - x * x))); + } else if (w < one) { + t = one - w; + w = t + t; + return (atanl(x / sqrtl(w - t * t))); + } else if (w == one) + return (atan2l(x, zero)); /* asin(+-1) = +- PI/2 */ + else + return (zero / zero); /* |x| > 1: invalid */ +} diff --git a/usr/src/lib/libm/common/Q/atan2l.c b/usr/src/lib/libm/common/Q/atan2l.c new file mode 100644 index 0000000000..d7a538cd2b --- /dev/null +++ b/usr/src/lib/libm/common/Q/atan2l.c @@ -0,0 +1,160 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * atan2l(y,x) + * + * Method : + * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). + * 2. Reduce x to positive by (if x and y are unexceptional): + * ARG (x+iy) = arctan(y/x) ... if x > 0, + * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, + * + * Special cases: + * + * ATAN2((anything), NaN ) is NaN; + * ATAN2(NAN , (anything) ) is NaN; + * ATAN2(+-0, +(anything but NaN)) is +-0 ; + * ATAN2(+-0, -(anything but NaN)) is +-PI ; + * ATAN2(+-(anything but 0 and NaN), 0) is +-PI/2; + * ATAN2(+-(anything but INF and NaN), +INF) is +-0 ; + * ATAN2(+-(anything but INF and NaN), -INF) is +-PI; + * ATAN2(+-INF,+INF ) is +-PI/4 ; + * ATAN2(+-INF,-INF ) is +-3PI/4; + * ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-PI/2; + * + * Constants: + * The hexadecimal values are the intended ones for the following constants. + * The decimal values may be used, provided that the compiler will convert + * from decimal to binary accurately enough to produce the hexadecimal values + * shown. + */ + +#pragma weak atan2l = __atan2l + +#include "libm.h" +#include "longdouble.h" + +static const long double + zero = 0.0L, + tiny = 1.0e-40L, + one = 1.0L, + half = 0.5L, + PI3o4 = 2.356194490192344928846982537459627163148L, + PIo4 = 0.785398163397448309615660845819875721049L, + PIo2 = 1.570796326794896619231321691639751442099L, + PI = 3.141592653589793238462643383279502884197L, + PI_lo = 8.671810130123781024797044026043351968762e-35L; + +long double +atan2l(long double y, long double x) { + long double t, z; + int k, m, signy, signx; + + if (x != x || y != y) + return (x + y); /* return NaN if x or y is NAN */ + signy = signbitl(y); + signx = signbitl(x); + if (x == one) + return (atanl(y)); + m = signy + signx + signx; + + /* when y = 0 */ + if (y == zero) + switch (m) { + case 0: + return (y); /* atan(+0,+anything) */ + case 1: + return (y); /* atan(-0,+anything) */ + case 2: + return (PI + tiny); /* atan(+0,-anything) */ + case 3: + return (-PI - tiny); /* atan(-0,-anything) */ + } + + /* when x = 0 */ + if (x == zero) + return (signy == 1 ? -PIo2 - tiny : PIo2 + tiny); + + /* when x is INF */ + if (!finitel(x)) { + if (!finitel(y)) { + switch (m) { + case 0: + return (PIo4 + tiny); /* atan(+INF,+INF) */ + case 1: + return (-PIo4 - tiny); /* atan(-INF,+INF) */ + case 2: + return (PI3o4 + tiny); /* atan(+INF,-INF) */ + case 3: + return (-PI3o4 - tiny); /* atan(-INF,-INF) */ + } + } else { + switch (m) { + case 0: + return (zero); /* atan(+...,+INF) */ + case 1: + return (-zero); /* atan(-...,+INF) */ + case 2: + return (PI + tiny); /* atan(+...,-INF) */ + case 3: + return (-PI - tiny); /* atan(-...,-INF) */ + } + } + } + /* when y is INF */ + if (!finitel(y)) + return (signy == 1 ? -PIo2 - tiny : PIo2 + tiny); + + /* compute y/x */ + x = fabsl(x); + y = fabsl(y); + t = PI_lo; + k = (ilogbl(y) - ilogbl(x)); + + if (k > 120) + z = PIo2 + half * t; + else if (m > 1 && k < -120) + z = zero; + else + z = atanl(y / x); + + switch (m) { + case 0: + return (z); /* atan(+,+) */ + case 1: + return (-z); /* atan(-,+) */ + case 2: + return (PI - (z - t)); /* atan(+,-) */ + case 3: + return ((z - t) - PI); /* atan(-,-) */ + } + /* NOTREACHED */ + return 0.0L; +} diff --git a/usr/src/lib/libm/common/Q/atan2pil.c b/usr/src/lib/libm/common/Q/atan2pil.c new file mode 100644 index 0000000000..28b31e2ed9 --- /dev/null +++ b/usr/src/lib/libm/common/Q/atan2pil.c @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak atan2pil = __atan2pil + +#include "libm.h" + +/* + * atan2pil(y,x) = atan2l(y, x) / pi + */ + +static const long double invpi = 3.183098861837906715377675267450287240689e-1L; + +long double +atan2pil(long double y, long double x) { + return (atan2l(y, x) * invpi); +} diff --git a/usr/src/lib/libm/common/Q/atanhl.c b/usr/src/lib/libm/common/Q/atanhl.c new file mode 100644 index 0000000000..f7462ca1ef --- /dev/null +++ b/usr/src/lib/libm/common/Q/atanhl.c @@ -0,0 +1,61 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak atanhl = __atanhl + +#include "libm.h" + +/* + * 1 2x x + * atanhl(x) = --- * LOG(1 + -------) = 0.5 * log1pl(2 * --------) + * 2 1 - x 1 - x + * Note: to guarantee atanhl(-x) = -atanhl(x), we use + * sign(x) |x| + * atanhl(x) = ------- * log1pl(2*-------). + * 2 1 - |x| + * + * Special cases: + * atanhl(x) is NaN if |x| > 1 with signal; + * atanhl(NaN) is that NaN with no signal; + * atanhl(+-1) is +-INF with signal. + * + */ + +static const long double zero = 0.0L, half = 0.5L, one = 1.0L; + +long double +atanhl(long double x) { + long double t; + + t = fabsl(x); + if (t == one) + return (x / zero); + t = t / (one - t); + return (copysignl(half, x) * log1pl(t + t)); +} diff --git a/usr/src/lib/libm/common/Q/atanl.c b/usr/src/lib/libm/common/Q/atanl.c new file mode 100644 index 0000000000..10b6b71daf --- /dev/null +++ b/usr/src/lib/libm/common/Q/atanl.c @@ -0,0 +1,209 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak atanl = __atanl + +/* + * atanl(x) + * Table look-up algorithm + * By K.C. Ng, March 9, 1989 + * + * Algorithm. + * + * The algorithm is based on atan(x)=atan(y)+atan((x-y)/(1+x*y)). + * We use poly1(x) to approximate atan(x) for x in [0,1/8] with + * error (relative) + * |(atan(x)-poly1(x))/x|<= 2^-115.94 long double + * |(atan(x)-poly1(x))/x|<= 2^-58.85 double + * |(atan(x)-poly1(x))/x|<= 2^-25.53 float + * and use poly2(x) to approximate atan(x) for x in [0,1/65] with + * error (absolute) + * |atan(x)-poly2(x)|<= 2^-122.15 long double + * |atan(x)-poly2(x)|<= 2^-64.79 double + * |atan(x)-poly2(x)|<= 2^-35.36 float + * Here poly1 and poly2 are odd polynomial with the following form: + * x + x^3*(a1+x^2*(a2+...)) + * + * (0). Purge off Inf and NaN and 0 + * (1). Reduce x to positive by atan(x) = -atan(-x). + * (2). For x <= 1/8, use + * (2.1) if x < 2^(-prec/2-2), atan(x) = x with inexact + * (2.2) Otherwise + * atan(x) = poly1(x) + * (3). For x >= 8 then + * (3.1) if x >= 2^(prec+2), atan(x) = atan(inf) - pio2lo + * (3.2) if x >= 2^(prec/3+2), atan(x) = atan(inf) - 1/x + * (3.3) if x > 65, atan(x) = atan(inf) - poly2(1/x) + * (3.4) Otherwise, atan(x) = atan(inf) - poly1(1/x) + * + * (4). Now x is in (0.125, 8) + * Find y that match x to 4.5 bit after binary (easy). + * If iy is the high word of y, then + * single : j = (iy - 0x3e000000) >> 19 + * double : j = (iy - 0x3fc00000) >> 16 + * quad : j = (iy - 0x3ffc0000) >> 12 + * + * Let s = (x-y)/(1+x*y). Then + * atan(x) = atan(y) + poly1(s) + * = _TBL_atanl_hi[j] + (_TBL_atanl_lo[j] + poly2(s) ) + * + * Note. |s| <= 1.5384615385e-02 = 1/65. Maxium occurs at x = 1.03125 + * + */ + +#include "libm.h" + +extern const long double _TBL_atanl_hi[], _TBL_atanl_lo[]; +static const long double + one = 1.0L, + p1 = -3.333333333333333333333333333331344526118e-0001L, + p2 = 1.999999999999999999999999989931277668570e-0001L, + p3 = -1.428571428571428571428553606221309530901e-0001L, + p4 = 1.111111111111111111095219842737139747418e-0001L, + p5 = -9.090909090909090825503603835248061123323e-0002L, + p6 = 7.692307692307664052130743214708925258904e-0002L, + p7 = -6.666666666660213835187713228363717388266e-0002L, + p8 = 5.882352940152439399097283359608661949504e-0002L, + p9 = -5.263157780447533993046614040509529668487e-0002L, + p10 = 4.761895816878184933175855990886788439447e-0002L, + p11 = -4.347345005832274022681019724553538135922e-0002L, + p12 = 3.983031914579635037502589204647752042736e-0002L, + p13 = -3.348206704469830575196657749413894897554e-0002L, + q1 = -3.333333333333333333333333333195273650186e-0001L, + q2 = 1.999999999999999999999988146114392615808e-0001L, + q3 = -1.428571428571428571057630319435467111253e-0001L, + q4 = 1.111111111111105373263048208994541544098e-0001L, + q5 = -9.090909090421834209167373258681021816441e-0002L, + q6 = 7.692305377813692706850171767150701644539e-0002L, + q7 = -6.660896644393861499914731734305717901330e-0002L, + pio2hi = 1.570796326794896619231321691639751398740e+0000L, + pio2lo = 4.335905065061890512398522013021675984381e-0035L; + +#define i0 0 +#define i1 3 + +long double +atanl(long double x) { + long double y, z, r, p, s; + int *px = (int *) &x, *py = (int *) &y; + int ix, iy, sign, j; + + ix = px[i0]; + sign = ix & 0x80000000; + ix ^= sign; + + /* for |x| < 1/8 */ + if (ix < 0x3ffc0000) { + if (ix < 0x3feb0000) { /* when |x| < 2**(-prec/6-2) */ + if (ix < 0x3fc50000) { /* if |x| < 2**(-prec/2-2) */ + s = one; + *(3 - i0 + (int *) &s) = -1; /* s = 1-ulp */ + *(1 + (int *) &s) = -1; + *(2 + (int *) &s) = -1; + *(i0 + (int *) &s) -= 1; + if ((int) (s * x) < 1) + return (x); /* raise inexact */ + } + z = x * x; + if (ix < 0x3fe20000) { /* if |x| < 2**(-prec/4-1) */ + return (x + (x * z) * p1); + } else { /* if |x| < 2**(-prec/6-2) */ + return (x + (x * z) * (p1 + z * p2)); + } + } + z = x * x; + return (x + (x * z) * (p1 + z * (p2 + z * (p3 + z * (p4 + + z * (p5 + z * (p6 + z * (p7 + z * (p8 + z * (p9 + + z * (p10 + z * (p11 + z * (p12 + z * p13))))))))))))); + } + + /* for |x| >= 8.0 */ + if (ix >= 0x40020000) { + px[i0] = ix; + if (ix < 0x40050400) { /* x < 65 */ + r = one / x; + z = r * r; + /* + * poly1 + */ + y = r * (one + z * (p1 + z * (p2 + z * (p3 + + z * (p4 + z * (p5 + z * (p6 + z * (p7 + + z * (p8 + z * (p9 + z * (p10 + z * (p11 + + z * (p12 + z * p13))))))))))))); + y -= pio2lo; + } else if (ix < 0x40260000) { /* x < 2**(prec/3+2) */ + r = one / x; + z = r * r; + /* + * poly2 + */ + y = r * (one + z * (q1 + z * (q2 + z * (q3 + z * (q4 + + z * (q5 + z * (q6 + z * q7))))))); + y -= pio2lo; + } else if (ix < 0x40720000) { /* x < 2**(prec+2) */ + y = one / x - pio2lo; + } else if (ix < 0x7fff0000) { /* x < inf */ + y = -pio2lo; + } else { /* x is inf or NaN */ + if (((ix - 0x7fff0000) | px[1] | px[2] | px[i1]) != 0) + return (x - x); + y = -pio2lo; + } + + if (sign == 0) + return (pio2hi - y); + else + return (y - pio2hi); + } + + /* now x is between 1/8 and 8 */ + px[i0] = ix; + iy = (ix + 0x00000800) & 0x7ffff000; + py[i0] = iy; + py[1] = py[2] = py[i1] = 0; + j = (iy - 0x3ffc0000) >> 12; + + if (sign == 0) + s = (x - y) / (one + x * y); + else + s = (y - x) / (one + x * y); + z = s * s; + if (ix == iy) + p = s * (one + z * (q1 + z * (q2 + z * (q3 + z * q4)))); + else + p = s * (one + z * (q1 + z * (q2 + z * (q3 + z * (q4 + + z * (q5 + z * (q6 + z * q7))))))); + if (sign == 0) { + r = p + _TBL_atanl_lo[j]; + return (r + _TBL_atanl_hi[j]); + } else { + r = p - _TBL_atanl_lo[j]; + return (r - _TBL_atanl_hi[j]); + } +} diff --git a/usr/src/lib/libm/common/Q/cbrtl.c b/usr/src/lib/libm/common/Q/cbrtl.c new file mode 100644 index 0000000000..274fa24430 --- /dev/null +++ b/usr/src/lib/libm/common/Q/cbrtl.c @@ -0,0 +1,70 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak cbrtl = __cbrtl + +#include "libm.h" +#include "longdouble.h" + +#define n0 0 + +long double +cbrtl(long double x) { + long double s, t, r, w, y; + double dx, dy; + int *py = (int *) &dy; + int n, m, m3, sx; + + if (!finitel(x)) + return (x + x); + if (iszerol(x)) + return (x); + sx = signbitl(x); + x = fabsl(x); + n = ilogbl(x); + m = n / 3; + m3 = m + m + m; + y = scalbnl(x, -m3); + dx = (double) y; + dy = cbrt(dx); + py[1 - n0] += 2; + if (py[1 - n0] == 0) + py[n0] += 1; + + /* one step newton iteration to 113 bits with error < 0.667ulps */ + t = (long double) dy; + t = scalbnl(t, m); + s = t * t; + r = x / s; + w = t + t; + r = (r - t) / (w + r); + t += t * r; + + return (sx == 0 ? t : -t); +} diff --git a/usr/src/lib/libm/common/Q/copysignl.c b/usr/src/lib/libm/common/Q/copysignl.c new file mode 100644 index 0000000000..97c758d303 --- /dev/null +++ b/usr/src/lib/libm/common/Q/copysignl.c @@ -0,0 +1,43 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak copysignl = __copysignl +#endif + +#include "libm.h" + +long double +copysignl(long double x, long double y) { + int *px = (int *) &x; + int *py = (int *) &y; + + px[HIXWORD] = (px[HIXWORD] & ~XSGNMSK) | (py[HIXWORD] & XSGNMSK); + return (x); +} diff --git a/usr/src/lib/libm/common/Q/coshl.c b/usr/src/lib/libm/common/Q/coshl.c new file mode 100644 index 0000000000..5187f9dbcf --- /dev/null +++ b/usr/src/lib/libm/common/Q/coshl.c @@ -0,0 +1,107 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak coshl = __coshl + +#include "libm.h" +#include "longdouble.h" + + +/* + * coshl(X) + * RETURN THE HYPERBOLIC COSINE OF X + * + * Method : + * 1. Replace x by |x| (coshl(x) = coshl(-x)). + * 2. + * [ expl(x) - 1 ]^2 + * 0 <= x <= 0.3465 : coshl(x) := 1 + ------------------- + * 2*expl(x) + * + * expl(x) + 1/expl(x) + * 0.3465 <= x <= thresh : coshl(x) := ------------------- + * 2 + * thresh <= x <= lnovft : coshl(x) := expl(x)/2 + * lnovft <= x < INF : coshl(x) := scalbnl(expl(x-1024*ln2),1023) + * + * here + * thr1 a number that is near one half of ln2. + * thr2 a number such that + * expl(thresh)+expl(-thresh)=expl(thresh) + * lnovft: logrithm of the overflow threshold + * = MEP1*ln2 chopped to machine precision. + * ME maximum exponent + * MEP1 maximum exponent plus 1 + * + * Special cases: + * coshl(x) is |x| if x is +INF, -INF, or NaN. + * only coshl(0)=1 is exact for finite x. + */ + +#define ME 16383 +#define MEP1 16384 +#define LNOVFT 1.135652340629414394949193107797076342845e+4L + /* last 32 bits of LN2HI is zero */ +#define LN2HI 6.931471805599453094172319547495844850203e-0001L +#define LN2LO 1.667085920830552208890449330400379754169e-0025L +#define THR1 0.3465L +#define THR2 45.L + +static const long double + half = 0.5L, + tinyl = 7.5e-37L, + one = 1.0L, + ln2hi = LN2HI, + ln2lo = LN2LO, + lnovftL = LNOVFT, + thr1 = THR1, + thr2 = THR2; + +long double +coshl(long double x) { + long double t, w; + + w = fabsl(x); + if (!finitel(w)) + return (w + w); /* x is INF or NaN */ + if (w < thr1) { + t = w < tinyl ? w : expm1l(w); + w = one + t; + if (w != one) + w = one + (t * t) / (w + w); + return (w); + } else if (w < thr2) { + t = expl(w); + return (half * (t + one / t)); + } else if (w <= lnovftL) + return (half * expl(w)); + else { + return (scalbnl(expl((w - MEP1 * ln2hi) - MEP1 * ln2lo), ME)); + } +} diff --git a/usr/src/lib/libm/common/Q/cosl.c b/usr/src/lib/libm/common/Q/cosl.c new file mode 100644 index 0000000000..bea6b35b37 --- /dev/null +++ b/usr/src/lib/libm/common/Q/cosl.c @@ -0,0 +1,94 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * cosl(x) + * Table look-up algorithm by K.C. Ng, November, 1989. + * + * kernel function: + * __k_sinl ... sin function on [-pi/4,pi/4] + * __k_cosl ... cos function on [-pi/4,pi/4] + * __rem_pio2l ... argument reduction routine + * + * Method. + * Let S and C denote the sin and cos respectively on [-PI/4, +PI/4]. + * 1. Assume the argument x is reduced to y1+y2 = x-k*pi/2 in + * [-pi/2 , +pi/2], and let n = k mod 4. + * 2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C S/C + * 1 C -S -C/S + * 2 -S -C S/C + * 3 -C S -C/S + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * computer TRIG(x) returns trig(x) nearly rounded. + */ + +#pragma weak cosl = __cosl + +#include "libm.h" +#include "longdouble.h" + +long double +cosl(long double x) { + long double y[2], z = 0.0L; + int n, ix; + + ix = *(int *) &x; /* High word of x */ + + ix &= 0x7fffffff; + if (ix <= 0x3ffe9220) /* |x| ~< pi/4 */ + return (__k_cosl(x, z)); + else if (ix >= 0x7fff0000) /* trig(Inf or NaN) is NaN */ + return (x - x); + else { /* argument reduction needed */ + n = __rem_pio2l(x, y); + switch (n & 3) { + case 0: + return (__k_cosl(y[0], y[1])); + case 1: + return (-__k_sinl(y[0], y[1])); + case 2: + return (-__k_cosl(y[0], y[1])); + case 3: + return (__k_sinl(y[0], y[1])); + } + } + /* NOTREACHED */ + return 0.0L; +} diff --git a/usr/src/lib/libm/common/Q/erfl.c b/usr/src/lib/libm/common/Q/erfl.c new file mode 100644 index 0000000000..4ec7b83eb5 --- /dev/null +++ b/usr/src/lib/libm/common/Q/erfl.c @@ -0,0 +1,366 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * long double function erf,erfc (long double x) + * K.C. Ng, September, 1989. + * x + * 2 |\ + * erf(x) = --------- | exp(-t*t)dt + * sqrt(pi) \| + * 0 + * + * erfc(x) = 1-erf(x) + * + * method: + * Since erf(-x) = -erf(x), we assume x>=0. + * For x near 0, we have the expansion + * + * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....). + * + * Since 2/sqrt(pi) = 1.128379167095512573896158903121545171688, + * we use x + x*P(x^2) to approximate erf(x). This formula will + * guarantee the error less than one ulp where x is not too far + * away from 0. We note that erf(x)=x at x = 0.6174...... After + * some experiment, we choose the following approximation on + * interval [0,0.84375]. + * + * For x in [0,0.84375] + * 2 2 4 40 + * P = P(x ) = (p0 + p1 * x + p2 * x + ... + p20 * x ) + * + * erf(x) = x + x*P + * erfc(x) = 1 - erf(x) if x<=0.25 + * = 0.5 + ((0.5-x)-x*P) if x in [0.25,0.84375] + * precision: |P(x^2)-(erf(x)-x)/x| <= 2**-122.50 + * + * For x in [0.84375,1.25], let s = x - 1, and + * c = 0.84506291151 rounded to single (24 bits) + * erf(x) = c + P1(s)/Q1(s) + * erfc(x) = (1-c) - P1(s)/Q1(s) + * precision: |P1/Q1 - (erf(x)-c)| <= 2**-118.41 + * + * + * For x in [1.25,1.75], let s = x - 1.5, and + * c = 0.95478588343 rounded to single (24 bits) + * erf(x) = c + P2(s)/Q2(s) + * erfc(x) = (1-c) - P2(s)/Q2(s) + * precision: |P1/Q1 - (erf(x)-c)| <= 2**-123.83 + * + * + * For x in [1.75,16/3] + * erfc(x) = exp(-x*x)*(1/x)*R1(1/x)/S1(1/x) + * erf(x) = 1 - erfc(x) + * precision: absolute error of R1/S1 is bounded by 2**-124.03 + * + * For x in [16/3,107] + * erfc(x) = exp(-x*x)*(1/x)*R2(1/x)/S2(1/x) + * erf(x) = 1 - erfc(x) (if x>=9 simple return erf(x)=1 with inexact) + * precision: absolute error of R2/S2 is bounded by 2**-120.07 + * + * Else if inf > x >= 107 + * erf(x) = 1 with inexact + * erfc(x) = 0 with underflow + * + * Special case: + * erf(inf) = 1 + * erfc(inf) = 0 + */ + +#pragma weak erfl = __erfl +#pragma weak erfcl = __erfcl + +#include "libm.h" +#include "longdouble.h" + +static const long double + tiny = 1e-40L, + nearunfl = 1e-4000L, + half = 0.5L, + one = 1.0L, + onehalf = 1.5L, + L16_3 = 16.0L/3.0L; +/* + * Coefficients for even polynomial P for erf(x)=x+x*P(x^2) on [0,0.84375] + */ +static const long double P[] = { /* 21 coeffs */ + 1.283791670955125738961589031215451715556e-0001L, + -3.761263890318375246320529677071815594603e-0001L, + 1.128379167095512573896158903121205899135e-0001L, + -2.686617064513125175943235483344625046092e-0002L, + 5.223977625442187842111846652980454568389e-0003L, + -8.548327023450852832546626271083862724358e-0004L, + 1.205533298178966425102164715902231976672e-0004L, + -1.492565035840625097674944905027897838996e-0005L, + 1.646211436588924733604648849172936692024e-0006L, + -1.636584469123491976815834704799733514987e-0007L, + 1.480719281587897445302529007144770739305e-0008L, + -1.229055530170782843046467986464722047175e-0009L, + 9.422759064320307357553954945760654341633e-0011L, + -6.711366846653439036162105104991433380926e-0012L, + 4.463224090341893165100275380693843116240e-0013L, + -2.783513452582658245422635662559779162312e-0014L, + 1.634227412586960195251346878863754661546e-0015L, + -9.060782672889577722765711455623117802795e-0017L, + 4.741341801266246873412159213893613602354e-0018L, + -2.272417596497826188374846636534317381203e-0019L, + 8.069088733716068462496835658928566920933e-0021L, +}; + +/* + * Rational erf(x) = ((float)0.84506291151) + P1(x-1)/Q1(x-1) on [0.84375,1.25] + */ +static const long double C1 = (long double)((float)0.84506291151); +static const long double P1[] = { /* 12 top coeffs */ + -2.362118560752659955654364917390741930316e-0003L, + 4.129623379624420034078926610650759979146e-0001L, + -3.973857505403547283109417923182669976904e-0002L, + 4.357503184084022439763567513078036755183e-0002L, + 8.015593623388421371247676683754171456950e-0002L, + -1.034459310403352486685467221776778474602e-0002L, + 5.671850295381046679675355719017720821383e-0003L, + 1.219262563232763998351452194968781174318e-0003L, + 5.390833481581033423020320734201065475098e-0004L, + -1.978853912815115495053119023517805528300e-0004L, + 6.184234513953600118335017885706420552487e-0005L, + -5.331802711697810861017518515816271808286e-0006L, +}; +static const long double Q1[] = { /* 12 bottom coeffs with leading 1.0 hidden */ + 9.081506296064882195280178373107623196655e-0001L, + 6.821049531968204097604392183650687642520e-0001L, + 4.067869178233539502315055970743271822838e-0001L, + 1.702332233546316765818144723063881095577e-0001L, + 7.498098377690553934266423088708614219356e-0002L, + 2.050154396918178697056927234366372760310e-0002L, + 7.012988534031999899054782333851905939379e-0003L, + 1.149904787014400354649843451234570731076e-0003L, + 3.185620255011299476196039491205159718620e-0004L, + 1.273405072153008775426376193374105840517e-0005L, + 4.753866999959432971956781228148402971454e-0006L, + -1.002287602111660026053981728549540200683e-0006L, +}; +/* + * Rational erf(x) = ((float)0.95478588343) + P2(x-1.5)/Q2(x-1.5) + * on [1.25,1.75] + */ +static const long double C2 = (long double)((float)0.95478588343); +static const long double P2[] = { /* 12 top coeffs */ + 1.131926304864446730135126164594785863512e-0002L, + 1.273617996967754151544330055186210322832e-0001L, + -8.169980734667512519897816907190281143423e-0002L, + 9.512267486090321197833634271787944271746e-0002L, + -2.394251569804872160005274999735914368170e-0002L, + 1.108768660227528667525252333184520222905e-0002L, + 3.527435492933902414662043314373277494221e-0004L, + 4.946116273341953463584319006669474625971e-0004L, + -4.289851942513144714600285769022420962418e-0005L, + 8.304719841341952705874781636002085119978e-0005L, + -1.040460226177309338781902252282849903189e-0005L, + 2.122913331584921470381327583672044434087e-0006L, +}; +static const long double Q2[] = { /* 13 bottom coeffs with leading 1.0 hidden */ + 7.448815737306992749168727691042003832150e-0001L, + 7.161813850236008294484744312430122188043e-0001L, + 3.603134756584225766144922727405641236121e-0001L, + 1.955811609133766478080550795194535852653e-0001L, + 7.253059963716225972479693813787810711233e-0002L, + 2.752391253757421424212770221541238324978e-0002L, + 7.677654852085240257439050673446546828005e-0003L, + 2.141102244555509687346497060326630061069e-0003L, + 4.342123013830957093949563339130674364271e-0004L, + 8.664587895570043348530991997272212150316e-0005L, + 1.109201582511752087060167429397033701988e-0005L, + 1.357834375781831062713347000030984364311e-0006L, + 4.957746280594384997273090385060680016451e-0008L, +}; +/* + * erfc(x) = exp(-x*x)/x * R1(1/x)/S1(1/x) on [1.75, 16/3] + */ +static const long double R1[] = { /* 14 top coeffs */ + 4.630195122654315016370705767621550602948e+0006L, + 1.257949521746494830700654204488675713628e+0007L, + 1.704153822720260272814743497376181625707e+0007L, + 1.502600568706061872381577539537315739943e+0007L, + 9.543710793431995284827024445387333922861e+0006L, + 4.589344808584091011652238164935949522427e+0006L, + 1.714660662941745791190907071920671844289e+0006L, + 5.034802147768798894307672256192466283867e+0005L, + 1.162286400443554670553152110447126850725e+0005L, + 2.086643834548901681362757308058660399137e+0004L, + 2.839793161868140305907004392890348777338e+0003L, + 2.786687241658423601778258694498655680778e+0002L, + 1.779177837102695602425897452623985786464e+0001L, + 5.641895835477470769043614623819144434731e-0001L, +}; +static const long double S1[] = { /* 15 bottom coeffs with leading 1.0 hidden */ + 4.630195122654331529595606896287596843110e+0006L, + 1.780411093345512024324781084220509055058e+0007L, + 3.250113097051800703707108623715776848283e+0007L, + 3.737857099176755050912193712123489115755e+0007L, + 3.029787497516578821459174055870781168593e+0007L, + 1.833850619965384765005769632103205777227e+0007L, + 8.562719999736915722210391222639186586498e+0006L, + 3.139684562074658971315545539760008136973e+0006L, + 9.106421313731384880027703627454366930945e+0005L, + 2.085108342384266508613267136003194920001e+0005L, + 3.723126272693120340730491416449539290600e+0004L, + 5.049169878567344046145695360784436929802e+0003L, + 4.944274532748010767670150730035392093899e+0002L, + 3.153510608818213929982940249162268971412e+0001L, + 1.0e00L, +}; + +/* + * erfc(x) = exp(-x*x)/x * R2(1/x)/S2(1/x) on [16/3, 107] + */ +static const long double R2[] = { /* 15 top coeffs in reverse order!!*/ + 2.447288012254302966796326587537136931669e+0005L, + 8.768592567189861896653369912716538739016e+0005L, + 1.552293152581780065761497908005779524953e+0006L, + 1.792075924835942935864231657504259926729e+0006L, + 1.504001463155897344947500222052694835875e+0006L, + 9.699485556326891411801230186016013019935e+0005L, + 4.961449933661807969863435013364796037700e+0005L, + 2.048726544693474028061176764716228273791e+0005L, + 6.891532964330949722479061090551896886635e+0004L, + 1.888014709010307507771964047905823237985e+0004L, + 4.189692064988957745054734809642495644502e+0003L, + 7.362346487427048068212968889642741734621e+0002L, + 9.980359714211411423007641056580813116207e+0001L, + 9.426910895135379181107191962193485174159e+0000L, + 5.641895835477562869480794515623601280429e-0001L, +}; +static const long double S2[] = { /* 16 coefficients */ + 2.447282203601902971246004716790604686880e+0005L, + 1.153009852759385309367759460934808489833e+0006L, + 2.608580649612639131548966265078663384849e+0006L, + 3.766673917346623308850202792390569025740e+0006L, + 3.890566255138383910789924920541335370691e+0006L, + 3.052882073900746207613166259994150527732e+0006L, + 1.885574519970380988460241047248519418407e+0006L, + 9.369722034759943185851450846811445012922e+0005L, + 3.792278350536686111444869752624492443659e+0005L, + 1.257750606950115799965366001773094058720e+0005L, + 3.410830600242369370645608634643620355058e+0004L, + 7.513984469742343134851326863175067271240e+0003L, + 1.313296320593190002554779998138695507840e+0003L, + 1.773972700887629157006326333696896516769e+0002L, + 1.670876451822586800422009013880457094162e+0001L, + 1.000L, +}; + +long double erfl(x) +long double x; +{ + long double s,y,t; + + if (!finitel(x)) { + if (x != x) return x+x; /* NaN */ + return copysignl(one,x); /* return +-1.0 is x=Inf */ + } + + y = fabsl(x); + if (y <= 0.84375L) { + if (y<=tiny) return x+P[0]*x; + s = y*y; + t = __poly_libmq(s,21,P); + return x+x*t; + } + if (y<=1.25L) { + s = y-one; + t = C1+__poly_libmq(s,12,P1)/(one+s*__poly_libmq(s,12,Q1)); + return (signbitl(x))? -t: t; + } else if (y<=1.75L) { + s = y-onehalf; + t = C2+__poly_libmq(s,12,P2)/(one+s*__poly_libmq(s,13,Q2)); + return (signbitl(x))? -t: t; + } + if (y<=9.0L) t = erfcl(y); else t = tiny; + return (signbitl(x))? t-one: one-t; +} + +long double erfcl(x) +long double x; +{ + long double s,y,t; + + if (!finitel(x)) { + if (x != x) return x+x; /* NaN */ + /* return 2.0 if x= -inf; 0.0 if x= +inf */ + if (x < 0.0L) return 2.0L; else return 0.0L; + } + + if (x <= 0.84375L) { + if (x<=0.25) return one-erfl(x); + s = x*x; + t = half-x; + t = t - x*__poly_libmq(s,21,P); + return half+t; + } + if (x<=1.25L) { + s = x-one; + t = one-C1; + return t - __poly_libmq(s,12,P1)/(one+s*__poly_libmq(s,12,Q1)); + } else if (x<=1.75L) { + s = x-onehalf; + t = one-C2; + return t - __poly_libmq(s,12,P2)/(one+s*__poly_libmq(s,13,Q2)); + } + if (x>=107.0L) return nearunfl*nearunfl; /* underflow */ + else if (x >= L16_3) { + y = __poly_libmq(x,15,R2); + t = y/__poly_libmq(x,16,S2); + } else { + y = __poly_libmq(x,14,R1); + t = y/__poly_libmq(x,15,S1); + } + /* + * Note that exp(-x*x+d) = exp(-x*x)*exp(d), so to compute + * exp(-x*x) with a small relative error, we need to compute + * -x*x with a small absolute error. To this end, we set y + * equal to the leading part of x but with enough trailing + * zeros that y*y can be computed exactly and we rewrite x*x + * as y*y + (x-y)*(x+y), distributing the latter expression + * across the exponential. + * + * We could construct y in a portable way by setting + * + * int i = (int)(x * ptwo); + * y = (long double)i * 1/ptwo; + * + * where ptwo is some power of two large enough to make x-y + * small but not so large that the conversion to int overflows. + * When long double arithmetic is slow, however, the following + * non-portable code is preferable. + */ + y = x; + *(2+(int*)&y) = *(3+(int*)&y) = 0; + t *= expl(-y*y)*expl(-(x-y)*(x+y)); + return t; +} diff --git a/usr/src/lib/libm/common/Q/exp10l.c b/usr/src/lib/libm/common/Q/exp10l.c new file mode 100644 index 0000000000..34fce2721a --- /dev/null +++ b/usr/src/lib/libm/common/Q/exp10l.c @@ -0,0 +1,104 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak exp10l = __exp10l + +#include "libm.h" +#include "longdouble.h" + +/* + * exp10l(x) + * n = nint(x*(log10/log2)) ; + * exp10(x) = 10**x = exp(x*ln(10)) = exp(n*ln2+(x*ln10-n*ln2)) + * = 2**n*exp(ln10*(x-n*log2/log10))) + * If x is an integer <= M then use repeat multiplication. For + * 10**M is the largest representable integer, where + * M = 10 single precision (24 bits) + * M = 22 double precision (53 bits) + * M = 48 quadruple precision (113 bits) + */ + +#define TINY 1.0e-20L /* single: 1e-5, double: 1e-10, quad: 1e-20 */ +#define LG10OVT 4933.L /* single: 39, double: 309, quad: 4933 */ +#define LG10UFT -4966.L /* single: -45, double: -323, quad: -4966 */ +#define M 48 + /* logt2hi : last 32 bits is zero for quad prec */ +#define LOGT2HI 0.30102999566398119521373889472420986034688L +#define LOGT2LO 2.831664213089468167896664371953e-31L + +static const long double + zero = 0.0L, + tiny = TINY * TINY, + one = 1.0L, + lg10 = 3.321928094887362347870319429489390175865e+0000L, + ln10 = 2.302585092994045684017991454684364207601e+0000L, + logt2hi = LOGT2HI, + logt2lo = LOGT2LO, + lg10ovt = LG10OVT, + lg10uft = LG10UFT; + +long double +exp10l(long double x) { + long double t, tenp; + int k; + + if (!finitel(x)) { + if (isnanl(x) || x > zero) + return (x + x); + else + return (zero); + } + if (fabsl(x) < tiny) + return (one + x); + if (x <= lg10ovt) + if (x >= lg10uft) { + k = (int) x; + tenp = 10.0L; + /* x is a small +integer */ + if (0 <= k && k <= M && (long double) k == x) { + t = one; + if (k & 1) + t *= tenp; + k >>= 1; + while (k) { + tenp *= tenp; + if (k & 1) + t *= tenp; + k >>= 1; + } + return (t); + } + t = anintl(x * lg10); + return (scalbnl(expl(ln10 * ((x - t * logt2hi) - + t * logt2lo)), (int) t)); + } else + return (scalbnl(one, -50000)); /* underflow */ + else + return (scalbnl(one, 50000)); /* overflow */ +} diff --git a/usr/src/lib/libm/common/Q/exp2l.c b/usr/src/lib/libm/common/Q/exp2l.c new file mode 100644 index 0000000000..7b0814d90a --- /dev/null +++ b/usr/src/lib/libm/common/Q/exp2l.c @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak exp2l = __exp2l + +#include "libm.h" +#include "longdouble.h" + +/* + * exp2l(x) = 2**x = 2**((x-anint(x))+anint(x)) + * = 2**anint(x)*2**(x-anint(x)) + * = 2**anint(x)*exp((x-anint(x))*ln2) + */ + +#define TINY 1.0e-20L /* single: 1e-5, double: 1e-10, quad: 1e-20 */ +#define OVFLEXP 16400 /* single: 130, double 1030, quad: 16400 */ +#define UNFLEXP -16520 /* single:-155, double -1080, quad:-16520 */ + +static const long double + zero = 0.0L, + tiny = TINY * TINY, + half = 0.5L, + ln2 = 6.931471805599453094172321214581765680755e-0001L, + one = 1.0L; + +static const int + ovflexp = OVFLEXP, + unflexp = UNFLEXP; + +long double +exp2l(long double x) { + long double t; + + if (!finitel(x)) { + if (isnanl(x) || x > zero) + return (x + x); + else + return (zero); + } + t = fabsl(x); + if (t < half) { + if (t < tiny) + return (one + x); + else + return (expl(ln2 * x)); + } + t = anintl(x); + if (t < ovflexp) { + if (t >= unflexp) + return (scalbnl(expl(ln2 * (x - t)), (int) t)); + else + return (scalbnl(one, unflexp)); /* underflow */ + } else + return (scalbnl(one, ovflexp)); /* overflow */ +} diff --git a/usr/src/lib/libm/common/Q/expl.c b/usr/src/lib/libm/common/Q/expl.c new file mode 100644 index 0000000000..92ace61d75 --- /dev/null +++ b/usr/src/lib/libm/common/Q/expl.c @@ -0,0 +1,126 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * expl(x) + * Table driven method + * Written by K.C. Ng, November 1988. + * Algorithm : + * 1. Argument Reduction: given the input x, find r and integer k + * and j such that + * x = (32k+j)*ln2 + r, |r| <= (1/64)*ln2 . + * + * 2. expl(x) = 2^k * (2^(j/32) + 2^(j/32)*expm1(r)) + * Note: + * a. expm1(r) = (2r)/(2-R), R = r - r^2*(t1 + t2*r^2) + * b. 2^(j/32) is represented as + * _TBL_expl_hi[j]+_TBL_expl_lo[j] + * where + * _TBL_expl_hi[j] = 2^(j/32) rounded + * _TBL_expl_lo[j] = 2^(j/32) - _TBL_expl_hi[j]. + * + * Special cases: + * expl(INF) is INF, expl(NaN) is NaN; + * expl(-INF)= 0; + * for finite argument, only expl(0)=1 is exact. + * + * Accuracy: + * according to an error analysis, the error is always less than + * an ulp (unit in the last place). + * + * Misc. info. + * For 113 bit long double + * if x > 1.135652340629414394949193107797076342845e+4 + * then expl(x) overflow; + * if x < -1.143346274333629787883724384345262150341e+4 + * then expl(x) underflow + * + * Constants: + * Only decimal values are given. We assume that the compiler will convert + * from decimal to binary accurately enough to produce the correct + * hexadecimal values. + */ + +#pragma weak expl = __expl + +#include "libm.h" + +extern const long double _TBL_expl_hi[], _TBL_expl_lo[]; + +static const long double +one = 1.0L, +two = 2.0L, +ln2_64 = 1.083042469624914545964425189778400898568e-2L, +ovflthreshold = 1.135652340629414394949193107797076342845e+4L, +unflthreshold = -1.143346274333629787883724384345262150341e+4L, +invln2_32 = 4.616624130844682903551758979206054839765e+1L, +ln2_32hi = 2.166084939249829091928849858592451515688e-2L, +ln2_32lo = 5.209643502595475652782654157501186731779e-27L; + +/* rational approximation coeffs for [-(ln2)/64,(ln2)/64] */ +static const long double +t1 = 1.666666666666666666666666666660876387437e-1L, +t2 = -2.777777777777777777777707812093173478756e-3L, +t3 = 6.613756613756613482074280932874221202424e-5L, +t4 = -1.653439153392139954169609822742235851120e-6L, +t5 = 4.175314851769539751387852116610973796053e-8L; + +long double +expl(long double x) { + int *px = (int *) &x, ix, j, k, m; + long double t, r; + + ix = px[0]; /* high word of x */ + if (ix >= 0x7fff0000) + return (x + x); /* NaN of +inf */ + if (((unsigned) ix) >= 0xffff0000) + return (-one / x); /* NaN or -inf */ + if ((ix & 0x7fffffff) < 0x3fc30000) { + if ((int) x < 1) + return (one + x); /* |x|<2^-60 */ + } + if (ix > 0) { + if (x > ovflthreshold) + return (scalbnl(x, 20000)); + k = (int) (invln2_32 * (x + ln2_64)); + } else { + if (x < unflthreshold) + return (scalbnl(-x, -40000)); + k = (int) (invln2_32 * (x - ln2_64)); + } + j = k&0x1f; + m = k>>5; + t = (long double) k; + x = (x - t * ln2_32hi) - t * ln2_32lo; + t = x * x; + r = (x - t * (t1 + t * (t2 + t * (t3 + t * (t4 + t * t5))))) - two; + x = _TBL_expl_hi[j] - ((_TBL_expl_hi[j] * (x + x)) / r - + _TBL_expl_lo[j]); + return (scalbnl(x, m)); +} diff --git a/usr/src/lib/libm/common/Q/expm1l.c b/usr/src/lib/libm/common/Q/expm1l.c new file mode 100644 index 0000000000..155acbdc54 --- /dev/null +++ b/usr/src/lib/libm/common/Q/expm1l.c @@ -0,0 +1,185 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak expm1l = __expm1l +#endif +#if !defined(__sparc) +#error Unsupported architecture +#endif + +/* + * expm1l(x) + * + * Table driven method + * Written by K.C. Ng, June 1995. + * Algorithm : + * 1. expm1(x) = x if x<2**-114 + * 2. if |x| <= 0.0625 = 1/16, use approximation + * expm1(x) = x + x*P/(2-P) + * where + * P = x - z*(P1+z*(P2+z*(P3+z*(P4+z*(P5+z*P6+z*P7))))), z = x*x; + * (this formula is derived from + * 2-P+x = R = x*(exp(x)+1)/(exp(x)-1) ~ 2 + x*x/6 - x^4/360 + ...) + * + * P1 = 1.66666666666666666666666666666638500528074603030e-0001 + * P2 = -2.77777777777777777777777759668391122822266551158e-0003 + * P3 = 6.61375661375661375657437408890138814721051293054e-0005 + * P4 = -1.65343915343915303310185228411892601606669528828e-0006 + * P5 = 4.17535139755122945763580609663414647067443411178e-0008 + * P6 = -1.05683795988668526689182102605260986731620026832e-0009 + * P7 = 2.67544168821852702827123344217198187229611470514e-0011 + * + * Accuracy: |R-x*(exp(x)+1)/(exp(x)-1)|<=2**-119.13 + * + * 3. For 1/16 < |x| < 1.125, choose x(+-i) ~ +-(i+4.5)/64, i=0,..,67 + * since + * exp(x) = exp(xi+(x-xi))= exp(xi)*exp((x-xi)) + * we have + * expm1(x) = expm1(xi)+(exp(xi))*(expm1(x-xi)) + * where + * |s=x-xi| <= 1/128 + * and + * expm1(s)=2s/(2-R), R= s-s^2*(T1+s^2*(T2+s^2*(T3+s^2*(T4+s^2*T5)))) + * + * T1 = 1.666666666666666666666666666660876387437e-1L, + * T2 = -2.777777777777777777777707812093173478756e-3L, + * T3 = 6.613756613756613482074280932874221202424e-5L, + * T4 = -1.653439153392139954169609822742235851120e-6L, + * T5 = 4.175314851769539751387852116610973796053e-8L; + * + * 4. For |x| >= 1.125, return exp(x)-1. + * (see algorithm for exp) + * + * Special cases: + * expm1l(INF) is INF, expm1l(NaN) is NaN; + * expm1l(-INF)= -1; + * for finite argument, only expm1l(0)=0 is exact. + * + * Accuracy: + * according to an error analysis, the error is always less than + * 2 ulp (unit in the last place). + * + * Misc. info. + * For 113 bit long double + * if x > 1.135652340629414394949193107797076342845e+4 + * then expm1l(x) overflow; + * + * Constants: + * Only decimal values are given. We assume that the compiler will convert + * from decimal to binary accurately enough to produce the correct + * hexadecimal values. + */ + +#include "libm.h" + +extern const long double _TBL_expl_hi[], _TBL_expl_lo[]; +extern const long double _TBL_expm1lx[], _TBL_expm1l[]; + +static const long double + zero = +0.0L, + one = +1.0L, + two = +2.0L, + ln2_64 = +1.083042469624914545964425189778400898568e-2L, + ovflthreshold = +1.135652340629414394949193107797076342845e+4L, + invln2_32 = +4.616624130844682903551758979206054839765e+1L, + ln2_32hi = +2.166084939249829091928849858592451515688e-2L, + ln2_32lo = +5.209643502595475652782654157501186731779e-27L, + huge = +1.0e4000L, + tiny = +1.0e-4000L, + P1 = +1.66666666666666666666666666666638500528074603030e-0001L, + P2 = -2.77777777777777777777777759668391122822266551158e-0003L, + P3 = +6.61375661375661375657437408890138814721051293054e-0005L, + P4 = -1.65343915343915303310185228411892601606669528828e-0006L, + P5 = +4.17535139755122945763580609663414647067443411178e-0008L, + P6 = -1.05683795988668526689182102605260986731620026832e-0009L, + P7 = +2.67544168821852702827123344217198187229611470514e-0011L, +/* rational approximation coeffs for [-(ln2)/64,(ln2)/64] */ + T1 = +1.666666666666666666666666666660876387437e-1L, + T2 = -2.777777777777777777777707812093173478756e-3L, + T3 = +6.613756613756613482074280932874221202424e-5L, + T4 = -1.653439153392139954169609822742235851120e-6L, + T5 = +4.175314851769539751387852116610973796053e-8L; + +long double +expm1l(long double x) { + int hx, ix, j, k, m; + long double t, r, s, w; + + hx = ((int *) &x)[HIXWORD]; + ix = hx & ~0x80000000; + if (ix >= 0x7fff0000) { + if (x != x) + return (x + x); /* NaN */ + if (x < zero) + return (-one); /* -inf */ + return (x); /* +inf */ + } + if (ix < 0x3fff4000) { /* |x| < 1.25 */ + if (ix < 0x3ffb0000) { /* |x| < 0.0625 */ + if (ix < 0x3f8d0000) { + if ((int) x == 0) + return (x); /* |x|<2^-114 */ + } + t = x * x; + r = (x - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * + (P5 + t * (P6 + t * P7))))))); + return (x + (x * r) / (two - r)); + } + /* compute i = [64*x] */ + m = 0x4009 - (ix >> 16); + j = ((ix & 0x0000ffff) | 0x10000) >> m; /* j=4,...,67 */ + if (hx < 0) + j += 82; /* negative */ + s = x - _TBL_expm1lx[j]; + t = s * s; + r = s - t * (T1 + t * (T2 + t * (T3 + t * (T4 + t * T5)))); + r = (s + s) / (two - r); + w = _TBL_expm1l[j]; + return (w + (w + one) * r); + } + if (hx > 0) { + if (x > ovflthreshold) + return (huge * huge); + k = (int) (invln2_32 * (x + ln2_64)); + } else { + if (x < -80.0) + return (tiny - x / x); + k = (int) (invln2_32 * (x - ln2_64)); + } + j = k & 0x1f; + m = k >> 5; + t = (long double) k; + x = (x - t * ln2_32hi) - t * ln2_32lo; + t = x * x; + r = (x - t * (T1 + t * (T2 + t * (T3 + t * (T4 + t * T5))))) - two; + x = _TBL_expl_hi[j] - ((_TBL_expl_hi[j] * (x + x)) / r - + _TBL_expl_lo[j]); + return (scalbnl(x, m) - one); +} diff --git a/usr/src/lib/libm/common/Q/fabsl.c b/usr/src/lib/libm/common/Q/fabsl.c new file mode 100644 index 0000000000..0b0ddf2527 --- /dev/null +++ b/usr/src/lib/libm/common/Q/fabsl.c @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak fabsl = __fabsl + +#include "libm.h" + +long double +fabsl(long double x) { + int *px = (int *) &x; + + px[0] &= 0x7fffffff; + return (x); +} diff --git a/usr/src/lib/libm/common/Q/finitel.c b/usr/src/lib/libm/common/Q/finitel.c new file mode 100644 index 0000000000..bbe255514f --- /dev/null +++ b/usr/src/lib/libm/common/Q/finitel.c @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak finitel = __finitel +#endif + +#include "libm.h" + +#if defined(__sparc) +int +finitel(long double x) { + int *px = (int *) &x; + return ((px[0] & ~0x80000000) < 0x7fff0000); +} +#elif defined(__x86) +int +finitel(long double x) { + int *px = (int *) &x, t = px[2] & 0x7fff; +#if defined(HANDLE_UNSUPPORTED) + return (t != 0x7fff && ((px[1] & 0x80000000) != 0 || t == 0)); +#else + return (t != 0x7fff); +#endif +} +#endif /* defined(__sparc) || defined(__x86) */ diff --git a/usr/src/lib/libm/common/Q/floorl.c b/usr/src/lib/libm/common/Q/floorl.c new file mode 100644 index 0000000000..d899d3fac8 --- /dev/null +++ b/usr/src/lib/libm/common/Q/floorl.c @@ -0,0 +1,70 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * ceill(x) return the biggest integral value below x + * floorl(x) return the least integral value above x + * + * NOTE: aintl(x), anintl(x), ceill(x), floorl(x), and rintl(x) return result + * with the same sign as x's, including 0.0. + */ + +#pragma weak ceill = __ceill +#pragma weak floorl = __floorl + +#include "libm.h" +#include "longdouble.h" + +static const long double qone = 1.0L; + +long double +ceill(long double x) { + long double t; + + if (!finitel(x)) + return (x + x); + t = rintl(x); + if (t >= x) /* already ceil(x) */ + return (t); + else /* t < x case: return t+1 */ + return (copysignl(t + qone, x)); +} + +long double +floorl(long double x) { + long double t; + + if (!finitel(x)) + return (x + x); + t = rintl(x); + if (t <= x) + return (t); /* already floor(x) */ + else /* x < t case: return t-1 */ + return (copysignl(t - qone, x)); +} diff --git a/usr/src/lib/libm/common/Q/fmodl.c b/usr/src/lib/libm/common/Q/fmodl.c new file mode 100644 index 0000000000..e5dc93dee5 --- /dev/null +++ b/usr/src/lib/libm/common/Q/fmodl.c @@ -0,0 +1,275 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak fmodl = __fmodl + +#include "libm.h" + +static const int + is = -0x7fffffff - 1, + im = 0x0000ffff, + iu = 0x00010000; + +static const long double + zero = 0.0L, + one = 1.0L; + +#ifdef __LITTLE_ENDIAN +#define __H0(x) *(3 + (int *) &x) +#define __H1(x) *(2 + (int *) &x) +#define __H2(x) *(1 + (int *) &x) +#define __H3(x) *(0 + (int *) &x) +#else +#define __H0(x) *(0 + (int *) &x) +#define __H1(x) *(1 + (int *) &x) +#define __H2(x) *(2 + (int *) &x) +#define __H3(x) *(3 + (int *) &x) +#endif + +long double +fmodl(long double x, long double y) { + long double a, b; + int n, ix, iy, k, sx; + int hx; + int x0, y0, z0, carry; + unsigned x1, x2, x3, y1, y2, y3, z1, z2, z3; + + hx = __H0(x); + x1 = __H1(x); + x2 = __H2(x); + x3 = __H3(x); + y0 = __H0(y); + y1 = __H1(y); + y2 = __H2(y); + y3 = __H3(y); + + sx = hx & 0x80000000; + x0 = hx ^ sx; + y0 &= 0x7fffffff; + + /* purge off exception values */ + if (x0 >= 0x7fff0000 || /* !finitel(x) */ + (y0 > 0x7fff0000) || (y0 == 0x7fff0000 && ((y1 | y2 | y3) != 0)) || + (y0 | y1 | y2 | y3) == 0) /* isnanl(y) || y = 0 */ + return ((x * y) / (x * y)); + a = fabsl(x); + b = fabsl(y); + if (a <= b) { + if (a < b) + return (x); + else + return (zero * x); + } + /* determine ix = ilogbl(x) */ + if (x0 < iu) { /* subnormal x */ + ix = -16382; + while (x0 == 0) { + ix -= 16; + x0 = x1 >> 16; + x1 = (x1 << 16) | (x2 >> 16); + x2 = (x2 << 16) | (x3 >> 16); + x3 = (x3 << 16); + } + while (x0 < iu) { + ix -= 1; + x0 = (x0 << 1) | (x1 >> 31); + x1 = (x1 << 1) | (x2 >> 31); + x2 = (x2 << 1) | (x3 >> 31); + x3 <<= 1; + } + } else { + ix = (x0 >> 16) - 16383; + x0 = iu | (x0 & im); + } + + /* determine iy = ilogbl(y) */ + if (y0 < iu) { /* subnormal y */ + iy = -16382; + while (y0 == 0) { + iy -= 16; + y0 = y1 >> 16; + y1 = (y1 << 16) | (y2 >> 16); + y2 = (y2 << 16) | (y3 >> 16); + y3 = (y3 << 16); + } + while (y0 < iu) { + iy -= 1; + y0 = (y0 << 1) | (y1 >> 31); + y1 = (y1 << 1) | (y2 >> 31); + y2 = (y2 << 1) | (y3 >> 31); + y3 <<= 1; + } + } else { + iy = (y0 >> 16) - 16383; + y0 = iu | (y0 & im); + } + + /* fix point fmod */ + n = ix - iy; + while (n--) { + while (x0 == 0 && n >= 16) { + n -= 16; + x0 = x1 >> 16; + x1 = (x1 << 16) | (x2 >> 16); + x2 = (x2 << 16) | (x3 >> 16); + x3 = (x3 << 16); + } + while (x0 < iu && n >= 1) { + n -= 1; + x0 = (x0 << 1) | (x1 >> 31); + x1 = (x1 << 1) | (x2 >> 31); + x2 = (x2 << 1) | (x3 >> 31); + x3 = (x3 << 1); + } + carry = 0; + z3 = x3 - y3; + carry = (z3 > x3); + if (carry == 0) { + z2 = x2 - y2; + carry = (z2 > x2); + } else { + z2 = x2 - y2 - 1; + carry = (z2 >= x2); + } + if (carry == 0) { + z1 = x1 - y1; + carry = (z1 > x1); + } else { + z1 = x1 - y1 - 1; + carry = (z1 >= x1); + } + z0 = x0 - y0 - carry; + if (z0 < 0) { /* double x */ + x0 = x0 + x0 + ((x1 & is) != 0); + x1 = x1 + x1 + ((x2 & is) != 0); + x2 = x2 + x2 + ((x3 & is) != 0); + x3 = x3 + x3; + } else { + if (z0 == 0) { + if ((z1 | z2 | z3) == 0) { /* 0: done */ + __H0(a) = hx & is; + __H1(a) = __H2(a) = __H3(a) = 0; + return (a); + } + } + /* x = z << 1 */ + z0 = z0 + z0 + ((z1 & is) != 0); + z1 = z1 + z1 + ((z2 & is) != 0); + z2 = z2 + z2 + ((z3 & is) != 0); + z3 = z3 + z3; + x0 = z0; + x1 = z1; + x2 = z2; + x3 = z3; + } + } + + carry = 0; + z3 = x3 - y3; + carry = (z3 > x3); + if (carry == 0) { + z2 = x2 - y2; + carry = (z2 > x2); + } else { + z2 = x2 - y2 - 1; + carry = (z2 >= x2); + } + if (carry == 0) { + z1 = x1 - y1; + carry = (z1 > x1); + } else { + z1 = x1 - y1 - 1; + carry = (z1 >= x1); + } + z0 = x0 - y0 - carry; + if (z0 >= 0) { + x0 = z0; + x1 = z1; + x2 = z2; + x3 = z3; + } + /* convert back to floating value and restore the sign */ + if ((x0 | x1 | x2 | x3) == 0) { + __H0(a) = hx & is; + __H1(a) = __H2(a) = __H3(a) = 0; + return (a); + } + while (x0 < iu) { + if (x0 == 0) { + iy -= 16; + x0 = x1 >> 16; + x1 = (x1 << 16) | (x2 >> 16); + x2 = (x2 << 16) | (x3 >> 16); + x3 = (x3 << 16); + } else { + x0 = x0 + x0 + ((x1 & is) != 0); + x1 = x1 + x1 + ((x2 & is) != 0); + x2 = x2 + x2 + ((x3 & is) != 0); + x3 = x3 + x3; + iy -= 1; + } + } + + /* normalize output */ + if (iy >= -16382) { + __H0(a) = sx | (x0 - iu) | ((iy + 16383) << 16); + __H1(a) = x1; + __H2(a) = x2; + __H3(a) = x3; + } else { /* subnormal output */ + n = -16382 - iy; + k = n & 31; + if (k != 0) { + if (k <= 16) { + x3 = (x2 << (32 - k)) | (x3 >> k); + x2 = (x1 << (32 - k)) | (x2 >> k); + x1 = (x0 << (32 - k)) | (x1 >> k); + x0 >>= k; + } else { + x3 = (x2 << (32 - k)) | (x3 >> k); + x2 = (x1 << (32 - k)) | (x2 >> k); + x1 = (x0 << (32 - k)) | (x1 >> k); + x0 = 0; + } + } + while (n >= 32) { + n -= 32; + x3 = x2; + x2 = x1; + x1 = x0; + x0 = 0; + } + __H0(a) = x0 | sx; + __H1(a) = x1; + __H2(a) = x2; + __H3(a) = x3; + a *= one; + } + return (a); +} diff --git a/usr/src/lib/libm/common/Q/gammal.c b/usr/src/lib/libm/common/Q/gammal.c new file mode 100644 index 0000000000..961c2d08d0 --- /dev/null +++ b/usr/src/lib/libm/common/Q/gammal.c @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak gammal = __gammal + +/* + * long double gammal(long double x); + */ + +#include "libm.h" +#include "longdouble.h" + +extern int signgam; +extern int signgaml; + +long double +gammal(long double x) { + long double y = __k_lgammal(x, &signgaml); + + signgam = signgaml; /* SUSv3 requires the setting of signgam */ + return (y); +} diff --git a/usr/src/lib/libm/common/Q/gammal_r.c b/usr/src/lib/libm/common/Q/gammal_r.c new file mode 100644 index 0000000000..26d9745c6d --- /dev/null +++ b/usr/src/lib/libm/common/Q/gammal_r.c @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * long double gammal_r(long double x, int *signgamlp); + */ + +#pragma weak gammal_r = __gammal_r + +#include "libm.h" +#include "longdouble.h" + +long double +gammal_r(long double x, int *signgamlp) { + return (__k_lgammal(x, signgamlp)); +} diff --git a/usr/src/lib/libm/common/Q/hypotl.c b/usr/src/lib/libm/common/Q/hypotl.c new file mode 100644 index 0000000000..def794358d --- /dev/null +++ b/usr/src/lib/libm/common/Q/hypotl.c @@ -0,0 +1,152 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak hypotl = __hypotl + +/* + * long double hypotl(long double x, long double y); + * Method : + * If z=x*x+y*y has error less than sqrt(2)/2 ulp than sqrt(z) has + * error less than 1 ulp. + * So, compute sqrt(x*x+y*y) with some care as follows: + * Assume x>y>0; + * 1. save and set rounding to round-to-nearest + * 2. if x > 2y use + * x1*x1+(y*y+(x2*(x+x2))) for x*x+y*y + * where x1 = x with lower 64 bits cleared, x2 = x-x1; else + * 3. if x <= 2y use + * t1*y1+((x-y)*(x-y)+(t1*y2+t2*y)) + * where t1 = 2x with lower 64 bits cleared, t2 = 2x-t1, y1= y with + * lower 64 bits chopped, y2 = y-y1. + * + * NOTE: DO NOT remove parenthsis! + * + * Special cases: + * hypot(x,y) is INF if x or y is +INF or -INF; else + * hypot(x,y) is NAN if x or y is NAN. + * + * Accuracy: + * hypot(x,y) returns sqrt(x^2+y^2) with error less than 1 ulps (units + * in the last place) + */ + +#include "libm.h" +#include "longdouble.h" + +extern enum fp_direction_type __swapRD(enum fp_direction_type); + +static const long double zero = 0.0L, one = 1.0L; + +long double +hypotl(long double x, long double y) { + int n0, n1, n2, n3; + long double t1, t2, y1, y2, w; + int *px = (int *) &x, *py = (int *) &y; + int *pt1 = (int *) &t1, *py1 = (int *) &y1; + enum fp_direction_type rd; + int j, k, nx, ny, nz; + + if ((*(int *) &one) != 0) { /* determine word ordering */ + n0 = 0; + n1 = 1; + n2 = 2; + n3 = 3; + } else { + n0 = 3; + n1 = 2; + n2 = 1; + n3 = 0; + } + + px[n0] &= 0x7fffffff; /* clear sign bit of x and y */ + py[n0] &= 0x7fffffff; + k = 0x7fff0000; + nx = px[n0] & k; /* exponent of x and y */ + ny = py[n0] & k; + if (ny > nx) { + w = x; + x = y; + y = w; + nz = ny; + ny = nx; + nx = nz; + } /* force x > y */ + if ((nx - ny) >= 0x00730000) + return (x + y); /* x/y >= 2**116 */ + if (nx < 0x5ff30000 && ny > 0x205b0000) { /* medium x,y */ + /* save and set RD to Rounding to nearest */ + rd = __swapRD(fp_nearest); + w = x - y; + if (w > y) { + pt1[n0] = px[n0]; + pt1[n1] = px[n1]; + pt1[n2] = pt1[n3] = 0; + t2 = x - t1; + x = sqrtl(t1 * t1 - (y * (-y) - t2 * (x + t1))); + } else { + x = x + x; + py1[n0] = py[n0]; + py1[n1] = py[n1]; + py1[n2] = py1[n3] = 0; + y2 = y - y1; + pt1[n0] = px[n0]; + pt1[n1] = px[n1]; + pt1[n2] = pt1[n3] = 0; + t2 = x - t1; + x = sqrtl(t1 * y1 - (w * (-w) - (t2 * y1 + y2 * x))); + } + if (rd != fp_nearest) + (void) __swapRD(rd); /* restore rounding mode */ + return (x); + } else { + if (nx == k || ny == k) { /* x or y is INF or NaN */ + if (isinfl(x)) + t2 = x; + else if (isinfl(y)) + t2 = y; + else + t2 = x + y; /* invalid if x or y is sNaN */ + return (t2); + } + if (ny == 0) { + if (y == zero || x == zero) + return (x + y); + t1 = scalbnl(one, 16381); + x *= t1; + y *= t1; + return (scalbnl(one, -16381) * hypotl(x, y)); + } + j = nx - 0x3fff0000; + px[n0] -= j; + py[n0] -= j; + pt1[n0] = nx; + pt1[n1] = pt1[n2] = pt1[n3] = 0; + return (t1 * hypotl(x, y)); + } +} diff --git a/usr/src/lib/libm/common/Q/ieee_funcl.c b/usr/src/lib/libm/common/Q/ieee_funcl.c new file mode 100644 index 0000000000..74e6cacfe8 --- /dev/null +++ b/usr/src/lib/libm/common/Q/ieee_funcl.c @@ -0,0 +1,113 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak isinfl = __isinfl +#pragma weak isnormall = __isnormall +#pragma weak issubnormall = __issubnormall +#pragma weak iszerol = __iszerol +#pragma weak signbitl = __signbitl +#endif + +#include "libm.h" + +#if defined(__sparc) +int +isinfl(long double x) { + int *px = (int *) &x; + return ((px[0] & ~0x80000000) == 0x7fff0000 && px[1] == 0 && + px[2] == 0 && px[3] == 0); +} + +int +isnormall(long double x) { + int *px = (int *) &x; + return ((unsigned) ((px[0] & 0x7fff0000) - 0x10000) < 0x7ffe0000); +} + +int +issubnormall(long double x) { + int *px = (int *) &x; + px[0] &= ~0x80000000; + return (px[0] < 0x00010000 && (px[0] | px[1] | px[2] | px[3]) != 0); +} + +int +iszerol(long double x) { + int *px = (int *) &x; + return (((px[0] & ~0x80000000) | px[1] | px[2] | px[3]) == 0); +} + +int +signbitl(long double x) { + unsigned *px = (unsigned *) &x; + return (px[0] >> 31); +} +#elif defined(__x86) +int +isinfl(long double x) { + int *px = (int *) &x; +#if defined(HANDLE_UNSUPPORTED) + return ((px[2] & 0x7fff) == 0x7fff && + ((px[1] ^ 0x80000000) | px[0]) == 0); +#else + return ((px[2] & 0x7fff) == 0x7fff && + ((px[1] & ~0x80000000) | px[0]) == 0); +#endif +} + +int +isnormall(long double x) { + int *px = (int *) &x; +#if defined(HANDLE_UNSUPPORTED) + return ((unsigned) ((px[2] & 0x7fff) - 1) < 0x7ffe && + (px[1] & 0x80000000) != 0); +#else + return ((unsigned) ((px[2] & 0x7fff) - 1) < 0x7ffe); +#endif +} + +int +issubnormall(long double x) { + int *px = (int *) &x; + return ((px[2] & 0x7fff) == 0 && (px[0] | px[1]) != 0); +} + +int +iszerol(long double x) { + int *px = (int *) &x; + return (((px[2] & 0x7fff) | px[0] | px[1]) == 0); +} + +int +signbitl(long double x) { + unsigned *px = (unsigned *) &x; + return ((px[2] >> 15) & 1); +} +#endif /* defined(__sparc) || defined(__x86) */ diff --git a/usr/src/lib/libm/common/Q/ilogbl.c b/usr/src/lib/libm/common/Q/ilogbl.c new file mode 100644 index 0000000000..bdbe2dbd0f --- /dev/null +++ b/usr/src/lib/libm/common/Q/ilogbl.c @@ -0,0 +1,87 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak ilogbl = __ilogbl +#endif + +#include "libm.h" +#include "xpg6.h" /* __xpg6 */ + +#if defined(__sparc) +#define ISNORMALL(k, x) (k != 0x7fff) /* assuming k != 0 */ +#define X86PDNRM(k, x) +#define XSCALE_OFFSET 0x406f /* 0x3fff + 112 */ +static const long double xscale = 5192296858534827628530496329220096.0L; + /* 2^112 */ +#elif defined(__x86) +/* + * if pseudo-denormal, replace by the equivalent normal + */ +#define X86PDNRM(k, x) if (k == 0 && (((int *) &x)[1] & 0x80000000) != 0) \ + ((int *) &x)[2] |= k = 1 +#if defined(HANDLE_UNSUPPORTED) /* assuming k != 0 */ +#define ISNORMALL(k, x) (k != 0x7fff && (((int *) &x)[1] & 0x80000000) != 0) +#else +#define ISNORMALL(k, x) (k != 0x7fff) +#endif +#define XSCALE_OFFSET 0x403e /* 0x3fff + 63 */ +static const long double xscale = 9223372036854775808.0L; /* 2^63 */ +#endif + +static int +raise_invalid(int v) { /* SUSv3 requires ilogbl(0,+/-Inf,NaN) raise invalid */ +#ifndef lint + if ((__xpg6 & _C99SUSv3_ilogb_0InfNaN_raises_invalid) != 0) { + static const double zero = 0.0; + volatile double dummy; + + dummy = zero / zero; + } +#endif + return (v); +} + +int +ilogbl(long double x) { + int k = XBIASED_EXP(x); + + X86PDNRM(k, x); + if (k == 0) { + if (ISZEROL(x)) + return (raise_invalid(0x80000001)); + else { + x *= xscale; /* scale up by 2^112 or 2^63 */ + return (XBIASED_EXP(x) - XSCALE_OFFSET); + } + } else if (ISNORMALL(k, x)) + return (k - 0x3fff); + else + return (raise_invalid(0x7fffffff)); +} diff --git a/usr/src/lib/libm/common/Q/isnanl.c b/usr/src/lib/libm/common/Q/isnanl.c new file mode 100644 index 0000000000..0d3a853c8e --- /dev/null +++ b/usr/src/lib/libm/common/Q/isnanl.c @@ -0,0 +1,54 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak isnanl = __isnanl +#endif + +#include "libm.h" + +#if defined(__sparc) +int +isnanl(long double x) { + int *px = (int *) &x; + return ((px[0] & ~0x80000000) >= 0x7fff0000 && + ((px[0] & ~0xffff0000) | px[1] | px[2] | px[3]) != 0); +} +#elif defined(__x86) +int +isnanl(long double x) { + int *px = (int *) &x, t = px[2] & 0x7fff; +#if defined(HANDLE_UNSUPPORTED) + return (t == 0x7fff && ((px[1] & ~0x80000000) | px[0]) != 0 || + t != 0 && (px[1] & 0x80000000) == 0); +#else + return (t == 0x7fff && ((px[1] & ~0x80000000) | px[0]) != 0); +#endif +} +#endif /* defined(__sparc) || defined(__x86) */ diff --git a/usr/src/lib/libm/common/Q/j0l.c b/usr/src/lib/libm/common/Q/j0l.c new file mode 100644 index 0000000000..5d030e74d0 --- /dev/null +++ b/usr/src/lib/libm/common/Q/j0l.c @@ -0,0 +1,738 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * Floating point Bessel's function of the first and second kinds + * of order zero: j0(x),y0(x); + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + */ + +#pragma weak j0l = __j0l +#pragma weak y0l = __y0l + +#include "libm.h" +#include "longdouble.h" + +#define GENERIC long double +static const GENERIC +zero = 0.0L, +small = 1.0e-9L, +tiny = 1.0e-38L, +one = 1.0L, +five = 5.0L, +eight = 8.0L, +invsqrtpi= 5.641895835477562869480794515607725858441e-0001L, +tpi = 0.636619772367581343075535053490057448L; + +static GENERIC pzero(GENERIC); +static GENERIC qzero(GENERIC); + +static GENERIC r0[7] = { + -2.499999999999999999999999999999998934492e-0001L, + 1.272657927360049786327618451133763714880e-0002L, + -2.694499763712963276900636693400659600898e-0004L, + 2.724877475058977576903234070919616447883e-0006L, + -1.432617103214330236967477495393076320281e-0008L, + 3.823248804080079168706683540513792224471e-0011L, + -4.183174277567983647337568504286313665065e-0014L, +}; +static GENERIC s0[7] = { + 1.0e0L, + 1.159368290559800854689526195462884666395e-0002L, + 6.629397597394973383009743876169946772559e-0005L, + 2.426779981394054406305431142501735094340e-0007L, + 6.097663491248511069094400469635449749883e-0010L, + 1.017019133340929220238747413216052224036e-0012L, + 9.012593179306197579518374581969371278481e-0016L, +}; + +GENERIC +j0l(x) GENERIC x;{ + GENERIC z, s,c,ss,cc,r,u,v; + int i; + + if (isnanl(x)) return x+x; + x = fabsl(x); + if (x > 1.28L) { + if (!finitel(x)) return zero; + s = sinl(x); + c = cosl(x); + /* + * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0)) + * where x0 = x-pi/4 + * Better formula: + * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) + * = 1/sqrt(2) * (cos(x) + sin(x)) + * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if (x>1.0e2450L) { /* x+x may overflow */ + ss = s-c; + cc = s+c; + } else if (signbitl(s) != signbitl(c)) { + ss = s - c; + cc = -cosl(x+x)/ss; + } else { + cc = s + c; + ss = -cosl(x+x)/cc; + } + /* + * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) + * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) + */ + if (x>1.0e120L) return (invsqrtpi*cc)/sqrtl(x); + u = pzero(x); v = qzero(x); + return invsqrtpi*(u*cc-v*ss)/sqrtl(x); + } + if (x<=small) { + if (x<=tiny) return one-x; + else return one-x*x*0.25L; + } + z = x*x; + r = r0[6]; s = s0[6]; + for(i=5;i>=0;i--) { + r = r*z + r0[i]; + s = s*z + s0[i]; + } + return(one+z*(r/s)); +} + +static const GENERIC u0[8] = { + -7.380429510868722527434392794848301631220e-0002L, + 1.766855559625940791857536949301981816513e-0001L, + -1.386470722701047923235553251240162839408e-0002L, + 3.520149242724811578636970811631224862615e-0004L, + -3.978599663243790049853642275624951870025e-0006L, + 2.228801153263957224547222556806915479763e-0008L, + -6.121246764298785018658597179498837316177e-0011L, + 6.677103629722678833475965810525587396596e-0014L, +}; +static const GENERIC v0[8] = { + 1.0e0L, + 1.247164416539111311571676766127767127970e-0002L, + 7.829144749639791500052900281489367443576e-0005L, + 3.247126540422245330511218321013360336606e-0007L, + 9.750516724789499678567062572549568447869e-0010L, + 2.156713223173591212250543390258458098776e-0012L, + 3.322169561597890004231482431236452752624e-0015L, + 2.821213295314000924252226486305726805093e-0018L, +}; + +GENERIC +y0l(x) GENERIC x;{ + GENERIC z, s,c,ss,cc,u,v; + int i; + volatile GENERIC d; + + if (isnanl(x)) return x+x; + if (x <= zero) { + if (x == zero) + d= -one/(x-x); + else + d = zero/(x-x); + } +#ifdef lint + d = d; +#endif + if (x > 1.28L) { + if (!finitel(x)) return zero; + s = sinl(x); + c = cosl(x); + /* + * j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0)) + * where x0 = x-pi/4 + * Better formula: + * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) + * = 1/sqrt(2) * (cos(x) + sin(x)) + * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if (x>1.0e2450L) { /* x+x may overflow */ + ss = s-c; + cc = s+c; + } else if (signbitl(s) != signbitl(c)) { + ss = s - c; + cc = -cosl(x+x)/ss; + } else { + cc = s + c; + ss = -cosl(x+x)/cc; + } + /* + * j0(x) = 1/sqrt(pi*x) * (P(0,x)*cc - Q(0,x)*ss) + * y0(x) = 1/sqrt(pi*x) * (P(0,x)*ss + Q(0,x)*cc) + */ + if (x>1.0e120L) return (invsqrtpi*ss)/sqrtl(x); + return invsqrtpi*(pzero(x)*ss+qzero(x)*cc)/sqrtl(x); + + } + if (x<=tiny) { + return (u0[0] + tpi*logl(x)); + } + z = x*x; + u = u0[7]; v = v0[7]; + for(i=6;i>=0;i--) { + u = u*z + u0[i]; + v = v*z + v0[i]; + } + return(u/v + tpi*(j0l(x)*logl(x))); +} + +static const GENERIC pr0[12] = { /* [16 -- inf] */ + 9.999999999999999999999999999999999997515e-0001L, + 1.065981615377273376425365823967550598358e+0003L, + 4.390991200927588978306374718984240719130e+0005L, + 9.072086218607986711847069407339321363103e+0007L, + 1.022552886177375367408408501046461671528e+0010L, + 6.420766912243658241570635854089597269031e+0011L, + 2.206451725126933913591080211081242266908e+0013L, + 3.928369596816895077363705478743346298368e+0014L, + 3.258159928874124597286701119721482876596e+0015L, + 1.025715808134188978860679130140685101348e+0016L, + 7.537170874795721255796001687024031280685e+0015L, + -1.579413901450157332307745586004207687796e+0014L, +}; +static const GENERIC ps0[11] = { + 1.0e0L, + 1.066051927877273376425365823967550512687e+0003L, + 4.391739647168381592399173804329266353038e+0005L, + 9.075162261801343671805658294123888867884e+0007L, + 1.023186118519904751819581912075985995058e+0010L, + 6.427861860414223746340515376512730275061e+0011L, + 2.210861503237823589735481303627993406235e+0013L, + 3.943247335784292905915956840901818177989e+0014L, + 3.283720976777545142150200110647270004481e+0015L, + 1.045346918812754048903645641538728986759e+0016L, + 8.043455468065618900750599584291193680463e+0015L, +}; +static const GENERIC pr1[12] = { /* [8 -- 16] */ + 9.999999999999999999999784422701108683618e-0001L, + 6.796098532948334207755488692777907062894e+0002L, + 1.840036112605722168824530758797169836042e+0005L, + 2.598490483191916637264894340635847598122e+0007L, + 2.105774863242707025525730249472054578523e+0009L, + 1.015822044230542426666314997796944979959e+0011L, + 2.931557457008110436764077699944189071875e+0012L, + 4.962885121125457633655259224179322808824e+0013L, + 4.705424055148223269155430598563351566279e+0014L, + 2.294439854910747229152056080910427001110e+0015L, + 4.905531843137486691500950019322475458629e+0015L, + 3.187543169710339218793442542845735994565e+0015L, +}; +static const GENERIC ps1[14] = { + 1.0e0L, + 6.796801657948334207754571576066758180288e+0002L, + 1.840512891201300567325421059826676366447e+0005L, + 2.599777028312918975306252167127695075221e+0007L, + 2.107582572771047636846811284634244892537e+0009L, + 1.017275794694156108975782763889979940348e+0011L, + 2.938487645192463845428059755454762316011e+0012L, + 4.982512164735557054521042916182317924466e+0013L, + 4.737639900153703274792677468264564361437e+0014L, + 2.323398719123742743524249528275097100646e+0015L, + 5.033419107069210577868909797896984419391e+0015L, + 3.409036105931068609601317076759804716059e+0015L, + 7.505655364352679737585745147753521662166e+0013L, + -9.976837153983688250780198248297109118313e+0012L, +}; +static const GENERIC pr2[12] = { /* [5 -- 8 ] */ + 9.999999999999999937857236789277366320220e-0001L, + 3.692848765268649571651602420376358849214e+0002L, + 5.373022067535476576926715900057760985410e+0004L, + 4.038738891191314969971504035057219430725e+0006L, + 1.728285706306940523397385566659762646999e+0008L, + 4.375400819645889911158688737206054788534e+0009L, + 6.598950418204912408375591217782088567076e+0010L, + 5.827182039183238492480275401520072793783e+0011L, + 2.884222642913492390887572414999490975844e+0012L, + 7.373278873797767721932837830628688632775e+0012L, + 8.338295457568973761205077964397969230489e+0012L, + 2.911383183467288345772308817209806922143e+0012L, +}; +static const GENERIC ps2[14] = { + 1.0e0L, + 3.693551890268649477288896267171993213102e+0002L, + 5.375607880998361502474715133828068514297e+0004L, + 4.042477764024108249744998862572786367328e+0006L, + 1.731069838737016956685839588670132939513e+0008L, + 4.387147674049898778738226585935491417728e+0009L, + 6.628058659620653765349556940567715258165e+0010L, + 5.869659904164177740471685856367322160664e+0011L, + 2.919839445622817017058977559638969436383e+0012L, + 7.535314897696671402628203718612309253907e+0012L, + 8.696355561452933775773309859748610658935e+0012L, + 3.216155103141537221173601557697083216257e+0012L, + 4.756857081068942248246880159213789086363e+0010L, + -3.496356619666608032231074866481472824067e+0009L, +}; +static const GENERIC pr3[13] = { /* [3.5 -- 5 ] */ + 9.999999999999916693107285612398196588247e-0001L, + 2.263975921282917721194425320484974336945e+0002L, + 1.994358386744245848889492762781484199966e+0004L, + 8.980067458430542243559962493831661323168e+0005L, + 2.282213787521372663705567756420087553508e+0007L, + 3.409784374889063618250288699908375135923e+0008L, + 3.024380857401448589254343517589811711108e+0009L, + 1.571110368046740246895071721443082286379e+0010L, + 4.603187020243604632153685300463160593768e+0010L, + 7.087196453409712719449549280664058793403e+0010L, + 5.046196021776346356803687409644239065041e+0010L, + 1.287758439080165765709154276618854799932e+0010L, + 5.900679773415023433787846658096813590784e+0008L, +}; +static const GENERIC ps3[13] = { + 1.0e0L, + 2.264679046282855061328604619231774747116e+0002L, + 1.995939523988944553755653255389812103448e+0004L, + 8.993853144706348727038389967490183236820e+0005L, + 2.288326099634588843906989983704795468773e+0007L, + 3.424967100255240885169240956804790118282e+0008L, + 3.046311797972463991368023759640028910016e+0009L, + 1.589614961932826812790222479700797224003e+0010L, + 4.692406624527744816497089139325073939927e+0010L, + 7.320486495902008912866462849073108323948e+0010L, + 5.345945972828978289935309597742981360994e+0010L, + 1.444033091910423754121309915092247171008e+0010L, + 7.987714685115314668378957273824383610525e+0008L, +}; +static const GENERIC pr4[13] = { /* [2.5, 3.5] */ + 9.999999999986736677961118722747757712260e-0001L, + 1.453824980703800559037873123568378845663e+0002L, + 8.097327216430682288267610447006508661032e+0003L, + 2.273847252038264370231169686380192662135e+0005L, + 3.561056728046211111354759998976985449622e+0006L, + 3.244933588800096378434627029369680378599e+0007L, + 1.740112392860717950376210038908476792588e+0008L, + 5.426170187455893285197878563881579269524e+0008L, + 9.490107486454362321004377336020526281371e+0008L, + 8.688872439428470049801714121070005313806e+0008L, + 3.673315853166437222811910656900123215515e+0008L, + 5.577770470359303305164877446339693270239e+0007L, + 1.540438642031689641308197880181291865714e+0006L, +}; +static const GENERIC ps4[13] = { /* [2.5, 3.5] */ + 1.0e0L, + 1.454528105698159439773035951959131799816e+0002L, + 8.107442215200392397172179900434987859618e+0003L, + 2.279390393778242887574177096606328994140e+0005L, + 3.576251625592252008424781111770934135844e+0006L, + 3.267909499056932631405942058670933813863e+0007L, + 1.760021515330805537499778238099704648805e+0008L, + 5.525553787667353981242060222587465726729e+0008L, + 9.769870295912820457889384082671269328511e+0008L, + 9.110582071004774279226905629624018008454e+0008L, + 3.981857678621955599371967680343918454345e+0008L, + 6.482404686230769399073192961667697036706e+0007L, + 2.210046943095878402443535460329391782298e+0006L, +}; +static const GENERIC pr5[13] = { /* [1.777..., 2.5] */ + 9.999999999114986107951817871144655880699e-0001L, + 9.252583736048588342568344570315435947614e+0001L, + 3.218726757856078715214631502407386264637e+0003L, + 5.554009964621111656479588505862577040831e+0004L, + 5.269993115643664338253196944523510290175e+0005L, + 2.874613773778430691192912190618220544575e+0006L, + 9.133538151103658353874146919613442436035e+0006L, + 1.673067041410338922825193013077354249193e+0007L, + 1.706913873848398011744790289200151840498e+0007L, + 9.067766583853288534551600235576747618679e+0006L, + 2.216746733457884568532695355036338655872e+0006L, + 1.945753880802872541235703812722344514405e+0005L, + 3.132374412921948071539195638885330951749e+0003L, +}; +static const GENERIC ps5[13] = { /* [1.777..., 2.5] */ + 1.0e0L, + 9.259614983862181118883831670990340052982e+0001L, + 3.225125275462903384842124075132609290304e+0003L, + 5.575705362829101545292760055941855246492e+0004L, + 5.306049863037087855496170121958448492522e+0005L, + 2.907060758873509564309729903109018597215e+0006L, + 9.298059206584995898298257827131208539289e+0006L, + 1.720391071006963176836108026556547062980e+0007L, + 1.782614812922865190479394509487941920612e+0007L, + 9.708016389605273153536452032839879950155e+0006L, + 2.476495084688170096480215640962175140027e+0006L, + 2.363200660365585759668077790194604917187e+0005L, + 4.803239569848196077121203575704356936731e+0003L, +}; +static const GENERIC pr6[13] = { /* [1.28, 1.777...] */ + 9.999999969777095495998606925524322559556e-0001L, + 5.825486719466194430503283824096872219216e+0001L, + 1.248155491637757281915184824965379905380e+0003L, + 1.302093199842358609321338417071710477615e+0004L, + 7.353835804186292782840961999810543016039e+0004L, + 2.356471661113686180549195092555751341757e+0005L, + 4.350553267429009581632987060942780847101e+0005L, + 4.588762661876600638719159826652389418235e+0005L, + 2.675796398548523436544221045225290128611e+0005L, + 8.077649557108971388298292919988449940464e+0004L, + 1.117640459221306873519068741664054573776e+0004L, + 5.544400072396814695175787511557757885585e+0002L, + 5.072550541191480498431289089905822910718e+0000L, +}; +static const GENERIC ps6[13] = { /* [1.28, 1.777...] */ + 1.0e0L, + 5.832517925357165050639075848183613063291e+0001L, + 1.252144364743592128171256104364976466898e+0003L, + 1.310300234342216813579118022415585740772e+0004L, + 7.434667697093812197817292154032863632923e+0004L, + 2.398706595587719165726469002404004614711e+0005L, + 4.472737517625103157004869372427480602511e+0005L, + 4.786313523337761975294171429067037723611e+0005L, + 2.851161872872731228472536061865365370192e+0005L, + 8.891648269899148412331918021801385815586e+0004L, + 1.297097489535351517572978123584751042287e+0004L, + 7.096761640545975756202184143400469812618e+0002L, + 8.378049338590233325977702401733340820351e+0000L, +}; +static const GENERIC sixteen = 16.0L; +static const GENERIC huge = 1.0e30L; + +static GENERIC pzero(x) +GENERIC x; +{ + GENERIC s,r,t,z; + int i; + if (x>huge) return one; + t = one/x; z = t*t; + if (x>sixteen) { + r = z*pr0[11]+pr0[10]; s = ps0[10]; + for (i=9;i>=0;i--) { + r = z*r + pr0[i]; + s = z*s + ps0[i]; + } + } else if (x > eight) { + r = pr1[11]; s = ps1[11]+z*(ps1[12]+z*ps1[13]); + for (i=10;i>=0;i--) { + r = z*r + pr1[i]; + s = z*s + ps1[i]; + } + } else if (x > five) { /* x > 5.0 */ + r = pr2[11]; s = ps2[11]+z*(ps2[12]+z*ps2[13]); + for (i=10;i>=0;i--) { + r = z*r + pr2[i]; + s = z*s + ps2[i]; + } + } else if (x>3.5L) { + r = pr3[12]; s = ps3[12]; + for (i=11;i>=0;i--) { + r = z*r + pr3[i]; + s = z*s + ps3[i]; + } + } else if (x>2.5L) { + r = pr4[12]; s = ps4[12]; + for (i=11;i>=0;i--) { + r = z*r + pr4[i]; + s = z*s + ps4[i]; + } + } else if (x> (1.0L/0.5625L)) { + r = pr5[12]; s = ps5[12]; + for (i=11;i>=0;i--) { + r = z*r + pr5[i]; + s = z*s + ps5[i]; + } + } else { /* assume x > 1.28 */ + r = pr6[12]; s = ps6[12]; + for (i=11;i>=0;i--) { + r = z*r + pr6[i]; + s = z*s + ps6[i]; + } + } + return r/s; +} + + +static const GENERIC qr0[12] = { /* [16, inf] */ + -1.249999999999999999999999999999999972972e-0001L, + -1.425179595545670577414395762503991596897e+0002L, + -6.312499645625970845534460257936222407219e+0004L, + -1.411374326457208384315121243698814446848e+0007L, + -1.735034212758873581410984757860787252842e+0009L, + -1.199777647512789489421826342485055280680e+0011L, + -4.596025334081655714499860409699100373644e+0012L, + -9.262525628201284107792924477031653399187e+0013L, + -8.858394728685039245344398842180662867639e+0014L, + -3.267527953687534887623740622709505972113e+0015L, + -2.664222971186311967587129347029450062019e+0015L, + 3.442464060723987869585180095344504100204e+0014L, +}; +static const GENERIC qs0[11] = { + 1.0e0L, + 1.140729613936536461931516610003185687881e+0003L, + 5.056665510442299351009198186490085803580e+0005L, + 1.132041763825642787943941650522718199115e+0008L, + 1.394570111872581606392620678214246479767e+0010L, + 9.677945218152264789534431079563744378421e+0011L, + 3.731140327851536828225143058896348502096e+0013L, + 7.612785951064869291722846681020881676410e+0014L, + 7.476077016406764891730191004811863975940e+0015L, + 2.951246482613592035421503427100393831709e+0016L, + 3.108361803691811711136854587074302034901e+0016L, +}; +static const GENERIC qr1[12] = { /* [8, 16 ] */ + -1.249999999999999999997949010383433818157e-0001L, + -9.051215166393822640636752244895124126934e+0001L, + -2.620782703428148837671179031904208303947e+0004L, + -3.975571261553504457766177974508785790884e+0006L, + -3.479029330759311306270072218074074994090e+0008L, + -1.823955008124268573036216746186239829089e+0010L, + -5.765932697111801375765156029221568664435e+0011L, + -1.079843680798742592954002192417934779114e+0013L, + -1.146893630504592739082205764611581332897e+0014L, + -6.367016059683898464936104447282880704182e+0014L, + -1.583109041961213490464459111903484209098e+0015L, + -1.230149555764242473103128650135795639412e+0015L, +}; +static const GENERIC qs1[14] = { + 1.0e0L, + 7.246831508115058112438579847778014458432e+0002L, + 2.100854184439168518399383786306927037611e+0005L, + 3.192636418837951507430188285940994235122e+0007L, + 2.801558443383354674538443461124434216152e+0009L, + 1.475026997664373739293483927250653467487e+0011L, + 4.694486824913954608552363821799927145318e+0012L, + 8.890350100919200250838438709601547334021e+0013L, + 9.626844429082905144874701068760469752067e+0014L, + 5.541110744600460773528263862687521642140e+0015L, + 1.486500494789452556727470329232123096563e+0016L, + 1.415840104845959400365430773732093899210e+0016L, + 1.780866095241517418081312567239682336483e+0015L, + -2.359230917384889357887631544079990129494e+0014L, +}; +static const GENERIC qr2[12] = { /* [5, 8] */ + -1.249999999999999531937744362527772181614e-0001L, + -4.944373897356969774839375977239241573966e+0001L, + -7.728449175433465285314261650078450473909e+0003L, + -6.262574329612752346336901434651220705903e+0005L, + -2.900948220220943306027235217424380672732e+0007L, + -7.988719647634192770463917157562874119535e+0008L, + -1.318228171927181389547760026626357012375e+0010L, + -1.282439773983029245309263271945424928196e+0011L, + -7.050925570827818040186149940257918845138e+0011L, + -2.021751882573871990004205616874202684429e+0012L, + -2.592939962400668552384333900573812635658e+0012L, + -1.038267109518891262840601514932972850326e+0012L, +}; +static const GENERIC qs2[14] = { + 1.0e0L, + 3.961358492885570003202784022894248952116e+0002L, + 6.205788738864701882828752634586510926968e+0004L, + 5.045715603932670286550673813011764406749e+0006L, + 2.349248611362658323353343389430968751429e+0008L, + 6.520244524415828635917683553721880063911e+0009L, + 1.089111211223507719337067159886281887722e+0011L, + 1.080406000905359867958779409414903018610e+0012L, + 6.135645280895514703514154680623769562148e+0012L, + 1.862433040246625874245867151368643668215e+0013L, + 2.667780805786648888840777888702193708994e+0013L, + 1.394401107289087774765300711809313112824e+0013L, + 1.093247500616320375562898297156722445484e+0012L, + -7.228875530378928722826604216491493780775e+0010L, +}; +static const GENERIC qr3[13] = { /* [3.5 5] */ + -1.249999999999473067748420379578481661075e-0001L, + -3.044549048635289351913574324803250977998e+0001L, + -2.890081140649769078496693003524681440869e+0003L, + -1.404922456817202235879343275330529107684e+0005L, + -3.862746614385573443518177403617349281869e+0006L, + -6.257517309110249049201133708911155047689e+0007L, + -6.031451330920839916987079782727323477520e+0008L, + -3.411542405173830611454025765755854382346e+0009L, + -1.089392478149726672133014498723021526099e+0010L, + -1.824934078420210941290140903415956782726e+0010L, + -1.400780278304358710423481070486939531139e+0010L, + -3.716484136064917363926635716743771092093e+0009L, + -1.397591075296425529970434890954904331580e+0008L, +}; +static const GENERIC qs3[13] = { + 1.0e0L, + 2.441498613904962049391000187014945858042e+0002L, + 2.326188882072370711500164222341514337043e+0004L, + 1.137138213121231338494977104659239578165e+0006L, + 3.152918070735662728722998452605364253517e+0007L, + 5.172877993426507259314270488444013595108e+0008L, + 5.083086439731669807455961078856470774115e+0009L, + 2.961842732066434123119325521139476909941e+0010L, + 9.912185866862440735829781856081353151390e+0010L, + 1.793560561251622234430564181567297983598e+0011L, + 1.577090119341228122525265108497940403073e+0011L, + 5.509910306780166194333889999985463681636e+0010L, + 4.761691134078874491202320181517936758141e+0009L, +}; +static const GENERIC qr4[13] = { /* [2.5 3.5] */ + -1.249999999928567734339745043490705340835e-0001L, + -1.967201748731419063051601624435565528481e+0001L, + -1.186329146714562236407099740615528170707e+0003L, + -3.607736959222941810356301491152457934060e+0004L, + -6.119200717978104904932828468575194267125e+0005L, + -6.037847781158358226670305078652205586384e+0006L, + -3.503558153336140359700536720393565984740e+0007L, + -1.180196478268225718757218523746787309773e+0008L, + -2.221860232085134915841426363505169680528e+0008L, + -2.173372505452747585296176761701746236760e+0008L, + -9.649364865061237558517730539506568013963e+0007L, + -1.465429227847933034546039640094862650385e+0007L, + -3.083003197920262085170581866246663380607e+0005L, +}; +static const GENERIC qs4[13] = { /* [2.5 3.5] */ + 1.0e0L, + 1.579620773732259142752614142139986854055e+0002L, + 9.581372220329138733203879503753685054968e+0003L, + 2.939598672379108095776114131010825885308e+0005L, + 5.052183049314542218630341818692588448168e+0006L, + 5.083497695595206639433839326338971980149e+0007L, + 3.036385361800553388049719014005099206516e+0008L, + 1.067826481452753409910563785161661492137e+0009L, + 2.145644125557118044720741775125319669272e+0009L, + 2.324115615959719949363946673491552216799e+0009L, + 1.223262962112070757966959855619847011146e+0009L, + 2.569765553318495423738478585947110270709e+0008L, + 1.354744744299227127897905787732636565504e+0007L, +}; +static const GENERIC qr5[13] = { /* [1.777.., 2.5] */ + -1.249999995936639697637680428174576069971e-0001L, + -1.260846055371311453485891923426489068315e+0001L, + -4.772398467544467480801174330290141578895e+0002L, + -8.939852599990298486613760833996490599724e+0003L, + -9.184070787149542050979542226446134243197e+0004L, + -5.406038945018274458362637897739280435171e+0005L, + -1.845896544705190261018653728678171084418e+0006L, + -3.613616990680809501878667570653308071547e+0006L, + -3.908782978135693252252557720414348623779e+0006L, + -2.173711022517323927109138170588442768176e+0006L, + -5.431253130679918485836408549007856244495e+0005L, + -4.591098546452684510082591587275940765959e+0004L, + -5.244711364168207806835520057792229646578e+0002L, +}; +static const GENERIC qs5[13] = { /* [1.777.., 2.5] */ + 1.0e0L, + 1.014536210851290878350892750972474861447e+0002L, + 3.875547510687135314064434160096139681076e+0003L, + 7.361913122670079814955259281995617732580e+0004L, + 7.720288944218771126581086539585529314636e+0005L, + 4.681529554446752496404431433608306558038e+0006L, + 1.667882621940503925455031252308367745820e+0007L, + 3.469403153761399881888272620855305156241e+0007L, + 4.096992047964210711867089384719947863019e+0007L, + 2.596804755829217449311530735959560630554e+0007L, + 7.983933774697889238154465064019410763845e+0006L, + 9.818133816979900819087242425280757938152e+0005L, + 3.061083930868694396013541535670745443560e+0004L, +}; + +static const GENERIC qr6[13] = { /* [1.28, 1.777..] */ + -1.249999881577289001807137282824929082771e-0001L, + -7.998273510053110759610810594119533619282e+0000L, + -1.872481955335172543369089617771565632719e+0002L, + -2.122116786726300805079874003303799646812e+0003L, + -1.293850285839529282503178263484773478457e+0004L, + -4.445024742266316181033354192262529356093e+0004L, + -8.730161378334357767668344467356505347070e+0004L, + -9.706222895172078442801444972505315054736e+0004L, + -5.896325518259858270165531513618195321041e+0004L, + -1.823172034368108822276420827074668832233e+0004L, + -2.509304178635055926638833040337472387175e+0003L, + -1.156608965715779237316769828941729964099e+0002L, + -7.028005789650731396887346826397785210442e-0001L, +}; +static const GENERIC qs6[13] = { /* [1.28, 1.777..] */ + 1.0e0L, + 6.457211085058064845601261321277721075900e+0001L, + 1.534005216588011210342824555136008682950e+0003L, + 1.777217999176441782593357660462379097171e+0004L, + 1.118372652642469468091084810263231199696e+0005L, + 4.015242433858461813142365748386473605294e+0005L, + 8.377081045517098645448616514388280497673e+0005L, + 1.011495020008010352575398009604164287337e+0006L, + 6.886722075290430568652227875200208955970e+0005L, + 2.504735189948021472047157148613171956537e+0005L, + 4.408138920171044846941001844352009817062e+0004L, + 3.105572178072115145673058722853640854884e+0003L, + 5.588294821118916113437396504573817033678e+0001L, +}; +static GENERIC qzero(x) +GENERIC x; +{ + GENERIC s,r,t,z; + int i; + if (x>huge) return -0.125L/x; + t = one/x; z = t*t; + if (x>sixteen) { + r = z*qr0[11]+qr0[10]; s = qs0[10]; + for (i=9;i>=0;i--) { + r = z*r + qr0[i]; + s = z*s + qs0[i]; + } + } else if (x>eight) { + r = qr1[11]; s = qs1[11]+z*(qs1[12]+z*qs1[13]); + for (i=10;i>=0;i--) { + r = z*r + qr1[i]; + s = z*s + qs1[i]; + } + } else if (x>five) { /* assume x > 5.0 */ + r = qr2[11]; s = qs2[11]+z*(qs2[12]+z*qs2[13]); + for (i=10;i>=0;i--) { + r = z*r + qr2[i]; + s = z*s + qs2[i]; + } + } else if (x>3.5L) { + r = qr3[12]; s = qs3[12]; + for (i=11;i>=0;i--) { + r = z*r + qr3[i]; + s = z*s + qs3[i]; + } + } else if (x>2.5L) { + r = qr4[12]; s = qs4[12]; + for (i=11;i>=0;i--) { + r = z*r + qr4[i]; + s = z*s + qs4[i]; + } + } else if (x> (1.0L/0.5625L)) { + r = qr5[12]; s = qs5[12]; + for (i=11;i>=0;i--) { + r = z*r + qr5[i]; + s = z*s + qs5[i]; + } + } else { /* assume x > 1.28 */ + r = qr6[12]; s = qs6[12]; + for (i=11;i>=0;i--) { + r = z*r + qr6[i]; + s = z*s + qs6[i]; + } + } + return t*(r/s); +} diff --git a/usr/src/lib/libm/common/Q/j1l.c b/usr/src/lib/libm/common/Q/j1l.c new file mode 100644 index 0000000000..9009b4fb16 --- /dev/null +++ b/usr/src/lib/libm/common/Q/j1l.c @@ -0,0 +1,734 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * floating point Bessel's function of the first and second kinds + * of order zero: j1(x),y1(x); + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + */ + +#pragma weak j1l = __j1l +#pragma weak y1l = __y1l + +#include "libm.h" +#include "longdouble.h" + +#define GENERIC long double +static const GENERIC +zero = 0.0L, +small = 1.0e-9L, +tiny = 1.0e-38L, +one = 1.0L, +five = 5.0L, +invsqrtpi= 5.641895835477562869480794515607725858441e-0001L, +tpi = 0.636619772367581343075535053490057448L; + +static GENERIC pone(GENERIC); +static GENERIC qone(GENERIC); + +static const GENERIC r0[7] = { + -6.249999999999999999999999999999999627320e-0002L, + 1.940606727194041716205384618494641565464e-0003L, + -3.005630423155733701856481469986459043883e-0005L, + 2.345586219403918667468341047369572169358e-0007L, + -9.976809285885253587529010109133336669724e-0010L, + 2.218743258363623946078958783775107473381e-0012L, + -2.071079656218700604767650924103578046280e-0015L, +}; +static const GENERIC s0[7] = { + 1.0e0L, + 1.061695903156199920738051277075003059555e-0002L, + 5.521860513111180371566951179398862692060e-0005L, + 1.824214367413754193524107877084979441407e-0007L, + 4.098957778439576834818838198039029353925e-0010L, + 6.047735079699666389853240090925264056197e-0013L, + 4.679044728878836197247923279512047035041e-0016L, +}; + +GENERIC +j1l(x) GENERIC x;{ + GENERIC z, d, s,c,ss,cc,r; + int i, sgn; + + if (!finitel(x)) return one/x; + sgn = signbitl(x); + x = fabsl(x); + if (x > 1.28L) { + s = sinl(x); + c = cosl(x); + /* + * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x0)-q1(x)*sin(x0)) + * where x0 = x-3pi/4 + * Better formula: + * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = -1/sqrt(2) * (cos(x) + sin(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if (x>1.0e2450L) { /* x+x may overflow */ + ss = -s-c; + cc = s-c; + } else if (signbitl(s) != signbitl(c)) { + cc = s - c; + ss = cosl(x+x)/cc; + } else { + ss = -s-c; + cc = cosl(x+x)/ss; + } + /* + * j1(x) = 1/sqrt(pi*x) * (P(1,x)*cc - Q(1,x)*ss) + * y1(x) = 1/sqrt(pi*x) * (P(1,x)*ss + Q(1,x)*cc) + */ + if (x>1.0e120L) return (invsqrtpi*cc)/sqrtl(x); + d = invsqrtpi*(pone(x)*cc-qone(x)*ss)/sqrtl(x); + if (sgn == 0) return d; else return -d; + } + if (x<=small) { + if (x<=tiny) d = 0.5L*x; + else d = x*(0.5L-x*x*0.125L); + if (sgn == 0) return d; else return -d; + } + z = x*x; + r = r0[6]; + s = s0[6]; + for (i=5;i>=0;i--) { + r = r*z + r0[i]; + s = s*z + s0[i]; + } + d = x*0.5L+x*(z*(r/s)); + if (sgn == 0) return d; else return -d; +} + +static const GENERIC u0[7] = { + -1.960570906462389484060557273467558703503e-0001L, + 5.166389353148318460304315890665450006495e-0002L, + -2.229699464105910913337190798743451115604e-0003L, + 3.625437034548863342715657067759078267158e-0005L, + -2.689902826993117212255524537353883987171e-0007L, + 9.304570592456930912969387719010256018466e-0010L, + -1.234878126794286643318321347997500346131e-0012L, +}; +static const GENERIC v0[8] = { + 1.0e0L, + 1.369394302535807332517110204820556695644e-0002L, + 9.508438148097659501433367062605935379588e-0005L, + 4.399007309420092056052714797296467565655e-0007L, + 1.488083087443756398305819693177715000787e-0009L, + 3.751609832625793536245746965768587624922e-0012L, + 6.680926434086257291872903276124244131448e-0015L, + 6.676602383908906988160099057991121446058e-0018L, +}; + +GENERIC +y1l(x) GENERIC x;{ + GENERIC z, s,c,ss,cc,u,v; + int i; + + if (isnanl(x)) return x+x; + if (x <= zero) { + if (x == zero) + return -one/zero; + else + return zero/zero; + } + if (x > 1.28L) { + if (!finitel(x)) return zero; + s = sinl(x); + c = cosl(x); + /* + * j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x0)-q1(x)*sin(x0)) + * where x0 = x-3pi/4 + * Better formula: + * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = -1/sqrt(2) * (cos(x) + sin(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if (x>1.0e2450L) { /* x+x may overflow */ + ss = -s-c; + cc = s-c; + } else if (signbitl(s) != signbitl(c)) { + cc = s - c; + ss = cosl(x+x)/cc; + } else { + ss = -s-c; + cc = cosl(x+x)/ss; + } + /* + * j1(x) = 1/sqrt(pi*x) * (P(1,x)*cc - Q(1,x)*ss) + * y1(x) = 1/sqrt(pi*x) * (P(1,x)*ss + Q(1,x)*cc) + */ + if (x>1.0e91L) return (invsqrtpi*ss)/sqrtl(x); + return invsqrtpi*(pone(x)*ss+qone(x)*cc)/sqrtl(x); + } + if (x<=tiny) { + return (-tpi/x); + } + z = x*x; + u = u0[6]; v = v0[6]+z*v0[7]; + for (i=5;i>=0;i--) { + u = u*z + u0[i]; + v = v*z + v0[i]; + } + return(x*(u/v) + tpi*(j1l(x)*logl(x)-one/x)); +} + +static const GENERIC pr0[12] = { + 1.000000000000000000000000000000000000267e+0000L, + 1.060717875045891455602180843276758003035e+0003L, + 4.344347542892127024446687712181105852335e+0005L, + 8.915680220724007016377924252717410457094e+0007L, + 9.969502259938406062809873257569171272819e+0009L, + 6.200290193138613035646510338707386316595e+0011L, + 2.105978548788015119851815854422247330118e+0013L, + 3.696635772784601239371730810311998368948e+0014L, + 3.015913097920694682057958412534134515156e+0015L, + 9.370298471339353098123277427328592725921e+0015L, + 7.190349005196335967340799265074029443057e+0015L, + 2.736097786240689996880391074927552517982e+0014L, +}; +static const GENERIC ps0[11] = { + 1.0e0L, + 1.060600687545891455602180843276758095107e+0003L, + 4.343106093416975589147153906505338900961e+0005L, + 8.910605869002176566582072242244353399059e+0007L, + 9.959122058635087888690713917622056540190e+0009L, + 6.188744967234948231792482949171041843894e+0011L, + 2.098863976953783506401759873801990304907e+0013L, + 3.672870357018063196746729751479938908450e+0014L, + 2.975538419246824921049011529574385888420e+0015L, + 9.063657659995043205018686029284479837091e+0015L, + 6.401953344314747916729366441508892711691e+0015L, +}; +static const GENERIC pr1[12] = { + 1.000000000000000000000023667524130660984e+0000L, + 6.746154419979618754354803488126452971204e+0002L, + 1.811210781083390154857018330296145970502e+0005L, + 2.533098390379924268038005329095287842244e+0007L, + 2.029683619805342145252338570875424600729e+0009L, + 9.660859662192711465301069401598929980319e+0010L, + 2.743396238644831519934098967716621316316e+0012L, + 4.553097354140854377931023170263455246288e+0013L, + 4.210245069852219757476169864974870720374e+0014L, + 1.987334056229596485076645967176169801727e+0015L, + 4.067120052787096893838970455751338930462e+0015L, + 2.486539606380406398310845264910691398133e+0015L, +}; +static const GENERIC ps1[14] = { + 1.0e0L, + 6.744982544979618754355808680196859521782e+0002L, + 1.810421795396966762032155290441364740350e+0005L, + 2.530986460644310651529583759699988435573e+0007L, + 2.026743276048023121360249288818290224145e+0009L, + 9.637461924407405935245269407052641341836e+0010L, + 2.732378628423766417402292797028314160831e+0012L, + 4.522345274960527124354844364012184278488e+0013L, + 4.160650668341743132685335758415469856545e+0014L, + 1.943730242988858208243492424892435901211e+0015L, + 3.880228532692127989901131618598067450001e+0015L, + 2.178020816161154615841000173683302999728e+0015L, + -8.994062666842225551554346698171600634173e+0013L, + 1.368520368508851253495764806934619574990e+0013L, +}; +static const GENERIC pr2[12] = { + 1.000000000000000006938651621840396237282e+0000L, + 3.658416291850404981407101077037948144698e+0002L, + 5.267073772170356547709794670602812447537e+0004L, + 3.912012101226837463014925210735894620442e+0006L, + 1.651295648974103957193874928714180765625e+0008L, + 4.114901144480797609972484998142146783499e+0009L, + 6.092524309766036681542980572526335147672e+0010L, + 5.263913178071282616719249969074134570577e+0011L, + 2.538408581124324223367341020538081330994e+0012L, + 6.288607929360291027895126983015365677648e+0012L, + 6.848330048211148419047055075386525945280e+0012L, + 2.290309646838867941423178163991423244690e+0012L, +}; +static const GENERIC ps2[14] = { + 1.0e0L, + 3.657244416850405086459410165762319861856e+0002L, + 5.262802358425023243992387075861237306312e+0004L, + 3.905896813959919648136295861661483848364e+0006L, + 1.646791907791461220742694842108202772763e+0008L, + 4.096132803064256022224954120208201437344e+0009L, + 6.046665195915950447544429445730680236759e+0010L, + 5.198061739781991313414052212328653295168e+0011L, + 2.484233851814333966401527626421254279796e+0012L, + 6.047868806925315879339651539434315255940e+0012L, + 6.333103831254091652501642567294101813354e+0012L, + 1.875143098754284994467609936924685024968e+0012L, + -5.238330920563392692965412762508813601534e+0010L, + 4.656888609439364725427789198383779259957e+0009L, +}; +static const GENERIC pr3[13] = { + 1.000000000000009336887318068056137842897e+0000L, + 2.242719942728459588488051572002835729183e+0002L, + 1.955450611382026550266257737331095691092e+0004L, + 8.707143293993619899395400562409175590739e+0005L, + 2.186267894487004565948324289010954505316e+0007L, + 3.224328510541957792360691585667502864688e+0008L, + 2.821057355151380597331792896882741364897e+0009L, + 1.445371387295422404365584793796028979840e+0010L, + 4.181743160669891357783011002656658107864e+0010L, + 6.387371088767993119325536137794535513922e+0010L, + 4.575619999412716078064070587767416436396e+0010L, + 1.228415651211639160620284441690503550842e+0010L, + 7.242170349875563053436050532153112882072e+0008L, +}; +static const GENERIC ps3[13] = { + 1.0e0L, + 2.241548067728529551049804610486061401070e+0002L, + 1.952838216795552145132137932931237181307e+0004L, + 8.684574926493185744628127341069974575526e+0005L, + 2.176357771067037962940853412819852189164e+0007L, + 3.199958682356132977319258783167122100567e+0008L, + 2.786218931525334687844675219914201872570e+0009L, + 1.416283776951741549631417572317916039767e+0010L, + 4.042962659271567948735676834609348842922e+0010L, + 6.028168462646694510083847222968444402161e+0010L, + 4.118410226794641413833887606580085281111e+0010L, + 9.918735736297038430744161253338202230263e+0009L, + 4.092967198238098023219124487437130332038e+0008L, +}; +static const GENERIC pr4[13] = { + 1.000000000001509220978157399042059553390e+0000L, + 1.437551868378147851133499996323782607787e+0002L, + 7.911335537418177296041518061404505428004e+0003L, + 2.193710939115317214716518908935756104804e+0005L, + 3.390662495136730962513489796538274984382e+0006L, + 3.048655347929348891006070609293884274789e+0007L, + 1.613781633489496606354045161527450975195e+0008L, + 4.975089835037230277110156150038482159988e+0008L, + 8.636047087015115403880904418339566323264e+0008L, + 7.918202912328366140110671223076949101509e+0008L, + 3.423294665798984733439650311722794853294e+0008L, + 5.621904953441963961040503934782662613621e+0007L, + 2.086303543310240260758670404509484499793e+0006L, +}; +static const GENERIC ps4[13] = { + 1.0e0L, + 1.436379993384532371670493319591847362304e+0002L, + 7.894647154785430678061053848847436659499e+0003L, + 2.184659753392097529008981741550878586174e+0005L, + 3.366109083305465176803513738147049499361e+0006L, + 3.011911545968996817697665866587226343186e+0007L, + 1.582262913779689851316760148459414895301e+0008L, + 4.819268809494937919217938589530138201770e+0008L, + 8.201355762990450679702837123432527154830e+0008L, + 7.268232093982510937417446421282341425212e+0008L, + 2.950911909015572933262131323934036480462e+0008L, + 4.242839924305934423010858966540621219396e+0007L, + 1.064387620445090779182117666330405186866e+0006L, +}; +static const GENERIC pr5[13] = { + 1.000000000102434805241171427253847353861e+0000L, + 9.129332257083629259060502249025963234821e+0001L, + 3.132238483586953037576119377504557191413e+0003L, + 5.329782528269307971278943122454171107861e+0004L, + 4.988460157184117790692873002103052944145e+0005L, + 2.686602071615786816147010334256047469378e+0006L, + 8.445418526028961197703799808701268301831e+0006L, + 1.536575358646141157475725889907900827390e+0007L, + 1.568405818236523821796862770586544811945e+0007L, + 8.450876239888770102387618667362302173547e+0006L, + 2.154414900139567328424026827163203446077e+0006L, + 2.105656926565043898888460254808062352205e+0005L, + 4.739165011023396507022134303736862812975e+0003L, +}; +static const GENERIC ps5[13] = { + 1.0e0L, + 9.117613509595327476509152673394703847793e+0001L, + 3.121697972484015639301279229281770795147e+0003L, + 5.294447222735893568040911873834576440255e+0004L, + 4.930368882192772335798256684110887882807e+0005L, + 2.634854685641165298302167435798357437768e+0006L, + 8.185462775400326393555896157031818280918e+0006L, + 1.462417423080215192609668642663030667086e+0007L, + 1.450624993985851675982860844153954896015e+0007L, + 7.460467647561995283219086567162006113864e+0006L, + 1.754210981405612478869227142579056338965e+0006L, + 1.463286721155271971526264914524746699596e+0005L, + 2.155894725796702015341211116579827039459e+0003L, +}; +static const GENERIC pr6[13] = { + 1.000000003564855546741735920315743157129e+0000L, + 5.734003934862540458119423509909510288366e+0001L, + 1.209572491935850486086559692291796887976e+0003L, + 1.243398391422281247933674779163660286838e+0004L, + 6.930996755181437937258220998601708278787e+0004L, + 2.198067659532757598646722249966767620099e+0005L, + 4.033659432712058633933179115820576858455e+0005L, + 4.257759657219008027016047206574574358678e+0005L, + 2.511917395876004349480721277445763916389e+0005L, + 7.813756153070623654178731651381881953552e+0004L, + 1.152069173381127881385588092905864352891e+0004L, + 6.548580782804088553777816037551523398082e+0002L, + 8.668725370116906132327542766127938496880e+0000L, +}; +static const GENERIC ps6[13] = { + 1.0e0L, + 5.722285236357114566499221525736286205184e+0001L, + 1.203010842878317935444582950620339570506e+0003L, + 1.230058335378583550155825502172435371208e+0004L, + 6.800998550607861288865300438648089894412e+0004L, + 2.130767829599304262987769347536850885921e+0005L, + 3.840483466643916681759936972992155310026e+0005L, + 3.947432373459225542861819148108081160393e+0005L, + 2.237816239393081111481588434457838526738e+0005L, + 6.545820495124419723398946273790921540774e+0004L, + 8.729563630320892741500726213278834737196e+0003L, + 4.130762660291894753450174794196998813709e+0002L, + 3.480368898672684645130335786015075595598e+0000L, +}; +static const GENERIC sixteen = 16.0L; +static const GENERIC eight = 8.0L; +static const GENERIC huge = 1.0e30L; + +static GENERIC pone(x) +GENERIC x; +{ + GENERIC s,r,t,z; + int i; + if (x>huge) return one; + t = one/x; z = t*t; + if (x>sixteen) { + r = z*pr0[11]+pr0[10]; s = ps0[10]; + for (i=9;i>=0;i--) { + r = z*r + pr0[i]; + s = z*s + ps0[i]; + } + } else if (x>eight) { + r = pr1[11]; s = ps1[11]+z*(ps1[12]+z*ps1[13]); + for (i=10;i>=0;i--) { + r = z*r + pr1[i]; + s = z*s + ps1[i]; + } + } else if (x>five) { + r = pr2[11]; s = ps2[11]+z*(ps2[12]+z*ps2[13]); + for (i=10;i>=0;i--) { + r = z*r + pr2[i]; + s = z*s + ps2[i]; + } + } else if (x>3.5L) { + r = pr3[12]; s = ps3[12]; + for (i=11;i>=0;i--) { + r = z*r + pr3[i]; + s = z*s + ps3[i]; + } + } else if (x>2.5L) { + r = pr4[12]; s = ps4[12]; + for (i=11;i>=0;i--) { + r = z*r + pr4[i]; + s = z*s + ps4[i]; + } + } else if (x> (1.0L/0.5625L)) { + r = pr5[12]; s = ps5[12]; + for (i=11;i>=0;i--) { + r = z*r + pr5[i]; + s = z*s + ps5[i]; + } + } else { /* assume x > 1.28 */ + r = pr6[12]; s = ps6[12]; + for (i=11;i>=0;i--) { + r = z*r + pr6[i]; + s = z*s + ps6[i]; + } + } + return r/s; +} + + +static const GENERIC qr0[12] = { + 3.749999999999999999999999999999999971033e-0001L, + 4.256726035237050601607682277433094262226e+0002L, + 1.875976490812878489192409978945401066066e+0005L, + 4.170314268048041914273603680317745592790e+0007L, + 5.092750132543855817293451118974555746551e+0009L, + 3.494749676278488654103505795794139483404e+0011L, + 1.327062148257437316997667817096694173709e+0013L, + 2.648993138273427226907503742066551150490e+0014L, + 2.511695665909547412222430494473998127684e+0015L, + 9.274694506662289043224310499164702306096e+0015L, + 8.150904170663663829331320302911792892002e+0015L, + -5.001918733707662355772037829620388765122e+0014L, +}; +static const GENERIC qs0[11] = { + 1.0e0L, + 1.135400380229880160428715273982155760093e+0003L, + 5.005701183877126164326765545516590744360e+0005L, + 1.113444200113712167984337603933040102987e+0008L, + 1.361074819925223062778717565699039471124e+0010L, + 9.355750985802849484438933905325982809653e+0011L, + 3.563462786008988825003965543857998084828e+0013L, + 7.155145113900094163648726863803802910454e+0014L, + 6.871266835834472758055559013851843654113e+0015L, + 2.622030899226736712644974988157345234092e+0016L, + 2.602912729172876330650077021706139707746e+0016L, +}; +static const GENERIC qr1[12] = { + 3.749999999999999999997762458207284405806e-0001L, + 2.697883998881706839929255517498189980485e+0002L, + 7.755195925781028489386938870473834411019e+0004L, + 1.166777762104017777198211072895528968355e+0007L, + 1.011504772984321168320010084520261069362e+0009L, + 5.246007703574156853577754571720205550010e+0010L, + 1.637692549885592683166116551691266537647e+0012L, + 3.022303623698185669912990310925039382495e+0013L, + 3.154769927290655684846107030265909987946e+0014L, + 1.715819913441554770089730934808123360921e+0015L, + 4.165044355759732622273534445131736188510e+0015L, + 3.151381420874174705643100381708086287596e+0015L, +}; +static const GENERIC qs1[14] = { + 1.0e0L, + 7.197091705351218239785633172408276982828e+0002L, + 2.070012799599548685544883041297609861055e+0005L, + 3.117014815317656221871840152778458754516e+0007L, + 2.705719678902554974863325877025902971727e+0009L, + 1.406113614727345726925060648750867264098e+0011L, + 4.403777536067131320363005978631674817359e+0012L, + 8.170725690209322283061499386703167242894e+0013L, + 8.609458844975495289227794126964431210566e+0014L, + 4.766766367015473481257280600694952920204e+0015L, + 1.202286587943342194863557940888115641650e+0016L, + 1.012474328306200909525063936061756024120e+0016L, + 6.183552022678917858273222879615824070703e+0014L, + -9.756731548558226997573737400988225722740e+0013L, +}; +static const GENERIC qr2[12] = { + 3.749999999999999481245647262226994293189e-0001L, + 1.471366807289771354491181140167359026735e+0002L, + 2.279432486768448220142080962843526951250e+0004L, + 1.828943048523771225163804043356958285893e+0006L, + 8.379828388647823135832220596417725010837e+0007L, + 2.279814029335044024585393671278378022053e+0009L, + 3.711653952257118120832817785271466441420e+0010L, + 3.557650914518554549916730572553105048068e+0011L, + 1.924583483146095896259774329498934160650e+0012L, + 5.424386256063736390759567088291887140278e+0012L, + 6.839325621241776786206509704671746841737e+0012L, + 2.702169563144001166291686452305436313971e+0012L, +}; +static const GENERIC qs2[14] = { + 1.0e0L, + 3.926379194439388135703211933895203191089e+0002L, + 6.089148804106598297488336063007609312276e+0004L, + 4.893546162973278583711376356041614150645e+0006L, + 2.247571119114497845046388801813832219404e+0008L, + 6.137635663350177751290469334200757872645e+0009L, + 1.005115019784102856424493519524998953678e+0011L, + 9.725664462014503832860151384604677240620e+0011L, + 5.345525100485511116148634192844434636072e+0012L, + 1.549944007398946691720862738173956994779e+0013L, + 2.067148441178952625710302124163264760362e+0013L, + 9.401565402641963611295119487242595462301e+0012L, + 3.548217088622398274748837287769709374385e+0011L, + -2.934470341719047120076509938432417352365e+0010L, +}; +static const GENERIC qr3[13] = { + 3.749999999999412724084579833297451472091e-0001L, + 9.058478580291706212422978492938435582527e+0001L, + 8.524056033161038750461083666711724381171e+0003L, + 4.105967158629109427753434569223631014730e+0005L, + 1.118326603378531348259783091972623333657e+0007L, + 1.794636683403578918528064904714132329343e+0008L, + 1.714314157463635959556133236004368896724e+0009L, + 9.622092032236084846572067257267661456030e+0009L, + 3.057759524485859159957762858780768355020e+0010L, + 5.129306780754798531609621454415938890020e+0010L, + 3.999122002794961070680636194346316041352e+0010L, + 1.122298454643493485989721564358100345388e+0010L, + 5.603981987645989709668830968522362582221e+0008L, +}; +static const GENERIC qs3[13] = { + 1.0e0L, + 2.418328663076578169836155170053634419922e+0002L, + 2.279620205900121042587523541281272875520e+0004L, + 1.100984222585729521470129014992217092794e+0006L, + 3.010743223679247091004262516286654516282e+0007L, + 4.860925542827367817289619265215599433996e+0008L, + 4.686668111035348691982715864307839581243e+0009L, + 2.668701788405102017427214705946730894074e+0010L, + 8.677395746106802640390580944836650584903e+0010L, + 1.511936455574951790658498795945106643036e+0011L, + 1.260845604432623478002018696873608353093e+0011L, + 4.052692278419853853911440231600864589805e+0010L, + 2.965516519212226064983267822243329694729e+0009L, +}; +static const GENERIC qr4[13] = { + 3.749999999919234164154669754440123072618e-0001L, + 5.844218580776819864791168253485055101858e+0001L, + 3.489273514092912982675669411371435670220e+0003L, + 1.050523637774575684509663430018995479594e+0005L, + 1.764549172059701565500717319792780115289e+0006L, + 1.725532438844133795028063102681497371154e+0007L, + 9.938114847359778539965140247590176334874e+0007L, + 3.331710808184595545396883770200772842314e+0008L, + 6.271970557641881511609560444872797282698e+0008L, + 6.188529798677357075020774923903737913285e+0008L, + 2.821905302742849974509982167877885011629e+0008L, + 4.615467358646911976773290256984329814896e+0007L, + 1.348140608731546467396685802693380693275e+0006L, +}; +static const GENERIC qs4[13] = { + 1.0e0L, + 1.561192663112345185261418296389902133372e+0002L, + 9.346678031144098270547225423124213083072e+0003L, + 2.825851246482293547838023847601704751590e+0005L, + 4.776572711622156091710902891124911556293e+0006L, + 4.715106953717135402977938048006267859302e+0007L, + 2.753962350894311316439652227611209035193e+0008L, + 9.428501434615463207768964787500411575223e+0008L, + 1.832650858775206787088236896454141572617e+0009L, + 1.901697378939743226948920874296595242257e+0009L, + 9.433322226854293780627188599226380812725e+0008L, + 1.808520540608671608680284520798858587370e+0008L, + 7.983342331736662753157217446919462398008e+0006L, +}; +static const GENERIC qr5[13] = { + 3.749999995331364437028988850515190446719e-0001L, + 3.739356381766559882677514593041627547911e+0001L, + 1.399562500629413529355265462912819802551e+0003L, + 2.594154053098947925345332218062210111753e+0004L, + 2.640149879297408640394163979394594318371e+0005L, + 1.542471854873199142031889093591449397995e+0006L, + 5.242272868972053374067572098992335425895e+0006L, + 1.025834487769410221329633071426044839935e+0007L, + 1.116553924239448940142230579060124209622e+0007L, + 6.318076065595910176374916303525884653514e+0006L, + 1.641218086168640408527639735915512881785e+0006L, + 1.522369793529178644168813882912134706444e+0005L, + 2.526530541062297200914180060208669584055e+0003L, +}; +static const GENERIC qs5[13] = { + 1.0e0L, + 9.998960735935075380397545659016287506660e+0001L, + 3.758767417842043742686475060540416737562e+0003L, + 7.013652806952306520121959742519780781653e+0004L, + 7.208949808818615099246529616211730446850e+0005L, + 4.272753927109614455417836186072202009252e+0006L, + 1.482524411356470699336129814111025434703e+0007L, + 2.988750366665678233425279237627700803473e+0007L, + 3.396957890261080492694709150553619185065e+0007L, + 2.050652487738593004111578091156304540386e+0007L, + 5.900504120811732547616511555946279451316e+0006L, + 6.563391409260160897024498082273183468347e+0005L, + 1.692629845012790205348966731477187041419e+0004L, +}; +static const GENERIC qr6[13] = { + 3.749999861516664133157566870858975421296e-0001L, + 2.367863756747764863120797431599473468918e+0001L, + 5.476715802114976248882067325630793143777e+0002L, + 6.143190357869842894025012945444096170251e+0003L, + 3.716250534677997850513733595140463851730e+0004L, + 1.270883463823876752138326905022875657430e+0005L, + 2.495301449636814481646371665429083801388e+0005L, + 2.789578988212952248340486296254398601942e+0005L, + 1.718247946911109055931819087137397324634e+0005L, + 5.458973214011665714330326732204106364229e+0004L, + 7.912102686687948786048943339759596652813e+0003L, + 4.077961006160866935722030715149087938091e+0002L, + 3.765206972770245085551057237882528510428e+0000L, +}; +static const GENERIC qs6[13] = { + 1.0e0L, + 6.341646532940517305641893852673926809601e+0001L, + 1.477058277414040790932597537920671025359e+0003L, + 1.674406564031044491436044253393536487604e+0004L, + 1.028516501369755949895050806908994650768e+0005L, + 3.593620042532885295087463507733285434207e+0005L, + 7.267924991381020915185873399453724799625e+0005L, + 8.462277510768818399961191426205006083088e+0005L, + 5.514399892230892163373611895645500250514e+0005L, + 1.898084241009259353540620272932188102299e+0005L, + 3.102941242117739015721984123081026253068e+0004L, + 1.958971184431466907681440650181421086143e+0003L, + 2.878853357310495087181721613889455121867e+0001L, +}; +static GENERIC qone(x) +GENERIC x; +{ + GENERIC s,r,t,z; + int i; + if (x>huge) return 0.375L/x; + t = one/x; z = t*t; + if (x>sixteen) { + r = z*qr0[11]+qr0[10]; s = qs0[10]; + for (i=9;i>=0;i--) { + r = z*r + qr0[i]; + s = z*s + qs0[i]; + } + } else if (x>eight) { + r = qr1[11]; s = qs1[11]+z*(qs1[12]+z*qs1[13]); + for (i=10;i>=0;i--) { + r = z*r + qr1[i]; + s = z*s + qs1[i]; + } + } else if (x>five) { /* x > 5.0 */ + r = qr2[11]; s = qs2[11]+z*(qs2[12]+z*qs2[13]); + for (i=10;i>=0;i--) { + r = z*r + qr2[i]; + s = z*s + qs2[i]; + } + } else if (x>3.5L) { + r = qr3[12]; s = qs3[12]; + for (i=11;i>=0;i--) { + r = z*r + qr3[i]; + s = z*s + qs3[i]; + } + } else if (x>2.5L) { + r = qr4[12]; s = qs4[12]; + for (i=11;i>=0;i--) { + r = z*r + qr4[i]; + s = z*s + qs4[i]; + } + } else if (x> (1.0L/0.5625L)) { + r = qr5[12]; s = qs5[12]; + for (i=11;i>=0;i--) { + r = z*r + qr5[i]; + s = z*s + qs5[i]; + } + } else { /* assume x > 1.28 */ + r = qr6[12]; s = qs6[12]; + for (i=11;i>=0;i--) { + r = z*r + qr6[i]; + s = z*s + qs6[i]; + } + } + return t*(r/s); +} diff --git a/usr/src/lib/libm/common/Q/jnl.c b/usr/src/lib/libm/common/Q/jnl.c new file mode 100644 index 0000000000..40d5d061e5 --- /dev/null +++ b/usr/src/lib/libm/common/Q/jnl.c @@ -0,0 +1,289 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak jnl = __jnl +#pragma weak ynl = __ynl +#endif + +/* + * floating point Bessel's function of the 1st and 2nd kind + * of order n: jn(n,x),yn(n,x); + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + * Note 2. About jn(n,x), yn(n,x) + * For n=0, j0(x) is called, + * for n=1, j1(x) is called, + * for n<x, forward recursion us used starting + * from values of j0(x) and j1(x). + * for n>x, a continued fraction approximation to + * j(n,x)/j(n-1,x) is evaluated and then backward + * recursion is used starting from a supposed value + * for j(n,x). The resulting value of j(0,x) is + * compared with the actual value to correct the + * supposed value of j(n,x). + * + * yn(n,x) is similar in all respects, except + * that forward recursion is used for all + * values of n>1. + * + */ + +#include "libm.h" +#include "longdouble.h" +#include <float.h> /* LDBL_MAX */ + +#define GENERIC long double + +static const GENERIC +invsqrtpi = 5.641895835477562869480794515607725858441e-0001L, +two = 2.0L, +zero = 0.0L, +one = 1.0L; + +GENERIC +jnl(n, x) int n; GENERIC x; { + int i, sgn; + GENERIC a, b, temp, z, w; + + /* + * J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) + * Thus, J(-n,x) = J(n,-x) + */ + if (n < 0) { + n = -n; + x = -x; + } + if (n == 0) + return (j0l(x)); + if (n == 1) + return (j1l(x)); + if (x != x) + return (x+x); + if ((n&1) == 0) + sgn = 0; /* even n */ + else + sgn = signbitl(x); /* old n */ + x = fabsl(x); + if (x == zero || !finitel(x)) b = zero; + else if ((GENERIC)n <= x) { + /* + * Safe to use + * J(n+1,x)=2n/x *J(n,x)-J(n-1,x) + */ + if (x > 1.0e91L) { + /* + * x >> n**2 + * Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + * Let s=sin(x), c=cos(x), + * xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + * + * n sin(xn)*sqt2 cos(xn)*sqt2 + * ---------------------------------- + * 0 s-c c+s + * 1 -s-c -c+s + * 2 -s+c -c-s + * 3 s+c c-s + */ + switch (n&3) { + case 0: temp = cosl(x)+sinl(x); break; + case 1: temp = -cosl(x)+sinl(x); break; + case 2: temp = -cosl(x)-sinl(x); break; + case 3: temp = cosl(x)-sinl(x); break; + } + b = invsqrtpi*temp/sqrtl(x); + } else { + a = j0l(x); + b = j1l(x); + for (i = 1; i < n; i++) { + temp = b; + b = b*((GENERIC)(i+i)/x) - a; /* avoid underflow */ + a = temp; + } + } + } else { + if (x < 1e-17L) { /* use J(n,x) = 1/n!*(x/2)^n */ + b = powl(0.5L*x, (GENERIC)n); + if (b != zero) { + for (a = one, i = 1; i <= n; i++) a *= (GENERIC)i; + b = b/a; + } + } else { + /* use backward recurrence */ + /* + * x x^2 x^2 + * J(n,x)/J(n-1,x) = ---- ------ ------ ..... + * 2n - 2(n+1) - 2(n+2) + * + * 1 1 1 + * (for large x) = ---- ------ ------ ..... + * 2n 2(n+1) 2(n+2) + * -- - ------ - ------ - + * x x x + * + * Let w = 2n/x and h=2/x, then the above quotient + * is equal to the continued fraction: + * 1 + * = ----------------------- + * 1 + * w - ----------------- + * 1 + * w+h - --------- + * w+2h - ... + * + * To determine how many terms needed, let + * Q(0) = w, Q(1) = w(w+h) - 1, + * Q(k) = (w+k*h)*Q(k-1) - Q(k-2), + * When Q(k) > 1e4 good for single + * When Q(k) > 1e9 good for double + * When Q(k) > 1e17 good for quaduple + */ + /* determin k */ + GENERIC t, v; + double q0, q1, h, tmp; int k, m; + w = (n+n)/(double)x; h = 2.0/(double)x; + q0 = w; z = w+h; q1 = w*z - 1.0; k = 1; + while (q1 < 1.0e17) { + k += 1; z += h; + tmp = z*q1 - q0; + q0 = q1; + q1 = tmp; + } + m = n+n; + for (t = zero, i = 2*(n+k); i >= m; i -= 2) t = one/(i/x-t); + a = t; + b = one; + /* + * estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) + * hence, if n*(log(2n/x)) > ... + * single 8.8722839355e+01 + * double 7.09782712893383973096e+02 + * long double 1.1356523406294143949491931077970765006170e+04 + * then recurrent value may overflow and the result is + * likely underflow to zero + */ + tmp = n; + v = two/x; + tmp = tmp*logl(fabsl(v*tmp)); + if (tmp < 1.1356523406294143949491931077970765e+04L) { + for (i = n-1; i > 0; i--) { + temp = b; + b = ((i+i)/x)*b - a; + a = temp; + } + } else { + for (i = n-1; i > 0; i--) { + temp = b; + b = ((i+i)/x)*b - a; + a = temp; + if (b > 1e1000L) { + a /= b; + t /= b; + b = 1.0; + } + } + } + b = (t*j0l(x)/b); + } + } + if (sgn == 1) + return (-b); + else + return (b); +} + +GENERIC ynl(n, x) +int n; GENERIC x; { + int i; + int sign; + GENERIC a, b, temp; + + if (x != x) + return (x+x); + if (x <= zero) { + if (x == zero) + return (-one/zero); + else + return (zero/zero); + } + sign = 1; + if (n < 0) { + n = -n; + if ((n&1) == 1) sign = -1; + } + if (n == 0) + return (y0l(x)); + if (n == 1) + return (sign*y1l(x)); + if (!finitel(x)) + return (zero); + + if (x > 1.0e91L) { /* x >> n**2 + Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + Let s = sin(x), c = cos(x), + xn = x-(2n+1)*pi/4, sqt2 = sqrt(2), then + + n sin(xn)*sqt2 cos(xn)*sqt2 + ---------------------------------- + 0 s-c c+s + 1 -s-c -c+s + 2 -s+c -c-s + 3 s+c c-s + */ + switch (n&3) { + case 0: temp = sinl(x)-cosl(x); break; + case 1: temp = -sinl(x)-cosl(x); break; + case 2: temp = -sinl(x)+cosl(x); break; + case 3: temp = sinl(x)+cosl(x); break; + } + b = invsqrtpi*temp/sqrtl(x); + } else { + a = y0l(x); + b = y1l(x); + /* + * fix 1262058 and take care of non-default rounding + */ + for (i = 1; i < n; i++) { + temp = b; + b *= (GENERIC) (i + i) / x; + if (b <= -LDBL_MAX) + break; + b -= a; + a = temp; + } + } + if (sign > 0) + return (b); + else + return (-b); +} diff --git a/usr/src/lib/libm/common/Q/lgammal.c b/usr/src/lib/libm/common/Q/lgammal.c new file mode 100644 index 0000000000..f54621dc99 --- /dev/null +++ b/usr/src/lib/libm/common/Q/lgammal.c @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak lgammal = __lgammal + +/* + * long double lgammal(long double x); + */ + +#include "libm.h" +#include "longdouble.h" + +extern int signgam; +extern int signgaml; + +long double +lgammal(long double x) { + long double y = __k_lgammal(x, &signgaml); + + signgam = signgaml; /* SUSv3 requires the setting of signgam */ + return (y); +} diff --git a/usr/src/lib/libm/common/Q/lgammal_r.c b/usr/src/lib/libm/common/Q/lgammal_r.c new file mode 100644 index 0000000000..bba4986004 --- /dev/null +++ b/usr/src/lib/libm/common/Q/lgammal_r.c @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * long double lgammal_r(long double x, int *signgamlp); + */ + +#pragma weak lgammal_r = __lgammal_r + +#include "libm.h" +#include "longdouble.h" + +long double +lgammal_r(long double x, int *signgamlp) { + return (__k_lgammal(x, signgamlp)); +} diff --git a/usr/src/lib/libm/common/Q/log10l.c b/usr/src/lib/libm/common/Q/log10l.c new file mode 100644 index 0000000000..9c83580531 --- /dev/null +++ b/usr/src/lib/libm/common/Q/log10l.c @@ -0,0 +1,110 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak log10l = __log10l +#endif + +/* + * log10l(X) + * + * Method : + * Let log10_2hi = leading 98(SPARC)/49(x86) bits of log10(2) and + * log10_2lo = log10(2) - log10_2hi, + * ivln10 = 1/log(10) rounded. + * Then + * n = ilogb(x), + * if (n<0) n = n+1; + * x = scalbn(x,-n); + * LOG10(x) := n*log10_2hi + (n*log10_2lo + ivln10*log(x)) + * + * Note1: + * For fear of destroying log10(10**n)=n, the rounding mode is + * set to Round-to-Nearest. + * + * Special cases: + * log10(x) is NaN with signal if x < 0; + * log10(+INF) is +INF with no signal; log10(0) is -INF with signal; + * log10(NaN) is that NaN with no signal; + * log10(10**N) = N for N=0,1,...,22. + * + * Constants: + * The hexadecimal values are the intended ones for the following constants. + * The decimal values may be used, provided that the compiler will convert + * from decimal to binary accurately enough to produce the hexadecimal values + * shown. + */ + +#include "libm.h" +#include "longdouble.h" + +#if defined(__x86) +#define __swapRD __swap87RD +#endif +extern enum fp_direction_type __swapRD(enum fp_direction_type); + +static const long double + zero = 0.0L, + ivln10 = 4.342944819032518276511289189166050822944e-0001L, + one = 1.0L, +#if defined(__x86) + log10_2hi = 3.010299956639803653501985536422580480576e-01L, + log10_2lo = 8.298635403410822349787106337291183585413e-16L; +#elif defined(__sparc) + log10_2hi = 3.010299956639811952137388947242098603469e-01L, + log10_2lo = 2.831664213089468167896664371953210945664e-31L; +#else +#error Unknown Architecture! +#endif + +long double +log10l(long double x) { + long double y, z; + enum fp_direction_type rd; + int n; + + if (!finitel(x)) + return (x + fabsl(x)); /* x is +-INF or NaN */ + else if (x > zero) { + n = ilogbl(x); + if (n < 0) + n += 1; + rd = __swapRD(fp_nearest); + y = n; + x = scalbnl(x, -n); + z = y * log10_2lo + ivln10 * logl(x); + z += y * log10_2hi; + if (rd != fp_nearest) + (void) __swapRD(rd); + return (z); + } else if (x == zero) /* -INF */ + return (-one / zero); + else /* x <0, return NaN */ + return (zero / zero); +} diff --git a/usr/src/lib/libm/common/Q/log1pl.c b/usr/src/lib/libm/common/Q/log1pl.c new file mode 100644 index 0000000000..f00c5eb4ed --- /dev/null +++ b/usr/src/lib/libm/common/Q/log1pl.c @@ -0,0 +1,217 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifdef __LITTLE_ENDIAN +#define H0(x) *(3 + (int *) &x) +#define H1(x) *(2 + (int *) &x) +#define H2(x) *(1 + (int *) &x) +#define H3(x) *(int *) &x +#else +#define H0(x) *(int *) &x +#define H1(x) *(1 + (int *) &x) +#define H2(x) *(2 + (int *) &x) +#define H3(x) *(3 + (int *) &x) +#endif + +/* + * log1pl(x) + * Table look-up algorithm by modifying logl.c + * By K.C. Ng, July 6, 1995 + * + * (a). For 1+x in [31/33,33/31], using a special approximation: + * s = x/(2.0+x); ... here |s| <= 0.03125 + * z = s*s; + * return x-s*(x-z*(B1+z*(B2+z*(B3+z*(B4+...+z*B9)...)))); + * (i.e., x is in [-2/33,2/31]) + * + * (b). Otherwise, normalize 1+x = 2^n * 1.f. + * Here we may need a correction term for 1+x rounded. + * Use a 6-bit table look-up: find a 6 bit g that match f to 6.5 bits, + * then + * log(1+x) = n*ln2 + log(1.g) + log(1.f/1.g). + * Here the leading and trailing values of log(1.g) are obtained from + * a size-64 table. + * For log(1.f/1.g), let s = (1.f-1.g)/(1.f+1.g). Note that + * 1.f = 2^-n(1+x) + * + * then + * log(1.f/1.g) = log((1+s)/(1-s)) = 2s + 2/3 s^3 + 2/5 s^5 +... + * Note that |s|<2**-8=0.00390625. We use an odd s-polynomial + * approximation to compute log(1.f/1.g): + * s*(A1+s^2*(A2+s^2*(A3+s^2*(A4+s^2*(A5+s^2*(A6+s^2*A7)))))) + * (Precision is 2**-136.91 bits, absolute error) + * + * CAUTION: + * For x>=1, compute 1+x will lost one bit (OK). + * For x in [-0.5,-1), 1+x is exact. + * For x in (-0.5,-2/33]U[2/31,1), up to 4 last bits of x will be lost + * in 1+x. Therefore, to recover the lost bits, one need to compute + * 1.f-1.g accurately. + * + * Let hx = HI(x), m = (hx>>16)-0x3fff (=ilogbl(x)), note that + * -2/33 = -0.0606...= 2^-5 * 1.939..., + * 2/31 = 0.09375 = 2^-4 * 1.500..., + * so for x in (-0.5,-2/33], -5<=m<=-2, n= -1, 1+f=2*(1+x) + * for x in [2/33,1), -4<=m<=-1, n= 0, f=x + * + * In short: + * if x>0, let g: hg= ((hx + (0x200<<(-m)))>>(10-m))<<(10-m) + * then 1.f-1.g = x-g + * if x<0, let g': hg' =((ix-(0x200)<<(-m-1))>>(9-m))<<(9-m) + * (ix=hx&0x7fffffff) + * then 1.f-1.g = 2*(g'+x), + * + * (c). The final result is computed by + * (n*ln2_hi+_TBL_logl_hi[j]) + + * ( (n*ln2_lo+_TBL_logl_lo[j]) + s*(A1+...) ) + * + * Note. + * For ln2_hi and _TBL_logl_hi[j], we force their last 32 bit to be zero + * so that n*ln2_hi + _TBL_logl_hi[j] is exact. Here + * _TBL_logl_hi[j] + _TBL_logl_lo[j] match log(1+j*2**-6) to 194 bits + * + * + * Special cases: + * log(x) is NaN with signal if x < 0 (including -INF) ; + * log(+INF) is +INF; log(0) is -INF with signal; + * log(NaN) is that NaN with no signal. + * + * Constants: + * The hexadecimal values are the intended ones for the following constants. + * The decimal values may be used, provided that the compiler will convert + * from decimal to binary accurately enough to produce the hexadecimal values + * shown. + */ + +#pragma weak log1pl = __log1pl + +#include "libm.h" + +extern const long double _TBL_logl_hi[], _TBL_logl_lo[]; + +static const long double +zero = 0.0L, +one = 1.0L, +two = 2.0L, +ln2hi = 6.931471805599453094172319547495844850203e-0001L, +ln2lo = 1.667085920830552208890449330400379754169e-0025L, +A1 = 2.000000000000000000000000000000000000024e+0000L, +A2 = 6.666666666666666666666666666666091393804e-0001L, +A3 = 4.000000000000000000000000407167070220671e-0001L, +A4 = 2.857142857142857142730077490612903681164e-0001L, +A5 = 2.222222222222242577702836920812882605099e-0001L, +A6 = 1.818181816435493395985912667105885828356e-0001L, +A7 = 1.538537835211839751112067512805496931725e-0001L, +B1 = 6.666666666666666666666666666666961498329e-0001L, +B2 = 3.999999999999999999999999990037655042358e-0001L, +B3 = 2.857142857142857142857273426428347457918e-0001L, +B4 = 2.222222222222222221353229049747910109566e-0001L, +B5 = 1.818181818181821503532559306309070138046e-0001L, +B6 = 1.538461538453809210486356084587356788556e-0001L, +B7 = 1.333333344463358756121456892645178795480e-0001L, +B8 = 1.176460904783899064854645174603360383792e-0001L, +B9 = 1.057293869956598995326368602518056990746e-0001L; + +long double +log1pl(long double x) { + long double f, s, z, qn, h, t, y, g; + int i, j, ix, iy, n, hx, m; + + hx = H0(x); + ix = hx & 0x7fffffff; + if (ix < 0x3ffaf07c) { /* |x|<2/33 */ + if (ix <= 0x3f8d0000) { /* x <= 2**-114, return x */ + if ((int) x == 0) + return (x); + } + s = x / (two + x); /* |s|<2**-8 */ + z = s * s; + return (x - s * (x - z * (B1 + z * (B2 + z * (B3 + z * (B4 + + z * (B5 + z * (B6 + z * (B7 + z * (B8 + z * B9)))))))))); + } + if (ix >= 0x7fff0000) { /* x is +inf or NaN */ + return (x + fabsl(x)); + } + if (hx < 0 && ix >= 0x3fff0000) { + if (ix > 0x3fff0000 || (H1(x) | H2(x) | H3(x)) != 0) + x = zero; + return (x / zero); /* log1p(x) is NaN if x<-1 */ + /* log1p(-1) is -inf */ + } + if (ix >= 0x7ffeffff) + y = x; /* avoid spurious overflow */ + else + y = one + x; + iy = H0(y); + n = ((iy + 0x200) >> 16) - 0x3fff; + iy = (iy & 0x0000ffff) | 0x3fff0000; /* scale 1+x to [1,2] */ + H0(y) = iy; + z = zero; + m = (ix >> 16) - 0x3fff; + /* HI(1+x) = (((hx&0xffff)|0x10000)>>(-m))|0x3fff0000 */ + if (n == 0) { /* x in [2/33,1) */ + g = zero; + H0(g) = ((hx + (0x200 << (-m))) >> (10 - m)) << (10 - m); + t = x - g; + i = (((((hx & 0xffff) | 0x10000) >> (-m)) | 0x3fff0000) + + 0x200) >> 10; + H0(z) = i << 10; + + } else if ((1 + n) == 0 && (ix < 0x3ffe0000)) { /* x in (-0.5,-2/33] */ + g = zero; + H0(g) = ((ix + (0x200 << (-m - 1))) >> (9 - m)) << (9 - m); + t = g + x; + t = t + t; + /* + * HI(2*(1+x)) = + * ((0x10000-(((hx&0xffff)|0x10000)>>(-m)))<<1)|0x3fff0000 + */ + /* + * i = + * ((((0x10000-(((hx&0xffff)|0x10000)>>(-m)))<<1)|0x3fff0000)+ + * 0x200)>>10; H0(z)=i<<10; + */ + z = two * (one - g); + i = H0(z) >> 10; + } else { + i = (iy + 0x200) >> 10; + H0(z) = i << 10; + t = y - z; + } + + s = t / (y + z); + j = i & 0x3f; + z = s * s; + qn = (long double) n; + t = qn * ln2lo + _TBL_logl_lo[j]; + h = qn * ln2hi + _TBL_logl_hi[j]; + f = t + s * (A1 + z * (A2 + z * (A3 + z * (A4 + z * (A5 + z * (A6 + + z * A7)))))); + return (h + f); +} diff --git a/usr/src/lib/libm/common/Q/log2l.c b/usr/src/lib/libm/common/Q/log2l.c new file mode 100644 index 0000000000..08023126f3 --- /dev/null +++ b/usr/src/lib/libm/common/Q/log2l.c @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * log2l(x) + * RETURN THE BASE 2 LOGARITHM OF X + * + * Method: + * purge off 0,INF, and NaN. + * n = ilogb(x) + * if (n<0) n+=1 + * z = scalbn(x,-n) + * LOG2(x) = n + (1/ln2)*log(x) + */ + +#pragma weak log2l = __log2l + +#include "libm.h" +#include "longdouble.h" + +static const long double + zero = 0.0L, + half = 0.5L, + one = 1.0L, + invln2 = 1.442695040888963407359924681001892137427e+0000L; + +long double +log2l(long double x) { + int n; + + if (x == zero || !finitel(x)) + return (logl(x)); + n = ilogbl(x); + if (n < 0) + n += 1; + x = scalbnl(x, -n); + if (x == half) + return (n - one); + return (n + invln2 * logl(x)); +} diff --git a/usr/src/lib/libm/common/Q/logbl.c b/usr/src/lib/libm/common/Q/logbl.c new file mode 100644 index 0000000000..62bb59e6e8 --- /dev/null +++ b/usr/src/lib/libm/common/Q/logbl.c @@ -0,0 +1,83 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak logbl = __logbl +#endif + +#include "libm.h" +#include "xpg6.h" /* __xpg6 */ +#define _C99SUSv3_logb _C99SUSv3_logb_subnormal_is_like_ilogb + +#if defined(__sparc) +#define ISNORMALL(k, x) (k != 0x7fff) /* assuming k != 0 */ +#define X86PDNRM(k, x) +#define XSCALE_OFFSET 0x406f /* 0x3fff + 112 */ +static const long double xscale = 5192296858534827628530496329220096.0L; + /* 2^112 */ +#elif defined(__x86) +/* + * if pseudo-denormal, replace by the equivalent normal + */ +#define X86PDNRM(k, x) if (k == 0 && (((int *) &x)[1] & 0x80000000) != 0) \ + ((int *) &x)[2] |= k = 1 +#if defined(HANDLE_UNSUPPORTED) /* assuming k != 0 */ +#define ISNORMALL(k, x) (k != 0x7fff && (((int *) &x)[1] & 0x80000000) != 0) +#else +#define ISNORMALL(k, x) (k != 0x7fff) +#endif +#define XSCALE_OFFSET 0x403e /* 0x3fff + 63 */ +static const long double xscale = 9223372036854775808.0L; /* 2^63 */ +#endif + +static long double +raise_division(long double v) { +#pragma STDC FENV_ACCESS ON + static const long double zero = 0.0L; + return (v / zero); +} + +long double +logbl(long double x) { + int k = XBIASED_EXP(x); + + X86PDNRM(k, x); + if (k == 0) { + if (ISZEROL(x)) + return (raise_division(-1.0L)); + else if ((__xpg6 & _C99SUSv3_logb) != 0) { + x *= xscale; /* scale up by 2^112 or 2^63 */ + return (long double) (XBIASED_EXP(x) - XSCALE_OFFSET); + } else + return (-16382.L); + } else if (ISNORMALL(k, x)) + return ((long double) (k - 0x3fff)); + else + return (x * x); +} diff --git a/usr/src/lib/libm/common/Q/logl.c b/usr/src/lib/libm/common/Q/logl.c new file mode 100644 index 0000000000..1cdf224c07 --- /dev/null +++ b/usr/src/lib/libm/common/Q/logl.c @@ -0,0 +1,173 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak logl = __logl + +/* + * logl(x) + * Table look-up algorithm + * By K.C. Ng, March 6, 1989 + * + * (a). For x in [31/33,33/31], using a special approximation: + * f = x - 1; + * s = f/(2.0+f); ... here |s| <= 0.03125 + * z = s*s; + * return f-s*(f-z*(B1+z*(B2+z*(B3+z*(B4+...+z*B9)...)))); + * + * (b). Otherwise, normalize x = 2^n * 1.f. + * Use a 6-bit table look-up: find a 6 bit g that match f to 6.5 bits, + * then + * log(x) = n*ln2 + log(1.g) + log(1.f/1.g). + * Here the leading and trailing values of log(1.g) are obtained from + * a size-64 table. + * For log(1.f/1.g), let s = (1.f-1.g)/(1.f+1.g), then + * log(1.f/1.g) = log((1+s)/(1-s)) = 2s + 2/3 s^3 + 2/5 s^5 +... + * Note that |s|<2**-8=0.00390625. We use an odd s-polynomial + * approximation to compute log(1.f/1.g): + * s*(A1+s^2*(A2+s^2*(A3+s^2*(A4+s^2*(A5+s^2*(A6+s^2*A7)))))) + * (Precision is 2**-136.91 bits, absolute error) + * + * (c). The final result is computed by + * (n*ln2_hi+_TBL_logl_hi[j]) + + * ( (n*ln2_lo+_TBL_logl_lo[j]) + s*(A1+...) ) + * + * Note. + * For ln2_hi and _TBL_logl_hi[j], we force their last 32 bit to be zero + * so that n*ln2_hi + _TBL_logl_hi[j] is exact. Here + * _TBL_logl_hi[j] + _TBL_logl_lo[j] match log(1+j*2**-6) to 194 bits + * + * + * Special cases: + * log(x) is NaN with signal if x < 0 (including -INF) ; + * log(+INF) is +INF; log(0) is -INF with signal; + * log(NaN) is that NaN with no signal. + * + * Constants: + * The hexadecimal values are the intended ones for the following constants. + * The decimal values may be used, provided that the compiler will convert + * from decimal to binary accurately enough to produce the hexadecimal values + * shown. + */ + +#include "libm.h" + +extern const long double _TBL_logl_hi[], _TBL_logl_lo[]; + +static const long double + zero = 0.0L, + one = 1.0L, + two = 2.0L, + two113 = 10384593717069655257060992658440192.0L, + ln2hi = 6.931471805599453094172319547495844850203e-0001L, + ln2lo = 1.667085920830552208890449330400379754169e-0025L, + A1 = 2.000000000000000000000000000000000000024e+0000L, + A2 = 6.666666666666666666666666666666091393804e-0001L, + A3 = 4.000000000000000000000000407167070220671e-0001L, + A4 = 2.857142857142857142730077490612903681164e-0001L, + A5 = 2.222222222222242577702836920812882605099e-0001L, + A6 = 1.818181816435493395985912667105885828356e-0001L, + A7 = 1.538537835211839751112067512805496931725e-0001L, + B1 = 6.666666666666666666666666666666961498329e-0001L, + B2 = 3.999999999999999999999999990037655042358e-0001L, + B3 = 2.857142857142857142857273426428347457918e-0001L, + B4 = 2.222222222222222221353229049747910109566e-0001L, + B5 = 1.818181818181821503532559306309070138046e-0001L, + B6 = 1.538461538453809210486356084587356788556e-0001L, + B7 = 1.333333344463358756121456892645178795480e-0001L, + B8 = 1.176460904783899064854645174603360383792e-0001L, + B9 = 1.057293869956598995326368602518056990746e-0001L; + +long double +logl(long double x) { + long double f, s, z, qn, h, t; + int *px = (int *) &x; + int *pz = (int *) &z; + int i, j, ix, i0, i1, n; + + /* get long double precision word ordering */ + if (*(int *) &one == 0) { + i0 = 3; + i1 = 0; + } else { + i0 = 0; + i1 = 3; + } + + n = 0; + ix = px[i0]; + if (ix > 0x3ffee0f8) { /* if x > 31/33 */ + if (ix < 0x3fff1084) { /* if x < 33/31 */ + f = x - one; + z = f * f; + if (((ix - 0x3fff0000) | px[i1] | px[2] | px[1]) == 0) { + return (zero); /* log(1)= +0 */ + } + s = f / (two + f); /* |s|<2**-8 */ + z = s * s; + return (f - s * (f - z * (B1 + z * (B2 + z * (B3 + + z * (B4 + z * (B5 + z * (B6 + z * (B7 + + z * (B8 + z * B9)))))))))); + } + if (ix >= 0x7fff0000) + return (x + x); /* x is +inf or NaN */ + goto LARGE_N; + } + if (ix >= 0x00010000) + goto LARGE_N; + i = ix & 0x7fffffff; + if ((i | px[i1] | px[2] | px[1]) == 0) { + px[i0] |= 0x80000000; + return (one / x); /* log(0.0) = -inf */ + } + if (ix < 0) { + if ((unsigned) ix >= 0xffff0000) + return (x - x); /* x is -inf or NaN */ + return (zero / zero); /* log(x<0) is NaN */ + } + /* subnormal x */ + x *= two113; + n = -113; + ix = px[i0]; +LARGE_N: + n += ((ix + 0x200) >> 16) - 0x3fff; + ix = (ix & 0x0000ffff) | 0x3fff0000; /* scale x to [1,2] */ + px[i0] = ix; + i = ix + 0x200; + pz[i0] = i & 0xfffffc00; + pz[i1] = pz[1] = pz[2] = 0; + s = (x - z) / (x + z); + j = (i >> 10) & 0x3f; + z = s * s; + qn = (long double) n; + t = qn * ln2lo + _TBL_logl_lo[j]; + h = qn * ln2hi + _TBL_logl_hi[j]; + f = t + s * (A1 + z * (A2 + z * (A3 + z * (A4 + z * (A5 + + z * (A6 + z * A7)))))); + return (h + f); +} diff --git a/usr/src/lib/libm/common/Q/longdouble.h b/usr/src/lib/libm/common/Q/longdouble.h new file mode 100644 index 0000000000..5aca94ded1 --- /dev/null +++ b/usr/src/lib/libm/common/Q/longdouble.h @@ -0,0 +1,161 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _Q_LONGDOUBLE_H +#define _Q_LONGDOUBLE_H + +#include <sys/ieeefp.h> + +extern long double __k_cosl(long double, long double); +extern long double __k_lgammal(long double, int *); +extern long double __k_sincosl(long double, long double, long double *); +extern long double __k_sinl(long double, long double); +extern long double __k_tanl(long double, long double, int); +extern long double __poly_libmq(long double, int, const long double *); +extern int __rem_pio2l(long double, long double *); + +extern long double acosdl(long double); +extern long double acoshl(long double); +extern long double acosl(long double); +extern long double acospil(long double); +extern long double acospl(long double); +extern long double aintl(long double); +extern long double anintl(long double); +extern long double annuityl(long double, long double); +extern long double asindl(long double); +extern long double asinhl(long double); +extern long double asinl(long double); +extern long double asinpil(long double); +extern long double asinpl(long double); +extern long double atan2dl(long double, long double); +extern long double atan2l(long double, long double); +extern long double atan2pil(long double, long double); +extern long double atandl(long double); +extern long double atanhl(long double); +extern long double atanl(long double); +extern long double atanpil(long double); +extern long double atanpl(long double); +extern long double cbrtl(long double); +extern long double ceill(long double); +extern long double compoundl(long double, long double); +extern long double copysignl(long double, long double); +extern long double cosdl(long double); +extern long double coshl(long double); +extern long double cosl(long double); +extern long double cospil(long double); +extern long double cospl(long double); +extern long double erfcl(long double); +extern long double erfl(long double); +extern long double exp10l(long double); +extern long double exp2l(long double); +extern long double expl(long double); +extern long double expm1l(long double); +extern long double fabsl(long double); +extern int finitel(long double); +extern long double floorl(long double); +extern long double fmodl(long double, long double); +extern enum fp_class_type fp_classl(long double); +extern long double gammal(long double); +extern long double hypotl(long double, long double); +extern int ilogbl(long double); +extern long double infinityl(void); +extern int irintl(long double); +extern int isinfl(long double); +extern int isnanl(long double); +extern int isnormall(long double); +extern int issubnormall(long double); +extern int iszerol(long double); +extern long double j0l(long double); +extern long double j1l(long double); +extern long double jnl(int, long double); +extern long double lgammal(long double); +extern long double log10l(long double); +extern long double log1pl(long double); +extern long double log2l(long double); +extern long double logbl(long double); +extern long double logl(long double); +extern long double max_normall(void); +extern long double max_subnormall(void); +extern long double min_normall(void); +extern long double min_subnormall(void); +extern long double nextafterl(long double, long double); +extern int nintl(long double); +extern long double pow_li(long double *, int *); +extern long double powl(long double, long double); +extern long double quiet_nanl(long); +extern long double remainderl(long double, long double); +extern long double rintl(long double); +extern long double scalbl(long double, long double); +extern long double scalbnl(long double, int); +extern long double signaling_nanl(long); +extern int signbitl(long double); +extern long double significandl(long double); +extern void sincosdl(long double, long double *, long double *); +extern void sincosl(long double, long double *, long double *); +extern void sincospil(long double, long double *, long double *); +extern void sincospl(long double, long double *, long double *); +extern long double sindl(long double); +extern long double sinhl(long double); +extern long double sinl(long double); +extern long double sinpil(long double); +extern long double sinpl(long double); +extern long double sqrtl(long double); +extern long double tandl(long double); +extern long double tanhl(long double); +extern long double tanl(long double); +extern long double tanpil(long double); +extern long double tanpl(long double); +extern long double y0l(long double); +extern long double y1l(long double); +extern long double ynl(int, long double); + +extern long double q_copysign_(long double *, long double *); +extern long double q_fabs_(long double *); +extern int iq_finite_(long double *); +extern long double q_fmod_(long double *, long double *); +extern enum fp_class_type iq_fp_class_(long double *); +extern int iq_ilogb_(long double *); +extern long double q_infinity_(void); +extern int iq_isinf_(long double *); +extern int iq_isnan_(long double *); +extern int iq_isnormal_(long double *); +extern int iq_issubnormal_(long double *); +extern int iq_iszero_(long double *); +extern long double q_max_normal_(void); +extern long double q_max_subnormal_(void); +extern long double q_min_normal_(void); +extern long double q_min_subnormal_(void); +extern long double q_nextafter_(long double *, long double *); +extern long double q_quiet_nan_(long *); +extern long double q_remainder_(long double *, long double *); +extern long double q_scalbn_(long double *, int *); +extern long double q_signaling_nan_(long *); +extern int iq_signbit_(long double *); + +#endif /* _Q_LONGDOUBLE_H */ diff --git a/usr/src/lib/libm/common/Q/nextafterl.c b/usr/src/lib/libm/common/Q/nextafterl.c new file mode 100644 index 0000000000..1f6e40d398 --- /dev/null +++ b/usr/src/lib/libm/common/Q/nextafterl.c @@ -0,0 +1,119 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak nextafterl = __nextafterl +#endif + +#include "libm.h" +#include <float.h> /* LDBL_MAX, LDBL_MIN */ + +#if defined(__sparc) +#define n0 0 +#define n1 1 +#define n2 2 +#define n3 3 +#define X86PDNRM1(x) +#define INC(px) { \ + if (++px[n3] == 0) \ + if (++px[n2] == 0) \ + if (++px[n1] == 0) \ + ++px[n0]; \ + } +#define DEC(px) { \ + if (--px[n3] == 0xffffffff) \ + if (--px[n2] == 0xffffffff) \ + if (--px[n1] == 0xffffffff) \ + --px[n0]; \ + } +#elif defined(__x86) +#define n0 2 +#define n1 1 +#define n2 0 +#define n3 0 +/* + * if pseudo-denormal, replace by the equivalent normal + */ +#define X86PDNRM1(x) if (XBIASED_EXP(x) == 0 && (((int *) &x)[1] & \ + 0x80000000) != 0) \ + ((int *) &x)[2] |= 1 +#define INC(px) { \ + if (++px[n2] == 0) \ + if ((++px[n1] & ~0x80000000) == 0) \ + px[n1] = 0x80000000, ++px[n0]; \ + } +#define DEC(px) { \ + if (--px[n2] == 0xffffffff) \ + if (--px[n1] == 0x7fffffff) \ + if ((--px[n0] & 0x7fff) != 0) \ + px[n1] |= 0x80000000; \ + } +#endif + +long double +nextafterl(long double x, long double y) { + int *px = (int *) &x; + int *py = (int *) &y; + + if (x == y) + return (y); /* C99 requirement */ + if (x != x || y != y) + return (x * y); + + if (ISZEROL(x)) { /* x == 0.0 */ + px[n0] = py[n0] & XSGNMSK; + px[n1] = px[n2] = 0; + px[n3] = 1; + } else { + X86PDNRM1(x); + if ((px[n0] & XSGNMSK) == 0) { /* x > 0.0 */ + if (x > y) /* x > y */ + DEC(px) + else + INC(px) + } else { + if (x < y) /* x < y */ + DEC(px) + else + INC(px) + } + } +#ifndef lint + { + volatile long double dummy; + int k = XBIASED_EXP(x); + + if (k == 0) + dummy = LDBL_MIN * copysignl(LDBL_MIN, x); + else if (k == 0x7fff) + dummy = LDBL_MAX * copysignl(LDBL_MAX, x); + } +#endif + return (x); +} diff --git a/usr/src/lib/libm/common/Q/powl.c b/usr/src/lib/libm/common/Q/powl.c new file mode 100644 index 0000000000..b88e42a1ca --- /dev/null +++ b/usr/src/lib/libm/common/Q/powl.c @@ -0,0 +1,320 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak powl = __powl +#endif + +#include "libm.h" +#include "xpg6.h" /* __xpg6 */ +#define _C99SUSv3_pow _C99SUSv3_pow_treats_Inf_as_an_even_int + +#if defined(__sparc) +#define i0 0 +#define i1 1 +#define i2 2 +#define i3 3 + +static const long double zero = 0.0L, one = 1.0L, two = 2.0L; + +extern const long double _TBL_logl_hi[], _TBL_logl_lo[]; + +static const long double + two113 = 10384593717069655257060992658440192.0L, + ln2hi = 6.931471805599453094172319547495844850203e-0001L, + ln2lo = 1.667085920830552208890449330400379754169e-0025L, + A2 = 6.666666666666666666666666666666091393804e-0001L, + A3 = 4.000000000000000000000000407167070220671e-0001L, + A4 = 2.857142857142857142730077490612903681164e-0001L, + A5 = 2.222222222222242577702836920812882605099e-0001L, + A6 = 1.818181816435493395985912667105885828356e-0001L, + A7 = 1.538537835211839751112067512805496931725e-0001L, + B1 = 6.666666666666666666666666666666666667787e-0001L, + B2 = 3.999999999999999999999999999999848524411e-0001L, + B3 = 2.857142857142857142857142865084581075070e-0001L, + B4 = 2.222222222222222222222010781800643808497e-0001L, + B5 = 1.818181818181818185051442171337036403674e-0001L, + B6 = 1.538461538461508363540720286292008207673e-0001L, + B7 = 1.333333333506731842033180638329317108428e-0001L, + B8 = 1.176469984587418890634302788283946761670e-0001L, + B9 = 1.053794891561452331722969901564862497132e-0001L; + +static long double +logl_x(long double x, long double *w) { + long double f, f1, v, s, z, qn, h, t; + int *px = (int *) &x; + int *pz = (int *) &z; + int i, j, ix, n; + + n = 0; + ix = px[i0]; + if (ix > 0x3ffef03f && ix < 0x3fff0820) { /* 65/63 > x > 63/65 */ + f = x - one; + z = f * f; + if (((ix - 0x3fff0000) | px[i1] | px[i2] | px[i3]) == 0) { + *w = zero; + return (zero); /* log(1)= +0 */ + } + qn = one / (two + f); + s = f * qn; /* |s|<2**-6 */ + v = s * s; + h = (long double) (2.0 * (double) s); + f1 = (long double) ((double) f); + t = ((two * (f - h) - h * f1) - h * (f - f1)) * qn + + s * (v * (B1 + v * (B2 + v * (B3 + v * (B4 + + v * (B5 + v * (B6 + v * (B7 + v * (B8 + v * B9))))))))); + s = (long double) ((double) (h + t)); + *w = t - (s - h); + return (s); + } + if (ix < 0x00010000) { /* subnormal x */ + x *= two113; + n = -113; + ix = px[i0]; + } + /* LARGE_N */ + n += ((ix + 0x200) >> 16) - 0x3fff; + ix = (ix & 0x0000ffff) | 0x3fff0000; /* scale x to [1,2] */ + px[i0] = ix; + i = ix + 0x200; + pz[i0] = i & 0xfffffc00; + pz[i1] = pz[i2] = pz[i3] = 0; + qn = one / (x + z); + f = x - z; + s = f * qn; + f1 = (long double) ((double) f); + h = (long double) (2.0 * (double) s); + t = qn * ((two * (f - z * h) - h * f1) - h * (f - f1)); + j = (i >> 10) & 0x3f; + v = s * s; + qn = (long double) n; + t += qn * ln2lo + _TBL_logl_lo[j]; + t += s * (v * (A2 + v * (A3 + v * (A4 + v * (A5 + v * (A6 + + v * A7)))))); + v = qn * ln2hi + _TBL_logl_hi[j]; + s = h + v; + t += (h - (s - v)); + z = (long double) ((double) (s + t)); + *w = t - (z - s); + return (z); +} + +extern const long double _TBL_expl_hi[], _TBL_expl_lo[]; +static const long double + invln2_32 = 4.616624130844682903551758979206054839765e+1L, + ln2_32hi = 2.166084939249829091928849858592451515688e-2L, + ln2_32lo = 5.209643502595475652782654157501186731779e-27L, + ln2_64 = 1.083042469624914545964425189778400898568e-2L; + +long double +powl(long double x, long double y) { + long double z, ax; + long double y1, y2, w1, w2; + int sbx, sby, j, k, yisint, m; + int hx, lx, hy, ly, ahx, ahy; + int *pz = (int *) &z; + int *px = (int *) &x; + int *py = (int *) &y; + + hx = px[i0]; + lx = px[i1] | px[i2] | px[i3]; + hy = py[i0]; + ly = py[i1] | py[i2] | py[i3]; + ahx = hx & ~0x80000000; + ahy = hy & ~0x80000000; + + if ((ahy | ly) == 0) + return (one); /* x**+-0 = 1 */ + else if (hx == 0x3fff0000 && lx == 0 && + (__xpg6 & _C99SUSv3_pow) != 0) + return (one); /* C99: 1**anything = 1 */ + else if (ahx > 0x7fff0000 || (ahx == 0x7fff0000 && lx != 0) || + ahy > 0x7fff0000 || (ahy == 0x7fff0000 && ly != 0)) + return (x + y); /* +-NaN return x+y */ + /* includes Sun: 1**NaN = NaN */ + sbx = (unsigned) hx >> 31; + sby = (unsigned) hy >> 31; + ax = fabsl(x); + /* + * determine if y is an odd int when x < 0 + * yisint = 0 ... y is not an integer + * yisint = 1 ... y is an odd int + * yisint = 2 ... y is an even int + */ + yisint = 0; + if (sbx) { + if (ahy >= 0x40700000) /* if |y|>=2**113 */ + yisint = 2; /* even integer y */ + else if (ahy >= 0x3fff0000) { + k = (ahy >> 16) - 0x3fff; /* exponent */ + if (k > 80) { + j = ((unsigned) py[i3]) >> (112 - k); + if ((j << (112 - k)) == py[i3]) + yisint = 2 - (j & 1); + } else if (k > 48) { + j = ((unsigned) py[i2]) >> (80 - k); + if ((j << (80 - k)) == py[i2]) + yisint = 2 - (j & 1); + } else if (k > 16) { + j = ((unsigned) py[i1]) >> (48 - k); + if ((j << (48 - k)) == py[i1]) + yisint = 2 - (j & 1); + } else if (ly == 0) { + j = ahy >> (16 - k); + if ((j << (16 - k)) == ahy) + yisint = 2 - (j & 1); + } + } + } + + /* special value of y */ + if (ly == 0) { + if (ahy == 0x7fff0000) { /* y is +-inf */ + if (((ahx - 0x3fff0000) | lx) == 0) { + if ((__xpg6 & _C99SUSv3_pow) != 0) + return (one); + /* C99: (-1)**+-inf = 1 */ + else + return (y - y); + /* Sun: (+-1)**+-inf = NaN */ + } else if (ahx >= 0x3fff0000) + /* (|x|>1)**+,-inf = inf,0 */ + return (sby == 0 ? y : zero); + else /* (|x|<1)**-,+inf = inf,0 */ + return (sby != 0 ? -y : zero); + } else if (ahy == 0x3fff0000) { /* y is +-1 */ + if (sby != 0) + return (one / x); + else + return (x); + } else if (hy == 0x40000000) /* y is 2 */ + return (x * x); + else if (hy == 0x3ffe0000) { /* y is 0.5 */ + if (!((ahx | lx) == 0 || ((ahx - 0x7fff0000) | lx) == + 0)) + return (sqrtl(x)); + } + } + + /* special value of x */ + if (lx == 0) { + if (ahx == 0x7fff0000 || ahx == 0 || ahx == 0x3fff0000) { + /* x is +-0,+-inf,+-1 */ + z = ax; + if (sby == 1) + z = one / z; /* z = 1/|x| if y is negative */ + if (sbx == 1) { + if (ahx == 0x3fff0000 && yisint == 0) + z = zero / zero; + /* (-1)**non-int is NaN */ + else if (yisint == 1) + z = -z; /* (x<0)**odd = -(|x|**odd) */ + } + return (z); + } + } + + /* (x<0)**(non-int) is NaN */ + if (sbx == 1 && yisint == 0) + return (zero / zero); /* should be volatile */ + + /* Now ax is finite, y is finite */ + /* first compute log(ax) = w1+w2, with 53 bits w1 */ + w1 = logl_x(ax, &w2); + + /* split up y into y1+y2 and compute (y1+y2)*(w1+w2) */ + if (ly == 0 || ahy >= 0x43fe0000) { + y1 = y * w1; + y2 = y * w2; + } else { + y1 = (long double) ((double) y); + y2 = (y - y1) * w1 + y * w2; + y1 *= w1; + } + z = y1 + y2; + j = pz[i0]; + if ((unsigned) j >= 0xffff0000) { /* NaN or -inf */ + if (sbx == 1 && yisint == 1) + return (one / z); + else + return (-one / z); + } else if ((j & ~0x80000000) < 0x3fc30000) { /* |x|<2^-60 */ + if (sbx == 1 && yisint == 1) + return (-one - z); + else + return (one + z); + } else if (j > 0) { + if (j > 0x400d0000) { + if (sbx == 1 && yisint == 1) + return (scalbnl(-one, 20000)); + else + return (scalbnl(one, 20000)); + } + k = (int) (invln2_32 * (z + ln2_64)); + } else { + if ((unsigned) j > 0xc00d0000) { + if (sbx == 1 && yisint == 1) + return (scalbnl(-one, -20000)); + else + return (scalbnl(one, -20000)); + } + k = (int) (invln2_32 * (z - ln2_64)); + } + j = k & 0x1f; + m = k >> 5; + { + /* rational approximation coeffs for [-(ln2)/64,(ln2)/64] */ + long double + t1 = 1.666666666666666666666666666660876387437e-1L, + t2 = -2.777777777777777777777707812093173478756e-3L, + t3 = 6.613756613756613482074280932874221202424e-5L, + t4 = -1.653439153392139954169609822742235851120e-6L, + t5 = 4.175314851769539751387852116610973796053e-8L; + long double t = (long double) k; + + w1 = (y2 - (t * ln2_32hi - y1)) - t * ln2_32lo; + t = w1 * w1; + w2 = (w1 - t * (t1 + t * (t2 + t * (t3 + t * (t4 + t * t5))))) - + two; + z = _TBL_expl_hi[j] - ((_TBL_expl_hi[j] * (w1 + w1)) / w2 - + _TBL_expl_lo[j]); + } + j = m + (pz[i0] >> 16); + if (j && (unsigned) j < 0x7fff) + pz[i0] += m << 16; + else + z = scalbnl(z, m); + + if (sbx == 1 && yisint == 1) + z = -z; /* (-ve)**(odd int) */ + return (z); +} +#else +#error Unsupported Architecture +#endif /* defined(__sparc) */ diff --git a/usr/src/lib/libm/common/Q/remainderl.c b/usr/src/lib/libm/common/Q/remainderl.c new file mode 100644 index 0000000000..82d47328ca --- /dev/null +++ b/usr/src/lib/libm/common/Q/remainderl.c @@ -0,0 +1,88 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak remainderl = __remainderl + +#include "libm.h" +#include "longdouble.h" + +/* + * remainderl(x,p) + * returns x REM p = x - [x/p]*p as if in infinite + * precise arithmetic, where [x/p] is the (inifinite bit) + * integer nearest x/p (in half way case choose the even one). + * Method : + * Based on fmodl() return x-[x/p]chopped*p exactly. + */ + +#define HFMAX 5.948657476786158825428796633140035080982e+4931L +#define DBMIN 6.724206286224187012525355634643505205196e-4932L + +static const long double + zero = 0.0L, + half = 0.5L, + hfmax = HFMAX, /* half of the maximum number */ + dbmin = DBMIN; /* double of the minimum (normal) number */ + +long double +remainderl(long double x, long double p) { + long double hp; + int sx; + + if (isnanl(p)) + return (x + p); + if (!finitel(x)) + return (x - x); + p = fabsl(p); + if (p <= hfmax) + x = fmodl(x, p + p); + sx = signbitl(x); + x = fabsl(x); + if (p < dbmin) { + if (x + x > p) { + if (x == p) + x = zero; + else + x -= p; /* avoid x-x=-0 in RM mode */ + if (x + x >= p) + x -= p; + } + } else { + hp = half * p; + if (x > hp) { + if (x == p) + x = zero; + else + x -= p; /* avoid x-x=-0 in RM mode */ + if (x >= hp) + x -= p; + } + } + return (sx == 0 ? x : -x); +} diff --git a/usr/src/lib/libm/common/Q/rintl.c b/usr/src/lib/libm/common/Q/rintl.c new file mode 100644 index 0000000000..a721e4231b --- /dev/null +++ b/usr/src/lib/libm/common/Q/rintl.c @@ -0,0 +1,75 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak rintl = __rintl + +/* + * rintl(long double x) return x rounded to integral according to + * the prevailing rounding direction + * + * NOTE: aintl(x), anintl(x), ceill(x), floorl(x), and rintl(x) return result + * with the same sign as x's, including 0.0L. + */ + +#include "libm.h" +#include "longdouble.h" + +extern enum fp_precision_type __swapRP(enum fp_precision_type); + +static const double one = 1.0; +static const long double qzero = 0.0L; + +long double +rintl(long double x) { + enum fp_precision_type rp; + long double t, w, two112; + int *pt = (int *) &two112; + + if (!finitel(x)) + return (x + x); + + if (*(int *) &one != 0) { /* set two112 = 2^112 */ + pt[0] = 0x406f0000; + pt[1] = pt[2] = pt[3] = 0; + } else { + pt[3] = 0x406f0000; + pt[0] = pt[1] = pt[2] = 0; + } + + if (fabsl(x) >= two112) + return (x); /* already an integer */ + t = copysignl(two112, x); + rp = __swapRP(fp_extended); /* make sure precision is long double */ + w = x + t; /* x+sign(x)*2^112 rounded to integer */ + (void) __swapRP(rp); /* restore precision mode */ + if (w == t) + return (copysignl(qzero, x)); /* x rounded to zero */ + else + return (w - t); +} diff --git a/usr/src/lib/libm/common/Q/rndintl.c b/usr/src/lib/libm/common/Q/rndintl.c new file mode 100644 index 0000000000..50e7ed1f77 --- /dev/null +++ b/usr/src/lib/libm/common/Q/rndintl.c @@ -0,0 +1,116 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak aintl = __aintl +#pragma weak anintl = __anintl +#pragma weak irintl = __irintl +#pragma weak nintl = __nintl + +/* + * aintl(x) return x chopped to integral value + * anintl(x) return sign(x)*(|x|+0.5) chopped to integral value + * irintl(x) return rint(x) in integer format + * nintl(x) return anint(x) in integer format + * + * NOTE: aintl(x), anintl(x), ceill(x), floorl(x), and rintl(x) return result + * with the same sign as x's, including 0.0. + */ + +#include "libm.h" +#include "longdouble.h" + +extern enum fp_direction_type __swapRD(enum fp_direction_type); + +static const long double qone = 1.0L, qhalf = 0.5L, qmhalf = -0.5L; + +long double +aintl(long double x) { + long double t, w; + + if (!finitel(x)) + return (x + x); + w = fabsl(x); + t = rintl(w); + if (t <= w) + return (copysignl(t, x)); /* NaN or already aint(|x|) */ + else /* |t|>|x| case */ + return (copysignl(t - qone, x)); /* |t-1|*sign(x) */ +} + +long double +anintl(long double x) { + long double t, w, z; + + if (!finitel(x)) + return (x + x); + w = fabsl(x); + t = rintl(w); + if (t == w) + return (copysignl(t, x)); + z = t - w; + if (z > qhalf) + t = t - qone; + else if (z <= qmhalf) + t = t + qone; + return (copysignl(t, x)); +} + +int +irintl(long double x) { + enum fp_direction_type rd; + + rd = __swapRD(fp_nearest); + (void) __swapRD(rd); /* restore Rounding Direction */ + switch (rd) { + case fp_nearest: + if (x < 2147483647.5L && x >= -2147483648.5L) + return ((int)rintl(x)); + break; + case fp_tozero: + if (x < 2147483648.0L && x > -2147483649.0L) + return ((int)rintl(x)); + break; + case fp_positive: + if (x <= 2147483647.0L && x > -2147483649.0L) + return ((int)rintl(x)); + break; + case fp_negative: + if (x < 2147483648.0L && x >= -2147483648.0L) + return ((int)rintl(x)); + break; + } + return ((int)copysignl(1.0e100L, x)); +} + +int +nintl(long double x) { + if ((x < 2147483647.5L) && (x > -2147483648.5L)) + return ((int)anintl(x)); + else + return ((int)copysignl(1.0e100L, x)); +} diff --git a/usr/src/lib/libm/common/Q/scalbl.c b/usr/src/lib/libm/common/Q/scalbl.c new file mode 100644 index 0000000000..7346954a95 --- /dev/null +++ b/usr/src/lib/libm/common/Q/scalbl.c @@ -0,0 +1,68 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak scalbl = __scalbl + +/* + * scalbl(x,n): return x * 2^n by manipulating exponent. + */ + +#include "libm.h" + +#define n0 0 + +long double +scalbl(long double x, long double fn) { + int *py = (int *) &fn, n; + long double z; + + if (isnanl(x) || isnanl(fn)) + return (x * fn); + + /* + * fn is inf or NaN + */ + if ((py[n0] & 0x7fff0000) == 0x7fff0000) { + if ((py[n0] & 0x80000000) != 0) + return (x / (-fn)); + else + return (x * fn); + } + if (rintl(fn) != fn) + return ((fn - fn) / (fn - fn)); + if (fn > 65000.0L) + z = scalbnl(x, 65000); + else if (-fn > 65000.0L) + z = scalbnl(x, -65000); + else { + n = (int) fn; + z = scalbnl(x, n); + } + return (z); +} diff --git a/usr/src/lib/libm/common/Q/scalbnl.c b/usr/src/lib/libm/common/Q/scalbnl.c new file mode 100644 index 0000000000..9351040f0b --- /dev/null +++ b/usr/src/lib/libm/common/Q/scalbnl.c @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak scalbnl = __scalbnl +#endif + +#include "libm.h" +#include <float.h> /* LDBL_MAX, LDBL_MIN */ +#include <stdlib.h> /* abs */ + +#if defined(__sparc) +#define XSET_EXP(k, x) ((int *) &x)[0] = (((int *) &x)[0] & ~0x7fff0000) | \ + (k << 16) +#define ISINFNANL(k, x) (k == 0x7fff) +#define XTWOT_OFFSET 113 +static const long double xtwot = 10384593717069655257060992658440192.0L, + /* 2^113 */ + twomtm1 = 4.814824860968089632639944856462318296E-35L; /* 2^-114 */ +#elif defined(__x86) +#define XSET_EXP(k, x) ((int *) &x)[2] = (((int *) &x)[2] & ~0x7fff) | k +#if defined(HANDLE_UNSUPPORTED) +#define ISINFNANL(k, x) (k == 0x7fff || k != 0 && \ + (((int *) &x)[1] & 0x80000000) == 0) +#else +#define ISINFNANL(k, x) (k == 0x7fff) +#endif +#define XTWOT_OFFSET 64 +static const long double xtwot = 18446744073709551616.0L, /* 2^64 */ + twomtm1 = 2.7105054312137610850186E-20L; /* 2^-65 */ +#endif + +long double +scalbnl(long double x, int n) { + int k = XBIASED_EXP(x); + + if (ISINFNANL(k, x)) + return (x + x); + if (ISZEROL(x) || n == 0) + return (x); + if (k == 0) { + x *= xtwot; + k = XBIASED_EXP(x) - XTWOT_OFFSET; + } + if ((unsigned) abs(n) >= 131072) /* cast to unsigned for -2^31 */ + n >>= 1; /* avoid subsequent integer overflow */ + k += n; + if (k > 0x7ffe) + return (LDBL_MAX * copysignl(LDBL_MAX, x)); + if (k <= -XTWOT_OFFSET - 1) + return (LDBL_MIN * copysignl(LDBL_MIN, x)); + if (k > 0) { + XSET_EXP(k, x); + return (x); + } + k += XTWOT_OFFSET + 1; + XSET_EXP(k, x); + return (x * twomtm1); +} diff --git a/usr/src/lib/libm/common/Q/signgaml.c b/usr/src/lib/libm/common/Q/signgaml.c new file mode 100644 index 0000000000..77aeecf389 --- /dev/null +++ b/usr/src/lib/libm/common/Q/signgaml.c @@ -0,0 +1,34 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak signgaml = __signgaml + +#include "libm.h" + +int signgaml = 0; diff --git a/usr/src/lib/libm/common/Q/significandl.c b/usr/src/lib/libm/common/Q/significandl.c new file mode 100644 index 0000000000..8140463a2e --- /dev/null +++ b/usr/src/lib/libm/common/Q/significandl.c @@ -0,0 +1,42 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak significandl = __significandl +#endif + +#include "libm.h" + +long double +significandl(long double x) { + if (ISZEROL(x) || XBIASED_EXP(x) == 0x7fff) /* 0/+-Inf/NaN */ + return (x + x); + else + return (scalbnl(x, -ilogbl(x))); +} diff --git a/usr/src/lib/libm/common/Q/sincosl.c b/usr/src/lib/libm/common/Q/sincosl.c new file mode 100644 index 0000000000..95fafc9523 --- /dev/null +++ b/usr/src/lib/libm/common/Q/sincosl.c @@ -0,0 +1,98 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * sincosl(x) + * Table look-up algorithm by K.C. Ng, November, 1989. + * + * kernel function: + * __k_sincosl ... sin and cos function on [-pi/4,pi/4] + * __rem_pio2l ... argument reduction routine + * + * Method. + * Let S and C denote the sin and cos respectively on [-PI/4, +PI/4]. + * 1. Assume the argument x is reduced to y1+y2 = x-k*pi/2 in + * [-pi/2 , +pi/2], and let n = k mod 4. + * 2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C S/C + * 1 C -S -C/S + * 2 -S -C S/C + * 3 -C S -C/S + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * computer TRIG(x) returns trig(x) nearly rounded. + */ + +#pragma weak sincosl = __sincosl + +#include "libm.h" +#include "longdouble.h" + +void +sincosl(long double x, long double *s, long double *c) { + long double y[2], z = 0.0L; + int n, ix; + + ix = *(int *) &x; /* High word of x */ + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if (ix <= 0x3ffe9220) + *s = __k_sincosl(x, z, c); + else if (ix >= 0x7fff0000) + *s = *c = x - x; /* trig(Inf or NaN) is NaN */ + else { /* argument reduction needed */ + n = __rem_pio2l(x, y); + switch (n & 3) { + case 0: + *s = __k_sincosl(y[0], y[1], c); + break; + case 1: + *c = -__k_sincosl(y[0], y[1], s); + break; + case 2: + *s = -__k_sincosl(y[0], y[1], c); + *c = -*c; + break; + case 3: + *c = __k_sincosl(y[0], y[1], s); + *s = -*s; + break; + } + } +} diff --git a/usr/src/lib/libm/common/Q/sincospil.c b/usr/src/lib/libm/common/Q/sincospil.c new file mode 100644 index 0000000000..fda3d45490 --- /dev/null +++ b/usr/src/lib/libm/common/Q/sincospil.c @@ -0,0 +1,195 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak sincospil = __sincospil + +/* + * void sincospil(long double x, long double *s, long double *c) + * *s = sinl(pi*x); *c = cosl(pi*x); + * + * Algorithm, 10/17/2002, K.C. Ng + * ------------------------------ + * Let y = |4x|, z = floor(y), and n = (int)(z mod 8.0) (displayed in binary). + * 1. If y == z, then x is a multiple of pi/4. Return the following values: + * --------------------------------------------------- + * n x mod 2 sin(x*pi) cos(x*pi) tan(x*pi) + * --------------------------------------------------- + * 000 0.00 +0 ___ +1 ___ +0 + * 001 0.25 +\/0.5 +\/0.5 +1 + * 010 0.50 +1 ___ +0 ___ +inf + * 011 0.75 +\/0.5 -\/0.5 -1 + * 100 1.00 -0 ___ -1 ___ +0 + * 101 1.25 -\/0.5 -\/0.5 +1 + * 110 1.50 -1 ___ -0 ___ +inf + * 111 1.75 -\/0.5 +\/0.5 -1 + * --------------------------------------------------- + * 2. Otherwise, + * --------------------------------------------------- + * n t sin(x*pi) cos(x*pi) tan(x*pi) + * --------------------------------------------------- + * 000 (y-z)/4 sinpi(t) cospi(t) tanpi(t) + * 001 (z+1-y)/4 cospi(t) sinpi(t) 1/tanpi(t) + * 010 (y-z)/4 cospi(t) -sinpi(t) -1/tanpi(t) + * 011 (z+1-y)/4 sinpi(t) -cospi(t) -tanpi(t) + * 100 (y-z)/4 -sinpi(t) -cospi(t) tanpi(t) + * 101 (z+1-y)/4 -cospi(t) -sinpi(t) 1/tanpi(t) + * 110 (y-z)/4 -cospi(t) sinpi(t) -1/tanpi(t) + * 111 (z+1-y)/4 -sinpi(t) cospi(t) -tanpi(t) + * --------------------------------------------------- + * + * NOTE. This program compute sinpi/cospi(t<0.25) by __k_sin/cos(pi*t, 0.0). + * This will return a result with error slightly more than one ulp (but less + * than 2 ulp). If one wants accurate result, one may break up pi*t in + * high (tpi_h) and low (tpi_l) parts and call __k_sin/cos(tip_h, tip_lo) + * instead. + */ + +#include "libm.h" +#include "longdouble.h" + +#define I(q, m) ((int *) &(q))[m] +#define U(q, m) ((unsigned *) &(q))[m] +#if defined(__LITTLE_ENDIAN) || defined(__x86) +#define LDBL_MOST_SIGNIF_I(ld) ((I(ld, 2) << 16) | (0xffff & (I(ld, 1) >> 15))) +#define LDBL_LEAST_SIGNIF_U(ld) U(ld, 0) +#define PREC 64 +#define PRECM1 63 +#define PRECM2 62 +static const long double twoPRECM2 = 9.223372036854775808000000000000000e+18L; +#else +#define LDBL_MOST_SIGNIF_I(ld) I(ld, 0) +#define LDBL_LEAST_SIGNIF_U(ld) U(ld, sizeof (long double) / sizeof (int) - 1) +#define PREC 113 +#define PRECM1 112 +#define PRECM2 111 +static const long double twoPRECM2 = 5.192296858534827628530496329220096e+33L; +#endif + +static const long double +zero = 0.0L, +quater = 0.25L, +one = 1.0L, +pi = 3.141592653589793238462643383279502884197e+0000L, +sqrth = 0.707106781186547524400844362104849039284835937688474, +tiny = 1.0e-100; + +void +sincospil(long double x, long double *s, long double *c) { + long double y, z, t; + int hx, n, k; + unsigned lx; + + hx = LDBL_MOST_SIGNIF_I(x); + lx = LDBL_LEAST_SIGNIF_U(x); + k = ((hx & 0x7fff0000) >> 16) - 0x3fff; + if (k >= PRECM2) { /* |x| >= 2**(Prec-2) */ + if (k >= 16384) { + *s = *c = x - x; + } else { + if (k >= PREC) { + *s = zero; + *c = one; + } else if (k == PRECM1) { + if ((lx & 1) == 0) { + *s = zero; + *c = one; + } else { + *s = -zero; + *c = -one; + } + } else { /* k = Prec - 2 */ + if ((lx & 1) == 0) { + *s = zero; + *c = one; + } else { + *s = one; + *c = zero; + } + if ((lx & 2) != 0) { + *s = -*s; + *c = -*c; + } + } + } + } else if (k < -2) /* |x| < 0.25 */ + *s = __k_sincosl(pi * fabsl(x), zero, c); + else { + /* y = |4x|, z = floor(y), and n = (int)(z mod 8.0) */ + y = 4.0L * fabsl(x); + if (k < PRECM2) { + z = y + twoPRECM2; + n = LDBL_LEAST_SIGNIF_U(z) & 7; /* 3 LSb of z */ + t = z - twoPRECM2; + k = 0; + if (t == y) + k = 1; + else if (t > y) { + n -= 1; + t = quater + (y - t) * quater; + } else + t = (y - t) * quater; + } else { /* k = Prec-3 */ + n = LDBL_LEAST_SIGNIF_U(y) & 7; /* 3 LSb of z */ + k = 1; + } + if (k) { /* x = N/4 */ + if ((n & 1) != 0) + *s = *c = sqrth + tiny; + else + if ((n & 2) == 0) { + *s = zero; + *c = one; + } else { + *s = one; + *c = zero; + } + if ((n & 4) != 0) + *s = -*s; + if (((n + 1) & 4) != 0) + *c = -*c; + } else { + if ((n & 1) != 0) + t = quater - t; + if (((n + (n & 1)) & 2) == 0) + *s = __k_sincosl(pi * t, zero, c); + else + *c = __k_sincosl(pi * t, zero, s); + if ((n & 4) != 0) + *s = -*s; + if (((n + 2) & 4) != 0) + *c = -*c; + } + } + if (hx < 0) + *s = -*s; +} +#undef U +#undef LDBL_LEAST_SIGNIF_U +#undef I +#undef LDBL_MOST_SIGNIF_I diff --git a/usr/src/lib/libm/common/Q/sinhl.c b/usr/src/lib/libm/common/Q/sinhl.c new file mode 100644 index 0000000000..dc37e457a7 --- /dev/null +++ b/usr/src/lib/libm/common/Q/sinhl.c @@ -0,0 +1,90 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak sinhl = __sinhl + +#include "libm.h" +#include "longdouble.h" + +/* + * sinhl(X) + * RETURN THE HYPERBOLIC SINE OF X + * + * Method : + * 1. reduce x to non-negative by sinhl(-x) = - sinhl(x). + * 2. + * + * expm1l(x) + expm1l(x)/(expm1l(x)+1) + * 0 <= x <= lnovft : sinhl(x) := -------------------------------- + * 2 + * + * lnovft <= x < INF : sinhl(x) := expl(x-MEP1*ln2)*2**ME + * + * here + * lnovft: logrithm of the overflow threshold + * = MEP1*ln2 chopped to machine precision. + * ME maximum exponent + * MEP1 maximum exponent plus 1 + * + * Special cases: + * sinhl(x) is x if x is +INF, -INF, or NaN. + * only sinhl(0)=0 is exact for finite argument. + * + */ + +#define ME 16383 +#define MEP1 16384 +#define LNOVFT 1.135652340629414394949193107797076342845e+4L + /* last 32 bits of LN2HI is zero */ +#define LN2HI 6.931471805599453094172319547495844850203e-0001L +#define LN2LO 1.667085920830552208890449330400379754169e-0025L + +static const long double + half = 0.5L, + one = 1.0L, + ln2hi = LN2HI, + ln2lo = LN2LO, + lnovftL = LNOVFT; + +long double +sinhl(long double x) { + long double r, t; + + if (!finitel(x)) + return (x + x); /* sinh of NaN or +-INF is itself */ + r = fabsl(x); + if (r < lnovftL) { + t = expm1l(r); + r = copysignl((t + t / (one + t)) * half, x); + } else { + r = copysignl(expl((r - MEP1 * ln2hi) - MEP1 * ln2lo), x); + r = scalbnl(r, ME); + } + return (r); +} diff --git a/usr/src/lib/libm/common/Q/sinl.c b/usr/src/lib/libm/common/Q/sinl.c new file mode 100644 index 0000000000..302b9f4f1b --- /dev/null +++ b/usr/src/lib/libm/common/Q/sinl.c @@ -0,0 +1,93 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * sinl(x) + * Table look-up algorithm by K.C. Ng, November, 1989. + * + * kernel function: + * __k_sinl ... sin function on [-pi/4,pi/4] + * __k_cosl ... cos function on [-pi/4,pi/4] + * __rem_pio2l ... argument reduction routine + * + * Method. + * Let S and C denote the sin and cos respectively on [-PI/4, +PI/4]. + * 1. Assume the argument x is reduced to y1+y2 = x-k*pi/2 in + * [-pi/2 , +pi/2], and let n = k mod 4. + * 2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C S/C + * 1 C -S -C/S + * 2 -S -C S/C + * 3 -C S -C/S + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * computer TRIG(x) returns trig(x) nearly rounded. + */ + +#pragma weak sinl = __sinl + +#include "libm.h" +#include "longdouble.h" + +long double +sinl(long double x) { + long double y[2], z = 0.0L; + int n, ix; + + ix = *(int *) &x; /* High word of x */ + ix &= 0x7fffffff; + if (ix <= 0x3ffe9220) /* |x| ~< pi/4 */ + return (__k_sinl(x, z)); + else if (ix >= 0x7fff0000) /* sin(Inf or NaN) is NaN */ + return (x - x); + else { /* argument reduction needed */ + n = __rem_pio2l(x, y); + switch (n & 3) { + case 0: + return (__k_sinl(y[0], y[1])); + case 1: + return (__k_cosl(y[0], y[1])); + case 2: + return (-__k_sinl(y[0], y[1])); + case 3: + return (-__k_cosl(y[0], y[1])); + } + } + /* NOTREACHED */ + return 0.0L; +} diff --git a/usr/src/lib/libm/common/Q/sinpil.c b/usr/src/lib/libm/common/Q/sinpil.c new file mode 100644 index 0000000000..b708069de5 --- /dev/null +++ b/usr/src/lib/libm/common/Q/sinpil.c @@ -0,0 +1,169 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak sinpil = __sinpil + +/* + * long double sinpil(long double x), + * return long double precision sinl(pi*x). + * + * Algorithm, 10/17/2002, K.C. Ng + * ------------------------------ + * Let y = |4x|, z = floor(y), and n = (int)(z mod 8.0) (displayed in binary). + * 1. If y == z, then x is a multiple of pi/4. Return the following values: + * --------------------------------------------------- + * n x mod 2 sin(x*pi) cos(x*pi) tan(x*pi) + * --------------------------------------------------- + * 000 0.00 +0 ___ +1 ___ +0 + * 001 0.25 +\/0.5 +\/0.5 +1 + * 010 0.50 +1 ___ +0 ___ +inf + * 011 0.75 +\/0.5 -\/0.5 -1 + * 100 1.00 -0 ___ -1 ___ +0 + * 101 1.25 -\/0.5 -\/0.5 +1 + * 110 1.50 -1 ___ -0 ___ +inf + * 111 1.75 -\/0.5 +\/0.5 -1 + * --------------------------------------------------- + * 2. Otherwise, + * --------------------------------------------------- + * n t sin(x*pi) cos(x*pi) tan(x*pi) + * --------------------------------------------------- + * 000 (y-z)/4 sinpi(t) cospi(t) tanpi(t) + * 001 (z+1-y)/4 cospi(t) sinpi(t) 1/tanpi(t) + * 010 (y-z)/4 cospi(t) -sinpi(t) -1/tanpi(t) + * 011 (z+1-y)/4 sinpi(t) -cospi(t) -tanpi(t) + * 100 (y-z)/4 -sinpi(t) -cospi(t) tanpi(t) + * 101 (z+1-y)/4 -cospi(t) -sinpi(t) 1/tanpi(t) + * 110 (y-z)/4 -cospi(t) sinpi(t) -1/tanpi(t) + * 111 (z+1-y)/4 -sinpi(t) cospi(t) -tanpi(t) + * --------------------------------------------------- + * + * NOTE. This program compute sinpi/cospi(t<0.25) by __k_sin/cos(pi*t, 0.0). + * This will return a result with error slightly more than one ulp (but less + * than 2 ulp). If one wants accurate result, one may break up pi*t in + * high (tpi_h) and low (tpi_l) parts and call __k_sin/cos(tip_h, tip_lo) + * instead. + */ + +#include "libm.h" +#include "longdouble.h" + +#define I(q, m) ((int *) &(q))[m] +#define U(q, m) ((unsigned *) &(q))[m] +#if defined(__LITTLE_ENDIAN) || defined(__x86) +#define LDBL_MOST_SIGNIF_I(ld) ((I(ld, 2) << 16) | (0xffff & (I(ld, 1) >> 15))) +#define LDBL_LEAST_SIGNIF_U(ld) U(ld, 0) +#define PREC 64 +#define PRECM1 63 +#define PRECM2 62 +static const long double twoPRECM2 = 9.223372036854775808000000000000000e+18L; +#else +#define LDBL_MOST_SIGNIF_I(ld) I(ld, 0) +#define LDBL_LEAST_SIGNIF_U(ld) U(ld, sizeof (long double) / sizeof (int) - 1) +#define PREC 113 +#define PRECM1 112 +#define PRECM2 111 +static const long double twoPRECM2 = 5.192296858534827628530496329220096e+33L; +#endif + +static const long double +zero = 0.0L, +quater = 0.25L, +one = 1.0L, +pi = 3.141592653589793238462643383279502884197e+0000L, +sqrth = 0.707106781186547524400844362104849039284835937688474, +tiny = 1.0e-100; + +long double +sinpil(long double x) { + long double y, z, t; + int hx, n, k; + unsigned lx; + + hx = LDBL_MOST_SIGNIF_I(x); + lx = LDBL_LEAST_SIGNIF_U(x); + k = ((hx & 0x7fff0000) >> 16) - 0x3fff; + if (k >= PRECM2) { /* |x| >= 2**(Prec-2) */ + if (k >= 16384) + y = x - x; + else { + if (k >= PREC) + y = zero; + else if (k == PRECM1) + y = (lx & 1) == 0 ? zero: -zero; + else { /* k = Prec - 2 */ + y = (lx & 1) == 0 ? zero : one; + if ((lx & 2) != 0) + y = -y; + } + } + } else if (k < -2) /* |x| < 0.25 */ + y = __k_sinl(pi * fabsl(x), zero); + else { + /* y = |4x|, z = floor(y), and n = (int)(z mod 8.0) */ + y = 4.0L * fabsl(x); + if (k < PRECM2) { + z = y + twoPRECM2; + n = LDBL_LEAST_SIGNIF_U(z) & 7; /* 3 LSb of z */ + t = z - twoPRECM2; + k = 0; + if (t == y) + k = 1; + else if (t > y) { + n -= 1; + t = quater + (y - t) * quater; + } else + t = (y - t) * quater; + } else { /* k = Prec-3 */ + n = LDBL_LEAST_SIGNIF_U(y) & 7; /* 3 LSb of z */ + k = 1; + } + if (k) { /* x = N/4 */ + if ((n & 1) != 0) + y = sqrth + tiny; + else + y = (n & 2) == 0 ? zero : one; + if ((n & 4) != 0) + y = -y; + } else { + if ((n & 1) != 0) + t = quater - t; + if (((n + (n & 1)) & 2) == 0) + y = __k_sinl(pi * t, zero); + else + y = __k_cosl(pi * t, zero); + if ((n & 4) != 0) + y = -y; + } + } + return (hx >= 0 ? y : -y); +} +#undef U +#undef LDBL_LEAST_SIGNIF_U +#undef I +#undef LDBL_MOST_SIGNIF_I diff --git a/usr/src/lib/libm/common/Q/sqrtl.c b/usr/src/lib/libm/common/Q/sqrtl.c new file mode 100644 index 0000000000..30c8f5e097 --- /dev/null +++ b/usr/src/lib/libm/common/Q/sqrtl.c @@ -0,0 +1,479 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma weak sqrtl = __sqrtl + +#include "libm.h" +#include "longdouble.h" + +extern int __swapTE(int); +extern int __swapEX(int); +extern enum fp_direction_type __swapRD(enum fp_direction_type); + +/* + * in struct longdouble, msw consists of + * unsigned short sgn:1; + * unsigned short exp:15; + * unsigned short frac1:16; + */ + +#ifdef __LITTLE_ENDIAN + +/* array indices used to access words within a double */ +#define HIWORD 1 +#define LOWORD 0 + +/* structure used to access words within a quad */ +union longdouble { + struct { + unsigned int frac4; + unsigned int frac3; + unsigned int frac2; + unsigned int msw; + } l; + long double d; +}; + +/* default NaN returned for sqrt(neg) */ +static const union longdouble + qnan = { 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff }; + +/* signalling NaN used to raise invalid */ +static const union { + unsigned u[2]; + double d; +} snan = { 0, 0x7ff00001 }; + +#else + +/* array indices used to access words within a double */ +#define HIWORD 0 +#define LOWORD 1 + +/* structure used to access words within a quad */ +union longdouble { + struct { + unsigned int msw; + unsigned int frac2; + unsigned int frac3; + unsigned int frac4; + } l; + long double d; +}; + +/* default NaN returned for sqrt(neg) */ +static const union longdouble + qnan = { 0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff }; + +/* signalling NaN used to raise invalid */ +static const union { + unsigned u[2]; + double d; +} snan = { 0x7ff00001, 0 }; + +#endif /* __LITTLE_ENDIAN */ + + +static const double + zero = 0.0, + half = 0.5, + one = 1.0, + huge = 1.0e300, + tiny = 1.0e-300, + two36 = 6.87194767360000000000e+10, + two30 = 1.07374182400000000000e+09, + two6 = 6.40000000000000000000e+01, + two4 = 1.60000000000000000000e+01, + twom18 = 3.81469726562500000000e-06, + twom28 = 3.72529029846191406250e-09, + twom42 = 2.27373675443232059479e-13, + twom60 = 8.67361737988403547206e-19, + twom62 = 2.16840434497100886801e-19, + twom66 = 1.35525271560688054251e-20, + twom90 = 8.07793566946316088742e-28, + twom113 = 9.62964972193617926528e-35, + twom124 = 4.70197740328915003187e-38; + + +/* +* Extract the exponent and normalized significand (represented as +* an array of five doubles) from a finite, nonzero quad. +*/ +static int +__q_unpack(const union longdouble *x, double *s) +{ + union { + double d; + unsigned int l[2]; + } u; + double b; + unsigned int lx, w[3]; + int ex; + + /* get the normalized significand and exponent */ + ex = (int) ((x->l.msw & 0x7fffffff) >> 16); + lx = x->l.msw & 0xffff; + if (ex) + { + lx |= 0x10000; + w[0] = x->l.frac2; + w[1] = x->l.frac3; + w[2] = x->l.frac4; + } + else + { + if (lx | (x->l.frac2 & 0xfffe0000)) + { + w[0] = x->l.frac2; + w[1] = x->l.frac3; + w[2] = x->l.frac4; + ex = 1; + } + else if (x->l.frac2 | (x->l.frac3 & 0xfffe0000)) + { + lx = x->l.frac2; + w[0] = x->l.frac3; + w[1] = x->l.frac4; + w[2] = 0; + ex = -31; + } + else if (x->l.frac3 | (x->l.frac4 & 0xfffe0000)) + { + lx = x->l.frac3; + w[0] = x->l.frac4; + w[1] = w[2] = 0; + ex = -63; + } + else + { + lx = x->l.frac4; + w[0] = w[1] = w[2] = 0; + ex = -95; + } + while ((lx & 0x10000) == 0) + { + lx = (lx << 1) | (w[0] >> 31); + w[0] = (w[0] << 1) | (w[1] >> 31); + w[1] = (w[1] << 1) | (w[2] >> 31); + w[2] <<= 1; + ex--; + } + } + + /* extract the significand into five doubles */ + u.l[HIWORD] = 0x42300000; + u.l[LOWORD] = 0; + b = u.d; + u.l[LOWORD] = lx; + s[0] = u.d - b; + + u.l[HIWORD] = 0x40300000; + u.l[LOWORD] = 0; + b = u.d; + u.l[LOWORD] = w[0] & 0xffffff00; + s[1] = u.d - b; + + u.l[HIWORD] = 0x3e300000; + u.l[LOWORD] = 0; + b = u.d; + u.l[HIWORD] |= w[0] & 0xff; + u.l[LOWORD] = w[1] & 0xffff0000; + s[2] = u.d - b; + + u.l[HIWORD] = 0x3c300000; + u.l[LOWORD] = 0; + b = u.d; + u.l[HIWORD] |= w[1] & 0xffff; + u.l[LOWORD] = w[2] & 0xff000000; + s[3] = u.d - b; + + u.l[HIWORD] = 0x3c300000; + u.l[LOWORD] = 0; + b = u.d; + u.l[LOWORD] = w[2] & 0xffffff; + s[4] = u.d - b; + + return ex - 0x3fff; +} + + +/* +* Pack an exponent and array of three doubles representing a finite, +* nonzero number into a quad. Assume the sign is already there and +* the rounding mode has been fudged accordingly. +*/ +static void +__q_pack(const double *z, int exp, enum fp_direction_type rm, + union longdouble *x, int *inexact) +{ + union { + double d; + unsigned int l[2]; + } u; + double s[3], t, t2; + unsigned int msw, frac2, frac3, frac4; + + /* bias exponent and strip off integer bit */ + exp += 0x3fff; + s[0] = z[0] - one; + s[1] = z[1]; + s[2] = z[2]; + + /* + * chop the significand to obtain the fraction; + * use round-to-minus-infinity to ensure chopping + */ + (void) __swapRD(fp_negative); + + /* extract the first eighty bits of fraction */ + t = s[1] + s[2]; + u.d = two36 + (s[0] + t); + msw = u.l[LOWORD]; + s[0] -= (u.d - two36); + + u.d = two4 + (s[0] + t); + frac2 = u.l[LOWORD]; + s[0] -= (u.d - two4); + + u.d = twom28 + (s[0] + t); + frac3 = u.l[LOWORD]; + s[0] -= (u.d - twom28); + + /* condense the remaining fraction; errors here won't matter */ + t = s[0] + s[1]; + s[1] = ((s[0] - t) + s[1]) + s[2]; + s[0] = t; + + /* get the last word of fraction */ + u.d = twom60 + (s[0] + s[1]); + frac4 = u.l[LOWORD]; + s[0] -= (u.d - twom60); + + /* + * keep track of what's left for rounding; note that + * t2 will be non-negative due to rounding mode + */ + t = s[0] + s[1]; + t2 = (s[0] - t) + s[1]; + + if (t != zero) + { + *inexact = 1; + + /* decide whether to round the fraction up */ + if (rm == fp_positive || (rm == fp_nearest && (t > twom113 || + (t == twom113 && (t2 != zero || frac4 & 1))))) + { + /* round up and renormalize if necessary */ + if (++frac4 == 0) + if (++frac3 == 0) + if (++frac2 == 0) + if (++msw == 0x10000) + { + msw = 0; + exp++; + } + } + } + + /* assemble the result */ + x->l.msw |= msw | (exp << 16); + x->l.frac2 = frac2; + x->l.frac3 = frac3; + x->l.frac4 = frac4; +} + + +/* +* Compute the square root of x and place the TP result in s. +*/ +static void +__q_tp_sqrt(const double *x, double *s) +{ + double c, rr, r[3], tt[3], t[5]; + + /* approximate the divisor for the Newton iteration */ + c = sqrt((x[0] + x[1]) + x[2]); + rr = half / c; + + /* compute the first five "digits" of the square root */ + t[0] = (c + two30) - two30; + tt[0] = t[0] + t[0]; + r[0] = ((x[0] - t[0] * t[0]) + x[1]) + x[2]; + + t[1] = (rr * (r[0] + x[3]) + two6) - two6; + tt[1] = t[1] + t[1]; + r[0] -= tt[0] * t[1]; + r[1] = x[3] - t[1] * t[1]; + c = (r[1] + twom18) - twom18; + r[0] += c; + r[1] = (r[1] - c) + x[4]; + + t[2] = (rr * (r[0] + r[1]) + twom18) - twom18; + tt[2] = t[2] + t[2]; + r[0] -= tt[0] * t[2]; + r[1] -= tt[1] * t[2]; + c = (r[1] + twom42) - twom42; + r[0] += c; + r[1] = (r[1] - c) - t[2] * t[2]; + + t[3] = (rr * (r[0] + r[1]) + twom42) - twom42; + r[0] = ((r[0] - tt[0] * t[3]) + r[1]) - tt[1] * t[3]; + r[1] = -tt[2] * t[3]; + c = (r[1] + twom90) - twom90; + r[0] += c; + r[1] = (r[1] - c) - t[3] * t[3]; + + t[4] = (rr * (r[0] + r[1]) + twom66) - twom66; + + /* here we just need to get the sign of the remainder */ + c = (((((r[0] - tt[0] * t[4]) - tt[1] * t[4]) + r[1]) + - tt[2] * t[4]) - (t[3] + t[3]) * t[4]) - t[4] * t[4]; + + /* reduce to three doubles */ + t[0] += t[1]; + t[1] = t[2] + t[3]; + t[2] = t[4]; + + /* if the third term might lie on a rounding boundary, perturb it */ + if (c != zero && t[2] == (twom62 + t[2]) - twom62) + { + if (c < zero) + t[2] -= twom124; + else + t[2] += twom124; + } + + /* condense the square root */ + c = t[1] + t[2]; + t[2] += (t[1] - c); + t[1] = c; + c = t[0] + t[1]; + s[1] = t[1] + (t[0] - c); + s[0] = c; + if (s[1] == zero) + { + c = s[0] + t[2]; + s[1] = t[2] + (s[0] - c); + s[0] = c; + s[2] = zero; + } + else + { + c = s[1] + t[2]; + s[2] = t[2] + (s[1] - c); + s[1] = c; + } +} + + +long double +sqrtl(long double ldx) +{ + union longdouble x; + volatile double t; + double xx[5], zz[3]; + enum fp_direction_type rm; + int ex, inexact, exc, traps; + + /* clear cexc */ + t = zero; + t -= zero; + + /* check for zero operand */ + x.d = ldx; + if (!((x.l.msw & 0x7fffffff) | x.l.frac2 | x.l.frac3 | x.l.frac4)) + return ldx; + + /* handle nan and inf cases */ + if ((x.l.msw & 0x7fffffff) >= 0x7fff0000) + { + if ((x.l.msw & 0xffff) | x.l.frac2 | x.l.frac3 | x.l.frac4) + { + if (!(x.l.msw & 0x8000)) + { + /* snan, signal invalid */ + t += snan.d; + } + x.l.msw |= 0x8000; + return x.d; + } + if (x.l.msw & 0x80000000) + { + /* sqrt(-inf), signal invalid */ + t = -one; + t = sqrt(t); + return qnan.d; + } + /* sqrt(inf), return inf */ + return x.d; + } + + /* handle negative numbers */ + if (x.l.msw & 0x80000000) + { + t = -one; + t = sqrt(t); + return qnan.d; + } + + /* now x is finite, positive */ + + traps = __swapTE(0); + exc = __swapEX(0); + rm = __swapRD(fp_nearest); + + ex = __q_unpack(&x, xx); + if (ex & 1) + { + /* make exponent even */ + xx[0] += xx[0]; + xx[1] += xx[1]; + xx[2] += xx[2]; + xx[3] += xx[3]; + xx[4] += xx[4]; + ex--; + } + __q_tp_sqrt(xx, zz); + + /* put everything together */ + x.l.msw = 0; + inexact = 0; + __q_pack(zz, ex >> 1, rm, &x, &inexact); + + (void) __swapRD(rm); + (void) __swapEX(exc); + (void) __swapTE(traps); + if (inexact) + { + t = huge; + t += tiny; + } + return x.d; +} diff --git a/usr/src/lib/libm/common/Q/tanhl.c b/usr/src/lib/libm/common/Q/tanhl.c new file mode 100644 index 0000000000..08283bded9 --- /dev/null +++ b/usr/src/lib/libm/common/Q/tanhl.c @@ -0,0 +1,100 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#if defined(ELFOBJ) +#pragma weak tanhl = __tanhl +#endif + +/* + * tanhl(x) returns the hyperbolic tangent of x + * + * Method : + * 1. reduce x to non-negative: tanhl(-x) = - tanhl(x). + * 2. + * 0 < x <= small : tanhl(x) := x + * -expm1l(-2x) + * small < x <= 1 : tanhl(x) := -------------- + * expm1l(-2x) + 2 + * 2 + * 1 <= x <= threshold : tanhl(x) := 1 - --------------- + * expm1l(2x) + 2 + * threshold < x <= INF : tanhl(x) := 1. + * + * where + * single : small = 1.e-5 threshold = 11.0 + * double : small = 1.e-10 threshold = 22.0 + * quad : small = 1.e-20 threshold = 45.0 + * + * Note: threshold was chosen so that + * fl(1.0+2/(expm1(2*threshold)+2)) == 1. + * + * Special cases: + * tanhl(NaN) is NaN; + * only tanhl(0.0)=0.0 is exact for finite argument. + */ + +#include "libm.h" +#include "longdouble.h" + +static const long double small = 1.0e-20L, one = 1.0, two = 2.0, +#ifndef lint + big = 1.0e+20L, +#endif + threshold = 45.0L; + +long double +tanhl(long double x) { + long double t, y, z; + int signx; + volatile long double dummy; + + if (isnanl(x)) + return (x + x); /* x is NaN */ + signx = signbitl(x); + t = fabsl(x); + z = one; + if (t <= threshold) { + if (t > one) + z = one - two / (expm1l(t + t) + two); + else if (t > small) { + y = expm1l(-t - t); + z = -y / (y + two); + } else { +#ifndef lint + dummy = t + big; + /* inexact if t != 0 */ +#endif + return (x); + } + } else if (!finitel(t)) + return (copysignl(one, x)); + else + return (signx ? -z + small * small : z - small * small); + return (signx ? -z : z); +} diff --git a/usr/src/lib/libm/common/Q/tanl.c b/usr/src/lib/libm/common/Q/tanl.c new file mode 100644 index 0000000000..9fdd78ed8c --- /dev/null +++ b/usr/src/lib/libm/common/Q/tanl.c @@ -0,0 +1,81 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* + * tanl(x) + * Table look-up algorithm by K.C. Ng, November, 1989. + * + * kernel function: + * __k_tanl ... tangent function on [-pi/4,pi/4] + * __rem_pio2l ... argument reduction routine + * + * Method. + * Let S and C denote the sin and cos respectively on [-PI/4, +PI/4]. + * 1. Assume the argument x is reduced to y1+y2 = x-k*pi/2 in + * [-pi/2 , +pi/2], and let n = k mod 4. + * 2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C S/C + * 1 C -S -C/S + * 2 -S -C S/C + * 3 -C S -C/S + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * computer TRIG(x) returns trig(x) nearly rounded. + */ + +#pragma weak tanl = __tanl + +#include "libm.h" +#include "longdouble.h" + +long double +tanl(long double x) { + long double y[2], z = 0.0L; + int n, ix; + + ix = *(int *) &x; /* High word of x */ + ix &= 0x7fffffff; + if (ix <= 0x3ffe9220) /* |x| ~< pi/4 */ + return (__k_tanl(x, z, 0)); + else if (ix >= 0x7fff0000) /* trig(Inf or NaN) is NaN */ + return (x - x); + else { /* argument reduction needed */ + n = __rem_pio2l(x, y); + return (__k_tanl(y[0], y[1], (n & 1))); + } +} |