libm-test.inc 132 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521
  1. /* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1997.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. /* Part of testsuite for libm.
  17. This file is processed by a perl script. The resulting file has to
  18. be included by a master file that defines:
  19. Makros:
  20. FUNC(function): converts general function name (like cos) to
  21. name with correct suffix (e.g. cosl or cosf)
  22. MATHCONST(x): like FUNC but for constants (e.g convert 0.0 to 0.0L)
  23. FLOAT: floating point type to test
  24. - TEST_MSG: informal message to be displayed
  25. CHOOSE(Clongdouble,Cdouble,Cfloat,Cinlinelongdouble,Cinlinedouble,Cinlinefloat):
  26. chooses one of the parameters as delta for testing
  27. equality
  28. PRINTF_EXPR Floating point conversion specification to print a variable
  29. of type FLOAT with printf. PRINTF_EXPR just contains
  30. the specifier, not the percent and width arguments,
  31. e.g. "f".
  32. PRINTF_XEXPR Like PRINTF_EXPR, but print in hexadecimal format.
  33. PRINTF_NEXPR Like PRINTF_EXPR, but print nice. */
  34. /* This testsuite has currently tests for:
  35. acos, acosh, asin, asinh, atan, atan2, atanh,
  36. cbrt, ceil, copysign, cos, cosh, erf, erfc, exp, exp10, exp2, expm1,
  37. fabs, fdim, floor, fma, fmax, fmin, fmod, fpclassify,
  38. frexp, gamma, hypot,
  39. ilogb, isfinite, isinf, isnan, isnormal,
  40. isless, islessequal, isgreater, isgreaterequal, islessgreater, isunordered,
  41. j0, j1, jn,
  42. ldexp, lgamma, log, log10, log1p, log2, logb,
  43. modf, nearbyint, nextafter,
  44. pow, remainder, remquo, rint, lrint, llrint,
  45. round, lround, llround,
  46. scalb, scalbn, scalbln, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, trunc,
  47. y0, y1, yn
  48. and for the following complex math functions:
  49. cabs, cacos, cacosh, carg, casin, casinh, catan, catanh,
  50. ccos, ccosh, cexp, clog, cpow, cproj, csin, csinh, csqrt, ctan, ctanh.
  51. At the moment the following functions aren't tested:
  52. drem, significand, nan
  53. Parameter handling is primitive in the moment:
  54. --verbose=[0..3] for different levels of output:
  55. 0: only error count
  56. 1: basic report on failed tests (default)
  57. 2: full report on all tests
  58. -v for full output (equals --verbose=3)
  59. -u for generation of an ULPs file
  60. */
  61. /* "Philosophy":
  62. This suite tests some aspects of the correct implementation of
  63. mathematical functions in libm. Some simple, specific parameters
  64. are tested for correctness but there's no exhaustive
  65. testing. Handling of specific inputs (e.g. infinity, not-a-number)
  66. is also tested. Correct handling of exceptions is checked
  67. against. These implemented tests should check all cases that are
  68. specified in ISO C99.
  69. Exception testing: At the moment only divide-by-zero and invalid
  70. exceptions are tested. Overflow/underflow and inexact exceptions
  71. aren't checked at the moment.
  72. NaN values: There exist signalling and quiet NaNs. This implementation
  73. only uses signalling NaN as parameter but does not differenciate
  74. between the two kinds of NaNs as result.
  75. Inline functions: Inlining functions should give an improvement in
  76. speed - but not in precission. The inlined functions return
  77. reasonable values for a reasonable range of input values. The
  78. result is not necessarily correct for all values and exceptions are
  79. not correctly raised in all cases. Problematic input and return
  80. values are infinity, not-a-number and minus zero. This suite
  81. therefore does not check these specific inputs and the exception
  82. handling for inlined mathematical functions - just the "reasonable"
  83. values are checked.
  84. Beware: The tests might fail for any of the following reasons:
  85. - Tests are wrong
  86. - Functions are wrong
  87. - Floating Point Unit not working properly
  88. - Compiler has errors
  89. With e.g. gcc 2.7.2.2 the test for cexp fails because of a compiler error.
  90. To Do: All parameter should be numbers that can be represented as
  91. exact floating point values. Currently some values cannot be represented
  92. exactly and therefore the result is not the expected result.
  93. */
  94. #ifndef _GNU_SOURCE
  95. # define _GNU_SOURCE
  96. #endif
  97. #include "libm-test-ulps.h"
  98. #include <complex.h>
  99. #include <math.h>
  100. #include <float.h>
  101. #include <limits.h>
  102. #include <errno.h>
  103. #include <stdlib.h>
  104. #include <stdio.h>
  105. #include <string.h>
  106. #include <getopt.h>
  107. //#include <fenv.h>
  108. #define feclearexcept(X)
  109. #define fetestexcept(X) 0
  110. /* Possible exceptions */
  111. #define NO_EXCEPTION 0x0
  112. #define INVALID_EXCEPTION 0x1
  113. #define DIVIDE_BY_ZERO_EXCEPTION 0x2
  114. /* The next flags signals that those exceptions are allowed but not required. */
  115. #define INVALID_EXCEPTION_OK 0x4
  116. #define DIVIDE_BY_ZERO_EXCEPTION_OK 0x8
  117. #define EXCEPTIONS_OK INVALID_EXCEPTION_OK+DIVIDE_BY_ZERO_EXCEPTION_OK
  118. /* Some special test flags, passed togther with exceptions. */
  119. #define IGNORE_ZERO_INF_SIGN 0x10
  120. /* Various constants (we must supply them precalculated for accuracy). */
  121. #define M_PI_6l .52359877559829887307710723054658383L
  122. #define M_E2l 7.389056098930650227230427460575008L
  123. #define M_E3l 20.085536923187667740928529654581719L
  124. #define M_2_SQRT_PIl 3.5449077018110320545963349666822903L /* 2 sqrt (M_PIl) */
  125. #define M_SQRT_PIl 1.7724538509055160272981674833411451L /* sqrt (M_PIl) */
  126. #define M_LOG_SQRT_PIl 0.57236494292470008707171367567652933L /* log(sqrt(M_PIl)) */
  127. #define M_LOG_2_SQRT_PIl 1.265512123484645396488945797134706L /* log(2*sqrt(M_PIl)) */
  128. #define M_PI_34l (M_PIl - M_PI_4l) /* 3*pi/4 */
  129. #define M_PI_34_LOG10El (M_PIl - M_PI_4l) * M_LOG10El
  130. #define M_PI2_LOG10El M_PI_2l * M_LOG10El
  131. #define M_PI4_LOG10El M_PI_4l * M_LOG10El
  132. #define M_PI_LOG10El M_PIl * M_LOG10El
  133. static FILE *ulps_file; /* File to document difference. */
  134. static int output_ulps; /* Should ulps printed? */
  135. static int noErrors; /* number of errors */
  136. static int noTests; /* number of tests (without testing exceptions) */
  137. static int noExcTests; /* number of tests for exception flags */
  138. static int noXFails; /* number of expected failures. */
  139. static int noXPasses; /* number of unexpected passes. */
  140. static int verbose;
  141. static int output_max_error; /* Should the maximal errors printed? */
  142. static int output_points; /* Should the single function results printed? */
  143. static int ignore_max_ulp; /* Should we ignore max_ulp? */
  144. static FLOAT minus_zero, plus_zero;
  145. static FLOAT plus_infty, minus_infty, nan_value;
  146. static FLOAT max_error, real_max_error, imag_max_error;
  147. #define BUILD_COMPLEX(real, imag) \
  148. ({ __complex__ FLOAT __retval; \
  149. __real__ __retval = (real); \
  150. __imag__ __retval = (imag); \
  151. __retval; })
  152. #define BUILD_COMPLEX_INT(real, imag) \
  153. ({ __complex__ int __retval; \
  154. __real__ __retval = (real); \
  155. __imag__ __retval = (imag); \
  156. __retval; })
  157. #define MANT_DIG CHOOSE ((LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1), \
  158. (LDBL_MANT_DIG-1), (DBL_MANT_DIG-1), (FLT_MANT_DIG-1))
  159. static void
  160. init_max_error (void)
  161. {
  162. max_error = 0;
  163. real_max_error = 0;
  164. imag_max_error = 0;
  165. feclearexcept (FE_ALL_EXCEPT);
  166. }
  167. static void
  168. set_max_error (FLOAT current, FLOAT *curr_max_error)
  169. {
  170. if (current > *curr_max_error)
  171. *curr_max_error = current;
  172. }
  173. /* Should the message print to screen? This depends on the verbose flag,
  174. and the test status. */
  175. static int
  176. print_screen (int ok, int xfail)
  177. {
  178. if (output_points
  179. && (verbose > 1
  180. || (verbose == 1 && ok == xfail)))
  181. return 1;
  182. return 0;
  183. }
  184. /* Should the message print to screen? This depends on the verbose flag,
  185. and the test status. */
  186. static int
  187. print_screen_max_error (int ok, int xfail)
  188. {
  189. if (output_max_error
  190. && (verbose > 1
  191. || ((verbose == 1) && (ok == xfail))))
  192. return 1;
  193. return 0;
  194. }
  195. /* Update statistic counters. */
  196. static void
  197. update_stats (int ok, int xfail)
  198. {
  199. ++noTests;
  200. if (ok && xfail)
  201. ++noXPasses;
  202. else if (!ok && xfail)
  203. ++noXFails;
  204. else if (!ok && !xfail)
  205. ++noErrors;
  206. }
  207. static void
  208. print_ulps (const char *test_name, FLOAT ulp)
  209. {
  210. if (output_ulps)
  211. {
  212. fprintf (ulps_file, "Test \"%s\":\n", test_name);
  213. fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
  214. CHOOSE("ldouble", "double", "float",
  215. "ildouble", "idouble", "ifloat"),
  216. FUNC(ceil) (ulp));
  217. }
  218. }
  219. static void
  220. print_function_ulps (const char *function_name, FLOAT ulp)
  221. {
  222. if (output_ulps)
  223. {
  224. fprintf (ulps_file, "Function: \"%s\":\n", function_name);
  225. fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
  226. CHOOSE("ldouble", "double", "float",
  227. "ildouble", "idouble", "ifloat"),
  228. FUNC(ceil) (ulp));
  229. }
  230. }
  231. static void
  232. print_complex_function_ulps (const char *function_name, FLOAT real_ulp,
  233. FLOAT imag_ulp)
  234. {
  235. if (output_ulps)
  236. {
  237. if (real_ulp != 0.0)
  238. {
  239. fprintf (ulps_file, "Function: Real part of \"%s\":\n", function_name);
  240. fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
  241. CHOOSE("ldouble", "double", "float",
  242. "ildouble", "idouble", "ifloat"),
  243. FUNC(ceil) (real_ulp));
  244. }
  245. if (imag_ulp != 0.0)
  246. {
  247. fprintf (ulps_file, "Function: Imaginary part of \"%s\":\n", function_name);
  248. fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n",
  249. CHOOSE("ldouble", "double", "float",
  250. "ildouble", "idouble", "ifloat"),
  251. FUNC(ceil) (imag_ulp));
  252. }
  253. }
  254. }
  255. /* Test if Floating-Point stack hasn't changed */
  256. static void
  257. fpstack_test (const char *test_name)
  258. {
  259. #ifdef i386
  260. static int old_stack;
  261. int sw;
  262. asm ("fnstsw" : "=a" (sw));
  263. sw >>= 11;
  264. sw &= 7;
  265. if (sw != old_stack)
  266. {
  267. printf ("FP-Stack wrong after test %s (%d, should be %d)\n",
  268. test_name, sw, old_stack);
  269. ++noErrors;
  270. old_stack = sw;
  271. }
  272. #endif
  273. }
  274. static void
  275. print_max_error (const char *func_name, FLOAT allowed, int xfail)
  276. {
  277. int ok = 0;
  278. if (max_error == 0.0 || (max_error <= allowed && !ignore_max_ulp))
  279. {
  280. ok = 1;
  281. }
  282. if (!ok)
  283. print_function_ulps (func_name, max_error);
  284. if (print_screen_max_error (ok, xfail))
  285. {
  286. printf ("Maximal error of `%s'\n", func_name);
  287. printf (" is : %.0" PRINTF_NEXPR " ulp\n", FUNC(ceil) (max_error));
  288. printf (" accepted: %.0" PRINTF_NEXPR " ulp\n", FUNC(ceil) (allowed));
  289. }
  290. update_stats (ok, xfail);
  291. }
  292. static void
  293. print_complex_max_error (const char *func_name, __complex__ FLOAT allowed,
  294. __complex__ int xfail)
  295. {
  296. int ok = 0;
  297. if ((real_max_error == 0 && imag_max_error == 0)
  298. || (real_max_error <= __real__ allowed
  299. && imag_max_error <= __imag__ allowed
  300. && !ignore_max_ulp))
  301. {
  302. ok = 1;
  303. }
  304. if (!ok)
  305. print_complex_function_ulps (func_name, real_max_error, imag_max_error);
  306. if (print_screen_max_error (ok, xfail))
  307. {
  308. printf ("Maximal error of real part of: %s\n", func_name);
  309. printf (" is : %.0" PRINTF_NEXPR " ulp\n",
  310. FUNC(ceil) (real_max_error));
  311. printf (" accepted: %.0" PRINTF_NEXPR " ulp\n",
  312. FUNC(ceil) (__real__ allowed));
  313. printf ("Maximal error of imaginary part of: %s\n", func_name);
  314. printf (" is : %.0" PRINTF_NEXPR " ulp\n",
  315. FUNC(ceil) (imag_max_error));
  316. printf (" accepted: %.0" PRINTF_NEXPR " ulp\n",
  317. FUNC(ceil) (__imag__ allowed));
  318. }
  319. update_stats (ok, xfail);
  320. }
  321. /* Test whether a given exception was raised. */
  322. static void
  323. test_single_exception (const char *test_name,
  324. int exception,
  325. int exc_flag,
  326. int fe_flag,
  327. const char *flag_name)
  328. {
  329. #ifndef TEST_INLINE
  330. int ok = 1;
  331. if (exception & exc_flag)
  332. {
  333. if (fetestexcept (fe_flag))
  334. {
  335. if (print_screen (1, 0))
  336. printf ("Pass: %s: Exception \"%s\" set\n", test_name, flag_name);
  337. }
  338. else
  339. {
  340. ok = 0;
  341. if (print_screen (0, 0))
  342. printf ("Failure: %s: Exception \"%s\" not set\n",
  343. test_name, flag_name);
  344. }
  345. }
  346. else
  347. {
  348. if (fetestexcept (fe_flag))
  349. {
  350. ok = 0;
  351. if (print_screen (0, 0))
  352. printf ("Failure: %s: Exception \"%s\" set\n",
  353. test_name, flag_name);
  354. }
  355. else
  356. {
  357. if (print_screen (1, 0))
  358. printf ("%s: Exception \"%s\" not set\n", test_name,
  359. flag_name);
  360. }
  361. }
  362. if (!ok)
  363. ++noErrors;
  364. #endif
  365. }
  366. /* Test whether exceptions given by EXCEPTION are raised. Ignore thereby
  367. allowed but not required exceptions.
  368. */
  369. static void
  370. test_exceptions (const char *test_name, int exception)
  371. {
  372. ++noExcTests;
  373. #ifdef FE_DIVBYZERO
  374. if ((exception & DIVIDE_BY_ZERO_EXCEPTION_OK) == 0)
  375. test_single_exception (test_name, exception,
  376. DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO,
  377. "Divide by zero");
  378. #endif
  379. #ifdef FE_INVALID
  380. if ((exception & INVALID_EXCEPTION_OK) == 0)
  381. test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID,
  382. "Invalid operation");
  383. #endif
  384. feclearexcept (FE_ALL_EXCEPT);
  385. }
  386. static void
  387. check_float_internal (const char *test_name, FLOAT computed, FLOAT expected,
  388. FLOAT max_ulp, int xfail, int exceptions,
  389. FLOAT *curr_max_error)
  390. {
  391. int ok = 0;
  392. int print_diff = 0;
  393. FLOAT diff = 0;
  394. FLOAT ulp = 0;
  395. test_exceptions (test_name, exceptions);
  396. if (isnan (computed) && isnan (expected))
  397. ok = 1;
  398. else if (isinf (computed) && isinf (expected))
  399. {
  400. /* Test for sign of infinities. */
  401. if ((exceptions & IGNORE_ZERO_INF_SIGN) == 0
  402. && signbit (computed) != signbit (expected))
  403. {
  404. ok = 0;
  405. printf ("infinity has wrong sign.\n");
  406. }
  407. else
  408. ok = 1;
  409. }
  410. /* Don't calc ulp for NaNs or infinities. */
  411. else if (isinf (computed) || isnan (computed) || isinf (expected) || isnan (expected))
  412. ok = 0;
  413. else
  414. {
  415. diff = FUNC(fabs) (computed - expected);
  416. /* ilogb (0) isn't allowed. */
  417. if (expected == 0.0)
  418. ulp = diff / FUNC(ldexp) (1.0, - MANT_DIG);
  419. else
  420. ulp = diff / FUNC(ldexp) (1.0, FUNC(ilogb) (expected) - MANT_DIG);
  421. set_max_error (ulp, curr_max_error);
  422. print_diff = 1;
  423. if ((exceptions & IGNORE_ZERO_INF_SIGN) == 0
  424. && computed == 0.0 && expected == 0.0
  425. && signbit(computed) != signbit (expected))
  426. ok = 0;
  427. else if (ulp == 0.0 || (ulp <= max_ulp && !ignore_max_ulp))
  428. ok = 1;
  429. else
  430. {
  431. ok = 0;
  432. print_ulps (test_name, ulp);
  433. }
  434. }
  435. if (print_screen (ok, xfail))
  436. {
  437. if (!ok)
  438. printf ("Failure: ");
  439. printf ("Test: %s\n", test_name);
  440. printf ("Result:\n");
  441. printf (" is: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
  442. computed, computed);
  443. printf (" should be: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR "\n",
  444. expected, expected);
  445. if (print_diff)
  446. {
  447. printf (" difference: % .20" PRINTF_EXPR " % .20" PRINTF_XEXPR
  448. "\n", diff, diff);
  449. printf (" ulp : % .4" PRINTF_NEXPR "\n", ulp);
  450. printf (" max.ulp : % .4" PRINTF_NEXPR "\n", max_ulp);
  451. }
  452. }
  453. update_stats (ok, xfail);
  454. fpstack_test (test_name);
  455. }
  456. static void
  457. check_float (const char *test_name, FLOAT computed, FLOAT expected,
  458. FLOAT max_ulp, int xfail, int exceptions)
  459. {
  460. check_float_internal (test_name, computed, expected, max_ulp, xfail,
  461. exceptions, &max_error);
  462. }
  463. static void
  464. check_complex (const char *test_name, __complex__ FLOAT computed,
  465. __complex__ FLOAT expected,
  466. __complex__ FLOAT max_ulp, __complex__ int xfail,
  467. int exception)
  468. {
  469. FLOAT part_comp, part_exp, part_max_ulp;
  470. int part_xfail;
  471. char str[200];
  472. sprintf (str, "Real part of: %s", test_name);
  473. part_comp = __real__ computed;
  474. part_exp = __real__ expected;
  475. part_max_ulp = __real__ max_ulp;
  476. part_xfail = __real__ xfail;
  477. check_float_internal (str, part_comp, part_exp, part_max_ulp, part_xfail,
  478. exception, &real_max_error);
  479. sprintf (str, "Imaginary part of: %s", test_name);
  480. part_comp = __imag__ computed;
  481. part_exp = __imag__ expected;
  482. part_max_ulp = __imag__ max_ulp;
  483. part_xfail = __imag__ xfail;
  484. /* Don't check again for exceptions, just pass through the
  485. zero/inf sign test. */
  486. check_float_internal (str, part_comp, part_exp, part_max_ulp, part_xfail,
  487. exception & IGNORE_ZERO_INF_SIGN,
  488. &imag_max_error);
  489. }
  490. /* Check that computed and expected values are equal (int values). */
  491. static void
  492. check_int (const char *test_name, int computed, int expected, int max_ulp,
  493. int xfail, int exceptions)
  494. {
  495. int diff = computed - expected;
  496. int ok = 0;
  497. test_exceptions (test_name, exceptions);
  498. noTests++;
  499. if (abs (diff) <= max_ulp)
  500. ok = 1;
  501. if (!ok)
  502. print_ulps (test_name, diff);
  503. if (print_screen (ok, xfail))
  504. {
  505. if (!ok)
  506. printf ("Failure: ");
  507. printf ("Test: %s\n", test_name);
  508. printf ("Result:\n");
  509. printf (" is: %d\n", computed);
  510. printf (" should be: %d\n", expected);
  511. }
  512. update_stats (ok, xfail);
  513. fpstack_test (test_name);
  514. }
  515. /* Check that computed and expected values are equal (long int values). */
  516. static void
  517. check_long (const char *test_name, long int computed, long int expected,
  518. long int max_ulp, int xfail, int exceptions)
  519. {
  520. long int diff = computed - expected;
  521. int ok = 0;
  522. test_exceptions (test_name, exceptions);
  523. noTests++;
  524. if (labs (diff) <= max_ulp)
  525. ok = 1;
  526. if (!ok)
  527. print_ulps (test_name, diff);
  528. if (print_screen (ok, xfail))
  529. {
  530. if (!ok)
  531. printf ("Failure: ");
  532. printf ("Test: %s\n", test_name);
  533. printf ("Result:\n");
  534. printf (" is: %ld\n", computed);
  535. printf (" should be: %ld\n", expected);
  536. }
  537. update_stats (ok, xfail);
  538. fpstack_test (test_name);
  539. }
  540. /* Check that computed value is true/false. */
  541. static void
  542. check_bool (const char *test_name, int computed, int expected,
  543. long int max_ulp, int xfail, int exceptions)
  544. {
  545. int ok = 0;
  546. test_exceptions (test_name, exceptions);
  547. noTests++;
  548. if ((computed == 0) == (expected == 0))
  549. ok = 1;
  550. if (print_screen (ok, xfail))
  551. {
  552. if (!ok)
  553. printf ("Failure: ");
  554. printf ("Test: %s\n", test_name);
  555. printf ("Result:\n");
  556. printf (" is: %d\n", computed);
  557. printf (" should be: %d\n", expected);
  558. }
  559. update_stats (ok, xfail);
  560. fpstack_test (test_name);
  561. }
  562. /* check that computed and expected values are equal (long int values) */
  563. static void
  564. check_longlong (const char *test_name, long long int computed,
  565. long long int expected,
  566. long long int max_ulp, int xfail,
  567. int exceptions)
  568. {
  569. long long int diff = computed - expected;
  570. int ok = 0;
  571. test_exceptions (test_name, exceptions);
  572. noTests++;
  573. if (llabs (diff) <= max_ulp)
  574. ok = 1;
  575. if (!ok)
  576. print_ulps (test_name, diff);
  577. if (print_screen (ok, xfail))
  578. {
  579. if (!ok)
  580. printf ("Failure:");
  581. printf ("Test: %s\n", test_name);
  582. printf ("Result:\n");
  583. printf (" is: %lld\n", computed);
  584. printf (" should be: %lld\n", expected);
  585. }
  586. update_stats (ok, xfail);
  587. fpstack_test (test_name);
  588. }
  589. /* This is to prevent messages from the SVID libm emulation. */
  590. int
  591. matherr (struct exception *x __attribute__ ((unused)))
  592. {
  593. return 1;
  594. }
  595. /****************************************************************************
  596. Tests for single functions of libm.
  597. Please keep them alphabetically sorted!
  598. ****************************************************************************/
  599. static void
  600. acos_test (void)
  601. {
  602. errno = 0;
  603. FUNC(acos) (0);
  604. if (errno == ENOSYS)
  605. /* Function not implemented. */
  606. return;
  607. START (acos);
  608. TEST_f_f (acos, plus_infty, nan_value, INVALID_EXCEPTION);
  609. TEST_f_f (acos, minus_infty, nan_value, INVALID_EXCEPTION);
  610. TEST_f_f (acos, nan_value, nan_value);
  611. /* |x| > 1: */
  612. TEST_f_f (acos, 1.1L, nan_value, INVALID_EXCEPTION);
  613. TEST_f_f (acos, -1.1L, nan_value, INVALID_EXCEPTION);
  614. TEST_f_f (acos, 0, M_PI_2l);
  615. TEST_f_f (acos, minus_zero, M_PI_2l);
  616. TEST_f_f (acos, 1, 0);
  617. TEST_f_f (acos, -1, M_PIl);
  618. TEST_f_f (acos, 0.5, M_PI_6l*2.0);
  619. TEST_f_f (acos, -0.5, M_PI_6l*4.0);
  620. TEST_f_f (acos, 0.7L, 0.79539883018414355549096833892476432L);
  621. END (acos);
  622. }
  623. static void
  624. acosh_test (void)
  625. {
  626. errno = 0;
  627. FUNC(acosh) (7);
  628. if (errno == ENOSYS)
  629. /* Function not implemented. */
  630. return;
  631. START (acosh);
  632. TEST_f_f (acosh, plus_infty, plus_infty);
  633. TEST_f_f (acosh, minus_infty, nan_value, INVALID_EXCEPTION);
  634. /* x < 1: */
  635. TEST_f_f (acosh, -1.1L, nan_value, INVALID_EXCEPTION);
  636. TEST_f_f (acosh, 1, 0);
  637. TEST_f_f (acosh, 7, 2.633915793849633417250092694615937L);
  638. END (acosh);
  639. }
  640. static void
  641. asin_test (void)
  642. {
  643. errno = 0;
  644. FUNC(asin) (0);
  645. if (errno == ENOSYS)
  646. /* Function not implemented. */
  647. return;
  648. START (asin);
  649. TEST_f_f (asin, plus_infty, nan_value, INVALID_EXCEPTION);
  650. TEST_f_f (asin, minus_infty, nan_value, INVALID_EXCEPTION);
  651. TEST_f_f (asin, nan_value, nan_value);
  652. /* asin x == NaN plus invalid exception for |x| > 1. */
  653. TEST_f_f (asin, 1.1L, nan_value, INVALID_EXCEPTION);
  654. TEST_f_f (asin, -1.1L, nan_value, INVALID_EXCEPTION);
  655. TEST_f_f (asin, 0, 0);
  656. TEST_f_f (asin, minus_zero, minus_zero);
  657. TEST_f_f (asin, 0.5, M_PI_6l);
  658. TEST_f_f (asin, -0.5, -M_PI_6l);
  659. TEST_f_f (asin, 1.0, M_PI_2l);
  660. TEST_f_f (asin, -1.0, -M_PI_2l);
  661. TEST_f_f (asin, 0.7L, 0.77539749661075306374035335271498708L);
  662. END (asin);
  663. }
  664. static void
  665. asinh_test (void)
  666. {
  667. errno = 0;
  668. FUNC(asinh) (0.7L);
  669. if (errno == ENOSYS)
  670. /* Function not implemented. */
  671. return;
  672. START (asinh);
  673. TEST_f_f (asinh, 0, 0);
  674. TEST_f_f (asinh, minus_zero, minus_zero);
  675. #ifndef TEST_INLINE
  676. TEST_f_f (asinh, plus_infty, plus_infty);
  677. TEST_f_f (asinh, minus_infty, minus_infty);
  678. #endif
  679. TEST_f_f (asinh, nan_value, nan_value);
  680. TEST_f_f (asinh, 0.7L, 0.652666566082355786L);
  681. END (asinh);
  682. }
  683. static void
  684. atan_test (void)
  685. {
  686. errno = 0;
  687. FUNC(atan) (0);
  688. if (errno == ENOSYS)
  689. /* Function not implemented. */
  690. return;
  691. START (atan);
  692. TEST_f_f (atan, 0, 0);
  693. TEST_f_f (atan, minus_zero, minus_zero);
  694. TEST_f_f (atan, plus_infty, M_PI_2l);
  695. TEST_f_f (atan, minus_infty, -M_PI_2l);
  696. TEST_f_f (atan, nan_value, nan_value);
  697. TEST_f_f (atan, 1, M_PI_4l);
  698. TEST_f_f (atan, -1, -M_PI_4l);
  699. TEST_f_f (atan, 0.7L, 0.61072596438920861654375887649023613L);
  700. END (atan);
  701. }
  702. static void
  703. atanh_test (void)
  704. {
  705. errno = 0;
  706. FUNC(atanh) (0.7L);
  707. if (errno == ENOSYS)
  708. /* Function not implemented. */
  709. return;
  710. START (atanh);
  711. TEST_f_f (atanh, 0, 0);
  712. TEST_f_f (atanh, minus_zero, minus_zero);
  713. TEST_f_f (atanh, 1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  714. TEST_f_f (atanh, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  715. TEST_f_f (atanh, nan_value, nan_value);
  716. /* atanh (x) == NaN plus invalid exception if |x| > 1. */
  717. TEST_f_f (atanh, 1.1L, nan_value, INVALID_EXCEPTION);
  718. TEST_f_f (atanh, -1.1L, nan_value, INVALID_EXCEPTION);
  719. TEST_f_f (atanh, 0.7L, 0.8673005276940531944L);
  720. END (atanh);
  721. }
  722. static void
  723. atan2_test (void)
  724. {
  725. errno = 0;
  726. FUNC(atan2) (-0, 1);
  727. if (errno == ENOSYS)
  728. /* Function not implemented. */
  729. return;
  730. START (atan2);
  731. /* atan2 (0,x) == 0 for x > 0. */
  732. TEST_ff_f (atan2, 0, 1, 0);
  733. /* atan2 (-0,x) == -0 for x > 0. */
  734. TEST_ff_f (atan2, minus_zero, 1, minus_zero);
  735. TEST_ff_f (atan2, 0, 0, 0);
  736. TEST_ff_f (atan2, minus_zero, 0, minus_zero);
  737. /* atan2 (+0,x) == +pi for x < 0. */
  738. TEST_ff_f (atan2, 0, -1, M_PIl);
  739. /* atan2 (-0,x) == -pi for x < 0. */
  740. TEST_ff_f (atan2, minus_zero, -1, -M_PIl);
  741. TEST_ff_f (atan2, 0, minus_zero, M_PIl);
  742. TEST_ff_f (atan2, minus_zero, minus_zero, -M_PIl);
  743. /* atan2 (y,+0) == pi/2 for y > 0. */
  744. TEST_ff_f (atan2, 1, 0, M_PI_2l);
  745. /* atan2 (y,-0) == pi/2 for y > 0. */
  746. TEST_ff_f (atan2, 1, minus_zero, M_PI_2l);
  747. /* atan2 (y,+0) == -pi/2 for y < 0. */
  748. TEST_ff_f (atan2, -1, 0, -M_PI_2l);
  749. /* atan2 (y,-0) == -pi/2 for y < 0. */
  750. TEST_ff_f (atan2, -1, minus_zero, -M_PI_2l);
  751. /* atan2 (y,inf) == +0 for finite y > 0. */
  752. TEST_ff_f (atan2, 1, plus_infty, 0);
  753. /* atan2 (y,inf) == -0 for finite y < 0. */
  754. TEST_ff_f (atan2, -1, plus_infty, minus_zero);
  755. /* atan2(+inf, x) == pi/2 for finite x. */
  756. TEST_ff_f (atan2, plus_infty, -1, M_PI_2l);
  757. /* atan2(-inf, x) == -pi/2 for finite x. */
  758. TEST_ff_f (atan2, minus_infty, 1, -M_PI_2l);
  759. /* atan2 (y,-inf) == +pi for finite y > 0. */
  760. TEST_ff_f (atan2, 1, minus_infty, M_PIl);
  761. /* atan2 (y,-inf) == -pi for finite y < 0. */
  762. TEST_ff_f (atan2, -1, minus_infty, -M_PIl);
  763. TEST_ff_f (atan2, plus_infty, plus_infty, M_PI_4l);
  764. TEST_ff_f (atan2, minus_infty, plus_infty, -M_PI_4l);
  765. TEST_ff_f (atan2, plus_infty, minus_infty, M_PI_34l);
  766. TEST_ff_f (atan2, minus_infty, minus_infty, -M_PI_34l);
  767. TEST_ff_f (atan2, nan_value, nan_value, nan_value);
  768. TEST_ff_f (atan2, 0.7L, 1, 0.61072596438920861654375887649023613L);
  769. TEST_ff_f (atan2, -0.7L, 1.0L, -0.61072596438920861654375887649023613L);
  770. TEST_ff_f (atan2, 0.7L, -1.0L, 2.530866689200584621918884506789267L);
  771. TEST_ff_f (atan2, -0.7L, -1.0L, -2.530866689200584621918884506789267L);
  772. TEST_ff_f (atan2, 0.4L, 0.0003L, 1.5700463269355215717704032607580829L);
  773. TEST_ff_f (atan2, 1.4L, -0.93L, 2.1571487668237843754887415992772736L);
  774. END (atan2);
  775. }
  776. static void
  777. cabs_test (void)
  778. {
  779. errno = 0;
  780. FUNC(cabs) (BUILD_COMPLEX (0.7L, 12.4L));
  781. if (errno == ENOSYS)
  782. /* Function not implemented. */
  783. return;
  784. START (cabs);
  785. /* cabs (x + iy) is specified as hypot (x,y) */
  786. /* cabs (+inf + i x) == +inf. */
  787. TEST_c_f (cabs, plus_infty, 1.0, plus_infty);
  788. /* cabs (-inf + i x) == +inf. */
  789. TEST_c_f (cabs, minus_infty, 1.0, plus_infty);
  790. TEST_c_f (cabs, minus_infty, nan_value, plus_infty);
  791. TEST_c_f (cabs, minus_infty, nan_value, plus_infty);
  792. TEST_c_f (cabs, nan_value, nan_value, nan_value);
  793. /* cabs (x,y) == cabs (y,x). */
  794. TEST_c_f (cabs, 0.7L, 12.4L, 12.419742348374220601176836866763271L);
  795. /* cabs (x,y) == cabs (-x,y). */
  796. TEST_c_f (cabs, -12.4L, 0.7L, 12.419742348374220601176836866763271L);
  797. /* cabs (x,y) == cabs (-y,x). */
  798. TEST_c_f (cabs, -0.7L, 12.4L, 12.419742348374220601176836866763271L);
  799. /* cabs (x,y) == cabs (-x,-y). */
  800. TEST_c_f (cabs, -12.4L, -0.7L, 12.419742348374220601176836866763271L);
  801. /* cabs (x,y) == cabs (-y,-x). */
  802. TEST_c_f (cabs, -0.7L, -12.4L, 12.419742348374220601176836866763271L);
  803. /* cabs (x,0) == fabs (x). */
  804. TEST_c_f (cabs, -0.7L, 0, 0.7L);
  805. TEST_c_f (cabs, 0.7L, 0, 0.7L);
  806. TEST_c_f (cabs, -1.0L, 0, 1.0L);
  807. TEST_c_f (cabs, 1.0L, 0, 1.0L);
  808. TEST_c_f (cabs, -5.7e7L, 0, 5.7e7L);
  809. TEST_c_f (cabs, 5.7e7L, 0, 5.7e7L);
  810. TEST_c_f (cabs, 0.7L, 1.2L, 1.3892443989449804508432547041028554L);
  811. END (cabs);
  812. }
  813. #if 0
  814. static void
  815. cacos_test (void)
  816. {
  817. errno = 0;
  818. FUNC(cacos) (BUILD_COMPLEX (0.7L, 1.2L));
  819. if (errno == ENOSYS)
  820. /* Function not implemented. */
  821. return;
  822. START (cacos);
  823. TEST_c_c (cacos, 0, 0, M_PI_2l, minus_zero);
  824. TEST_c_c (cacos, minus_zero, 0, M_PI_2l, minus_zero);
  825. TEST_c_c (cacos, minus_zero, minus_zero, M_PI_2l, 0.0);
  826. TEST_c_c (cacos, 0, minus_zero, M_PI_2l, 0.0);
  827. TEST_c_c (cacos, minus_infty, plus_infty, M_PI_34l, minus_infty);
  828. TEST_c_c (cacos, minus_infty, minus_infty, M_PI_34l, plus_infty);
  829. TEST_c_c (cacos, plus_infty, plus_infty, M_PI_4l, minus_infty);
  830. TEST_c_c (cacos, plus_infty, minus_infty, M_PI_4l, plus_infty);
  831. TEST_c_c (cacos, -10.0, plus_infty, M_PI_2l, minus_infty);
  832. TEST_c_c (cacos, -10.0, minus_infty, M_PI_2l, plus_infty);
  833. TEST_c_c (cacos, 0, plus_infty, M_PI_2l, minus_infty);
  834. TEST_c_c (cacos, 0, minus_infty, M_PI_2l, plus_infty);
  835. TEST_c_c (cacos, 0.1L, plus_infty, M_PI_2l, minus_infty);
  836. TEST_c_c (cacos, 0.1L, minus_infty, M_PI_2l, plus_infty);
  837. TEST_c_c (cacos, minus_infty, 0, M_PIl, minus_infty);
  838. TEST_c_c (cacos, minus_infty, minus_zero, M_PIl, plus_infty);
  839. TEST_c_c (cacos, minus_infty, 100, M_PIl, minus_infty);
  840. TEST_c_c (cacos, minus_infty, -100, M_PIl, plus_infty);
  841. TEST_c_c (cacos, plus_infty, 0, 0.0, minus_infty);
  842. TEST_c_c (cacos, plus_infty, minus_zero, 0.0, plus_infty);
  843. TEST_c_c (cacos, plus_infty, 0.5, 0.0, minus_infty);
  844. TEST_c_c (cacos, plus_infty, -0.5, 0.0, plus_infty);
  845. TEST_c_c (cacos, plus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
  846. TEST_c_c (cacos, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
  847. TEST_c_c (cacos, 0, nan_value, M_PI_2l, nan_value);
  848. TEST_c_c (cacos, minus_zero, nan_value, M_PI_2l, nan_value);
  849. TEST_c_c (cacos, nan_value, plus_infty, nan_value, minus_infty);
  850. TEST_c_c (cacos, nan_value, minus_infty, nan_value, plus_infty);
  851. TEST_c_c (cacos, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  852. TEST_c_c (cacos, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  853. TEST_c_c (cacos, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
  854. TEST_c_c (cacos, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
  855. TEST_c_c (cacos, nan_value, nan_value, nan_value, nan_value);
  856. TEST_c_c (cacos, 0.7L, 1.2L, 1.1351827477151551088992008271819053L, -1.0927647857577371459105272080819308L);
  857. TEST_c_c (cacos, -2, -3, 2.1414491111159960199416055713254211L, 1.9833870299165354323470769028940395L);
  858. END (cacos, complex);
  859. }
  860. static void
  861. cacosh_test (void)
  862. {
  863. errno = 0;
  864. FUNC(cacosh) (BUILD_COMPLEX (0.7L, 1.2L));
  865. if (errno == ENOSYS)
  866. /* Function not implemented. */
  867. return;
  868. START (cacosh);
  869. TEST_c_c (cacosh, 0, 0, 0.0, M_PI_2l);
  870. TEST_c_c (cacosh, minus_zero, 0, 0.0, M_PI_2l);
  871. TEST_c_c (cacosh, 0, minus_zero, 0.0, -M_PI_2l);
  872. TEST_c_c (cacosh, minus_zero, minus_zero, 0.0, -M_PI_2l);
  873. TEST_c_c (cacosh, minus_infty, plus_infty, plus_infty, M_PI_34l);
  874. TEST_c_c (cacosh, minus_infty, minus_infty, plus_infty, -M_PI_34l);
  875. TEST_c_c (cacosh, plus_infty, plus_infty, plus_infty, M_PI_4l);
  876. TEST_c_c (cacosh, plus_infty, minus_infty, plus_infty, -M_PI_4l);
  877. TEST_c_c (cacosh, -10.0, plus_infty, plus_infty, M_PI_2l);
  878. TEST_c_c (cacosh, -10.0, minus_infty, plus_infty, -M_PI_2l);
  879. TEST_c_c (cacosh, 0, plus_infty, plus_infty, M_PI_2l);
  880. TEST_c_c (cacosh, 0, minus_infty, plus_infty, -M_PI_2l);
  881. TEST_c_c (cacosh, 0.1L, plus_infty, plus_infty, M_PI_2l);
  882. TEST_c_c (cacosh, 0.1L, minus_infty, plus_infty, -M_PI_2l);
  883. TEST_c_c (cacosh, minus_infty, 0, plus_infty, M_PIl);
  884. TEST_c_c (cacosh, minus_infty, minus_zero, plus_infty, -M_PIl);
  885. TEST_c_c (cacosh, minus_infty, 100, plus_infty, M_PIl);
  886. TEST_c_c (cacosh, minus_infty, -100, plus_infty, -M_PIl);
  887. TEST_c_c (cacosh, plus_infty, 0, plus_infty, 0.0);
  888. TEST_c_c (cacosh, plus_infty, minus_zero, plus_infty, minus_zero);
  889. TEST_c_c (cacosh, plus_infty, 0.5, plus_infty, 0.0);
  890. TEST_c_c (cacosh, plus_infty, -0.5, plus_infty, minus_zero);
  891. TEST_c_c (cacosh, plus_infty, nan_value, plus_infty, nan_value);
  892. TEST_c_c (cacosh, minus_infty, nan_value, plus_infty, nan_value);
  893. TEST_c_c (cacosh, 0, nan_value, nan_value, nan_value);
  894. TEST_c_c (cacosh, minus_zero, nan_value, nan_value, nan_value);
  895. TEST_c_c (cacosh, nan_value, plus_infty, plus_infty, nan_value);
  896. TEST_c_c (cacosh, nan_value, minus_infty, plus_infty, nan_value);
  897. TEST_c_c (cacosh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  898. TEST_c_c (cacosh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  899. TEST_c_c (cacosh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
  900. TEST_c_c (cacosh, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
  901. TEST_c_c (cacosh, nan_value, nan_value, nan_value, nan_value);
  902. TEST_c_c (cacosh, 0.7L, 1.2L, 1.0927647857577371459105272080819308L, 1.1351827477151551088992008271819053L);
  903. TEST_c_c (cacosh, -2, -3, -1.9833870299165354323470769028940395L, 2.1414491111159960199416055713254211L);
  904. END (cacosh, complex);
  905. }
  906. static void
  907. carg_test (void)
  908. {
  909. START (carg);
  910. /* carg (x + iy) is specified as atan2 (y, x) */
  911. /* carg (x + i 0) == 0 for x > 0. */
  912. TEST_c_f (carg, 2.0, 0, 0);
  913. /* carg (x - i 0) == -0 for x > 0. */
  914. TEST_c_f (carg, 2.0, minus_zero, minus_zero);
  915. TEST_c_f (carg, 0, 0, 0);
  916. TEST_c_f (carg, 0, minus_zero, minus_zero);
  917. /* carg (x + i 0) == +pi for x < 0. */
  918. TEST_c_f (carg, -2.0, 0, M_PIl);
  919. /* carg (x - i 0) == -pi for x < 0. */
  920. TEST_c_f (carg, -2.0, minus_zero, -M_PIl);
  921. TEST_c_f (carg, minus_zero, 0, M_PIl);
  922. TEST_c_f (carg, minus_zero, minus_zero, -M_PIl);
  923. /* carg (+0 + i y) == pi/2 for y > 0. */
  924. TEST_c_f (carg, 0, 2.0, M_PI_2l);
  925. /* carg (-0 + i y) == pi/2 for y > 0. */
  926. TEST_c_f (carg, minus_zero, 2.0, M_PI_2l);
  927. /* carg (+0 + i y) == -pi/2 for y < 0. */
  928. TEST_c_f (carg, 0, -2.0, -M_PI_2l);
  929. /* carg (-0 + i y) == -pi/2 for y < 0. */
  930. TEST_c_f (carg, minus_zero, -2.0, -M_PI_2l);
  931. /* carg (inf + i y) == +0 for finite y > 0. */
  932. TEST_c_f (carg, plus_infty, 2.0, 0);
  933. /* carg (inf + i y) == -0 for finite y < 0. */
  934. TEST_c_f (carg, plus_infty, -2.0, minus_zero);
  935. /* carg(x + i inf) == pi/2 for finite x. */
  936. TEST_c_f (carg, 10.0, plus_infty, M_PI_2l);
  937. /* carg(x - i inf) == -pi/2 for finite x. */
  938. TEST_c_f (carg, 10.0, minus_infty, -M_PI_2l);
  939. /* carg (-inf + i y) == +pi for finite y > 0. */
  940. TEST_c_f (carg, minus_infty, 10.0, M_PIl);
  941. /* carg (-inf + i y) == -pi for finite y < 0. */
  942. TEST_c_f (carg, minus_infty, -10.0, -M_PIl);
  943. TEST_c_f (carg, plus_infty, plus_infty, M_PI_4l);
  944. TEST_c_f (carg, plus_infty, minus_infty, -M_PI_4l);
  945. TEST_c_f (carg, minus_infty, plus_infty, 3 * M_PI_4l);
  946. TEST_c_f (carg, minus_infty, minus_infty, -3 * M_PI_4l);
  947. TEST_c_f (carg, nan_value, nan_value, nan_value);
  948. END (carg);
  949. }
  950. static void
  951. casin_test (void)
  952. {
  953. errno = 0;
  954. FUNC(casin) (BUILD_COMPLEX (0.7L, 1.2L));
  955. if (errno == ENOSYS)
  956. /* Function not implemented. */
  957. return;
  958. START (casin);
  959. TEST_c_c (casin, 0, 0, 0.0, 0.0);
  960. TEST_c_c (casin, minus_zero, 0, minus_zero, 0.0);
  961. TEST_c_c (casin, 0, minus_zero, 0.0, minus_zero);
  962. TEST_c_c (casin, minus_zero, minus_zero, minus_zero, minus_zero);
  963. TEST_c_c (casin, plus_infty, plus_infty, M_PI_4l, plus_infty);
  964. TEST_c_c (casin, plus_infty, minus_infty, M_PI_4l, minus_infty);
  965. TEST_c_c (casin, minus_infty, plus_infty, -M_PI_4l, plus_infty);
  966. TEST_c_c (casin, minus_infty, minus_infty, -M_PI_4l, minus_infty);
  967. TEST_c_c (casin, -10.0, plus_infty, minus_zero, plus_infty);
  968. TEST_c_c (casin, -10.0, minus_infty, minus_zero, minus_infty);
  969. TEST_c_c (casin, 0, plus_infty, 0.0, plus_infty);
  970. TEST_c_c (casin, 0, minus_infty, 0.0, minus_infty);
  971. TEST_c_c (casin, minus_zero, plus_infty, minus_zero, plus_infty);
  972. TEST_c_c (casin, minus_zero, minus_infty, minus_zero, minus_infty);
  973. TEST_c_c (casin, 0.1L, plus_infty, 0.0, plus_infty);
  974. TEST_c_c (casin, 0.1L, minus_infty, 0.0, minus_infty);
  975. TEST_c_c (casin, minus_infty, 0, -M_PI_2l, plus_infty);
  976. TEST_c_c (casin, minus_infty, minus_zero, -M_PI_2l, minus_infty);
  977. TEST_c_c (casin, minus_infty, 100, -M_PI_2l, plus_infty);
  978. TEST_c_c (casin, minus_infty, -100, -M_PI_2l, minus_infty);
  979. TEST_c_c (casin, plus_infty, 0, M_PI_2l, plus_infty);
  980. TEST_c_c (casin, plus_infty, minus_zero, M_PI_2l, minus_infty);
  981. TEST_c_c (casin, plus_infty, 0.5, M_PI_2l, plus_infty);
  982. TEST_c_c (casin, plus_infty, -0.5, M_PI_2l, minus_infty);
  983. TEST_c_c (casin, nan_value, plus_infty, nan_value, plus_infty);
  984. TEST_c_c (casin, nan_value, minus_infty, nan_value, minus_infty);
  985. TEST_c_c (casin, 0.0, nan_value, 0.0, nan_value);
  986. TEST_c_c (casin, minus_zero, nan_value, minus_zero, nan_value);
  987. TEST_c_c (casin, plus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
  988. TEST_c_c (casin, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
  989. TEST_c_c (casin, nan_value, 10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  990. TEST_c_c (casin, nan_value, -10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  991. TEST_c_c (casin, 0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  992. TEST_c_c (casin, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  993. TEST_c_c (casin, nan_value, nan_value, nan_value, nan_value);
  994. TEST_c_c (casin, 0.7L, 1.2L, 0.4356135790797415103321208644578462L, 1.0927647857577371459105272080819308L);
  995. TEST_c_c (casin, -2, -3, -0.57065278432109940071028387968566963L, -1.9833870299165354323470769028940395L);
  996. END (casin, complex);
  997. }
  998. static void
  999. casinh_test (void)
  1000. {
  1001. errno = 0;
  1002. FUNC(casinh) (BUILD_COMPLEX (0.7L, 1.2L));
  1003. if (errno == ENOSYS)
  1004. /* Function not implemented. */
  1005. return;
  1006. START (casinh);
  1007. TEST_c_c (casinh, 0, 0, 0.0, 0.0);
  1008. TEST_c_c (casinh, minus_zero, 0, minus_zero, 0);
  1009. TEST_c_c (casinh, 0, minus_zero, 0.0, minus_zero);
  1010. TEST_c_c (casinh, minus_zero, minus_zero, minus_zero, minus_zero);
  1011. TEST_c_c (casinh, plus_infty, plus_infty, plus_infty, M_PI_4l);
  1012. TEST_c_c (casinh, plus_infty, minus_infty, plus_infty, -M_PI_4l);
  1013. TEST_c_c (casinh, minus_infty, plus_infty, minus_infty, M_PI_4l);
  1014. TEST_c_c (casinh, minus_infty, minus_infty, minus_infty, -M_PI_4l);
  1015. TEST_c_c (casinh, -10.0, plus_infty, minus_infty, M_PI_2l);
  1016. TEST_c_c (casinh, -10.0, minus_infty, minus_infty, -M_PI_2l);
  1017. TEST_c_c (casinh, 0, plus_infty, plus_infty, M_PI_2l);
  1018. TEST_c_c (casinh, 0, minus_infty, plus_infty, -M_PI_2l);
  1019. TEST_c_c (casinh, minus_zero, plus_infty, minus_infty, M_PI_2l);
  1020. TEST_c_c (casinh, minus_zero, minus_infty, minus_infty, -M_PI_2l);
  1021. TEST_c_c (casinh, 0.1L, plus_infty, plus_infty, M_PI_2l);
  1022. TEST_c_c (casinh, 0.1L, minus_infty, plus_infty, -M_PI_2l);
  1023. TEST_c_c (casinh, minus_infty, 0, minus_infty, 0.0);
  1024. TEST_c_c (casinh, minus_infty, minus_zero, minus_infty, minus_zero);
  1025. TEST_c_c (casinh, minus_infty, 100, minus_infty, 0.0);
  1026. TEST_c_c (casinh, minus_infty, -100, minus_infty, minus_zero);
  1027. TEST_c_c (casinh, plus_infty, 0, plus_infty, 0.0);
  1028. TEST_c_c (casinh, plus_infty, minus_zero, plus_infty, minus_zero);
  1029. TEST_c_c (casinh, plus_infty, 0.5, plus_infty, 0.0);
  1030. TEST_c_c (casinh, plus_infty, -0.5, plus_infty, minus_zero);
  1031. TEST_c_c (casinh, plus_infty, nan_value, plus_infty, nan_value);
  1032. TEST_c_c (casinh, minus_infty, nan_value, minus_infty, nan_value);
  1033. TEST_c_c (casinh, nan_value, 0, nan_value, 0.0);
  1034. TEST_c_c (casinh, nan_value, minus_zero, nan_value, minus_zero);
  1035. TEST_c_c (casinh, nan_value, plus_infty, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
  1036. TEST_c_c (casinh, nan_value, minus_infty, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
  1037. TEST_c_c (casinh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1038. TEST_c_c (casinh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1039. TEST_c_c (casinh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1040. TEST_c_c (casinh, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1041. TEST_c_c (casinh, nan_value, nan_value, nan_value, nan_value);
  1042. TEST_c_c (casinh, 0.7L, 1.2L, 0.97865459559367387689317593222160964L, 0.91135418953156011567903546856170941L);
  1043. TEST_c_c (casinh, -2, -3, -1.9686379257930962917886650952454982L, -0.96465850440760279204541105949953237L);
  1044. END (casinh, complex);
  1045. }
  1046. static void
  1047. catan_test (void)
  1048. {
  1049. errno = 0;
  1050. FUNC(catan) (BUILD_COMPLEX (0.7L, 1.2L));
  1051. if (errno == ENOSYS)
  1052. /* Function not implemented. */
  1053. return;
  1054. START (catan);
  1055. TEST_c_c (catan, 0, 0, 0, 0);
  1056. TEST_c_c (catan, minus_zero, 0, minus_zero, 0);
  1057. TEST_c_c (catan, 0, minus_zero, 0, minus_zero);
  1058. TEST_c_c (catan, minus_zero, minus_zero, minus_zero, minus_zero);
  1059. TEST_c_c (catan, plus_infty, plus_infty, M_PI_2l, 0);
  1060. TEST_c_c (catan, plus_infty, minus_infty, M_PI_2l, minus_zero);
  1061. TEST_c_c (catan, minus_infty, plus_infty, -M_PI_2l, 0);
  1062. TEST_c_c (catan, minus_infty, minus_infty, -M_PI_2l, minus_zero);
  1063. TEST_c_c (catan, plus_infty, -10.0, M_PI_2l, minus_zero);
  1064. TEST_c_c (catan, minus_infty, -10.0, -M_PI_2l, minus_zero);
  1065. TEST_c_c (catan, plus_infty, minus_zero, M_PI_2l, minus_zero);
  1066. TEST_c_c (catan, minus_infty, minus_zero, -M_PI_2l, minus_zero);
  1067. TEST_c_c (catan, plus_infty, 0.0, M_PI_2l, 0);
  1068. TEST_c_c (catan, minus_infty, 0.0, -M_PI_2l, 0);
  1069. TEST_c_c (catan, plus_infty, 0.1L, M_PI_2l, 0);
  1070. TEST_c_c (catan, minus_infty, 0.1L, -M_PI_2l, 0);
  1071. TEST_c_c (catan, 0.0, minus_infty, M_PI_2l, minus_zero);
  1072. TEST_c_c (catan, minus_zero, minus_infty, -M_PI_2l, minus_zero);
  1073. TEST_c_c (catan, 100.0, minus_infty, M_PI_2l, minus_zero);
  1074. TEST_c_c (catan, -100.0, minus_infty, -M_PI_2l, minus_zero);
  1075. TEST_c_c (catan, 0.0, plus_infty, M_PI_2l, 0);
  1076. TEST_c_c (catan, minus_zero, plus_infty, -M_PI_2l, 0);
  1077. TEST_c_c (catan, 0.5, plus_infty, M_PI_2l, 0);
  1078. TEST_c_c (catan, -0.5, plus_infty, -M_PI_2l, 0);
  1079. TEST_c_c (catan, nan_value, 0.0, nan_value, 0);
  1080. TEST_c_c (catan, nan_value, minus_zero, nan_value, minus_zero);
  1081. TEST_c_c (catan, nan_value, plus_infty, nan_value, 0);
  1082. TEST_c_c (catan, nan_value, minus_infty, nan_value, minus_zero);
  1083. TEST_c_c (catan, 0.0, nan_value, nan_value, nan_value);
  1084. TEST_c_c (catan, minus_zero, nan_value, nan_value, nan_value);
  1085. TEST_c_c (catan, plus_infty, nan_value, M_PI_2l, 0, IGNORE_ZERO_INF_SIGN);
  1086. TEST_c_c (catan, minus_infty, nan_value, -M_PI_2l, 0, IGNORE_ZERO_INF_SIGN);
  1087. TEST_c_c (catan, nan_value, 10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1088. TEST_c_c (catan, nan_value, -10.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1089. TEST_c_c (catan, 0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1090. TEST_c_c (catan, -0.75, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1091. TEST_c_c (catan, nan_value, nan_value, nan_value, nan_value);
  1092. TEST_c_c (catan, 0.7L, 1.2L, 1.0785743834118921877443707996386368L, 0.57705737765343067644394541889341712L);
  1093. TEST_c_c (catan, -2, -3, -1.4099210495965755225306193844604208L, -0.22907268296853876629588180294200276L);
  1094. END (catan, complex);
  1095. }
  1096. static void
  1097. catanh_test (void)
  1098. {
  1099. errno = 0;
  1100. FUNC(catanh) (BUILD_COMPLEX (0.7L, 1.2L));
  1101. if (errno == ENOSYS)
  1102. /* Function not implemented. */
  1103. return;
  1104. START (catanh);
  1105. TEST_c_c (catanh, 0, 0, 0.0, 0.0);
  1106. TEST_c_c (catanh, minus_zero, 0, minus_zero, 0.0);
  1107. TEST_c_c (catanh, 0, minus_zero, 0.0, minus_zero);
  1108. TEST_c_c (catanh, minus_zero, minus_zero, minus_zero, minus_zero);
  1109. TEST_c_c (catanh, plus_infty, plus_infty, 0.0, M_PI_2l);
  1110. TEST_c_c (catanh, plus_infty, minus_infty, 0.0, -M_PI_2l);
  1111. TEST_c_c (catanh, minus_infty, plus_infty, minus_zero, M_PI_2l);
  1112. TEST_c_c (catanh, minus_infty, minus_infty, minus_zero, -M_PI_2l);
  1113. TEST_c_c (catanh, -10.0, plus_infty, minus_zero, M_PI_2l);
  1114. TEST_c_c (catanh, -10.0, minus_infty, minus_zero, -M_PI_2l);
  1115. TEST_c_c (catanh, minus_zero, plus_infty, minus_zero, M_PI_2l);
  1116. TEST_c_c (catanh, minus_zero, minus_infty, minus_zero, -M_PI_2l);
  1117. TEST_c_c (catanh, 0, plus_infty, 0.0, M_PI_2l);
  1118. TEST_c_c (catanh, 0, minus_infty, 0.0, -M_PI_2l);
  1119. TEST_c_c (catanh, 0.1L, plus_infty, 0.0, M_PI_2l);
  1120. TEST_c_c (catanh, 0.1L, minus_infty, 0.0, -M_PI_2l);
  1121. TEST_c_c (catanh, minus_infty, 0, minus_zero, M_PI_2l);
  1122. TEST_c_c (catanh, minus_infty, minus_zero, minus_zero, -M_PI_2l);
  1123. TEST_c_c (catanh, minus_infty, 100, minus_zero, M_PI_2l);
  1124. TEST_c_c (catanh, minus_infty, -100, minus_zero, -M_PI_2l);
  1125. TEST_c_c (catanh, plus_infty, 0, 0.0, M_PI_2l);
  1126. TEST_c_c (catanh, plus_infty, minus_zero, 0.0, -M_PI_2l);
  1127. TEST_c_c (catanh, plus_infty, 0.5, 0.0, M_PI_2l);
  1128. TEST_c_c (catanh, plus_infty, -0.5, 0.0, -M_PI_2l);
  1129. TEST_c_c (catanh, 0, nan_value, 0.0, nan_value);
  1130. TEST_c_c (catanh, minus_zero, nan_value, minus_zero, nan_value);
  1131. TEST_c_c (catanh, plus_infty, nan_value, 0.0, nan_value);
  1132. TEST_c_c (catanh, minus_infty, nan_value, minus_zero, nan_value);
  1133. TEST_c_c (catanh, nan_value, 0, nan_value, nan_value);
  1134. TEST_c_c (catanh, nan_value, minus_zero, nan_value, nan_value);
  1135. TEST_c_c (catanh, nan_value, plus_infty, 0.0, M_PI_2l, IGNORE_ZERO_INF_SIGN);
  1136. TEST_c_c (catanh, nan_value, minus_infty, 0.0, -M_PI_2l, IGNORE_ZERO_INF_SIGN);
  1137. TEST_c_c (catanh, 10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1138. TEST_c_c (catanh, -10.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1139. TEST_c_c (catanh, nan_value, 0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1140. TEST_c_c (catanh, nan_value, -0.75, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1141. TEST_c_c (catanh, nan_value, nan_value, nan_value, nan_value);
  1142. TEST_c_c (catanh, 0.7L, 1.2L, 0.2600749516525135959200648705635915L, 0.97024030779509898497385130162655963L);
  1143. TEST_c_c (catanh, -2, -3, -0.14694666622552975204743278515471595L, -1.3389725222944935611241935759091443L);
  1144. END (catanh, complex);
  1145. }
  1146. #endif
  1147. static void
  1148. cbrt_test (void)
  1149. {
  1150. errno = 0;
  1151. FUNC(cbrt) (8);
  1152. if (errno == ENOSYS)
  1153. /* Function not implemented. */
  1154. return;
  1155. START (cbrt);
  1156. TEST_f_f (cbrt, 0.0, 0.0);
  1157. TEST_f_f (cbrt, minus_zero, minus_zero);
  1158. TEST_f_f (cbrt, plus_infty, plus_infty);
  1159. TEST_f_f (cbrt, minus_infty, minus_infty);
  1160. TEST_f_f (cbrt, nan_value, nan_value);
  1161. TEST_f_f (cbrt, -0.001L, -0.1L);
  1162. TEST_f_f (cbrt, 8, 2);
  1163. TEST_f_f (cbrt, -27.0, -3.0);
  1164. TEST_f_f (cbrt, 0.970299L, 0.99L);
  1165. TEST_f_f (cbrt, 0.7L, 0.8879040017426007084L);
  1166. END (cbrt);
  1167. }
  1168. #if 0
  1169. static void
  1170. ccos_test (void)
  1171. {
  1172. errno = 0;
  1173. FUNC(ccos) (BUILD_COMPLEX (0, 0));
  1174. if (errno == ENOSYS)
  1175. /* Function not implemented. */
  1176. return;
  1177. START (ccos);
  1178. TEST_c_c (ccos, 0.0, 0.0, 1.0, minus_zero);
  1179. TEST_c_c (ccos, minus_zero, 0.0, 1.0, 0.0);
  1180. TEST_c_c (ccos, 0.0, minus_zero, 1.0, 0.0);
  1181. TEST_c_c (ccos, minus_zero, minus_zero, 1.0, minus_zero);
  1182. TEST_c_c (ccos, plus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1183. TEST_c_c (ccos, plus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1184. TEST_c_c (ccos, minus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1185. TEST_c_c (ccos, minus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1186. TEST_c_c (ccos, 0.0, plus_infty, plus_infty, minus_zero);
  1187. TEST_c_c (ccos, 0.0, minus_infty, plus_infty, 0.0);
  1188. TEST_c_c (ccos, minus_zero, plus_infty, plus_infty, 0.0);
  1189. TEST_c_c (ccos, minus_zero, minus_infty, plus_infty, minus_zero);
  1190. TEST_c_c (ccos, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
  1191. TEST_c_c (ccos, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
  1192. TEST_c_c (ccos, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
  1193. TEST_c_c (ccos, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
  1194. TEST_c_c (ccos, 4.625, plus_infty, minus_infty, plus_infty);
  1195. TEST_c_c (ccos, 4.625, minus_infty, minus_infty, minus_infty);
  1196. TEST_c_c (ccos, -4.625, plus_infty, minus_infty, minus_infty);
  1197. TEST_c_c (ccos, -4.625, minus_infty, minus_infty, plus_infty);
  1198. TEST_c_c (ccos, plus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
  1199. TEST_c_c (ccos, plus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
  1200. TEST_c_c (ccos, minus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
  1201. TEST_c_c (ccos, minus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
  1202. TEST_c_c (ccos, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
  1203. TEST_c_c (ccos, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
  1204. TEST_c_c (ccos, nan_value, plus_infty, plus_infty, nan_value);
  1205. TEST_c_c (ccos, nan_value, minus_infty, plus_infty, nan_value);
  1206. TEST_c_c (ccos, nan_value, 9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1207. TEST_c_c (ccos, nan_value, -9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1208. TEST_c_c (ccos, 0.0, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
  1209. TEST_c_c (ccos, minus_zero, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
  1210. TEST_c_c (ccos, 10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1211. TEST_c_c (ccos, -10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1212. TEST_c_c (ccos, plus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1213. TEST_c_c (ccos, minus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1214. TEST_c_c (ccos, nan_value, nan_value, nan_value, nan_value);
  1215. TEST_c_c (ccos, 0.7L, 1.2L, 1.3848657645312111080L, -0.97242170335830028619L);
  1216. TEST_c_c (ccos, -2, -3, -4.1896256909688072301L, -9.1092278937553365979L);
  1217. END (ccos, complex);
  1218. }
  1219. static void
  1220. ccosh_test (void)
  1221. {
  1222. errno = 0;
  1223. FUNC(ccosh) (BUILD_COMPLEX (0.7L, 1.2L));
  1224. if (errno == ENOSYS)
  1225. /* Function not implemented. */
  1226. return;
  1227. START (ccosh);
  1228. TEST_c_c (ccosh, 0.0, 0.0, 1.0, 0.0);
  1229. TEST_c_c (ccosh, minus_zero, 0.0, 1.0, minus_zero);
  1230. TEST_c_c (ccosh, 0.0, minus_zero, 1.0, minus_zero);
  1231. TEST_c_c (ccosh, minus_zero, minus_zero, 1.0, 0.0);
  1232. TEST_c_c (ccosh, 0.0, plus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1233. TEST_c_c (ccosh, minus_zero, plus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1234. TEST_c_c (ccosh, 0.0, minus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1235. TEST_c_c (ccosh, minus_zero, minus_infty, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1236. TEST_c_c (ccosh, plus_infty, 0.0, plus_infty, 0.0);
  1237. TEST_c_c (ccosh, minus_infty, 0.0, plus_infty, minus_zero);
  1238. TEST_c_c (ccosh, plus_infty, minus_zero, plus_infty, minus_zero);
  1239. TEST_c_c (ccosh, minus_infty, minus_zero, plus_infty, 0.0);
  1240. TEST_c_c (ccosh, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
  1241. TEST_c_c (ccosh, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
  1242. TEST_c_c (ccosh, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
  1243. TEST_c_c (ccosh, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
  1244. TEST_c_c (ccosh, plus_infty, 4.625, minus_infty, minus_infty);
  1245. TEST_c_c (ccosh, minus_infty, 4.625, minus_infty, plus_infty);
  1246. TEST_c_c (ccosh, plus_infty, -4.625, minus_infty, plus_infty);
  1247. TEST_c_c (ccosh, minus_infty, -4.625, minus_infty, minus_infty);
  1248. TEST_c_c (ccosh, 6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1249. TEST_c_c (ccosh, -6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1250. TEST_c_c (ccosh, 6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1251. TEST_c_c (ccosh, -6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1252. TEST_c_c (ccosh, 0.0, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
  1253. TEST_c_c (ccosh, minus_zero, nan_value, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
  1254. TEST_c_c (ccosh, plus_infty, nan_value, plus_infty, nan_value);
  1255. TEST_c_c (ccosh, minus_infty, nan_value, plus_infty, nan_value);
  1256. TEST_c_c (ccosh, 9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1257. TEST_c_c (ccosh, -9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1258. TEST_c_c (ccosh, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
  1259. TEST_c_c (ccosh, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
  1260. TEST_c_c (ccosh, nan_value, 10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1261. TEST_c_c (ccosh, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1262. TEST_c_c (ccosh, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1263. TEST_c_c (ccosh, nan_value, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1264. TEST_c_c (ccosh, nan_value, nan_value, nan_value, nan_value);
  1265. TEST_c_c (ccosh, 0.7L, 1.2L, 0.4548202223691477654L, 0.7070296600921537682L);
  1266. TEST_c_c (ccosh, -2, -3, -3.7245455049153225654L, 0.5118225699873846088L);
  1267. END (ccosh, complex);
  1268. }
  1269. #endif
  1270. static void
  1271. ceil_test (void)
  1272. {
  1273. START (ceil);
  1274. TEST_f_f (ceil, 0.0, 0.0);
  1275. TEST_f_f (ceil, minus_zero, minus_zero);
  1276. TEST_f_f (ceil, plus_infty, plus_infty);
  1277. TEST_f_f (ceil, minus_infty, minus_infty);
  1278. TEST_f_f (ceil, nan_value, nan_value);
  1279. TEST_f_f (ceil, M_PIl, 4.0);
  1280. TEST_f_f (ceil, -M_PIl, -3.0);
  1281. END (ceil);
  1282. }
  1283. #if 0
  1284. static void
  1285. cexp_test (void)
  1286. {
  1287. errno = 0;
  1288. FUNC(cexp) (BUILD_COMPLEX (0, 0));
  1289. if (errno == ENOSYS)
  1290. /* Function not implemented. */
  1291. return;
  1292. START (cexp);
  1293. TEST_c_c (cexp, plus_zero, plus_zero, 1, 0.0);
  1294. TEST_c_c (cexp, minus_zero, plus_zero, 1, 0.0);
  1295. TEST_c_c (cexp, plus_zero, minus_zero, 1, minus_zero);
  1296. TEST_c_c (cexp, minus_zero, minus_zero, 1, minus_zero);
  1297. TEST_c_c (cexp, plus_infty, plus_zero, plus_infty, 0.0);
  1298. TEST_c_c (cexp, plus_infty, minus_zero, plus_infty, minus_zero);
  1299. TEST_c_c (cexp, minus_infty, plus_zero, 0.0, 0.0);
  1300. TEST_c_c (cexp, minus_infty, minus_zero, 0.0, minus_zero);
  1301. TEST_c_c (cexp, 0.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1302. TEST_c_c (cexp, minus_zero, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1303. TEST_c_c (cexp, 0.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1304. TEST_c_c (cexp, minus_zero, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1305. TEST_c_c (cexp, 100.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1306. TEST_c_c (cexp, -100.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1307. TEST_c_c (cexp, 100.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1308. TEST_c_c (cexp, -100.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1309. TEST_c_c (cexp, minus_infty, 2.0, minus_zero, 0.0);
  1310. TEST_c_c (cexp, minus_infty, 4.0, minus_zero, minus_zero);
  1311. TEST_c_c (cexp, plus_infty, 2.0, minus_infty, plus_infty);
  1312. TEST_c_c (cexp, plus_infty, 4.0, minus_infty, minus_infty);
  1313. TEST_c_c (cexp, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1314. TEST_c_c (cexp, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1315. TEST_c_c (cexp, minus_infty, plus_infty, 0.0, 0.0, IGNORE_ZERO_INF_SIGN);
  1316. TEST_c_c (cexp, minus_infty, minus_infty, 0.0, minus_zero, IGNORE_ZERO_INF_SIGN);
  1317. TEST_c_c (cexp, minus_infty, nan_value, 0, 0, IGNORE_ZERO_INF_SIGN);
  1318. TEST_c_c (cexp, plus_infty, nan_value, plus_infty, nan_value);
  1319. TEST_c_c (cexp, nan_value, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1320. TEST_c_c (cexp, nan_value, 1.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1321. TEST_c_c (cexp, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1322. TEST_c_c (cexp, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1323. TEST_c_c (cexp, 1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1324. TEST_c_c (cexp, nan_value, nan_value, nan_value, nan_value);
  1325. TEST_c_c (cexp, 0.7L, 1.2L, 0.72969890915032360123451688642930727L, 1.8768962328348102821139467908203072L);
  1326. TEST_c_c (cexp, -2.0, -3.0, -0.13398091492954261346140525546115575L, -0.019098516261135196432576240858800925L);
  1327. END (cexp, complex);
  1328. }
  1329. static void
  1330. cimag_test (void)
  1331. {
  1332. START (cimag);
  1333. TEST_c_f (cimag, 1.0, 0.0, 0.0);
  1334. TEST_c_f (cimag, 1.0, minus_zero, minus_zero);
  1335. TEST_c_f (cimag, 1.0, nan_value, nan_value);
  1336. TEST_c_f (cimag, nan_value, nan_value, nan_value);
  1337. TEST_c_f (cimag, 1.0, plus_infty, plus_infty);
  1338. TEST_c_f (cimag, 1.0, minus_infty, minus_infty);
  1339. TEST_c_f (cimag, 2.0, 3.0, 3.0);
  1340. END (cimag);
  1341. }
  1342. static void
  1343. clog_test (void)
  1344. {
  1345. errno = 0;
  1346. FUNC(clog) (BUILD_COMPLEX (-2, -3));
  1347. if (errno == ENOSYS)
  1348. /* Function not implemented. */
  1349. return;
  1350. START (clog);
  1351. TEST_c_c (clog, minus_zero, 0, minus_infty, M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
  1352. TEST_c_c (clog, minus_zero, minus_zero, minus_infty, -M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
  1353. TEST_c_c (clog, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION);
  1354. TEST_c_c (clog, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION);
  1355. TEST_c_c (clog, minus_infty, plus_infty, plus_infty, M_PI_34l);
  1356. TEST_c_c (clog, minus_infty, minus_infty, plus_infty, -M_PI_34l);
  1357. TEST_c_c (clog, plus_infty, plus_infty, plus_infty, M_PI_4l);
  1358. TEST_c_c (clog, plus_infty, minus_infty, plus_infty, -M_PI_4l);
  1359. TEST_c_c (clog, 0, plus_infty, plus_infty, M_PI_2l);
  1360. TEST_c_c (clog, 3, plus_infty, plus_infty, M_PI_2l);
  1361. TEST_c_c (clog, minus_zero, plus_infty, plus_infty, M_PI_2l);
  1362. TEST_c_c (clog, -3, plus_infty, plus_infty, M_PI_2l);
  1363. TEST_c_c (clog, 0, minus_infty, plus_infty, -M_PI_2l);
  1364. TEST_c_c (clog, 3, minus_infty, plus_infty, -M_PI_2l);
  1365. TEST_c_c (clog, minus_zero, minus_infty, plus_infty, -M_PI_2l);
  1366. TEST_c_c (clog, -3, minus_infty, plus_infty, -M_PI_2l);
  1367. TEST_c_c (clog, minus_infty, 0, plus_infty, M_PIl);
  1368. TEST_c_c (clog, minus_infty, 1, plus_infty, M_PIl);
  1369. TEST_c_c (clog, minus_infty, minus_zero, plus_infty, -M_PIl);
  1370. TEST_c_c (clog, minus_infty, -1, plus_infty, -M_PIl);
  1371. TEST_c_c (clog, plus_infty, 0, plus_infty, 0.0);
  1372. TEST_c_c (clog, plus_infty, 1, plus_infty, 0.0);
  1373. TEST_c_c (clog, plus_infty, minus_zero, plus_infty, minus_zero);
  1374. TEST_c_c (clog, plus_infty, -1, plus_infty, minus_zero);
  1375. TEST_c_c (clog, plus_infty, nan_value, plus_infty, nan_value);
  1376. TEST_c_c (clog, minus_infty, nan_value, plus_infty, nan_value);
  1377. TEST_c_c (clog, nan_value, plus_infty, plus_infty, nan_value);
  1378. TEST_c_c (clog, nan_value, minus_infty, plus_infty, nan_value);
  1379. TEST_c_c (clog, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1380. TEST_c_c (clog, 3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1381. TEST_c_c (clog, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1382. TEST_c_c (clog, -3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1383. TEST_c_c (clog, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1384. TEST_c_c (clog, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1385. TEST_c_c (clog, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1386. TEST_c_c (clog, nan_value, -5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1387. TEST_c_c (clog, nan_value, nan_value, nan_value, nan_value);
  1388. TEST_c_c (clog, -2, -3, 1.2824746787307683680267437207826593L, -2.1587989303424641704769327722648368L);
  1389. END (clog, complex);
  1390. }
  1391. static void
  1392. clog10_test (void)
  1393. {
  1394. errno = 0;
  1395. FUNC(clog10) (BUILD_COMPLEX (0.7L, 1.2L));
  1396. if (errno == ENOSYS)
  1397. /* Function not implemented. */
  1398. return;
  1399. START (clog10);
  1400. TEST_c_c (clog10, minus_zero, 0, minus_infty, M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
  1401. TEST_c_c (clog10, minus_zero, minus_zero, minus_infty, -M_PIl, DIVIDE_BY_ZERO_EXCEPTION);
  1402. TEST_c_c (clog10, 0, 0, minus_infty, 0.0, DIVIDE_BY_ZERO_EXCEPTION);
  1403. TEST_c_c (clog10, 0, minus_zero, minus_infty, minus_zero, DIVIDE_BY_ZERO_EXCEPTION);
  1404. TEST_c_c (clog10, minus_infty, plus_infty, plus_infty, M_PI_34_LOG10El);
  1405. TEST_c_c (clog10, plus_infty, plus_infty, plus_infty, M_PI4_LOG10El);
  1406. TEST_c_c (clog10, plus_infty, minus_infty, plus_infty, -M_PI4_LOG10El);
  1407. TEST_c_c (clog10, 0, plus_infty, plus_infty, M_PI2_LOG10El);
  1408. TEST_c_c (clog10, 3, plus_infty, plus_infty, M_PI2_LOG10El);
  1409. TEST_c_c (clog10, minus_zero, plus_infty, plus_infty, M_PI2_LOG10El);
  1410. TEST_c_c (clog10, -3, plus_infty, plus_infty, M_PI2_LOG10El);
  1411. TEST_c_c (clog10, 0, minus_infty, plus_infty, -M_PI2_LOG10El);
  1412. TEST_c_c (clog10, 3, minus_infty, plus_infty, -M_PI2_LOG10El);
  1413. TEST_c_c (clog10, minus_zero, minus_infty, plus_infty, -M_PI2_LOG10El);
  1414. TEST_c_c (clog10, -3, minus_infty, plus_infty, -M_PI2_LOG10El);
  1415. TEST_c_c (clog10, minus_infty, 0, plus_infty, M_PI_LOG10El);
  1416. TEST_c_c (clog10, minus_infty, 1, plus_infty, M_PI_LOG10El);
  1417. TEST_c_c (clog10, minus_infty, minus_zero, plus_infty, -M_PI_LOG10El);
  1418. TEST_c_c (clog10, minus_infty, -1, plus_infty, -M_PI_LOG10El);
  1419. TEST_c_c (clog10, plus_infty, 0, plus_infty, 0.0);
  1420. TEST_c_c (clog10, plus_infty, 1, plus_infty, 0.0);
  1421. TEST_c_c (clog10, plus_infty, minus_zero, plus_infty, minus_zero);
  1422. TEST_c_c (clog10, plus_infty, -1, plus_infty, minus_zero);
  1423. TEST_c_c (clog10, plus_infty, nan_value, plus_infty, nan_value);
  1424. TEST_c_c (clog10, minus_infty, nan_value, plus_infty, nan_value);
  1425. TEST_c_c (clog10, nan_value, plus_infty, plus_infty, nan_value);
  1426. TEST_c_c (clog10, nan_value, minus_infty, plus_infty, nan_value);
  1427. TEST_c_c (clog10, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1428. TEST_c_c (clog10, 3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1429. TEST_c_c (clog10, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1430. TEST_c_c (clog10, -3, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1431. TEST_c_c (clog10, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1432. TEST_c_c (clog10, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1433. TEST_c_c (clog10, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1434. TEST_c_c (clog10, nan_value, -5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1435. TEST_c_c (clog10, nan_value, nan_value, nan_value, nan_value);
  1436. TEST_c_c (clog10, 0.7L, 1.2L, 0.1427786545038868803L, 0.4528483579352493248L);
  1437. TEST_c_c (clog10, -2, -3, 0.5569716761534183846L, -0.9375544629863747085L);
  1438. END (clog10, complex);
  1439. }
  1440. #endif
  1441. static void
  1442. conj_test (void)
  1443. {
  1444. START (conj);
  1445. TEST_c_c (conj, 0.0, 0.0, 0.0, minus_zero);
  1446. TEST_c_c (conj, 0.0, minus_zero, 0.0, 0.0);
  1447. TEST_c_c (conj, nan_value, nan_value, nan_value, nan_value);
  1448. TEST_c_c (conj, plus_infty, minus_infty, plus_infty, plus_infty);
  1449. TEST_c_c (conj, plus_infty, plus_infty, plus_infty, minus_infty);
  1450. TEST_c_c (conj, 1.0, 2.0, 1.0, -2.0);
  1451. TEST_c_c (conj, 3.0, -4.0, 3.0, 4.0);
  1452. END (conj, complex);
  1453. }
  1454. static void
  1455. copysign_test (void)
  1456. {
  1457. START (copysign);
  1458. TEST_ff_f (copysign, 0, 4, 0);
  1459. TEST_ff_f (copysign, 0, -4, minus_zero);
  1460. TEST_ff_f (copysign, minus_zero, 4, 0);
  1461. TEST_ff_f (copysign, minus_zero, -4, minus_zero);
  1462. TEST_ff_f (copysign, plus_infty, 0, plus_infty);
  1463. TEST_ff_f (copysign, plus_infty, minus_zero, minus_infty);
  1464. TEST_ff_f (copysign, minus_infty, 0, plus_infty);
  1465. TEST_ff_f (copysign, minus_infty, minus_zero, minus_infty);
  1466. TEST_ff_f (copysign, 0, plus_infty, 0);
  1467. TEST_ff_f (copysign, 0, minus_zero, minus_zero);
  1468. TEST_ff_f (copysign, minus_zero, plus_infty, 0);
  1469. TEST_ff_f (copysign, minus_zero, minus_zero, minus_zero);
  1470. /* XXX More correctly we would have to check the sign of the NaN. */
  1471. TEST_ff_f (copysign, nan_value, 0, nan_value);
  1472. TEST_ff_f (copysign, nan_value, minus_zero, nan_value);
  1473. TEST_ff_f (copysign, -nan_value, 0, nan_value);
  1474. TEST_ff_f (copysign, -nan_value, minus_zero, nan_value);
  1475. END (copysign);
  1476. }
  1477. static void
  1478. cos_test (void)
  1479. {
  1480. errno = 0;
  1481. FUNC(cos) (0);
  1482. if (errno == ENOSYS)
  1483. /* Function not implemented. */
  1484. return;
  1485. START (cos);
  1486. TEST_f_f (cos, 0, 1);
  1487. TEST_f_f (cos, minus_zero, 1);
  1488. TEST_f_f (cos, plus_infty, nan_value, INVALID_EXCEPTION);
  1489. TEST_f_f (cos, minus_infty, nan_value, INVALID_EXCEPTION);
  1490. TEST_f_f (cos, nan_value, nan_value);
  1491. TEST_f_f (cos, M_PI_6l * 2.0, 0.5);
  1492. TEST_f_f (cos, M_PI_6l * 4.0, -0.5);
  1493. TEST_f_f (cos, M_PI_2l, 0);
  1494. TEST_f_f (cos, 0.7L, 0.76484218728448842625585999019186495L);
  1495. END (cos);
  1496. }
  1497. static void
  1498. cosh_test (void)
  1499. {
  1500. errno = 0;
  1501. FUNC(cosh) (0.7L);
  1502. if (errno == ENOSYS)
  1503. /* Function not implemented. */
  1504. return;
  1505. START (cosh);
  1506. TEST_f_f (cosh, 0, 1);
  1507. TEST_f_f (cosh, minus_zero, 1);
  1508. #ifndef TEST_INLINE
  1509. TEST_f_f (cosh, plus_infty, plus_infty);
  1510. TEST_f_f (cosh, minus_infty, plus_infty);
  1511. #endif
  1512. TEST_f_f (cosh, nan_value, nan_value);
  1513. TEST_f_f (cosh, 0.7L, 1.255169005630943018L);
  1514. END (cosh);
  1515. }
  1516. #if 0
  1517. static void
  1518. cpow_test (void)
  1519. {
  1520. errno = 0;
  1521. FUNC(cpow) (BUILD_COMPLEX (1, 0), BUILD_COMPLEX (0, 0));
  1522. if (errno == ENOSYS)
  1523. /* Function not implemented. */
  1524. return;
  1525. START (cpow);
  1526. TEST_cc_c (cpow, 1, 0, 0, 0, 1.0, 0.0);
  1527. TEST_cc_c (cpow, 2, 0, 10, 0, 1024.0, 0.0);
  1528. TEST_cc_c (cpow, M_El, 0, 0, 2 * M_PIl, 1.0, 0.0);
  1529. TEST_cc_c (cpow, 2, 3, 4, 0, -119.0, -120.0);
  1530. TEST_cc_c (cpow, nan_value, nan_value, nan_value, nan_value, nan_value, nan_value);
  1531. END (cpow, complex);
  1532. }
  1533. static void
  1534. cproj_test (void)
  1535. {
  1536. START (cproj);
  1537. TEST_c_c (cproj, 0.0, 0.0, 0.0, 0.0);
  1538. TEST_c_c (cproj, minus_zero, minus_zero, minus_zero, minus_zero);
  1539. TEST_c_c (cproj, 0.0, minus_zero, 0.0, minus_zero);
  1540. TEST_c_c (cproj, minus_zero, 0.0, minus_zero, 0.0);
  1541. TEST_c_c (cproj, nan_value, nan_value, nan_value, nan_value);
  1542. TEST_c_c (cproj, plus_infty, plus_infty, plus_infty, 0.0);
  1543. TEST_c_c (cproj, plus_infty, minus_infty, plus_infty, minus_zero);
  1544. TEST_c_c (cproj, minus_infty, plus_infty, plus_infty, 0.0);
  1545. TEST_c_c (cproj, minus_infty, minus_infty, plus_infty, minus_zero);
  1546. TEST_c_c (cproj, 1.0, 0.0, 1.0, 0.0);
  1547. TEST_c_c (cproj, 2.0, 3.0, 0.2857142857142857142857142857142857L, 0.42857142857142857142857142857142855L);
  1548. END (cproj, complex);
  1549. }
  1550. static void
  1551. creal_test (void)
  1552. {
  1553. START (creal);
  1554. TEST_c_f (creal, 0.0, 1.0, 0.0);
  1555. TEST_c_f (creal, minus_zero, 1.0, minus_zero);
  1556. TEST_c_f (creal, nan_value, 1.0, nan_value);
  1557. TEST_c_f (creal, nan_value, nan_value, nan_value);
  1558. TEST_c_f (creal, plus_infty, 1.0, plus_infty);
  1559. TEST_c_f (creal, minus_infty, 1.0, minus_infty);
  1560. TEST_c_f (creal, 2.0, 3.0, 2.0);
  1561. END (creal);
  1562. }
  1563. static void
  1564. csin_test (void)
  1565. {
  1566. errno = 0;
  1567. FUNC(csin) (BUILD_COMPLEX (0.7L, 1.2L));
  1568. if (errno == ENOSYS)
  1569. /* Function not implemented. */
  1570. return;
  1571. START (csin);
  1572. TEST_c_c (csin, 0.0, 0.0, 0.0, 0.0);
  1573. TEST_c_c (csin, minus_zero, 0.0, minus_zero, 0.0);
  1574. TEST_c_c (csin, 0.0, minus_zero, 0, minus_zero);
  1575. TEST_c_c (csin, minus_zero, minus_zero, minus_zero, minus_zero);
  1576. TEST_c_c (csin, 0.0, plus_infty, 0.0, plus_infty);
  1577. TEST_c_c (csin, minus_zero, plus_infty, minus_zero, plus_infty);
  1578. TEST_c_c (csin, 0.0, minus_infty, 0.0, minus_infty);
  1579. TEST_c_c (csin, minus_zero, minus_infty, minus_zero, minus_infty);
  1580. TEST_c_c (csin, plus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1581. TEST_c_c (csin, minus_infty, 0.0, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1582. TEST_c_c (csin, plus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1583. TEST_c_c (csin, minus_infty, minus_zero, nan_value, 0.0, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1584. TEST_c_c (csin, plus_infty, plus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1585. TEST_c_c (csin, minus_infty, plus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1586. TEST_c_c (csin, plus_infty, minus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1587. TEST_c_c (csin, minus_infty, minus_infty, nan_value, plus_infty, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1588. TEST_c_c (csin, plus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
  1589. TEST_c_c (csin, plus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
  1590. TEST_c_c (csin, minus_infty, 6.75, nan_value, nan_value, INVALID_EXCEPTION);
  1591. TEST_c_c (csin, minus_infty, -6.75, nan_value, nan_value, INVALID_EXCEPTION);
  1592. TEST_c_c (csin, 4.625, plus_infty, minus_infty, minus_infty);
  1593. TEST_c_c (csin, 4.625, minus_infty, minus_infty, plus_infty);
  1594. TEST_c_c (csin, -4.625, plus_infty, plus_infty, minus_infty);
  1595. TEST_c_c (csin, -4.625, minus_infty, plus_infty, plus_infty);
  1596. TEST_c_c (csin, nan_value, 0.0, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
  1597. TEST_c_c (csin, nan_value, minus_zero, nan_value, 0.0, IGNORE_ZERO_INF_SIGN);
  1598. TEST_c_c (csin, nan_value, plus_infty, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
  1599. TEST_c_c (csin, nan_value, minus_infty, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
  1600. TEST_c_c (csin, nan_value, 9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1601. TEST_c_c (csin, nan_value, -9.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1602. TEST_c_c (csin, 0.0, nan_value, 0.0, nan_value);
  1603. TEST_c_c (csin, minus_zero, nan_value, minus_zero, nan_value);
  1604. TEST_c_c (csin, 10.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1605. TEST_c_c (csin, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1606. TEST_c_c (csin, plus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1607. TEST_c_c (csin, minus_infty, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1608. TEST_c_c (csin, nan_value, nan_value, nan_value, nan_value);
  1609. TEST_c_c (csin, 0.7L, 1.2L, 1.1664563419657581376L, 1.1544997246948547371L);
  1610. TEST_c_c (csin, -2, -3, -9.1544991469114295734L, 4.1689069599665643507L);
  1611. END (csin, complex);
  1612. }
  1613. static void
  1614. csinh_test (void)
  1615. {
  1616. errno = 0;
  1617. FUNC(csinh) (BUILD_COMPLEX (0.7L, 1.2L));
  1618. if (errno == ENOSYS)
  1619. /* Function not implemented. */
  1620. return;
  1621. START (csinh);
  1622. TEST_c_c (csinh, 0.0, 0.0, 0.0, 0.0);
  1623. TEST_c_c (csinh, minus_zero, 0.0, minus_zero, 0.0);
  1624. TEST_c_c (csinh, 0.0, minus_zero, 0.0, minus_zero);
  1625. TEST_c_c (csinh, minus_zero, minus_zero, minus_zero, minus_zero);
  1626. TEST_c_c (csinh, 0.0, plus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1627. TEST_c_c (csinh, minus_zero, plus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1628. TEST_c_c (csinh, 0.0, minus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1629. TEST_c_c (csinh, minus_zero, minus_infty, 0.0, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1630. TEST_c_c (csinh, plus_infty, 0.0, plus_infty, 0.0);
  1631. TEST_c_c (csinh, minus_infty, 0.0, minus_infty, 0.0);
  1632. TEST_c_c (csinh, plus_infty, minus_zero, plus_infty, minus_zero);
  1633. TEST_c_c (csinh, minus_infty, minus_zero, minus_infty, minus_zero);
  1634. TEST_c_c (csinh, plus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1635. TEST_c_c (csinh, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1636. TEST_c_c (csinh, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1637. TEST_c_c (csinh, minus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION|IGNORE_ZERO_INF_SIGN);
  1638. TEST_c_c (csinh, plus_infty, 4.625, minus_infty, minus_infty);
  1639. TEST_c_c (csinh, minus_infty, 4.625, plus_infty, minus_infty);
  1640. TEST_c_c (csinh, plus_infty, -4.625, minus_infty, plus_infty);
  1641. TEST_c_c (csinh, minus_infty, -4.625, plus_infty, plus_infty);
  1642. TEST_c_c (csinh, 6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1643. TEST_c_c (csinh, -6.75, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1644. TEST_c_c (csinh, 6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1645. TEST_c_c (csinh, -6.75, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1646. TEST_c_c (csinh, 0.0, nan_value, 0.0, nan_value, IGNORE_ZERO_INF_SIGN);
  1647. TEST_c_c (csinh, minus_zero, nan_value, 0.0, nan_value, IGNORE_ZERO_INF_SIGN);
  1648. TEST_c_c (csinh, plus_infty, nan_value, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
  1649. TEST_c_c (csinh, minus_infty, nan_value, plus_infty, nan_value, IGNORE_ZERO_INF_SIGN);
  1650. TEST_c_c (csinh, 9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1651. TEST_c_c (csinh, -9.0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1652. TEST_c_c (csinh, nan_value, 0.0, nan_value, 0.0);
  1653. TEST_c_c (csinh, nan_value, minus_zero, nan_value, minus_zero);
  1654. TEST_c_c (csinh, nan_value, 10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1655. TEST_c_c (csinh, nan_value, -10.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1656. TEST_c_c (csinh, nan_value, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1657. TEST_c_c (csinh, nan_value, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1658. TEST_c_c (csinh, nan_value, nan_value, nan_value, nan_value);
  1659. TEST_c_c (csinh, 0.7L, 1.2L, 0.27487868678117583582L, 1.1698665727426565139L);
  1660. TEST_c_c (csinh, -2, -3, 3.5905645899857799520L, -0.5309210862485198052L);
  1661. END (csinh, complex);
  1662. }
  1663. static void
  1664. csqrt_test (void)
  1665. {
  1666. errno = 0;
  1667. FUNC(csqrt) (BUILD_COMPLEX (-1, 0));
  1668. if (errno == ENOSYS)
  1669. /* Function not implemented. */
  1670. return;
  1671. START (csqrt);
  1672. TEST_c_c (csqrt, 0, 0, 0.0, 0.0);
  1673. TEST_c_c (csqrt, 0, minus_zero, 0, minus_zero);
  1674. TEST_c_c (csqrt, minus_zero, 0, 0.0, 0.0);
  1675. TEST_c_c (csqrt, minus_zero, minus_zero, 0.0, minus_zero);
  1676. TEST_c_c (csqrt, minus_infty, 0, 0.0, plus_infty);
  1677. TEST_c_c (csqrt, minus_infty, 6, 0.0, plus_infty);
  1678. TEST_c_c (csqrt, minus_infty, minus_zero, 0.0, minus_infty);
  1679. TEST_c_c (csqrt, minus_infty, -6, 0.0, minus_infty);
  1680. TEST_c_c (csqrt, plus_infty, 0, plus_infty, 0.0);
  1681. TEST_c_c (csqrt, plus_infty, 6, plus_infty, 0.0);
  1682. TEST_c_c (csqrt, plus_infty, minus_zero, plus_infty, minus_zero);
  1683. TEST_c_c (csqrt, plus_infty, -6, plus_infty, minus_zero);
  1684. TEST_c_c (csqrt, 0, plus_infty, plus_infty, plus_infty);
  1685. TEST_c_c (csqrt, 4, plus_infty, plus_infty, plus_infty);
  1686. TEST_c_c (csqrt, plus_infty, plus_infty, plus_infty, plus_infty);
  1687. TEST_c_c (csqrt, minus_zero, plus_infty, plus_infty, plus_infty);
  1688. TEST_c_c (csqrt, -4, plus_infty, plus_infty, plus_infty);
  1689. TEST_c_c (csqrt, minus_infty, plus_infty, plus_infty, plus_infty);
  1690. TEST_c_c (csqrt, 0, minus_infty, plus_infty, minus_infty);
  1691. TEST_c_c (csqrt, 4, minus_infty, plus_infty, minus_infty);
  1692. TEST_c_c (csqrt, plus_infty, minus_infty, plus_infty, minus_infty);
  1693. TEST_c_c (csqrt, minus_zero, minus_infty, plus_infty, minus_infty);
  1694. TEST_c_c (csqrt, -4, minus_infty, plus_infty, minus_infty);
  1695. TEST_c_c (csqrt, minus_infty, minus_infty, plus_infty, minus_infty);
  1696. TEST_c_c (csqrt, minus_infty, nan_value, nan_value, plus_infty, IGNORE_ZERO_INF_SIGN);
  1697. TEST_c_c (csqrt, plus_infty, nan_value, plus_infty, nan_value);
  1698. TEST_c_c (csqrt, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1699. TEST_c_c (csqrt, 1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1700. TEST_c_c (csqrt, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1701. TEST_c_c (csqrt, -1, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1702. TEST_c_c (csqrt, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1703. TEST_c_c (csqrt, nan_value, 8, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1704. TEST_c_c (csqrt, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1705. TEST_c_c (csqrt, nan_value, -8, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1706. TEST_c_c (csqrt, nan_value, nan_value, nan_value, nan_value);
  1707. TEST_c_c (csqrt, 16.0, -30.0, 5.0, -3.0);
  1708. TEST_c_c (csqrt, -1, 0, 0.0, 1.0);
  1709. TEST_c_c (csqrt, 0, 2, 1.0, 1.0);
  1710. TEST_c_c (csqrt, 119, 120, 12.0, 5.0);
  1711. TEST_c_c (csqrt, 0.7L, 1.2L, 1.022067610030026450706487883081139L, 0.58704531296356521154977678719838035L);
  1712. TEST_c_c (csqrt, -2, -3, 0.89597747612983812471573375529004348L, -1.6741492280355400404480393008490519L);
  1713. TEST_c_c (csqrt, -2, 3, 0.89597747612983812471573375529004348L, 1.6741492280355400404480393008490519L);
  1714. END (csqrt, complex);
  1715. }
  1716. static void
  1717. ctan_test (void)
  1718. {
  1719. errno = 0;
  1720. FUNC(ctan) (BUILD_COMPLEX (0.7L, 1.2L));
  1721. if (errno == ENOSYS)
  1722. /* Function not implemented. */
  1723. return;
  1724. START (ctan);
  1725. TEST_c_c (ctan, 0, 0, 0.0, 0.0);
  1726. TEST_c_c (ctan, 0, minus_zero, 0.0, minus_zero);
  1727. TEST_c_c (ctan, minus_zero, 0, minus_zero, 0.0);
  1728. TEST_c_c (ctan, minus_zero, minus_zero, minus_zero, minus_zero);
  1729. TEST_c_c (ctan, 0, plus_infty, 0.0, 1.0);
  1730. TEST_c_c (ctan, 1, plus_infty, 0.0, 1.0);
  1731. TEST_c_c (ctan, minus_zero, plus_infty, minus_zero, 1.0);
  1732. TEST_c_c (ctan, -1, plus_infty, minus_zero, 1.0);
  1733. TEST_c_c (ctan, 0, minus_infty, 0.0, -1.0);
  1734. TEST_c_c (ctan, 1, minus_infty, 0.0, -1.0);
  1735. TEST_c_c (ctan, minus_zero, minus_infty, minus_zero, -1.0);
  1736. TEST_c_c (ctan, -1, minus_infty, minus_zero, -1.0);
  1737. TEST_c_c (ctan, plus_infty, 0, nan_value, nan_value, INVALID_EXCEPTION);
  1738. TEST_c_c (ctan, plus_infty, 2, nan_value, nan_value, INVALID_EXCEPTION);
  1739. TEST_c_c (ctan, minus_infty, 0, nan_value, nan_value, INVALID_EXCEPTION);
  1740. TEST_c_c (ctan, minus_infty, 2, nan_value, nan_value, INVALID_EXCEPTION);
  1741. TEST_c_c (ctan, plus_infty, minus_zero, nan_value, nan_value, INVALID_EXCEPTION);
  1742. TEST_c_c (ctan, plus_infty, -2, nan_value, nan_value, INVALID_EXCEPTION);
  1743. TEST_c_c (ctan, minus_infty, minus_zero, nan_value, nan_value, INVALID_EXCEPTION);
  1744. TEST_c_c (ctan, minus_infty, -2, nan_value, nan_value, INVALID_EXCEPTION);
  1745. TEST_c_c (ctan, nan_value, plus_infty, 0.0, 1.0, IGNORE_ZERO_INF_SIGN);
  1746. TEST_c_c (ctan, nan_value, minus_infty, 0.0, -1.0, IGNORE_ZERO_INF_SIGN);
  1747. TEST_c_c (ctan, 0, nan_value, 0.0, nan_value);
  1748. TEST_c_c (ctan, minus_zero, nan_value, minus_zero, nan_value);
  1749. TEST_c_c (ctan, 0.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1750. TEST_c_c (ctan, -4.5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1751. TEST_c_c (ctan, nan_value, 0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1752. TEST_c_c (ctan, nan_value, 5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1753. TEST_c_c (ctan, nan_value, minus_zero, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1754. TEST_c_c (ctan, nan_value, -0.25, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1755. TEST_c_c (ctan, nan_value, nan_value, nan_value, nan_value);
  1756. TEST_c_c (ctan, 0.7L, 1.2L, 0.1720734197630349001L, 0.9544807059989405538L);
  1757. TEST_c_c (ctan, -2, -3, 0.0037640256415042482L, -1.0032386273536098014L);
  1758. END (ctan, complex);
  1759. }
  1760. static void
  1761. ctanh_test (void)
  1762. {
  1763. errno = 0;
  1764. FUNC(ctanh) (BUILD_COMPLEX (0, 0));
  1765. if (errno == ENOSYS)
  1766. /* Function not implemented. */
  1767. return;
  1768. START (ctanh);
  1769. TEST_c_c (ctanh, 0, 0, 0.0, 0.0);
  1770. TEST_c_c (ctanh, 0, minus_zero, 0.0, minus_zero);
  1771. TEST_c_c (ctanh, minus_zero, 0, minus_zero, 0.0);
  1772. TEST_c_c (ctanh, minus_zero, minus_zero, minus_zero, minus_zero);
  1773. TEST_c_c (ctanh, plus_infty, 0, 1.0, 0.0);
  1774. TEST_c_c (ctanh, plus_infty, 1, 1.0, 0.0);
  1775. TEST_c_c (ctanh, plus_infty, minus_zero, 1.0, minus_zero);
  1776. TEST_c_c (ctanh, plus_infty, -1, 1.0, minus_zero);
  1777. TEST_c_c (ctanh, minus_infty, 0, -1.0, 0.0);
  1778. TEST_c_c (ctanh, minus_infty, 1, -1.0, 0.0);
  1779. TEST_c_c (ctanh, minus_infty, minus_zero, -1.0, minus_zero);
  1780. TEST_c_c (ctanh, minus_infty, -1, -1.0, minus_zero);
  1781. TEST_c_c (ctanh, 0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1782. TEST_c_c (ctanh, 2, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1783. TEST_c_c (ctanh, 0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1784. TEST_c_c (ctanh, 2, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1785. TEST_c_c (ctanh, minus_zero, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1786. TEST_c_c (ctanh, -2, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1787. TEST_c_c (ctanh, minus_zero, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1788. TEST_c_c (ctanh, -2, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  1789. TEST_c_c (ctanh, plus_infty, nan_value, 1.0, 0.0, IGNORE_ZERO_INF_SIGN);
  1790. TEST_c_c (ctanh, minus_infty, nan_value, -1.0, 0.0, IGNORE_ZERO_INF_SIGN);
  1791. TEST_c_c (ctanh, nan_value, 0, nan_value, 0.0);
  1792. TEST_c_c (ctanh, nan_value, minus_zero, nan_value, minus_zero);
  1793. TEST_c_c (ctanh, nan_value, 0.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1794. TEST_c_c (ctanh, nan_value, -4.5, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1795. TEST_c_c (ctanh, 0, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1796. TEST_c_c (ctanh, 5, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1797. TEST_c_c (ctanh, minus_zero, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1798. TEST_c_c (ctanh, -0.25, nan_value, nan_value, nan_value, INVALID_EXCEPTION_OK);
  1799. TEST_c_c (ctanh, nan_value, nan_value, nan_value, nan_value);
  1800. TEST_c_c (ctanh, 0, M_PI_4l, 0.0, 1.0);
  1801. TEST_c_c (ctanh, 0.7L, 1.2L, 1.3472197399061191630L, 0.4778641038326365540L);
  1802. TEST_c_c (ctanh, -2, -3, -0.9653858790221331242L, 0.0098843750383224937L);
  1803. END (ctanh, complex);
  1804. }
  1805. #endif
  1806. static void
  1807. erf_test (void)
  1808. {
  1809. errno = 0;
  1810. FUNC(erf) (0);
  1811. if (errno == ENOSYS)
  1812. /* Function not implemented. */
  1813. return;
  1814. START (erf);
  1815. TEST_f_f (erf, 0, 0);
  1816. TEST_f_f (erf, minus_zero, minus_zero);
  1817. TEST_f_f (erf, plus_infty, 1);
  1818. TEST_f_f (erf, minus_infty, -1);
  1819. TEST_f_f (erf, nan_value, nan_value);
  1820. TEST_f_f (erf, 0.7L, 0.67780119383741847297L);
  1821. TEST_f_f (erf, 1.2L, 0.91031397822963538024L);
  1822. TEST_f_f (erf, 2.0, 0.99532226501895273416L);
  1823. TEST_f_f (erf, 4.1L, 0.99999999329997234592L);
  1824. TEST_f_f (erf, 27, 1.0L);
  1825. END (erf);
  1826. }
  1827. static void
  1828. erfc_test (void)
  1829. {
  1830. errno = 0;
  1831. FUNC(erfc) (0);
  1832. if (errno == ENOSYS)
  1833. /* Function not implemented. */
  1834. return;
  1835. START (erfc);
  1836. TEST_f_f (erfc, plus_infty, 0.0);
  1837. TEST_f_f (erfc, minus_infty, 2.0);
  1838. TEST_f_f (erfc, 0.0, 1.0);
  1839. TEST_f_f (erfc, minus_zero, 1.0);
  1840. TEST_f_f (erfc, nan_value, nan_value);
  1841. TEST_f_f (erfc, 0.7L, 0.32219880616258152702L);
  1842. TEST_f_f (erfc, 1.2L, 0.089686021770364619762L);
  1843. TEST_f_f (erfc, 2.0, 0.0046777349810472658379L);
  1844. TEST_f_f (erfc, 4.1L, 0.67000276540848983727e-8L);
  1845. TEST_f_f (erfc, 9, 0.41370317465138102381e-36L);
  1846. END (erfc);
  1847. }
  1848. static void
  1849. exp_test (void)
  1850. {
  1851. errno = 0;
  1852. FUNC(exp) (0);
  1853. if (errno == ENOSYS)
  1854. /* Function not implemented. */
  1855. return;
  1856. START (exp);
  1857. TEST_f_f (exp, 0, 1);
  1858. TEST_f_f (exp, minus_zero, 1);
  1859. #ifndef TEST_INLINE
  1860. TEST_f_f (exp, plus_infty, plus_infty);
  1861. TEST_f_f (exp, minus_infty, 0);
  1862. #endif
  1863. TEST_f_f (exp, nan_value, nan_value);
  1864. TEST_f_f (exp, 1, M_El);
  1865. TEST_f_f (exp, 2, M_E2l);
  1866. TEST_f_f (exp, 3, M_E3l);
  1867. TEST_f_f (exp, 0.7L, 2.0137527074704765216L);
  1868. TEST_f_f (exp, 50.0L, 5184705528587072464087.45332293348538L);
  1869. #ifdef TEST_LDOUBLE
  1870. /* The result can only be represented in long double. */
  1871. TEST_f_f (exp, 1000.0L, 0.197007111401704699388887935224332313e435L);
  1872. #endif
  1873. END (exp);
  1874. }
  1875. #if 0
  1876. static void
  1877. exp10_test (void)
  1878. {
  1879. errno = 0;
  1880. FUNC(exp10) (0);
  1881. if (errno == ENOSYS)
  1882. /* Function not implemented. */
  1883. return;
  1884. START (exp10);
  1885. TEST_f_f (exp10, 0, 1);
  1886. TEST_f_f (exp10, minus_zero, 1);
  1887. TEST_f_f (exp10, plus_infty, plus_infty);
  1888. TEST_f_f (exp10, minus_infty, 0);
  1889. TEST_f_f (exp10, nan_value, nan_value);
  1890. TEST_f_f (exp10, 3, 1000);
  1891. TEST_f_f (exp10, -1, 0.1L);
  1892. TEST_f_f (exp10, 1e6, plus_infty);
  1893. TEST_f_f (exp10, -1e6, 0);
  1894. TEST_f_f (exp10, 0.7L, 5.0118723362727228500155418688494574L);
  1895. END (exp10);
  1896. }
  1897. static void
  1898. exp2_test (void)
  1899. {
  1900. errno = 0;
  1901. FUNC(exp2) (0);
  1902. if (errno == ENOSYS)
  1903. /* Function not implemented. */
  1904. return;
  1905. START (exp2);
  1906. TEST_f_f (exp2, 0, 1);
  1907. TEST_f_f (exp2, minus_zero, 1);
  1908. TEST_f_f (exp2, plus_infty, plus_infty);
  1909. TEST_f_f (exp2, minus_infty, 0);
  1910. TEST_f_f (exp2, nan_value, nan_value);
  1911. TEST_f_f (exp2, 10, 1024);
  1912. TEST_f_f (exp2, -1, 0.5);
  1913. TEST_f_f (exp2, 1e6, plus_infty);
  1914. TEST_f_f (exp2, -1e6, 0);
  1915. TEST_f_f (exp2, 0.7L, 1.6245047927124710452L);
  1916. END (exp2);
  1917. }
  1918. #endif
  1919. static void
  1920. expm1_test (void)
  1921. {
  1922. errno = 0;
  1923. FUNC(expm1) (0);
  1924. if (errno == ENOSYS)
  1925. /* Function not implemented. */
  1926. return;
  1927. START (expm1);
  1928. TEST_f_f (expm1, 0, 0);
  1929. TEST_f_f (expm1, minus_zero, minus_zero);
  1930. #ifndef TEST_INLINE
  1931. TEST_f_f (expm1, plus_infty, plus_infty);
  1932. TEST_f_f (expm1, minus_infty, -1);
  1933. #endif
  1934. TEST_f_f (expm1, nan_value, nan_value);
  1935. TEST_f_f (expm1, 1, M_El - 1.0);
  1936. TEST_f_f (expm1, 0.7L, 1.0137527074704765216L);
  1937. END (expm1);
  1938. }
  1939. static void
  1940. fabs_test (void)
  1941. {
  1942. START (fabs);
  1943. TEST_f_f (fabs, 0, 0);
  1944. TEST_f_f (fabs, minus_zero, 0);
  1945. TEST_f_f (fabs, plus_infty, plus_infty);
  1946. TEST_f_f (fabs, minus_infty, plus_infty);
  1947. TEST_f_f (fabs, nan_value, nan_value);
  1948. TEST_f_f (fabs, 38.0, 38.0);
  1949. TEST_f_f (fabs, -M_El, M_El);
  1950. END (fabs);
  1951. }
  1952. #if 0
  1953. static void
  1954. fdim_test (void)
  1955. {
  1956. START (fdim);
  1957. TEST_ff_f (fdim, 0, 0, 0);
  1958. TEST_ff_f (fdim, 9, 0, 9);
  1959. TEST_ff_f (fdim, 0, 9, 0);
  1960. TEST_ff_f (fdim, -9, 0, 0);
  1961. TEST_ff_f (fdim, 0, -9, 9);
  1962. TEST_ff_f (fdim, plus_infty, 9, plus_infty);
  1963. TEST_ff_f (fdim, plus_infty, -9, plus_infty);
  1964. TEST_ff_f (fdim, minus_infty, 9, 0);
  1965. TEST_ff_f (fdim, minus_infty, -9, 0);
  1966. TEST_ff_f (fdim, 9, minus_infty, plus_infty);
  1967. TEST_ff_f (fdim, -9, minus_infty, plus_infty);
  1968. TEST_ff_f (fdim, 9, plus_infty, 0);
  1969. TEST_ff_f (fdim, -9, plus_infty, 0);
  1970. TEST_ff_f (fdim, 0, nan_value, nan_value);
  1971. TEST_ff_f (fdim, 9, nan_value, nan_value);
  1972. TEST_ff_f (fdim, -9, nan_value, nan_value);
  1973. TEST_ff_f (fdim, nan_value, 9, nan_value);
  1974. TEST_ff_f (fdim, nan_value, -9, nan_value);
  1975. TEST_ff_f (fdim, plus_infty, nan_value, nan_value);
  1976. TEST_ff_f (fdim, minus_infty, nan_value, nan_value);
  1977. TEST_ff_f (fdim, nan_value, plus_infty, nan_value);
  1978. TEST_ff_f (fdim, nan_value, minus_infty, nan_value);
  1979. TEST_ff_f (fdim, nan_value, nan_value, nan_value);
  1980. END (fdim);
  1981. }
  1982. #endif
  1983. static void
  1984. floor_test (void)
  1985. {
  1986. START (floor);
  1987. TEST_f_f (floor, 0.0, 0.0);
  1988. TEST_f_f (floor, minus_zero, minus_zero);
  1989. TEST_f_f (floor, plus_infty, plus_infty);
  1990. TEST_f_f (floor, minus_infty, minus_infty);
  1991. TEST_f_f (floor, nan_value, nan_value);
  1992. TEST_f_f (floor, M_PIl, 3.0);
  1993. TEST_f_f (floor, -M_PIl, -4.0);
  1994. END (floor);
  1995. }
  1996. #if 0
  1997. static void
  1998. fma_test (void)
  1999. {
  2000. START (fma);
  2001. TEST_fff_f (fma, 1.0, 2.0, 3.0, 5.0);
  2002. TEST_fff_f (fma, nan_value, 2.0, 3.0, nan_value);
  2003. TEST_fff_f (fma, 1.0, nan_value, 3.0, nan_value);
  2004. TEST_fff_f (fma, 1.0, 2.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  2005. TEST_fff_f (fma, plus_infty, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  2006. TEST_fff_f (fma, minus_infty, 0.0, nan_value, nan_value, INVALID_EXCEPTION_OK);
  2007. TEST_fff_f (fma, 0.0, plus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
  2008. TEST_fff_f (fma, 0.0, minus_infty, nan_value, nan_value, INVALID_EXCEPTION_OK);
  2009. TEST_fff_f (fma, plus_infty, 0.0, 1.0, nan_value, INVALID_EXCEPTION);
  2010. TEST_fff_f (fma, minus_infty, 0.0, 1.0, nan_value, INVALID_EXCEPTION);
  2011. TEST_fff_f (fma, 0.0, plus_infty, 1.0, nan_value, INVALID_EXCEPTION);
  2012. TEST_fff_f (fma, 0.0, minus_infty, 1.0, nan_value, INVALID_EXCEPTION);
  2013. TEST_fff_f (fma, plus_infty, plus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
  2014. TEST_fff_f (fma, minus_infty, plus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
  2015. TEST_fff_f (fma, plus_infty, minus_infty, plus_infty, nan_value, INVALID_EXCEPTION);
  2016. TEST_fff_f (fma, minus_infty, minus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
  2017. END (fma);
  2018. }
  2019. static void
  2020. fmax_test (void)
  2021. {
  2022. START (fmax);
  2023. TEST_ff_f (fmax, 0, 0, 0);
  2024. TEST_ff_f (fmax, minus_zero, minus_zero, minus_zero);
  2025. TEST_ff_f (fmax, 9, 0, 9);
  2026. TEST_ff_f (fmax, 0, 9, 9);
  2027. TEST_ff_f (fmax, -9, 0, 0);
  2028. TEST_ff_f (fmax, 0, -9, 0);
  2029. TEST_ff_f (fmax, plus_infty, 9, plus_infty);
  2030. TEST_ff_f (fmax, 0, plus_infty, plus_infty);
  2031. TEST_ff_f (fmax, -9, plus_infty, plus_infty);
  2032. TEST_ff_f (fmax, plus_infty, -9, plus_infty);
  2033. TEST_ff_f (fmax, minus_infty, 9, 9);
  2034. TEST_ff_f (fmax, minus_infty, -9, -9);
  2035. TEST_ff_f (fmax, 9, minus_infty, 9);
  2036. TEST_ff_f (fmax, -9, minus_infty, -9);
  2037. TEST_ff_f (fmax, 0, nan_value, 0);
  2038. TEST_ff_f (fmax, 9, nan_value, 9);
  2039. TEST_ff_f (fmax, -9, nan_value, -9);
  2040. TEST_ff_f (fmax, nan_value, 0, 0);
  2041. TEST_ff_f (fmax, nan_value, 9, 9);
  2042. TEST_ff_f (fmax, nan_value, -9, -9);
  2043. TEST_ff_f (fmax, plus_infty, nan_value, plus_infty);
  2044. TEST_ff_f (fmax, minus_infty, nan_value, minus_infty);
  2045. TEST_ff_f (fmax, nan_value, plus_infty, plus_infty);
  2046. TEST_ff_f (fmax, nan_value, minus_infty, minus_infty);
  2047. TEST_ff_f (fmax, nan_value, nan_value, nan_value);
  2048. END (fmax);
  2049. }
  2050. static void
  2051. fmin_test (void)
  2052. {
  2053. START (fmin);
  2054. TEST_ff_f (fmin, 0, 0, 0);
  2055. TEST_ff_f (fmin, minus_zero, minus_zero, minus_zero);
  2056. TEST_ff_f (fmin, 9, 0, 0);
  2057. TEST_ff_f (fmin, 0, 9, 0);
  2058. TEST_ff_f (fmin, -9, 0, -9);
  2059. TEST_ff_f (fmin, 0, -9, -9);
  2060. TEST_ff_f (fmin, plus_infty, 9, 9);
  2061. TEST_ff_f (fmin, 9, plus_infty, 9);
  2062. TEST_ff_f (fmin, plus_infty, -9, -9);
  2063. TEST_ff_f (fmin, -9, plus_infty, -9);
  2064. TEST_ff_f (fmin, minus_infty, 9, minus_infty);
  2065. TEST_ff_f (fmin, minus_infty, -9, minus_infty);
  2066. TEST_ff_f (fmin, 9, minus_infty, minus_infty);
  2067. TEST_ff_f (fmin, -9, minus_infty, minus_infty);
  2068. TEST_ff_f (fmin, 0, nan_value, 0);
  2069. TEST_ff_f (fmin, 9, nan_value, 9);
  2070. TEST_ff_f (fmin, -9, nan_value, -9);
  2071. TEST_ff_f (fmin, nan_value, 0, 0);
  2072. TEST_ff_f (fmin, nan_value, 9, 9);
  2073. TEST_ff_f (fmin, nan_value, -9, -9);
  2074. TEST_ff_f (fmin, plus_infty, nan_value, plus_infty);
  2075. TEST_ff_f (fmin, minus_infty, nan_value, minus_infty);
  2076. TEST_ff_f (fmin, nan_value, plus_infty, plus_infty);
  2077. TEST_ff_f (fmin, nan_value, minus_infty, minus_infty);
  2078. TEST_ff_f (fmin, nan_value, nan_value, nan_value);
  2079. END (fmin);
  2080. }
  2081. #endif
  2082. static void
  2083. fmod_test (void)
  2084. {
  2085. errno = 0;
  2086. FUNC(fmod) (6.5, 2.3L);
  2087. if (errno == ENOSYS)
  2088. /* Function not implemented. */
  2089. return;
  2090. START (fmod);
  2091. /* fmod (+0, y) == +0 for y != 0. */
  2092. TEST_ff_f (fmod, 0, 3, 0);
  2093. /* fmod (-0, y) == -0 for y != 0. */
  2094. TEST_ff_f (fmod, minus_zero, 3, minus_zero);
  2095. /* fmod (+inf, y) == NaN plus invalid exception. */
  2096. TEST_ff_f (fmod, plus_infty, 3, nan_value, INVALID_EXCEPTION);
  2097. /* fmod (-inf, y) == NaN plus invalid exception. */
  2098. TEST_ff_f (fmod, minus_infty, 3, nan_value, INVALID_EXCEPTION);
  2099. /* fmod (x, +0) == NaN plus invalid exception. */
  2100. TEST_ff_f (fmod, 3, 0, nan_value, INVALID_EXCEPTION);
  2101. /* fmod (x, -0) == NaN plus invalid exception. */
  2102. TEST_ff_f (fmod, 3, minus_zero, nan_value, INVALID_EXCEPTION);
  2103. /* fmod (x, +inf) == x for x not infinite. */
  2104. TEST_ff_f (fmod, 3.0, plus_infty, 3.0);
  2105. /* fmod (x, -inf) == x for x not infinite. */
  2106. TEST_ff_f (fmod, 3.0, minus_infty, 3.0);
  2107. TEST_ff_f (fmod, nan_value, nan_value, nan_value);
  2108. TEST_ff_f (fmod, 6.5, 2.3L, 1.9L);
  2109. TEST_ff_f (fmod, -6.5, 2.3L, -1.9L);
  2110. TEST_ff_f (fmod, 6.5, -2.3L, 1.9L);
  2111. TEST_ff_f (fmod, -6.5, -2.3L, -1.9L);
  2112. END (fmod);
  2113. }
  2114. static void
  2115. fpclassify_test (void)
  2116. {
  2117. START (fpclassify);
  2118. TEST_f_i (fpclassify, nan_value, FP_NAN);
  2119. TEST_f_i (fpclassify, plus_infty, FP_INFINITE);
  2120. TEST_f_i (fpclassify, minus_infty, FP_INFINITE);
  2121. TEST_f_i (fpclassify, plus_zero, FP_ZERO);
  2122. TEST_f_i (fpclassify, minus_zero, FP_ZERO);
  2123. TEST_f_i (fpclassify, 1000, FP_NORMAL);
  2124. END (fpclassify);
  2125. }
  2126. static void
  2127. frexp_test (void)
  2128. {
  2129. int x;
  2130. START (frexp);
  2131. TEST_fI_f1 (frexp, plus_infty, plus_infty, IGNORE);
  2132. TEST_fI_f1 (frexp, minus_infty, minus_infty, IGNORE);
  2133. TEST_fI_f1 (frexp, nan_value, nan_value, IGNORE);
  2134. TEST_fI_f1 (frexp, 0.0, 0.0, 0.0);
  2135. TEST_fI_f1 (frexp, minus_zero, minus_zero, 0.0);
  2136. TEST_fI_f1 (frexp, 12.8L, 0.8L, 4);
  2137. TEST_fI_f1 (frexp, -27.34L, -0.854375L, 5);
  2138. END (frexp);
  2139. }
  2140. static void
  2141. gamma_test (void)
  2142. {
  2143. errno = 0;
  2144. FUNC(gamma) (1);
  2145. if (errno == ENOSYS)
  2146. /* Function not implemented. */
  2147. return;
  2148. feclearexcept (FE_ALL_EXCEPT);
  2149. START (gamma);
  2150. TEST_f_f (gamma, plus_infty, plus_infty);
  2151. TEST_f_f (gamma, 0, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2152. TEST_f_f (gamma, -3, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2153. TEST_f_f (gamma, minus_infty, plus_infty);
  2154. TEST_f_f (gamma, nan_value, nan_value);
  2155. TEST_f_f1 (gamma, 1, 0, 1);
  2156. TEST_f_f1 (gamma, 3, M_LN2l, 1);
  2157. TEST_f_f1 (gamma, 0.5, M_LOG_SQRT_PIl, 1);
  2158. TEST_f_f1 (gamma, -0.5, M_LOG_2_SQRT_PIl, -1);
  2159. END (gamma);
  2160. }
  2161. static void
  2162. hypot_test (void)
  2163. {
  2164. errno = 0;
  2165. FUNC(hypot) (0.7L, 12.4L);
  2166. if (errno == ENOSYS)
  2167. /* Function not implemented. */
  2168. return;
  2169. START (hypot);
  2170. TEST_ff_f (hypot, plus_infty, 1, plus_infty, IGNORE_ZERO_INF_SIGN);
  2171. TEST_ff_f (hypot, minus_infty, 1, plus_infty, IGNORE_ZERO_INF_SIGN);
  2172. #ifndef TEST_INLINE
  2173. TEST_ff_f (hypot, plus_infty, nan_value, plus_infty);
  2174. TEST_ff_f (hypot, minus_infty, nan_value, plus_infty);
  2175. TEST_ff_f (hypot, nan_value, plus_infty, plus_infty);
  2176. TEST_ff_f (hypot, nan_value, minus_infty, plus_infty);
  2177. #endif
  2178. TEST_ff_f (hypot, nan_value, nan_value, nan_value);
  2179. /* hypot (x,y) == hypot (+-x, +-y) */
  2180. TEST_ff_f (hypot, 0.7L, 12.4L, 12.419742348374220601176836866763271L);
  2181. TEST_ff_f (hypot, -0.7L, 12.4L, 12.419742348374220601176836866763271L);
  2182. TEST_ff_f (hypot, 0.7L, -12.4L, 12.419742348374220601176836866763271L);
  2183. TEST_ff_f (hypot, -0.7L, -12.4L, 12.419742348374220601176836866763271L);
  2184. TEST_ff_f (hypot, 12.4L, 0.7L, 12.419742348374220601176836866763271L);
  2185. TEST_ff_f (hypot, -12.4L, 0.7L, 12.419742348374220601176836866763271L);
  2186. TEST_ff_f (hypot, 12.4L, -0.7L, 12.419742348374220601176836866763271L);
  2187. TEST_ff_f (hypot, -12.4L, -0.7L, 12.419742348374220601176836866763271L);
  2188. /* hypot (x,0) == fabs (x) */
  2189. TEST_ff_f (hypot, 0.7L, 0, 0.7L);
  2190. TEST_ff_f (hypot, -0.7L, 0, 0.7L);
  2191. TEST_ff_f (hypot, -5.7e7, 0, 5.7e7L);
  2192. TEST_ff_f (hypot, 0.7L, 1.2L, 1.3892443989449804508432547041028554L);
  2193. END (hypot);
  2194. }
  2195. static void
  2196. ilogb_test (void)
  2197. {
  2198. START (ilogb);
  2199. TEST_f_i (ilogb, 1, 0);
  2200. TEST_f_i (ilogb, M_El, 1);
  2201. TEST_f_i (ilogb, 1024, 10);
  2202. TEST_f_i (ilogb, -2000, 10);
  2203. /* XXX We have a problem here: the standard does not tell us whether
  2204. exceptions are allowed/required. ignore them for now. */
  2205. TEST_f_i (ilogb, 0.0, FP_ILOGB0, EXCEPTIONS_OK);
  2206. TEST_f_i (ilogb, nan_value, FP_ILOGBNAN, EXCEPTIONS_OK);
  2207. TEST_f_i (ilogb, plus_infty, INT_MAX, EXCEPTIONS_OK);
  2208. TEST_f_i (ilogb, minus_infty, INT_MAX, EXCEPTIONS_OK);
  2209. END (ilogb);
  2210. }
  2211. static void
  2212. isfinite_test (void)
  2213. {
  2214. START (isfinite);
  2215. TEST_f_b (isfinite, 0, 1);
  2216. TEST_f_b (isfinite, minus_zero, 1);
  2217. TEST_f_b (isfinite, 10, 1);
  2218. TEST_f_b (isfinite, plus_infty, 0);
  2219. TEST_f_b (isfinite, minus_infty, 0);
  2220. TEST_f_b (isfinite, nan_value, 0);
  2221. END (isfinite);
  2222. }
  2223. static void
  2224. isnormal_test (void)
  2225. {
  2226. START (isnormal);
  2227. TEST_f_b (isnormal, 0, 0);
  2228. TEST_f_b (isnormal, minus_zero, 0);
  2229. TEST_f_b (isnormal, 10, 1);
  2230. TEST_f_b (isnormal, plus_infty, 0);
  2231. TEST_f_b (isnormal, minus_infty, 0);
  2232. TEST_f_b (isnormal, nan_value, 0);
  2233. END (isnormal);
  2234. }
  2235. static void
  2236. j0_test (void)
  2237. {
  2238. errno = 0;
  2239. #if 0
  2240. FLOAT s, c;
  2241. FUNC (sincos) (0, &s, &c);
  2242. if (errno == ENOSYS)
  2243. /* Required function not implemented. */
  2244. return;
  2245. #endif
  2246. FUNC(j0) (0);
  2247. if (errno == ENOSYS)
  2248. /* Function not implemented. */
  2249. return;
  2250. START (j0);
  2251. /* j0 is the Bessel function of the first kind of order 0 */
  2252. TEST_f_f (j0, nan_value, nan_value);
  2253. TEST_f_f (j0, plus_infty, 0);
  2254. TEST_f_f (j0, -1.0, 0.76519768655796655145L);
  2255. TEST_f_f (j0, 0.0, 1.0);
  2256. TEST_f_f (j0, 0.1L, 0.99750156206604003228L);
  2257. TEST_f_f (j0, 0.7L, 0.88120088860740528084L);
  2258. TEST_f_f (j0, 1.0, 0.76519768655796655145L);
  2259. TEST_f_f (j0, 1.5, 0.51182767173591812875L);
  2260. TEST_f_f (j0, 2.0, 0.22389077914123566805L);
  2261. TEST_f_f (j0, 8.0, 0.17165080713755390609L);
  2262. TEST_f_f (j0, 10.0, -0.24593576445134833520L);
  2263. TEST_f_f (j0, 4.0, -3.9714980986384737228659076845169804197562E-1L);
  2264. TEST_f_f (j0, -4.0, -3.9714980986384737228659076845169804197562E-1L);
  2265. END (j0);
  2266. }
  2267. static void
  2268. j1_test (void)
  2269. {
  2270. errno = 0;
  2271. #if 0
  2272. FLOAT s, c;
  2273. FUNC (sincos) (0, &s, &c);
  2274. if (errno == ENOSYS)
  2275. /* Required function not implemented. */
  2276. return;
  2277. #endif
  2278. FUNC(j1) (0);
  2279. if (errno == ENOSYS)
  2280. /* Function not implemented. */
  2281. return;
  2282. /* j1 is the Bessel function of the first kind of order 1 */
  2283. START (j1);
  2284. TEST_f_f (j1, nan_value, nan_value);
  2285. TEST_f_f (j1, plus_infty, 0);
  2286. TEST_f_f (j1, -1.0, -0.44005058574493351596L);
  2287. TEST_f_f (j1, 0.0, 0.0);
  2288. TEST_f_f (j1, 0.1L, 0.049937526036241997556L);
  2289. TEST_f_f (j1, 0.7L, 0.32899574154005894785L);
  2290. TEST_f_f (j1, 1.0, 0.44005058574493351596L);
  2291. TEST_f_f (j1, 1.5, 0.55793650791009964199L);
  2292. TEST_f_f (j1, 2.0, 0.57672480775687338720L);
  2293. TEST_f_f (j1, 8.0, 0.23463634685391462438L);
  2294. TEST_f_f (j1, 10.0, 0.043472746168861436670L);
  2295. END (j1);
  2296. }
  2297. static void
  2298. jn_test (void)
  2299. {
  2300. errno = 0;
  2301. #if 0
  2302. FLOAT s, c;
  2303. FUNC (sincos) (0, &s, &c);
  2304. if (errno == ENOSYS)
  2305. /* Required function not implemented. */
  2306. return;
  2307. #endif
  2308. FUNC(jn) (1, 1);
  2309. if (errno == ENOSYS)
  2310. /* Function not implemented. */
  2311. return;
  2312. /* jn is the Bessel function of the first kind of order n. */
  2313. START (jn);
  2314. /* jn (0, x) == j0 (x) */
  2315. TEST_ff_f (jn, 0, nan_value, nan_value);
  2316. TEST_ff_f (jn, 0, plus_infty, 0);
  2317. TEST_ff_f (jn, 0, -1.0, 0.76519768655796655145L);
  2318. TEST_ff_f (jn, 0, 0.0, 1.0);
  2319. TEST_ff_f (jn, 0, 0.1L, 0.99750156206604003228L);
  2320. TEST_ff_f (jn, 0, 0.7L, 0.88120088860740528084L);
  2321. TEST_ff_f (jn, 0, 1.0, 0.76519768655796655145L);
  2322. TEST_ff_f (jn, 0, 1.5, 0.51182767173591812875L);
  2323. TEST_ff_f (jn, 0, 2.0, 0.22389077914123566805L);
  2324. TEST_ff_f (jn, 0, 8.0, 0.17165080713755390609L);
  2325. TEST_ff_f (jn, 0, 10.0, -0.24593576445134833520L);
  2326. /* jn (1, x) == j1 (x) */
  2327. TEST_ff_f (jn, 1, nan_value, nan_value);
  2328. TEST_ff_f (jn, 1, plus_infty, 0);
  2329. TEST_ff_f (jn, 1, -1.0, -0.44005058574493351596L);
  2330. TEST_ff_f (jn, 1, 0.0, 0.0);
  2331. TEST_ff_f (jn, 1, 0.1L, 0.049937526036241997556L);
  2332. TEST_ff_f (jn, 1, 0.7L, 0.32899574154005894785L);
  2333. TEST_ff_f (jn, 1, 1.0, 0.44005058574493351596L);
  2334. TEST_ff_f (jn, 1, 1.5, 0.55793650791009964199L);
  2335. TEST_ff_f (jn, 1, 2.0, 0.57672480775687338720L);
  2336. TEST_ff_f (jn, 1, 8.0, 0.23463634685391462438L);
  2337. TEST_ff_f (jn, 1, 10.0, 0.043472746168861436670L);
  2338. /* jn (3, x) */
  2339. TEST_ff_f (jn, 3, nan_value, nan_value);
  2340. TEST_ff_f (jn, 3, plus_infty, 0);
  2341. TEST_ff_f (jn, 3, -1.0, -0.019563353982668405919L);
  2342. TEST_ff_f (jn, 3, 0.0, 0.0);
  2343. TEST_ff_f (jn, 3, 0.1L, 0.000020820315754756261429L);
  2344. TEST_ff_f (jn, 3, 0.7L, 0.0069296548267508408077L);
  2345. TEST_ff_f (jn, 3, 1.0, 0.019563353982668405919L);
  2346. TEST_ff_f (jn, 3, 2.0, 0.12894324947440205110L);
  2347. TEST_ff_f (jn, 3, 10.0, 0.058379379305186812343L);
  2348. /* jn (10, x) */
  2349. TEST_ff_f (jn, 10, nan_value, nan_value);
  2350. TEST_ff_f (jn, 10, plus_infty, 0);
  2351. TEST_ff_f (jn, 10, -1.0, 0.26306151236874532070e-9L);
  2352. TEST_ff_f (jn, 10, 0.0, 0.0);
  2353. TEST_ff_f (jn, 10, 0.1L, 0.26905328954342155795e-19L);
  2354. TEST_ff_f (jn, 10, 0.7L, 0.75175911502153953928e-11L);
  2355. TEST_ff_f (jn, 10, 1.0, 0.26306151236874532070e-9L);
  2356. TEST_ff_f (jn, 10, 2.0, 0.25153862827167367096e-6L);
  2357. TEST_ff_f (jn, 10, 10.0, 0.20748610663335885770L);
  2358. END (jn);
  2359. }
  2360. static void
  2361. ldexp_test (void)
  2362. {
  2363. TEST_ff_f (ldexp, 0, 0, 0);
  2364. TEST_ff_f (ldexp, minus_zero, 0, minus_zero);
  2365. TEST_ff_f (ldexp, plus_infty, 1, plus_infty);
  2366. TEST_ff_f (ldexp, minus_infty, 1, minus_infty);
  2367. TEST_ff_f (ldexp, nan_value, 1, nan_value);
  2368. TEST_ff_f (ldexp, 0.8L, 4, 12.8L);
  2369. TEST_ff_f (ldexp, -0.854375L, 5, -27.34L);
  2370. /* ldexp (x, 0) == x. */
  2371. TEST_ff_f (ldexp, 1.0L, 0L, 1.0L);
  2372. }
  2373. static void
  2374. lgamma_test (void)
  2375. {
  2376. errno = 0;
  2377. FUNC(lgamma) (0);
  2378. if (errno == ENOSYS)
  2379. /* Function not implemented. */
  2380. return;
  2381. feclearexcept (FE_ALL_EXCEPT);
  2382. START (lgamma);
  2383. TEST_f_f (lgamma, plus_infty, plus_infty);
  2384. TEST_f_f (lgamma, 0, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2385. TEST_f_f (lgamma, nan_value, nan_value);
  2386. /* lgamma (x) == +inf plus divide by zero exception for integer x <= 0. */
  2387. TEST_f_f (lgamma, -3, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2388. TEST_f_f (lgamma, minus_infty, plus_infty);
  2389. TEST_f_f1 (lgamma, 1, 0, 1);
  2390. TEST_f_f1 (lgamma, 3, M_LN2l, 1);
  2391. TEST_f_f1 (lgamma, 0.5, M_LOG_SQRT_PIl, 1);
  2392. TEST_f_f1 (lgamma, -0.5, M_LOG_2_SQRT_PIl, -1);
  2393. TEST_f_f1 (lgamma, 0.7L, 0.26086724653166651439L, 1);
  2394. TEST_f_f1 (lgamma, 1.2L, -0.853740900033158497197e-1L, 1);
  2395. END (lgamma);
  2396. }
  2397. #if 0
  2398. static void
  2399. lrint_test (void)
  2400. {
  2401. /* XXX this test is incomplete. We need to have a way to specifiy
  2402. the rounding method and test the critical cases. So far, only
  2403. unproblematic numbers are tested. */
  2404. START (lrint);
  2405. TEST_f_l (lrint, 0.0, 0);
  2406. TEST_f_l (lrint, minus_zero, 0);
  2407. TEST_f_l (lrint, 0.2L, 0);
  2408. TEST_f_l (lrint, -0.2L, 0);
  2409. TEST_f_l (lrint, 1.4L, 1);
  2410. TEST_f_l (lrint, -1.4L, -1);
  2411. TEST_f_l (lrint, 8388600.3L, 8388600);
  2412. TEST_f_l (lrint, -8388600.3L, -8388600);
  2413. END (lrint);
  2414. }
  2415. static void
  2416. llrint_test (void)
  2417. {
  2418. /* XXX this test is incomplete. We need to have a way to specifiy
  2419. the rounding method and test the critical cases. So far, only
  2420. unproblematic numbers are tested. */
  2421. START (llrint);
  2422. TEST_f_L (llrint, 0.0, 0);
  2423. TEST_f_L (llrint, minus_zero, 0);
  2424. TEST_f_L (llrint, 0.2L, 0);
  2425. TEST_f_L (llrint, -0.2L, 0);
  2426. TEST_f_L (llrint, 1.4L, 1);
  2427. TEST_f_L (llrint, -1.4L, -1);
  2428. TEST_f_L (llrint, 8388600.3L, 8388600);
  2429. TEST_f_L (llrint, -8388600.3L, -8388600);
  2430. /* Test boundary conditions. */
  2431. /* 0x1FFFFF */
  2432. TEST_f_L (llrint, 2097151.0,2097151LL);
  2433. /* 0x800000 */
  2434. TEST_f_L (llrint, 8388608.0, 8388608LL);
  2435. /* 0x1000000 */
  2436. TEST_f_L (llrint, 16777216.0, 16777216LL);
  2437. /* 0x20000000000 */
  2438. TEST_f_L (llrint, 2199023255552.0, 2199023255552LL);
  2439. /* 0x40000000000 */
  2440. TEST_f_L (llrint, 4398046511104.0, 4398046511104LL);
  2441. /* 0x10000000000000 */
  2442. TEST_f_L (llrint, 4503599627370496.0, 4503599627370496LL);
  2443. /* 0x10000080000000 */
  2444. TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL);
  2445. /* 0x20000000000000 */
  2446. TEST_f_L (llrint, 9007199254740992.0, 9007199254740992LL);
  2447. /* 0x80000000000000 */
  2448. TEST_f_L (llrint, 36028797018963968.0, 36028797018963968LL);
  2449. /* 0x100000000000000 */
  2450. TEST_f_L (llrint, 72057594037927936.0, 72057594037927936LL);
  2451. END (llrint);
  2452. }
  2453. #endif
  2454. static void
  2455. log_test (void)
  2456. {
  2457. errno = 0;
  2458. FUNC(log) (1);
  2459. if (errno == ENOSYS)
  2460. /* Function not implemented. */
  2461. return;
  2462. START (log);
  2463. TEST_f_f (log, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2464. TEST_f_f (log, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2465. TEST_f_f (log, 1, 0);
  2466. TEST_f_f (log, -1, nan_value, INVALID_EXCEPTION);
  2467. TEST_f_f (log, plus_infty, plus_infty);
  2468. TEST_f_f (log, M_El, 1);
  2469. TEST_f_f (log, 1.0 / M_El, -1);
  2470. TEST_f_f (log, 2, M_LN2l);
  2471. TEST_f_f (log, 10, M_LN10l);
  2472. TEST_f_f (log, 0.7L, -0.35667494393873237891263871124118447L);
  2473. END (log);
  2474. }
  2475. static void
  2476. log10_test (void)
  2477. {
  2478. errno = 0;
  2479. FUNC(log10) (1);
  2480. if (errno == ENOSYS)
  2481. /* Function not implemented. */
  2482. return;
  2483. START (log10);
  2484. TEST_f_f (log10, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2485. TEST_f_f (log10, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2486. TEST_f_f (log10, 1, 0);
  2487. /* log10 (x) == NaN plus invalid exception if x < 0. */
  2488. TEST_f_f (log10, -1, nan_value, INVALID_EXCEPTION);
  2489. TEST_f_f (log10, plus_infty, plus_infty);
  2490. TEST_f_f (log10, nan_value, nan_value);
  2491. TEST_f_f (log10, 0.1L, -1);
  2492. TEST_f_f (log10, 10.0, 1);
  2493. TEST_f_f (log10, 100.0, 2);
  2494. TEST_f_f (log10, 10000.0, 4);
  2495. TEST_f_f (log10, M_El, M_LOG10El);
  2496. TEST_f_f (log10, 0.7L, -0.15490195998574316929L);
  2497. END (log10);
  2498. }
  2499. static void
  2500. log1p_test (void)
  2501. {
  2502. errno = 0;
  2503. FUNC(log1p) (0);
  2504. if (errno == ENOSYS)
  2505. /* Function not implemented. */
  2506. return;
  2507. START (log1p);
  2508. TEST_f_f (log1p, 0, 0);
  2509. TEST_f_f (log1p, minus_zero, minus_zero);
  2510. TEST_f_f (log1p, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2511. TEST_f_f (log1p, -2, nan_value, INVALID_EXCEPTION);
  2512. TEST_f_f (log1p, plus_infty, plus_infty);
  2513. TEST_f_f (log1p, nan_value, nan_value);
  2514. TEST_f_f (log1p, M_El - 1.0, 1);
  2515. TEST_f_f (log1p, -0.3L, -0.35667494393873237891263871124118447L);
  2516. END (log1p);
  2517. }
  2518. #if 0
  2519. static void
  2520. log2_test (void)
  2521. {
  2522. errno = 0;
  2523. FUNC(log2) (1);
  2524. if (errno == ENOSYS)
  2525. /* Function not implemented. */
  2526. return;
  2527. START (log2);
  2528. TEST_f_f (log2, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2529. TEST_f_f (log2, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2530. TEST_f_f (log2, 1, 0);
  2531. TEST_f_f (log2, -1, nan_value, INVALID_EXCEPTION);
  2532. TEST_f_f (log2, plus_infty, plus_infty);
  2533. TEST_f_f (log2, nan_value, nan_value);
  2534. TEST_f_f (log2, M_El, M_LOG2El);
  2535. TEST_f_f (log2, 2.0, 1);
  2536. TEST_f_f (log2, 16.0, 4);
  2537. TEST_f_f (log2, 256.0, 8);
  2538. TEST_f_f (log2, 0.7L, -0.51457317282975824043L);
  2539. END (log2);
  2540. }
  2541. #endif
  2542. static void
  2543. logb_test (void)
  2544. {
  2545. START (logb);
  2546. TEST_f_f (logb, plus_infty, plus_infty);
  2547. TEST_f_f (logb, minus_infty, plus_infty);
  2548. TEST_f_f (logb, 0, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2549. TEST_f_f (logb, minus_zero, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2550. TEST_f_f (logb, nan_value, nan_value);
  2551. TEST_f_f (logb, 1, 0);
  2552. TEST_f_f (logb, M_El, 1);
  2553. TEST_f_f (logb, 1024, 10);
  2554. TEST_f_f (logb, -2000, 10);
  2555. END (logb);
  2556. }
  2557. #if 0
  2558. static void
  2559. lround_test (void)
  2560. {
  2561. START (lround);
  2562. TEST_f_l (lround, 0, 0);
  2563. TEST_f_l (lround, minus_zero, 0);
  2564. TEST_f_l (lround, 0.2L, 0.0);
  2565. TEST_f_l (lround, -0.2L, 0);
  2566. TEST_f_l (lround, 0.5, 1);
  2567. TEST_f_l (lround, -0.5, -1);
  2568. TEST_f_l (lround, 0.8L, 1);
  2569. TEST_f_l (lround, -0.8L, -1);
  2570. TEST_f_l (lround, 1.5, 2);
  2571. TEST_f_l (lround, -1.5, -2);
  2572. TEST_f_l (lround, 22514.5, 22515);
  2573. TEST_f_l (lround, -22514.5, -22515);
  2574. #ifndef TEST_FLOAT
  2575. TEST_f_l (lround, 2097152.5, 2097153);
  2576. TEST_f_l (lround, -2097152.5, -2097153);
  2577. #endif
  2578. END (lround);
  2579. }
  2580. static void
  2581. llround_test (void)
  2582. {
  2583. START (llround);
  2584. TEST_f_L (llround, 0, 0);
  2585. TEST_f_L (llround, minus_zero, 0);
  2586. TEST_f_L (llround, 0.2L, 0.0);
  2587. TEST_f_L (llround, -0.2L, 0);
  2588. TEST_f_L (llround, 0.5, 1);
  2589. TEST_f_L (llround, -0.5, -1);
  2590. TEST_f_L (llround, 0.8L, 1);
  2591. TEST_f_L (llround, -0.8L, -1);
  2592. TEST_f_L (llround, 1.5, 2);
  2593. TEST_f_L (llround, -1.5, -2);
  2594. TEST_f_L (llround, 22514.5, 22515);
  2595. TEST_f_L (llround, -22514.5, -22515);
  2596. #ifndef TEST_FLOAT
  2597. TEST_f_L (llround, 2097152.5, 2097153);
  2598. TEST_f_L (llround, -2097152.5, -2097153);
  2599. TEST_f_L (llround, 34359738368.5, 34359738369ll);
  2600. TEST_f_L (llround, -34359738368.5, -34359738369ll);
  2601. #endif
  2602. /* Test boundary conditions. */
  2603. /* 0x1FFFFF */
  2604. TEST_f_L (llround, 2097151.0, 2097151LL);
  2605. /* 0x800000 */
  2606. TEST_f_L (llround, 8388608.0, 8388608LL);
  2607. /* 0x1000000 */
  2608. TEST_f_L (llround, 16777216.0, 16777216LL);
  2609. /* 0x20000000000 */
  2610. TEST_f_L (llround, 2199023255552.0, 2199023255552LL);
  2611. /* 0x40000000000 */
  2612. TEST_f_L (llround, 4398046511104.0, 4398046511104LL);
  2613. /* 0x10000000000000 */
  2614. TEST_f_L (llround, 4503599627370496.0, 4503599627370496LL);
  2615. /* 0x10000080000000 */
  2616. TEST_f_L (llrint, 4503601774854144.0, 4503601774854144LL);
  2617. /* 0x20000000000000 */
  2618. TEST_f_L (llround, 9007199254740992.0, 9007199254740992LL);
  2619. /* 0x80000000000000 */
  2620. TEST_f_L (llround, 36028797018963968.0, 36028797018963968LL);
  2621. /* 0x100000000000000 */
  2622. TEST_f_L (llround, 72057594037927936.0, 72057594037927936LL);
  2623. #ifndef TEST_FLOAT
  2624. /* 0x100000000 */
  2625. TEST_f_L (llround, 4294967295.5, 4294967296LL);
  2626. /* 0x200000000 */
  2627. TEST_f_L (llround, 8589934591.5, 8589934592LL);
  2628. #endif
  2629. END (llround);
  2630. }
  2631. #endif
  2632. static void
  2633. modf_test (void)
  2634. {
  2635. FLOAT x;
  2636. START (modf);
  2637. TEST_fF_f1 (modf, plus_infty, 0, plus_infty);
  2638. TEST_fF_f1 (modf, minus_infty, minus_zero, minus_infty);
  2639. TEST_fF_f1 (modf, nan_value, nan_value, nan_value);
  2640. TEST_fF_f1 (modf, 0, 0, 0);
  2641. TEST_fF_f1 (modf, 1.5, 0.5, 1);
  2642. TEST_fF_f1 (modf, 2.5, 0.5, 2);
  2643. TEST_fF_f1 (modf, -2.5, -0.5, -2);
  2644. TEST_fF_f1 (modf, 20, 0, 20);
  2645. TEST_fF_f1 (modf, 21, 0, 21);
  2646. TEST_fF_f1 (modf, 89.5, 0.5, 89);
  2647. END (modf);
  2648. }
  2649. #if 0
  2650. static void
  2651. nearbyint_test (void)
  2652. {
  2653. START (nearbyint);
  2654. TEST_f_f (nearbyint, 0.0, 0.0);
  2655. TEST_f_f (nearbyint, minus_zero, minus_zero);
  2656. TEST_f_f (nearbyint, plus_infty, plus_infty);
  2657. TEST_f_f (nearbyint, minus_infty, minus_infty);
  2658. TEST_f_f (nearbyint, nan_value, nan_value);
  2659. /* Default rounding mode is round to nearest. */
  2660. TEST_f_f (nearbyint, 0.5, 0.0);
  2661. TEST_f_f (nearbyint, 1.5, 2.0);
  2662. TEST_f_f (nearbyint, -0.5, minus_zero);
  2663. TEST_f_f (nearbyint, -1.5, -2.0);
  2664. END (nearbyint);
  2665. }
  2666. static void
  2667. nextafter_test (void)
  2668. {
  2669. START (nextafter);
  2670. TEST_ff_f (nextafter, 0, 0, 0);
  2671. TEST_ff_f (nextafter, minus_zero, 0, 0);
  2672. TEST_ff_f (nextafter, 0, minus_zero, minus_zero);
  2673. TEST_ff_f (nextafter, minus_zero, minus_zero, minus_zero);
  2674. TEST_ff_f (nextafter, 9, 9, 9);
  2675. TEST_ff_f (nextafter, -9, -9, -9);
  2676. TEST_ff_f (nextafter, plus_infty, plus_infty, plus_infty);
  2677. TEST_ff_f (nextafter, minus_infty, minus_infty, minus_infty);
  2678. TEST_ff_f (nextafter, nan_value, 1.1L, nan_value);
  2679. TEST_ff_f (nextafter, 1.1L, nan_value, nan_value);
  2680. TEST_ff_f (nextafter, nan_value, nan_value, nan_value);
  2681. /* XXX We need the hexadecimal FP number representation here for further
  2682. tests. */
  2683. END (nextafter);
  2684. }
  2685. static void
  2686. nexttoward_test (void)
  2687. {
  2688. START (nexttoward);
  2689. TEST_ff_f (nexttoward, 0, 0, 0);
  2690. TEST_ff_f (nexttoward, minus_zero, 0, 0);
  2691. TEST_ff_f (nexttoward, 0, minus_zero, minus_zero);
  2692. TEST_ff_f (nexttoward, minus_zero, minus_zero, minus_zero);
  2693. TEST_ff_f (nexttoward, 9, 9, 9);
  2694. TEST_ff_f (nexttoward, -9, -9, -9);
  2695. TEST_ff_f (nexttoward, plus_infty, plus_infty, plus_infty);
  2696. TEST_ff_f (nexttoward, minus_infty, minus_infty, minus_infty);
  2697. TEST_ff_f (nexttoward, nan_value, 1.1L, nan_value);
  2698. TEST_ff_f (nexttoward, 1.1L, nan_value, nan_value);
  2699. TEST_ff_f (nexttoward, nan_value, nan_value, nan_value);
  2700. /* XXX We need the hexadecimal FP number representation here for further
  2701. tests. */
  2702. END (nexttoward);
  2703. }
  2704. #endif
  2705. static void
  2706. pow_test (void)
  2707. {
  2708. errno = 0;
  2709. FUNC(pow) (0, 0);
  2710. if (errno == ENOSYS)
  2711. /* Function not implemented. */
  2712. return;
  2713. START (pow);
  2714. TEST_ff_f (pow, 0, 0, 1);
  2715. TEST_ff_f (pow, 0, minus_zero, 1);
  2716. TEST_ff_f (pow, minus_zero, 0, 1);
  2717. TEST_ff_f (pow, minus_zero, minus_zero, 1);
  2718. TEST_ff_f (pow, 10, 0, 1);
  2719. TEST_ff_f (pow, 10, minus_zero, 1);
  2720. TEST_ff_f (pow, -10, 0, 1);
  2721. TEST_ff_f (pow, -10, minus_zero, 1);
  2722. TEST_ff_f (pow, nan_value, 0, 1);
  2723. TEST_ff_f (pow, nan_value, minus_zero, 1);
  2724. #ifndef TEST_INLINE
  2725. TEST_ff_f (pow, 1.1L, plus_infty, plus_infty);
  2726. TEST_ff_f (pow, plus_infty, plus_infty, plus_infty);
  2727. TEST_ff_f (pow, -1.1L, plus_infty, plus_infty);
  2728. TEST_ff_f (pow, minus_infty, plus_infty, plus_infty);
  2729. TEST_ff_f (pow, 0.9L, plus_infty, 0);
  2730. TEST_ff_f (pow, 1e-7L, plus_infty, 0);
  2731. TEST_ff_f (pow, -0.9L, plus_infty, 0);
  2732. TEST_ff_f (pow, -1e-7L, plus_infty, 0);
  2733. TEST_ff_f (pow, 1.1L, minus_infty, 0);
  2734. TEST_ff_f (pow, plus_infty, minus_infty, 0);
  2735. TEST_ff_f (pow, -1.1L, minus_infty, 0);
  2736. TEST_ff_f (pow, minus_infty, minus_infty, 0);
  2737. TEST_ff_f (pow, 0.9L, minus_infty, plus_infty);
  2738. TEST_ff_f (pow, 1e-7L, minus_infty, plus_infty);
  2739. TEST_ff_f (pow, -0.9L, minus_infty, plus_infty);
  2740. TEST_ff_f (pow, -1e-7L, minus_infty, plus_infty);
  2741. TEST_ff_f (pow, plus_infty, 1e-7L, plus_infty);
  2742. TEST_ff_f (pow, plus_infty, 1, plus_infty);
  2743. TEST_ff_f (pow, plus_infty, 1e7L, plus_infty);
  2744. TEST_ff_f (pow, plus_infty, -1e-7L, 0);
  2745. TEST_ff_f (pow, plus_infty, -1, 0);
  2746. TEST_ff_f (pow, plus_infty, -1e7L, 0);
  2747. TEST_ff_f (pow, minus_infty, 1, minus_infty);
  2748. TEST_ff_f (pow, minus_infty, 11, minus_infty);
  2749. TEST_ff_f (pow, minus_infty, 1001, minus_infty);
  2750. TEST_ff_f (pow, minus_infty, 2, plus_infty);
  2751. TEST_ff_f (pow, minus_infty, 12, plus_infty);
  2752. TEST_ff_f (pow, minus_infty, 1002, plus_infty);
  2753. TEST_ff_f (pow, minus_infty, 0.1L, plus_infty);
  2754. TEST_ff_f (pow, minus_infty, 1.1L, plus_infty);
  2755. TEST_ff_f (pow, minus_infty, 11.1L, plus_infty);
  2756. TEST_ff_f (pow, minus_infty, 1001.1L, plus_infty);
  2757. TEST_ff_f (pow, minus_infty, -1, minus_zero);
  2758. TEST_ff_f (pow, minus_infty, -11, minus_zero);
  2759. TEST_ff_f (pow, minus_infty, -1001, minus_zero);
  2760. TEST_ff_f (pow, minus_infty, -2, 0);
  2761. TEST_ff_f (pow, minus_infty, -12, 0);
  2762. TEST_ff_f (pow, minus_infty, -1002, 0);
  2763. TEST_ff_f (pow, minus_infty, -0.1L, 0);
  2764. TEST_ff_f (pow, minus_infty, -1.1L, 0);
  2765. TEST_ff_f (pow, minus_infty, -11.1L, 0);
  2766. TEST_ff_f (pow, minus_infty, -1001.1L, 0);
  2767. #endif
  2768. TEST_ff_f (pow, nan_value, nan_value, nan_value);
  2769. TEST_ff_f (pow, 0, nan_value, nan_value);
  2770. TEST_ff_f (pow, 1, nan_value, 1);
  2771. TEST_ff_f (pow, -1, nan_value, nan_value);
  2772. TEST_ff_f (pow, nan_value, 1, nan_value);
  2773. TEST_ff_f (pow, nan_value, -1, nan_value);
  2774. /* pow (x, NaN) == NaN. */
  2775. TEST_ff_f (pow, 3.0, nan_value, nan_value);
  2776. TEST_ff_f (pow, 1, plus_infty, 1);
  2777. TEST_ff_f (pow, -1, plus_infty, 1);
  2778. TEST_ff_f (pow, 1, minus_infty, 1);
  2779. TEST_ff_f (pow, -1, minus_infty, 1);
  2780. TEST_ff_f (pow, -0.1L, 1.1L, nan_value, INVALID_EXCEPTION);
  2781. TEST_ff_f (pow, -0.1L, -1.1L, nan_value, INVALID_EXCEPTION);
  2782. TEST_ff_f (pow, -10.1L, 1.1L, nan_value, INVALID_EXCEPTION);
  2783. TEST_ff_f (pow, -10.1L, -1.1L, nan_value, INVALID_EXCEPTION);
  2784. TEST_ff_f (pow, 0, -1, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2785. TEST_ff_f (pow, 0, -11, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2786. TEST_ff_f (pow, minus_zero, -1, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2787. TEST_ff_f (pow, minus_zero, -11, minus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2788. TEST_ff_f (pow, 0, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2789. TEST_ff_f (pow, 0, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2790. TEST_ff_f (pow, minus_zero, -2, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2791. TEST_ff_f (pow, minus_zero, -11.1L, plus_infty, DIVIDE_BY_ZERO_EXCEPTION);
  2792. TEST_ff_f (pow, 0, 1, 0);
  2793. TEST_ff_f (pow, 0, 11, 0);
  2794. TEST_ff_f (pow, minus_zero, 1, minus_zero);
  2795. TEST_ff_f (pow, minus_zero, 11, minus_zero);
  2796. TEST_ff_f (pow, 0, 2, 0);
  2797. TEST_ff_f (pow, 0, 11.1L, 0);
  2798. TEST_ff_f (pow, minus_zero, 2, 0);
  2799. TEST_ff_f (pow, minus_zero, 11.1L, 0);
  2800. #ifndef TEST_INLINE
  2801. /* pow (x, +inf) == +inf for |x| > 1. */
  2802. TEST_ff_f (pow, 1.5, plus_infty, plus_infty);
  2803. /* pow (x, +inf) == +0 for |x| < 1. */
  2804. TEST_ff_f (pow, 0.5, plus_infty, 0.0);
  2805. /* pow (x, -inf) == +0 for |x| > 1. */
  2806. TEST_ff_f (pow, 1.5, minus_infty, 0.0);
  2807. /* pow (x, -inf) == +inf for |x| < 1. */
  2808. TEST_ff_f (pow, 0.5, minus_infty, plus_infty);
  2809. #endif
  2810. /* pow (+inf, y) == +inf for y > 0. */
  2811. TEST_ff_f (pow, plus_infty, 2, plus_infty);
  2812. /* pow (+inf, y) == +0 for y < 0. */
  2813. TEST_ff_f (pow, plus_infty, -1, 0.0);
  2814. /* pow (-inf, y) == -inf for y an odd integer > 0. */
  2815. TEST_ff_f (pow, minus_infty, 27, minus_infty);
  2816. /* pow (-inf, y) == +inf for y > 0 and not an odd integer. */
  2817. TEST_ff_f (pow, minus_infty, 28, plus_infty);
  2818. /* pow (-inf, y) == -0 for y an odd integer < 0. */
  2819. TEST_ff_f (pow, minus_infty, -3, minus_zero);
  2820. /* pow (-inf, y) == +0 for y < 0 and not an odd integer. */
  2821. TEST_ff_f (pow, minus_infty, -2.0, 0.0);
  2822. /* pow (+0, y) == +0 for y an odd integer > 0. */
  2823. TEST_ff_f (pow, 0.0, 27, 0.0);
  2824. /* pow (-0, y) == -0 for y an odd integer > 0. */
  2825. TEST_ff_f (pow, minus_zero, 27, minus_zero);
  2826. /* pow (+0, y) == +0 for y > 0 and not an odd integer. */
  2827. TEST_ff_f (pow, 0.0, 4, 0.0);
  2828. /* pow (-0, y) == +0 for y > 0 and not an odd integer. */
  2829. TEST_ff_f (pow, minus_zero, 4, 0.0);
  2830. TEST_ff_f (pow, 0.7L, 1.2L, 0.65180494056638638188L);
  2831. #if defined TEST_DOUBLE || defined TEST_LDOUBLE
  2832. TEST_ff_f (pow, -7.49321e+133, -9.80818e+16, 0);
  2833. #endif
  2834. END (pow);
  2835. }
  2836. static void
  2837. remainder_test (void)
  2838. {
  2839. errno = 0;
  2840. FUNC(remainder) (1.625, 1.0);
  2841. if (errno == ENOSYS)
  2842. /* Function not implemented. */
  2843. return;
  2844. START (remainder);
  2845. TEST_ff_f (remainder, 1, 0, nan_value, INVALID_EXCEPTION);
  2846. TEST_ff_f (remainder, 1, minus_zero, nan_value, INVALID_EXCEPTION);
  2847. TEST_ff_f (remainder, plus_infty, 1, nan_value, INVALID_EXCEPTION);
  2848. TEST_ff_f (remainder, minus_infty, 1, nan_value, INVALID_EXCEPTION);
  2849. TEST_ff_f (remainder, nan_value, nan_value, nan_value);
  2850. TEST_ff_f (remainder, 1.625, 1.0, -0.375);
  2851. TEST_ff_f (remainder, -1.625, 1.0, 0.375);
  2852. TEST_ff_f (remainder, 1.625, -1.0, -0.375);
  2853. TEST_ff_f (remainder, -1.625, -1.0, 0.375);
  2854. TEST_ff_f (remainder, 5.0, 2.0, 1.0);
  2855. TEST_ff_f (remainder, 3.0, 2.0, -1.0);
  2856. END (remainder);
  2857. }
  2858. #if 0
  2859. static void
  2860. remquo_test (void)
  2861. {
  2862. /* x is needed. */
  2863. int x;
  2864. errno = 0;
  2865. FUNC(remquo) (1.625, 1.0, &x);
  2866. if (errno == ENOSYS)
  2867. /* Function not implemented. */
  2868. return;
  2869. START (remquo);
  2870. TEST_ffI_f1 (remquo, 1, 0, nan_value, IGNORE, INVALID_EXCEPTION);
  2871. TEST_ffI_f1 (remquo, 1, minus_zero, nan_value, IGNORE, INVALID_EXCEPTION);
  2872. TEST_ffI_f1 (remquo, plus_infty, 1, nan_value, IGNORE, INVALID_EXCEPTION);
  2873. TEST_ffI_f1 (remquo, minus_infty, 1, nan_value, IGNORE, INVALID_EXCEPTION);
  2874. TEST_ffI_f1 (remquo, nan_value, nan_value, nan_value, IGNORE);
  2875. TEST_ffI_f1 (remquo, 1.625, 1.0, -0.375, 2);
  2876. TEST_ffI_f1 (remquo, -1.625, 1.0, 0.375, -2);
  2877. TEST_ffI_f1 (remquo, 1.625, -1.0, -0.375, -2);
  2878. TEST_ffI_f1 (remquo, -1.625, -1.0, 0.375, 2);
  2879. TEST_ffI_f1 (remquo, 5, 2, 1, 2);
  2880. TEST_ffI_f1 (remquo, 3, 2, -1, 2);
  2881. END (remquo);
  2882. }
  2883. #endif
  2884. static void
  2885. rint_test (void)
  2886. {
  2887. START (rint);
  2888. TEST_f_f (rint, 0.0, 0.0);
  2889. TEST_f_f (rint, minus_zero, minus_zero);
  2890. TEST_f_f (rint, plus_infty, plus_infty);
  2891. TEST_f_f (rint, minus_infty, minus_infty);
  2892. /* Default rounding mode is round to even. */
  2893. TEST_f_f (rint, 0.5, 0.0);
  2894. TEST_f_f (rint, 1.5, 2.0);
  2895. TEST_f_f (rint, 2.5, 2.0);
  2896. TEST_f_f (rint, 3.5, 4.0);
  2897. TEST_f_f (rint, 4.5, 4.0);
  2898. TEST_f_f (rint, -0.5, -0.0);
  2899. TEST_f_f (rint, -1.5, -2.0);
  2900. TEST_f_f (rint, -2.5, -2.0);
  2901. TEST_f_f (rint, -3.5, -4.0);
  2902. TEST_f_f (rint, -4.5, -4.0);
  2903. END (rint);
  2904. }
  2905. #if 0
  2906. static void
  2907. round_test (void)
  2908. {
  2909. START (round);
  2910. TEST_f_f (round, 0, 0);
  2911. TEST_f_f (round, minus_zero, minus_zero);
  2912. TEST_f_f (round, 0.2L, 0.0);
  2913. TEST_f_f (round, -0.2L, minus_zero);
  2914. TEST_f_f (round, 0.5, 1.0);
  2915. TEST_f_f (round, -0.5, -1.0);
  2916. TEST_f_f (round, 0.8L, 1.0);
  2917. TEST_f_f (round, -0.8L, -1.0);
  2918. TEST_f_f (round, 1.5, 2.0);
  2919. TEST_f_f (round, -1.5, -2.0);
  2920. TEST_f_f (round, 2097152.5, 2097153);
  2921. TEST_f_f (round, -2097152.5, -2097153);
  2922. END (round);
  2923. }
  2924. #endif
  2925. static void
  2926. scalb_test (void)
  2927. {
  2928. START (scalb);
  2929. TEST_ff_f (scalb, 2.0, 0.5, nan_value, INVALID_EXCEPTION);
  2930. TEST_ff_f (scalb, 3.0, -2.5, nan_value, INVALID_EXCEPTION);
  2931. TEST_ff_f (scalb, 0, nan_value, nan_value);
  2932. TEST_ff_f (scalb, 1, nan_value, nan_value);
  2933. TEST_ff_f (scalb, 1, 0, 1);
  2934. TEST_ff_f (scalb, -1, 0, -1);
  2935. TEST_ff_f (scalb, 0, plus_infty, nan_value, INVALID_EXCEPTION);
  2936. TEST_ff_f (scalb, minus_zero, plus_infty, nan_value, INVALID_EXCEPTION);
  2937. TEST_ff_f (scalb, 0, 2, 0);
  2938. TEST_ff_f (scalb, minus_zero, -4, minus_zero);
  2939. TEST_ff_f (scalb, 0, 0, 0);
  2940. TEST_ff_f (scalb, minus_zero, 0, minus_zero);
  2941. TEST_ff_f (scalb, 0, -1, 0);
  2942. TEST_ff_f (scalb, minus_zero, -10, minus_zero);
  2943. TEST_ff_f (scalb, 0, minus_infty, 0);
  2944. TEST_ff_f (scalb, minus_zero, minus_infty, minus_zero);
  2945. TEST_ff_f (scalb, plus_infty, -1, plus_infty);
  2946. TEST_ff_f (scalb, minus_infty, -10, minus_infty);
  2947. TEST_ff_f (scalb, plus_infty, 0, plus_infty);
  2948. TEST_ff_f (scalb, minus_infty, 0, minus_infty);
  2949. TEST_ff_f (scalb, plus_infty, 2, plus_infty);
  2950. TEST_ff_f (scalb, minus_infty, 100, minus_infty);
  2951. TEST_ff_f (scalb, 0.1L, minus_infty, 0.0);
  2952. TEST_ff_f (scalb, -0.1L, minus_infty, minus_zero);
  2953. TEST_ff_f (scalb, 1, plus_infty, plus_infty);
  2954. TEST_ff_f (scalb, -1, plus_infty, minus_infty);
  2955. TEST_ff_f (scalb, plus_infty, plus_infty, plus_infty);
  2956. TEST_ff_f (scalb, minus_infty, plus_infty, minus_infty);
  2957. TEST_ff_f (scalb, plus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
  2958. TEST_ff_f (scalb, minus_infty, minus_infty, nan_value, INVALID_EXCEPTION);
  2959. TEST_ff_f (scalb, nan_value, 1, nan_value);
  2960. TEST_ff_f (scalb, 1, nan_value, nan_value);
  2961. TEST_ff_f (scalb, nan_value, 0, nan_value);
  2962. TEST_ff_f (scalb, 0, nan_value, nan_value);
  2963. TEST_ff_f (scalb, nan_value, plus_infty, nan_value);
  2964. TEST_ff_f (scalb, plus_infty, nan_value, nan_value);
  2965. TEST_ff_f (scalb, nan_value, nan_value, nan_value);
  2966. TEST_ff_f (scalb, 0.8L, 4, 12.8L);
  2967. TEST_ff_f (scalb, -0.854375L, 5, -27.34L);
  2968. END (scalb);
  2969. }
  2970. static void
  2971. scalbn_test (void)
  2972. {
  2973. START (scalbn);
  2974. TEST_fi_f (scalbn, 0, 0, 0);
  2975. TEST_fi_f (scalbn, minus_zero, 0, minus_zero);
  2976. TEST_fi_f (scalbn, plus_infty, 1, plus_infty);
  2977. TEST_fi_f (scalbn, minus_infty, 1, minus_infty);
  2978. TEST_fi_f (scalbn, nan_value, 1, nan_value);
  2979. TEST_fi_f (scalbn, 0.8L, 4, 12.8L);
  2980. TEST_fi_f (scalbn, -0.854375L, 5, -27.34L);
  2981. TEST_fi_f (scalbn, 1, 0L, 1);
  2982. END (scalbn);
  2983. }
  2984. #if 0
  2985. static void
  2986. scalbln_test (void)
  2987. {
  2988. START (scalbln);
  2989. TEST_fl_f (scalbln, 0, 0, 0);
  2990. TEST_fl_f (scalbln, minus_zero, 0, minus_zero);
  2991. TEST_fl_f (scalbln, plus_infty, 1, plus_infty);
  2992. TEST_fl_f (scalbln, minus_infty, 1, minus_infty);
  2993. TEST_fl_f (scalbln, nan_value, 1, nan_value);
  2994. TEST_fl_f (scalbln, 0.8L, 4, 12.8L);
  2995. TEST_fl_f (scalbln, -0.854375L, 5, -27.34L);
  2996. TEST_fl_f (scalbln, 1, 0L, 1);
  2997. END (scalbn);
  2998. }
  2999. #endif
  3000. static void
  3001. signbit_test (void)
  3002. {
  3003. START (signbit);
  3004. TEST_f_b (signbit, 0, 0);
  3005. TEST_f_b (signbit, minus_zero, 1);
  3006. TEST_f_b (signbit, plus_infty, 0);
  3007. TEST_f_b (signbit, minus_infty, 1);
  3008. /* signbit (x) != 0 for x < 0. */
  3009. TEST_f_b (signbit, -1, 1);
  3010. /* signbit (x) == 0 for x >= 0. */
  3011. TEST_f_b (signbit, 1, 0);
  3012. END (signbit);
  3013. }
  3014. static void
  3015. sin_test (void)
  3016. {
  3017. errno = 0;
  3018. FUNC(sin) (0);
  3019. if (errno == ENOSYS)
  3020. /* Function not implemented. */
  3021. return;
  3022. START (sin);
  3023. TEST_f_f (sin, 0, 0);
  3024. TEST_f_f (sin, minus_zero, minus_zero);
  3025. TEST_f_f (sin, plus_infty, nan_value, INVALID_EXCEPTION);
  3026. TEST_f_f (sin, minus_infty, nan_value, INVALID_EXCEPTION);
  3027. TEST_f_f (sin, nan_value, nan_value);
  3028. TEST_f_f (sin, M_PI_6l, 0.5);
  3029. TEST_f_f (sin, -M_PI_6l, -0.5);
  3030. TEST_f_f (sin, M_PI_2l, 1);
  3031. TEST_f_f (sin, -M_PI_2l, -1);
  3032. TEST_f_f (sin, 0.7L, 0.64421768723769105367261435139872014L);
  3033. END (sin);
  3034. }
  3035. #if 0
  3036. static void
  3037. sincos_test (void)
  3038. {
  3039. FLOAT sin_res, cos_res;
  3040. errno = 0;
  3041. FUNC(sincos) (0, &sin_res, &cos_res);
  3042. if (errno == ENOSYS)
  3043. /* Function not implemented. */
  3044. return;
  3045. START (sincos);
  3046. /* sincos is treated differently because it returns void. */
  3047. TEST_extra (sincos, 0, 0, 1);
  3048. TEST_extra (sincos, minus_zero, minus_zero, 1);
  3049. TEST_extra (sincos, plus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  3050. TEST_extra (sincos, minus_infty, nan_value, nan_value, INVALID_EXCEPTION);
  3051. TEST_extra (sincos, nan_value, nan_value, nan_value);
  3052. TEST_extra (sincos, M_PI_2l, 1, 0);
  3053. TEST_extra (sincos, M_PI_6l, 0.5, 0.86602540378443864676372317075293616L);
  3054. TEST_extra (sincos, M_PI_6l*2.0, 0.86602540378443864676372317075293616L, 0.5);
  3055. TEST_extra (sincos, 0.7L, 0.64421768723769105367261435139872014L, 0.76484218728448842625585999019186495L);
  3056. END (sincos);
  3057. }
  3058. #endif
  3059. static void
  3060. sinh_test (void)
  3061. {
  3062. errno = 0;
  3063. FUNC(sinh) (0.7L);
  3064. if (errno == ENOSYS)
  3065. /* Function not implemented. */
  3066. return;
  3067. START (sinh);
  3068. TEST_f_f (sinh, 0, 0);
  3069. TEST_f_f (sinh, minus_zero, minus_zero);
  3070. #ifndef TEST_INLINE
  3071. TEST_f_f (sinh, plus_infty, plus_infty);
  3072. TEST_f_f (sinh, minus_infty, minus_infty);
  3073. #endif
  3074. TEST_f_f (sinh, nan_value, nan_value);
  3075. TEST_f_f (sinh, 0.7L, 0.75858370183953350346L);
  3076. TEST_f_f (sinh, 0x8p-32L, 1.86264514923095703232705808926175479e-9L);
  3077. END (sinh);
  3078. }
  3079. static void
  3080. sqrt_test (void)
  3081. {
  3082. errno = 0;
  3083. FUNC(sqrt) (1);
  3084. if (errno == ENOSYS)
  3085. /* Function not implemented. */
  3086. return;
  3087. START (sqrt);
  3088. TEST_f_f (sqrt, 0, 0);
  3089. TEST_f_f (sqrt, nan_value, nan_value);
  3090. TEST_f_f (sqrt, plus_infty, plus_infty);
  3091. TEST_f_f (sqrt, minus_zero, minus_zero);
  3092. /* sqrt (x) == NaN plus invalid exception for x < 0. */
  3093. TEST_f_f (sqrt, -1, nan_value, INVALID_EXCEPTION);
  3094. TEST_f_f (sqrt, minus_infty, nan_value, INVALID_EXCEPTION);
  3095. TEST_f_f (sqrt, nan_value, nan_value);
  3096. TEST_f_f (sqrt, 2209, 47);
  3097. TEST_f_f (sqrt, 4, 2);
  3098. TEST_f_f (sqrt, 2, M_SQRT2l);
  3099. TEST_f_f (sqrt, 0.25, 0.5);
  3100. TEST_f_f (sqrt, 6642.25, 81.5);
  3101. TEST_f_f (sqrt, 15239.9025L, 123.45L);
  3102. TEST_f_f (sqrt, 0.7L, 0.83666002653407554797817202578518747L);
  3103. END (sqrt);
  3104. }
  3105. static void
  3106. tan_test (void)
  3107. {
  3108. errno = 0;
  3109. FUNC(tan) (0);
  3110. if (errno == ENOSYS)
  3111. /* Function not implemented. */
  3112. return;
  3113. START (tan);
  3114. TEST_f_f (tan, 0, 0);
  3115. TEST_f_f (tan, minus_zero, minus_zero);
  3116. TEST_f_f (tan, plus_infty, nan_value, INVALID_EXCEPTION);
  3117. TEST_f_f (tan, minus_infty, nan_value, INVALID_EXCEPTION);
  3118. TEST_f_f (tan, nan_value, nan_value);
  3119. TEST_f_f (tan, M_PI_4l, 1);
  3120. TEST_f_f (tan, 0.7L, 0.84228838046307944812813500221293775L);
  3121. END (tan);
  3122. }
  3123. static void
  3124. tanh_test (void)
  3125. {
  3126. errno = 0;
  3127. FUNC(tanh) (0.7L);
  3128. if (errno == ENOSYS)
  3129. /* Function not implemented. */
  3130. return;
  3131. START (tanh);
  3132. TEST_f_f (tanh, 0, 0);
  3133. TEST_f_f (tanh, minus_zero, minus_zero);
  3134. #ifndef TEST_INLINE
  3135. TEST_f_f (tanh, plus_infty, 1);
  3136. TEST_f_f (tanh, minus_infty, -1);
  3137. #endif
  3138. TEST_f_f (tanh, nan_value, nan_value);
  3139. TEST_f_f (tanh, 0.7L, 0.60436777711716349631L);
  3140. TEST_f_f (tanh, -0.7L, -0.60436777711716349631L);
  3141. TEST_f_f (tanh, 1.0L, 0.7615941559557648881194582826047935904L);
  3142. TEST_f_f (tanh, -1.0L, -0.7615941559557648881194582826047935904L);
  3143. /* 2^-57 */
  3144. TEST_f_f (tanh, 6.938893903907228377647697925567626953125e-18L,6.938893903907228377647697925567626953125e-18L);
  3145. END (tanh);
  3146. }
  3147. #if 0
  3148. static void
  3149. tgamma_test (void)
  3150. {
  3151. errno = 0;
  3152. FUNC(tgamma) (1);
  3153. if (errno == ENOSYS)
  3154. /* Function not implemented. */
  3155. return;
  3156. feclearexcept (FE_ALL_EXCEPT);
  3157. START (tgamma);
  3158. TEST_f_f (tgamma, plus_infty, plus_infty);
  3159. TEST_f_f (tgamma, 0, nan_value, INVALID_EXCEPTION);
  3160. TEST_f_f (tgamma, minus_zero, nan_value, INVALID_EXCEPTION);
  3161. /* tgamma (x) == NaN plus invalid exception for integer x <= 0. */
  3162. TEST_f_f (tgamma, -2, nan_value, INVALID_EXCEPTION);
  3163. TEST_f_f (tgamma, minus_infty, nan_value, INVALID_EXCEPTION);
  3164. TEST_f_f (tgamma, nan_value, nan_value);
  3165. TEST_f_f (tgamma, 0.5, M_SQRT_PIl);
  3166. TEST_f_f (tgamma, -0.5, -M_2_SQRT_PIl);
  3167. TEST_f_f (tgamma, 1, 1);
  3168. TEST_f_f (tgamma, 4, 6);
  3169. TEST_f_f (tgamma, 0.7L, 1.29805533264755778568L);
  3170. TEST_f_f (tgamma, 1.2L, 0.91816874239976061064L);
  3171. END (tgamma);
  3172. }
  3173. #endif
  3174. #if 0
  3175. static void
  3176. trunc_test (void)
  3177. {
  3178. START (trunc);
  3179. TEST_f_f (trunc, plus_infty, plus_infty);
  3180. TEST_f_f (trunc, minus_infty, minus_infty);
  3181. TEST_f_f (trunc, nan_value, nan_value);
  3182. TEST_f_f (trunc, 0, 0);
  3183. TEST_f_f (trunc, minus_zero, minus_zero);
  3184. TEST_f_f (trunc, 0.625, 0);
  3185. TEST_f_f (trunc, -0.625, minus_zero);
  3186. TEST_f_f (trunc, 1, 1);
  3187. TEST_f_f (trunc, -1, -1);
  3188. TEST_f_f (trunc, 1.625, 1);
  3189. TEST_f_f (trunc, -1.625, -1);
  3190. TEST_f_f (trunc, 1048580.625L, 1048580L);
  3191. TEST_f_f (trunc, -1048580.625L, -1048580L);
  3192. TEST_f_f (trunc, 8388610.125L, 8388610.0L);
  3193. TEST_f_f (trunc, -8388610.125L, -8388610.0L);
  3194. TEST_f_f (trunc, 4294967296.625L, 4294967296.0L);
  3195. TEST_f_f (trunc, -4294967296.625L, -4294967296.0L);
  3196. END (trunc);
  3197. }
  3198. #endif
  3199. static void
  3200. y0_test (void)
  3201. {
  3202. errno = 0;
  3203. #if 0
  3204. FLOAT s, c;
  3205. FUNC (sincos) (0, &s, &c);
  3206. if (errno == ENOSYS)
  3207. /* Required function not implemented. */
  3208. return;
  3209. #endif
  3210. FUNC(y0) (1);
  3211. if (errno == ENOSYS)
  3212. /* Function not implemented. */
  3213. return;
  3214. /* y0 is the Bessel function of the second kind of order 0 */
  3215. START (y0);
  3216. TEST_f_f (y0, -1.0, minus_infty);
  3217. TEST_f_f (y0, 0.0, minus_infty);
  3218. TEST_f_f (y0, nan_value, nan_value);
  3219. TEST_f_f (y0, plus_infty, 0);
  3220. TEST_f_f (y0, 0.1L, -1.5342386513503668441L);
  3221. TEST_f_f (y0, 0.7L, -0.19066492933739506743L);
  3222. TEST_f_f (y0, 1.0, 0.088256964215676957983L);
  3223. TEST_f_f (y0, 1.5, 0.38244892379775884396L);
  3224. TEST_f_f (y0, 2.0, 0.51037567264974511960L);
  3225. TEST_f_f (y0, 8.0, 0.22352148938756622053L);
  3226. TEST_f_f (y0, 10.0, 0.055671167283599391424L);
  3227. END (y0);
  3228. }
  3229. static void
  3230. y1_test (void)
  3231. {
  3232. errno = 0;
  3233. #if 0
  3234. FLOAT s, c;
  3235. FUNC (sincos) (0, &s, &c);
  3236. if (errno == ENOSYS)
  3237. /* Required function not implemented. */
  3238. return;
  3239. #endif
  3240. FUNC(y1) (1);
  3241. if (errno == ENOSYS)
  3242. /* Function not implemented. */
  3243. return;
  3244. /* y1 is the Bessel function of the second kind of order 1 */
  3245. START (y1);
  3246. TEST_f_f (y1, -1.0, minus_infty);
  3247. TEST_f_f (y1, 0.0, minus_infty);
  3248. TEST_f_f (y1, plus_infty, 0);
  3249. TEST_f_f (y1, nan_value, nan_value);
  3250. TEST_f_f (y1, 0.1L, -6.4589510947020269877L);
  3251. TEST_f_f (y1, 0.7L, -1.1032498719076333697L);
  3252. TEST_f_f (y1, 1.0, -0.78121282130028871655L);
  3253. TEST_f_f (y1, 1.5, -0.41230862697391129595L);
  3254. TEST_f_f (y1, 2.0, -0.10703243154093754689L);
  3255. TEST_f_f (y1, 8.0, -0.15806046173124749426L);
  3256. TEST_f_f (y1, 10.0, 0.24901542420695388392L);
  3257. END (y1);
  3258. }
  3259. static void
  3260. yn_test (void)
  3261. {
  3262. errno = 0;
  3263. #if 0
  3264. FLOAT s, c;
  3265. FUNC (sincos) (0, &s, &c);
  3266. if (errno == ENOSYS)
  3267. /* Required function not implemented. */
  3268. return;
  3269. #endif
  3270. FUNC(yn) (1, 1);
  3271. if (errno == ENOSYS)
  3272. /* Function not implemented. */
  3273. return;
  3274. /* yn is the Bessel function of the second kind of order n */
  3275. START (yn);
  3276. /* yn (0, x) == y0 (x) */
  3277. TEST_ff_f (yn, 0, -1.0, minus_infty);
  3278. TEST_ff_f (yn, 0, 0.0, minus_infty);
  3279. TEST_ff_f (yn, 0, nan_value, nan_value);
  3280. TEST_ff_f (yn, 0, plus_infty, 0);
  3281. TEST_ff_f (yn, 0, 0.1L, -1.5342386513503668441L);
  3282. TEST_ff_f (yn, 0, 0.7L, -0.19066492933739506743L);
  3283. TEST_ff_f (yn, 0, 1.0, 0.088256964215676957983L);
  3284. TEST_ff_f (yn, 0, 1.5, 0.38244892379775884396L);
  3285. TEST_ff_f (yn, 0, 2.0, 0.51037567264974511960L);
  3286. TEST_ff_f (yn, 0, 8.0, 0.22352148938756622053L);
  3287. TEST_ff_f (yn, 0, 10.0, 0.055671167283599391424L);
  3288. /* yn (1, x) == y1 (x) */
  3289. TEST_ff_f (yn, 1, -1.0, minus_infty);
  3290. TEST_ff_f (yn, 1, 0.0, minus_infty);
  3291. TEST_ff_f (yn, 1, plus_infty, 0);
  3292. TEST_ff_f (yn, 1, nan_value, nan_value);
  3293. TEST_ff_f (yn, 1, 0.1L, -6.4589510947020269877L);
  3294. TEST_ff_f (yn, 1, 0.7L, -1.1032498719076333697L);
  3295. TEST_ff_f (yn, 1, 1.0, -0.78121282130028871655L);
  3296. TEST_ff_f (yn, 1, 1.5, -0.41230862697391129595L);
  3297. TEST_ff_f (yn, 1, 2.0, -0.10703243154093754689L);
  3298. TEST_ff_f (yn, 1, 8.0, -0.15806046173124749426L);
  3299. TEST_ff_f (yn, 1, 10.0, 0.24901542420695388392L);
  3300. /* yn (3, x) */
  3301. TEST_ff_f (yn, 3, plus_infty, 0);
  3302. TEST_ff_f (yn, 3, nan_value, nan_value);
  3303. TEST_ff_f (yn, 3, 0.1L, -5099.3323786129048894L);
  3304. TEST_ff_f (yn, 3, 0.7L, -15.819479052819633505L);
  3305. TEST_ff_f (yn, 3, 1.0, -5.8215176059647288478L);
  3306. TEST_ff_f (yn, 3, 2.0, -1.1277837768404277861L);
  3307. TEST_ff_f (yn, 3, 10.0, -0.25136265718383732978L);
  3308. /* yn (10, x) */
  3309. TEST_ff_f (yn, 10, plus_infty, 0);
  3310. TEST_ff_f (yn, 10, nan_value, nan_value);
  3311. TEST_ff_f (yn, 10, 0.1L, -0.11831335132045197885e19L);
  3312. TEST_ff_f (yn, 10, 0.7L, -0.42447194260703866924e10L);
  3313. TEST_ff_f (yn, 10, 1.0, -0.12161801427868918929e9L);
  3314. TEST_ff_f (yn, 10, 2.0, -129184.54220803928264L);
  3315. TEST_ff_f (yn, 10, 10.0, -0.35981415218340272205L);
  3316. END (yn);
  3317. }
  3318. static void
  3319. initialize (void)
  3320. {
  3321. fpstack_test ("start *init*");
  3322. plus_zero = 0.0;
  3323. nan_value = plus_zero / plus_zero; /* Suppress GCC warning */
  3324. minus_zero = FUNC(copysign) (0.0, -1.0);
  3325. plus_infty = CHOOSE (HUGE_VALL, HUGE_VAL, HUGE_VALF,
  3326. HUGE_VALL, HUGE_VAL, HUGE_VALF);
  3327. minus_infty = CHOOSE (-HUGE_VALL, -HUGE_VAL, -HUGE_VALF,
  3328. -HUGE_VALL, -HUGE_VAL, -HUGE_VALF);
  3329. (void) &plus_zero;
  3330. (void) &nan_value;
  3331. (void) &minus_zero;
  3332. (void) &plus_infty;
  3333. (void) &minus_infty;
  3334. /* Clear all exceptions. From now on we must not get random exceptions. */
  3335. feclearexcept (FE_ALL_EXCEPT);
  3336. /* Test to make sure we start correctly. */
  3337. fpstack_test ("end *init*");
  3338. }
  3339. #if 0
  3340. /* function to check our ulp calculation. */
  3341. void
  3342. check_ulp (void)
  3343. {
  3344. int i;
  3345. FLOAT u, diff, ulp;
  3346. /* This gives one ulp. */
  3347. u = FUNC(nextafter) (10, 20);
  3348. check_equal (10.0, u, 1, &diff, &ulp);
  3349. printf ("One ulp: % .4" PRINTF_NEXPR "\n", ulp);
  3350. /* This gives one more ulp. */
  3351. u = FUNC(nextafter) (u, 20);
  3352. check_equal (10.0, u, 2, &diff, &ulp);
  3353. printf ("two ulp: % .4" PRINTF_NEXPR "\n", ulp);
  3354. /* And now calculate 100 ulp. */
  3355. for (i = 2; i < 100; i++)
  3356. u = FUNC(nextafter) (u, 20);
  3357. check_equal (10.0, u, 100, &diff, &ulp);
  3358. printf ("100 ulp: % .4" PRINTF_NEXPR "\n", ulp);
  3359. }
  3360. #endif
  3361. int
  3362. main (int argc, char **argv)
  3363. {
  3364. int key;
  3365. verbose = 1;
  3366. output_ulps = 0;
  3367. output_max_error = 1;
  3368. output_points = 1;
  3369. /* XXX set to 0 for releases. */
  3370. ignore_max_ulp = 0;
  3371. /* Parse and process arguments. */
  3372. while ((key = getopt(argc, argv, "fi:puv")) > 0) {
  3373. switch (key)
  3374. {
  3375. case 'f':
  3376. output_max_error = 0;
  3377. break;
  3378. case 'i':
  3379. if (strcmp (optarg, "yes") == 0)
  3380. ignore_max_ulp = 1;
  3381. else if (strcmp (optarg, "no") == 0)
  3382. ignore_max_ulp = 0;
  3383. break;
  3384. case 'p':
  3385. output_points = 0;
  3386. break;
  3387. case 'u':
  3388. output_ulps = 1;
  3389. break;
  3390. case 'v':
  3391. verbose = 3;
  3392. break;
  3393. default:
  3394. fprintf (stderr, "Unknown argument: %c", key);
  3395. exit (EXIT_FAILURE);
  3396. }
  3397. }
  3398. if (optind != argc)
  3399. {
  3400. fprintf (stderr, "wrong number of arguments");
  3401. exit (EXIT_FAILURE);
  3402. }
  3403. if (output_ulps)
  3404. {
  3405. ulps_file = fopen ("ULPs", "a");
  3406. if (ulps_file == NULL)
  3407. {
  3408. perror ("can't open file `ULPs' for writing: ");
  3409. exit (1);
  3410. }
  3411. }
  3412. initialize ();
  3413. printf (TEST_MSG);
  3414. #if 0
  3415. check_ulp ();
  3416. #endif
  3417. /* Keep the tests a wee bit ordered (according to ISO C99). */
  3418. /* Classification macros: */
  3419. fpclassify_test ();
  3420. isfinite_test ();
  3421. isnormal_test ();
  3422. signbit_test ();
  3423. /* Trigonometric functions: */
  3424. acos_test ();
  3425. asin_test ();
  3426. atan_test ();
  3427. atan2_test ();
  3428. cos_test ();
  3429. sin_test ();
  3430. #if 0
  3431. sincos_test ();
  3432. #endif
  3433. tan_test ();
  3434. /* Hyperbolic functions: */
  3435. acosh_test ();
  3436. asinh_test ();
  3437. atanh_test ();
  3438. cosh_test ();
  3439. sinh_test ();
  3440. tanh_test ();
  3441. /* Exponential and logarithmic functions: */
  3442. exp_test ();
  3443. #if 0
  3444. exp10_test ();
  3445. exp2_test ();
  3446. #endif
  3447. expm1_test ();
  3448. frexp_test ();
  3449. ldexp_test ();
  3450. log_test ();
  3451. log10_test ();
  3452. log1p_test ();
  3453. #if 0
  3454. log2_test ();
  3455. #endif
  3456. logb_test ();
  3457. modf_test ();
  3458. ilogb_test ();
  3459. scalb_test ();
  3460. scalbn_test ();
  3461. #if 0
  3462. scalbln_test ();
  3463. #endif
  3464. /* Power and absolute value functions: */
  3465. cbrt_test ();
  3466. fabs_test ();
  3467. hypot_test ();
  3468. pow_test ();
  3469. sqrt_test ();
  3470. /* Error and gamma functions: */
  3471. erf_test ();
  3472. erfc_test ();
  3473. gamma_test ();
  3474. lgamma_test ();
  3475. #if 0
  3476. tgamma_test ();
  3477. #endif
  3478. /* Nearest integer functions: */
  3479. ceil_test ();
  3480. floor_test ();
  3481. #if 0
  3482. nearbyint_test ();
  3483. #endif
  3484. rint_test ();
  3485. #if 0
  3486. lrint_test ();
  3487. llrint_test ();
  3488. round_test ();
  3489. lround_test ();
  3490. llround_test ();
  3491. trunc_test ();
  3492. #endif
  3493. /* Remainder functions: */
  3494. fmod_test ();
  3495. remainder_test ();
  3496. #if 0
  3497. remquo_test ();
  3498. #endif
  3499. /* Manipulation functions: */
  3500. copysign_test ();
  3501. #if 0
  3502. nextafter_test ();
  3503. nexttoward_test ();
  3504. /* maximum, minimum and positive difference functions */
  3505. fdim_test ();
  3506. fmax_test ();
  3507. fmin_test ();
  3508. /* Multiply and add: */
  3509. fma_test ();
  3510. /* Complex functions: */
  3511. cabs_test ();
  3512. cacos_test ();
  3513. cacosh_test ();
  3514. carg_test ();
  3515. casin_test ();
  3516. casinh_test ();
  3517. catan_test ();
  3518. catanh_test ();
  3519. ccos_test ();
  3520. ccosh_test ();
  3521. cexp_test ();
  3522. cimag_test ();
  3523. clog10_test ();
  3524. clog_test ();
  3525. conj_test ();
  3526. cpow_test ();
  3527. cproj_test ();
  3528. creal_test ();
  3529. csin_test ();
  3530. csinh_test ();
  3531. csqrt_test ();
  3532. ctan_test ();
  3533. ctanh_test ();
  3534. #endif
  3535. /* Bessel functions: */
  3536. #if 0
  3537. j0_test ();
  3538. j1_test ();
  3539. jn_test ();
  3540. y0_test ();
  3541. y1_test ();
  3542. yn_test ();
  3543. #endif
  3544. if (output_ulps)
  3545. fclose (ulps_file);
  3546. printf ("\nTest suite completed:\n");
  3547. printf (" %d test cases plus %d tests for exception flags executed.\n",
  3548. noTests, noExcTests);
  3549. if (noXFails)
  3550. printf (" %d expected failures occurred.\n", noXFails);
  3551. if (noXPasses)
  3552. printf (" %d unexpected passes occurred.\n", noXPasses);
  3553. if (noErrors)
  3554. {
  3555. printf (" %d errors occurred.\n", noErrors);
  3556. return 1;
  3557. }
  3558. printf (" All tests passed successfully.\n");
  3559. return 0;
  3560. }
  3561. /*
  3562. * Local Variables:
  3563. * mode:c
  3564. * End:
  3565. */