diff options
Diffstat (limited to 'usr/src/libm/src/LD')
43 files changed, 6669 insertions, 0 deletions
diff --git a/usr/src/libm/src/LD/_TBL_cosl.c b/usr/src/libm/src/LD/_TBL_cosl.c new file mode 100644 index 0000000..128dc8a --- /dev/null +++ b/usr/src/libm/src/LD/_TBL_cosl.c @@ -0,0 +1,194 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)_TBL_cosl.c 1.9 06/01/31 SMI" + +/* + * For i = 0L, ..., 75 let x(i) be the extended precision number + * whose exponent is given by 0x3ffc + ((i + 8) >> 5) and whose + * five most significant fraction bits are given by (i + 8) & 0x1f. + * (The remaining fraction bits are zero and the integer bit is 1.) + * Then _TBL_cosl_hi[i] := cos(x(i)) rounded to extended precisionL, + * and _TBL_cosl_lo[i] ~ cos(x(i)) - _TBL_cosl_hi[i]. + */ + +#include "libm.h" + +const long double _TBL_cosl_hi[] = { + 9.8781778381647194407734133e-01L, + 9.8720237785483049041453801e-01L, + 9.8657190839949758873065125e-01L, + 9.8592638507066143575569700e-01L, + 9.8526581771821381618451860e-01L, + 9.8459021642159980601798769e-01L, + 9.8389959148966397219646454e-01L, + 9.8319395346049307253706584e-01L, + 9.8247331310125525749262290e-01L, + 9.8173768140803577633441562e-01L, + 9.8098706960566919046918752e-01L, + 9.8022148914756809622147657e-01L, + 9.7944095171554836000860772e-01L, + 9.7864546921965086785991095e-01L, + 9.7783505379795979334592304e-01L, + 9.7700971781641738478493484e-01L, + 9.7616947386863527671421389e-01L, + 9.7531433477570232649326437e-01L, + 9.7444431358598898037593275e-01L, + 9.7355942357494817143660423e-01L, + 9.7265967824491275265730642e-01L, + 9.7174509132488946761517512e-01L, + 9.7081567677034946294446077e-01L, + 9.6987144876301534501253018e-01L, + 9.6891242171064478417089050e-01L, + 9.6695002923067782202260975e-01L, + 9.6492861910477100957986285e-01L, + 9.6284831470937969988364152e-01L, + 9.6070924301556190306409372e-01L, + 9.5851153458122862729886421e-01L, + 9.5625532354317529696403552e-01L, + 9.5394074760889473397129298e-01L, + 9.5156794804817220216272555e-01L, + 9.4913706968446302764510006e-01L, + 9.4664826088605332182323443e-01L, + 9.4410167355700434565568893e-01L, + 9.4149746312788106861798448e-01L, + 9.3883578854626548865214275e-01L, + 9.3611681226705529027757452e-01L, + 9.3334070024254843565662820e-01L, + 9.3050762191231429116015580e-01L, + 9.2761775019285190965094914e-01L, + 9.2467126146703609851492875e-01L, + 9.2166833557335191816090730e-01L, + 9.1860915579491826785281383e-01L, + 9.1549390884830122858606058e-01L, + 9.1232278487211784648910212e-01L, + 9.0909597741543105166956915e-01L, + 9.0581368342593642076004609e-01L, + 9.0247610323794150491687888e-01L, + 8.9908344056013845619268129e-01L, + 8.9563590246317069891836618e-01L, + 8.9213369936699440471096142e-01L, + 8.8857704502803554333020819e-01L, + 8.8496615652614329169001889e-01L, + 8.8130125425134059916022419e-01L, + 8.7758256189037271613028607e-01L, + 8.6998471805841738884335773e-01L, + 8.6217447993488050434493855e-01L, + 8.5415375427738538514389754e-01L, + 8.4592449923106795446874767e-01L, + 8.3748872385052368529220410e-01L, + 8.2884848760932573481351876e-01L, + 8.2000589989723400824016969e-01L, + 8.1096311950521790220310775e-01L, + 8.0172235409841845058843968e-01L, + 7.9228585967717854313466241e-01L, + 7.8265594002627279692635431e-01L, + 7.7283494615247154478458735e-01L, + 7.6282527571057625053081719e-01L, + 7.5262937241806647606931838e-01L, + 7.4224972545850130697074609e-01L, + 7.3168886887382088632511210e-01L, + 7.2094938094569641805946583e-01L, + 7.1003388356607967499180972e-01L, +}; + +const long double _TBL_cosl_lo[] = { + 2.3161701550475222913914987e-20L, + -1.8449479910096732184579231e-20L, + 2.6686158961121436032543157e-20L, + -8.6377467693509323999412576e-21L, + 1.9776110020628332806497627e-20L, + -3.5925805070704800589322274e-21L, + -1.8155190558460064943241466e-20L, + -9.1900782344860461108346151e-21L, + -5.2952188498928572418662889e-21L, + 1.8052490350294447403358175e-22L, + 1.4237809112451219388907461e-22L, + 2.6375298402937478119012648e-20L, + -1.0076765547845230197228052e-20L, + 2.4356732099577389276048253e-20L, + -1.3951467830437376437362152e-20L, + 1.7110854885636746562043992e-20L, + 9.7751412348794551526570426e-21L, + -1.5984515732024779414075399e-20L, + -2.6221693743524256098098490e-20L, + 2.1708281645344702813143892e-20L, + 1.3606643184793342931047312e-20L, + 4.0913737251026449191179388e-21L, + 3.0297735892921952471510043e-21L, + -2.0186136916357220892889611e-20L, + -2.6295048282251297741856903e-20L, + -1.4268128384616571293099177e-20L, + 1.2118148575499258442724515e-21L, + 1.6059569963428104840244296e-20L, + 2.5656322072743666174102425e-21L, + 3.1051993049709377435678279e-21L, + 1.1564422287617245178214769e-20L, + 1.0031811944878086819339264e-20L, + -1.7237335190163247756143591e-20L, + 2.0747363423904458194504323e-20L, + 2.2865077385189808827392339e-20L, + -2.5671240384658541701793951e-20L, + 2.6526752505060021072717663e-20L, + -1.9564443985440576261207264e-20L, + 1.6662891366649668957364366e-20L, + -1.3289734577249155895809888e-21L, + -1.0679012486769670465318810e-20L, + -2.2918344926389240849631303e-20L, + -1.2815734598986502345856155e-20L, + 1.4504064768242345767590746e-20L, + -1.4988853557132440148049946e-20L, + -2.2142847270523120702212966e-20L, + 2.9274200155749021994272015e-21L, + -1.9187410072234352245854903e-20L, + -1.5529430996486684056198058e-20L, + 8.3043961792850937525987774e-21L, + 2.3863634821654097616646090e-20L, + -1.7796180005854437467836689e-20L, + 1.2938828814644961764053094e-20L, + -1.2599167110905505919738134e-20L, + 7.2776486597245992496949283e-21L, + -2.0062284600282808092832087e-20L, + -1.4004485599673539406695080e-20L, + -1.4442131618989703782137918e-20L, + 2.2223959244287650022010583e-20L, + -4.4575975223558432505505015e-22L, + -9.0245930394257121787744934e-21L, + 2.3149253152495269264191463e-20L, + -3.3469699832521350974745777e-21L, + 1.5380944635427999356502468e-20L, + -1.3572945384913555811651506e-20L, + 1.9052929123346841342486920e-20L, + 6.8389097769442269862154625e-21L, + 4.4331336879906155675581769e-21L, + 2.6264491975559389159451170e-20L, + -2.3718434730140290189643472e-20L, + -1.4777051948748214572130603e-20L, + 2.0601161465229389031848878e-20L, + -1.3273342027649427778913402e-20L, + -1.5653047869359238584973515e-20L, + -1.7688078635602856653655125e-20L, +}; diff --git a/usr/src/libm/src/LD/_TBL_ipio2l.c b/usr/src/libm/src/LD/_TBL_ipio2l.c new file mode 100644 index 0000000..72ce06c --- /dev/null +++ b/usr/src/libm/src/LD/_TBL_ipio2l.c @@ -0,0 +1,503 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)_TBL_ipio2l.c 1.10 06/01/31 SMI" + +/* + * Table of constants for 2/pi, used in __rem_pio2l (trigl) function. + * By K.C. Ng, April 25, 1989 + */ + +#include "libm.h" + +const int _TBL_ipio2l_inf[] = { /* by DHBailey MP package */ + 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, + 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, + 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, + 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, + 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, + 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, + 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, + 0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, + 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, + 0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, + 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, + 0x47C419, 0xC367CD, 0xDCE809, 0x2A8359, 0xC4768B, 0x961CA6, + 0xDDAF44, 0xD15719, 0x053EA5, 0xFF0705, 0x3F7E33, 0xE832C2, + 0xDE4F98, 0x327DBB, 0xC33D26, 0xEF6B1E, 0x5EF89F, 0x3A1F35, + 0xCAF27F, 0x1D87F1, 0x21907C, 0x7C246A, 0xFA6ED5, 0x772D30, + 0x433B15, 0xC614B5, 0x9D19C3, 0xC2C4AD, 0x414D2C, 0x5D000C, + 0x467D86, 0x2D71E3, 0x9AC69B, 0x006233, 0x7CD2B4, 0x97A7B4, + 0xD55537, 0xF63ED7, 0x1810A3, 0xFC764D, 0x2A9D64, 0xABD770, + 0xF87C63, 0x57B07A, 0xE71517, 0x5649C0, 0xD9D63B, 0x3884A7, + 0xCB2324, 0x778AD6, 0x23545A, 0xB91F00, 0x1B0AF1, 0xDFCE19, + 0xFF319F, 0x6A1E66, 0x615799, 0x47FBAC, 0xD87F7E, 0xB76522, + 0x89E832, 0x60BFE6, 0xCDC4EF, 0x09366C, 0xD43F5D, 0xD7DE16, + 0xDE3B58, 0x929BDE, 0x2822D2, 0xE88628, 0x4D58E2, 0x32CAC6, + 0x16E308, 0xCB7DE0, 0x50C017, 0xA71DF3, 0x5BE018, 0x34132E, + 0x621283, 0x014883, 0x5B8EF5, 0x7FB0AD, 0xF2E91E, 0x434A48, + 0xD36710, 0xD8DDAA, 0x425FAE, 0xCE616A, 0xA4280A, 0xB499D3, + 0xF2A606, 0x7F775C, 0x83C2A3, 0x883C61, 0x78738A, 0x5A8CAF, + 0xBDD76F, 0x63A62D, 0xCBBFF4, 0xEF818D, 0x67C126, 0x45CA55, + 0x36D9CA, 0xD2A828, 0x8D61C2, 0x77C912, 0x142604, 0x9B4612, + 0xC459C4, 0x44C5C8, 0x91B24D, 0xF31700, 0xAD43D4, 0xE54929, + 0x10D5FD, 0xFCBE00, 0xCC941E, 0xEECE70, 0xF53E13, 0x80F1EC, + 0xC3E7B3, 0x28F8C7, 0x940593, 0x3E71C1, 0xB3092E, 0xF3450B, + 0x9C1288, 0x7B20AB, 0x9FB52E, 0xC29247, 0x2F327B, 0x6D550C, + 0x90A772, 0x1FE76B, 0x96CB31, 0x4A1679, 0xE27941, 0x89DFF4, + 0x9794E8, 0x84E6E2, 0x973199, 0x6BED88, 0x365F5F, 0x0EFDBB, + 0xB49A48, 0x6CA467, 0x427271, 0x325D8D, 0xB8159F, 0x09E5BC, + 0x25318D, 0x3974F7, 0x1C0530, 0x010C0D, 0x68084B, 0x58EE2C, + 0x90AA47, 0x02E774, 0x24D6BD, 0xA67DF7, 0x72486E, 0xEF169F, + 0xA6948E, 0xF691B4, 0x5153D1, 0xF20ACF, 0x339820, 0x7E4BF5, + 0x6863B2, 0x5F3EDD, 0x035D40, 0x7F8985, 0x295255, 0xC06437, + 0x10D86D, 0x324832, 0x754C5B, 0xD4714E, 0x6E5445, 0xC1090B, + 0x69F52A, 0xD56614, 0x9D0727, 0x50045D, 0xDB3BB4, 0xC576EA, + 0x17F987, 0x7D6B49, 0xBA271D, 0x296996, 0xACCCC6, 0x5414AD, + 0x6AE290, 0x89D988, 0x50722C, 0xBEA404, 0x940777, 0x7030F3, + 0x27FC00, 0xA871EA, 0x49C266, 0x3DE064, 0x83DD97, 0x973FA3, + 0xFD9443, 0x8C860D, 0xDE4131, 0x9D3992, 0x8C70DD, 0xE7B717, + 0x3BDF08, 0x2B3715, 0xA0805C, 0x93805A, 0x921110, 0xD8E80F, + 0xAF806C, 0x4BFFDB, 0x0F9038, 0x761859, 0x15A562, 0xBBCB61, + 0xB989C7, 0xBD4010, 0x04F2D2, 0x277549, 0xF6B6EB, 0xBB22DB, + 0xAA140A, 0x2F2689, 0x768364, 0x333B09, 0x1A940E, 0xAA3A51, + 0xC2A31D, 0xAEEDAF, 0x12265C, 0x4DC26D, 0x9C7A2D, 0x9756C0, + 0x833F03, 0xF6F009, 0x8C402B, 0x99316D, 0x07B439, 0x15200C, + 0x5BC3D8, 0xC492F5, 0x4BADC6, 0xA5CA4E, 0xCD37A7, 0x36A9E6, + 0x9492AB, 0x6842DD, 0xDE6319, 0xEF8C76, 0x528B68, 0x37DBFC, + 0xABA1AE, 0x3115DF, 0xA1AE00, 0xDAFB0C, 0x664D64, 0xB705ED, + 0x306529, 0xBF5657, 0x3AFF47, 0xB9F96A, 0xF3BE75, 0xDF9328, + 0x3080AB, 0xF68C66, 0x15CB04, 0x0622FA, 0x1DE4D9, 0xA4B33D, + 0x8F1B57, 0x09CD36, 0xE9424E, 0xA4BE13, 0xB52333, 0x1AAAF0, + 0xA8654F, 0xA5C1D2, 0x0F3F0B, 0xCD785B, 0x76F923, 0x048B7B, + 0x721789, 0x53A6C6, 0xE26E6F, 0x00EBEF, 0x584A9B, 0xB7DAC4, + 0xBA66AA, 0xCFCF76, 0x1D02D1, 0x2DF1B1, 0xC1998C, 0x77ADC3, + 0xDA4886, 0xA05DF7, 0xF480C6, 0x2FF0AC, 0x9AECDD, 0xBC5C3F, + 0x6DDED0, 0x1FC790, 0xB6DB2A, 0x3A25A3, 0x9AAF00, 0x9353AD, + 0x0457B6, 0xB42D29, 0x7E804B, 0xA707DA, 0x0EAA76, 0xA1597B, + 0x2A1216, 0x2DB7DC, 0xFDE5FA, 0xFEDB89, 0xFDBE89, 0x6C76E4, + 0xFCA906, 0x70803E, 0x156E85, 0xFF87FD, 0x073E28, 0x336761, + 0x86182A, 0xEABD4D, 0xAFE7B3, 0x6E6D8F, 0x396795, 0x5BBF31, + 0x48D784, 0x16DF30, 0x432DC7, 0x356125, 0xCE70C9, 0xB8CB30, + 0xFD6CBF, 0xA200A4, 0xE46C05, 0xA0DD5A, 0x476F21, 0xD21262, + 0x845CB9, 0x496170, 0xE0566B, 0x015299, 0x375550, 0xB7D51E, + 0xC4F133, 0x5F6E13, 0xE4305D, 0xA92E85, 0xC3B21D, 0x3632A1, + 0xA4B708, 0xD4B1EA, 0x21F716, 0xE4698F, 0x77FF27, 0x80030C, + 0x2D408D, 0xA0CD4F, 0x99A520, 0xD3A2B3, 0x0A5D2F, 0x42F9B4, + 0xCBDA11, 0xD0BE7D, 0xC1DB9B, 0xBD17AB, 0x81A2CA, 0x5C6A08, + 0x17552E, 0x550027, 0xF0147F, 0x8607E1, 0x640B14, 0x8D4196, + 0xDEBE87, 0x2AFDDA, 0xB6256B, 0x34897B, 0xFEF305, 0x9EBFB9, + 0x4F6A68, 0xA82A4A, 0x5AC44F, 0xBCF82D, 0x985AD7, 0x95C7F4, + 0x8D4D0D, 0xA63A20, 0x5F57A4, 0xB13F14, 0x953880, 0x0120CC, + 0x86DD71, 0xB6DEC9, 0xF560BF, 0x11654D, 0x6B0701, 0xACB08C, + 0xD0C0B2, 0x485551, 0x0EFB1E, 0xC37295, 0x3B06A3, 0x3540C0, + 0x7BDC06, 0xCC45E0, 0xFA294E, 0xC8CAD6, 0x41F3E8, 0xDE647C, + 0xD8649B, 0x31BED9, 0xC397A4, 0xD45877, 0xC5E369, 0x13DAF0, + 0x3C3ABA, 0x461846, 0x5F7555, 0xF5BDD2, 0xC6926E, 0x5D2EAC, + 0xED440E, 0x423E1C, 0x87C461, 0xE9FD29, 0xF3D6E7, 0xCA7C22, + 0x35916F, 0xC5E008, 0x8DD7FF, 0xE26A6E, 0xC6FDB0, 0xC10893, + 0x745D7C, 0xB2AD6B, 0x9D6ECD, 0x7B723E, 0x6A11C6, 0xA9CFF7, + 0xDF7329, 0xBAC9B5, 0x5100B7, 0x0DB2E2, 0x24BA74, 0x607DE5, + 0x8AD874, 0x2C150D, 0x0C1881, 0x94667E, 0x162901, 0x767A9F, + 0xBEFDFD, 0xEF4556, 0x367ED9, 0x13D9EC, 0xB9BA8B, 0xFC97C4, + 0x27A831, 0xC36EF1, 0x36C594, 0x56A8D8, 0xB5A8B4, 0x0ECCCF, + 0x2D8912, 0x34576F, 0x89562C, 0xE3CE99, 0xB920D6, 0xAA5E6B, + 0x9C2A3E, 0xCC5F11, 0x4A0BFD, 0xFBF4E1, 0x6D3B8E, 0x2C86E2, + 0x84D4E9, 0xA9B4FC, 0xD1EEEF, 0xC9352E, 0x61392F, 0x442138, + 0xC8D91B, 0x0AFC81, 0x6A4AFB, 0xD81C2F, 0x84B453, 0x8C994E, + 0xCC2254, 0xDC552A, 0xD6C6C0, 0x96190B, 0xB8701A, 0x649569, + 0x605A26, 0xEE523F, 0x0F117F, 0x11B5F4, 0xF5CBFC, 0x2DBC34, + 0xEEBC34, 0xCC5DE8, 0x605EDD, 0x9B8E67, 0xEF3392, 0xB817C9, + 0x9B5861, 0xBC57E1, 0xC68351, 0x103ED8, 0x4871DD, 0xDD1C2D, + 0xA118AF, 0x462C21, 0xD7F359, 0x987AD9, 0xC0549E, 0xFA864F, + 0xFC0656, 0xAE79E5, 0x362289, 0x22AD38, 0xDC9367, 0xAAE855, + 0x382682, 0x9BE7CA, 0xA40D51, 0xB13399, 0x0ED7A9, 0x480569, + 0xF0B265, 0xA7887F, 0x974C88, 0x36D1F9, 0xB39221, 0x4A827B, + 0x21CF98, 0xDC9F40, 0x5547DC, 0x3A74E1, 0x42EB67, 0xDF9DFE, + 0x5FD45E, 0xA4677B, 0x7AACBA, 0xA2F655, 0x23882B, 0x55BA41, + 0x086E59, 0x862A21, 0x834739, 0xE6E389, 0xD49EE5, 0x40FB49, + 0xE956FF, 0xCA0F1C, 0x8A59C5, 0x2BFA94, 0xC5C1D3, 0xCFC50F, + 0xAE5ADB, 0x86C547, 0x624385, 0x3B8621, 0x94792C, 0x876110, + 0x7B4C2A, 0x1A2C80, 0x12BF43, 0x902688, 0x893C78, 0xE4C4A8, + 0x7BDBE5, 0xC23AC4, 0xEAF426, 0x8A67F7, 0xBF920D, 0x2BA365, + 0xB1933D, 0x0B7CBD, 0xDC51A4, 0x63DD27, 0xDDE169, 0x19949A, + 0x9529A8, 0x28CE68, 0xB4ED09, 0x209F44, 0xCA984E, 0x638270, + 0x237C7E, 0x32B90F, 0x8EF5A7, 0xE75614, 0x08F121, 0x2A9DB5, + 0x4D7E6F, 0x5119A5, 0xABF9B5, 0xD6DF82, 0x61DD96, 0x023616, + 0x9F3AC4, 0xA1A283, 0x6DED72, 0x7A8D39, 0xA9B882, 0x5C326B, + 0x5B2746, 0xED3400, 0x7700D2, 0x55F4FC, 0x4D5901, 0x8071E0, + 0xE13F89, 0xB295F3, 0x64A8F1, 0xAEA74B, 0x38FC4C, 0xEAB2BB, + 0x47270B, 0xABC3A7, 0x34BA60, 0x52DD34, 0xF8563A, 0xEB7E8A, + 0x31BB36, 0x5895B7, 0x47F7A9, 0x94C3AA, 0xD39225, 0x1E7F3E, + 0xD8974E, 0xBBA94F, 0xD8AE01, 0xE661B4, 0x393D8E, 0xA523AA, + 0x33068E, 0x1633B5, 0x3BB188, 0x1D3A9D, 0x4013D0, 0xCC1BE5, + 0xF862E7, 0x3BF28F, 0x39B5BF, 0x0BC235, 0x22747E, 0xA247C0, + 0xD52D1F, 0x19ADD3, 0x9094DF, 0x9311D0, 0xB42B25, 0x496DB2, + 0xE264B2, 0x5EF135, 0x3BC6A4, 0x1A4AD0, 0xAAC92E, 0x64E886, + 0x573091, 0x982CFB, 0x311B1A, 0x08728B, 0xBDCEE1, 0x60E142, + 0xEB641D, 0xD0BBA3, 0xE559D4, 0x597B8C, 0x2A4483, 0xF332BA, + 0xF84867, 0x2C8D1B, 0x2FA9B0, 0x50F3DD, 0xF9F573, 0xDB61B4, + 0xFE233E, 0x6C41A6, 0xEEA318, 0x775A26, 0xBC5E5C, 0xCEA708, + 0x94DC57, 0xE20196, 0xF1E839, 0xBE4851, 0x5D2D2F, 0x4E9555, + 0xD96EC2, 0xE7D755, 0x6304E0, 0xC02E0E, 0xFC40A0, 0xBBF9B3, + 0x7125A7, 0x222DFB, 0xF619D8, 0x838C1C, 0x6619E6, 0xB20D55, + 0xBB5137, 0x79E809, 0xAF9149, 0x0D73DE, 0x0B0DA5, 0xCE7F58, + 0xAC1934, 0x724667, 0x7A1A13, 0x9E26BC, 0x4555E7, 0x585CB5, + 0x711D14, 0x486991, 0x480D60, 0x56ADAB, 0xD62F64, 0x96EE0C, + 0x212FF3, 0x5D6D88, 0xA67684, 0x95651E, 0xAB9E0A, 0x4DDEFE, + 0x571010, 0x836A39, 0xF8EA31, 0x9E381D, 0xEAC8B1, 0xCAC96B, + 0x37F21E, 0xD505E9, 0x984743, 0x9FC56C, 0x0331B7, 0x3B8BF8, + 0x86E56A, 0x8DC343, 0x6230E7, 0x93CFD5, 0x6A8F2D, 0x733005, + 0x1AF021, 0xA09FCB, 0x7415A1, 0xD56B23, 0x6FF725, 0x2F4BC7, + 0xB8A591, 0x7FAC59, 0x5C55DE, 0x212C38, 0xB13296, 0x5CFF50, + 0x366262, 0xFA7B16, 0xF4D9A6, 0x2ACFE7, 0xF07403, 0xD4D604, + 0x6FD916, 0x31B1BF, 0xCBB450, 0x5BD7C8, 0x0CE194, 0x6BD643, + 0x4FD91C, 0xDF4543, 0x5F3453, 0xE2B5AA, 0xC9AEC8, 0x131485, + 0xF9D2BF, 0xBADB9E, 0x76F5B9, 0xAF15CF, 0xCA3182, 0x14B56D, + 0xE9FE4D, 0x50FC35, 0xF5AED5, 0xA2D0C1, 0xC96057, 0x192EB6, + 0xE91D92, 0x07D144, 0xAEA3C6, 0x343566, 0x26D5B4, 0x3161E2, + 0x37F1A2, 0x209EFF, 0x958E23, 0x493798, 0x35F4A6, 0x4BDC02, + 0xC2BE13, 0xBE80A0, 0x0B72A3, 0x115C5F, 0x1E1BD1, 0x0DB4D3, + 0x869E85, 0x96976B, 0x2AC91F, 0x8A26C2, 0x3070F0, 0x041412, + 0xFC9FA5, 0xF72A38, 0x9C6878, 0xE2AA76, 0x50CFE1, 0x559274, + 0x934E38, 0x0A92F7, 0x5533F0, 0xA63DB4, 0x399971, 0xE2B755, + 0xA98A7C, 0x008F19, 0xAC54D2, 0x2EA0B4, 0xF5F3E0, 0x60C849, + 0xFFD269, 0xAE52CE, 0x7A5FDD, 0xE9CE06, 0xFB0AE8, 0xA50CCE, + 0xEA9D3E, 0x3766DD, 0xB834F5, 0x0DA090, +}; + +#if 0 +const int _TBL_ipio2l_66[] = { + 0xA2F983, 0x6E4E44, 0x152A00, 0x062BC4, 0x0DA276, 0xBED4C1, + 0xFDF905, 0x5CD5BA, 0x767CEC, 0x1F80D6, 0xC26053, 0x3A0070, + 0x107C2A, 0xF68EE9, 0x687B7A, 0xB990AA, 0x38DE4B, 0x96CFF3, + 0x92735E, 0x8B34F6, 0x195BFC, 0x27F88E, 0xA93EC5, 0x3958A5, + 0x3E5D13, 0x1C55A8, 0x5B4A8B, 0xA42E04, 0x12D105, 0x35580D, + 0xF62347, 0x450900, 0xB98BCA, 0xF7E8A4, 0xA2E5D5, 0x69BC52, + 0xF0381D, 0x1A0A88, 0xFE8714, 0x7F6735, 0xBB7D4D, 0xC6F642, + 0xB27E80, 0x6191BF, 0xB6B750, 0x52776E, 0xD60FD0, 0x607DCC, + 0x68BFAF, 0xED69FC, 0x6EB305, 0xD2557D, 0x25BDFB, 0x3E4AA1, + 0x84472D, 0x8B0376, 0xF77740, 0xD290DF, 0x15EC8C, 0x45A5C3, + 0x6181EF, 0xC5E7E8, 0xD8909C, 0xF62144, 0x298428, 0x6E5D9D, + 0xF9A9B4, 0xCDBD2F, 0xC083E7, 0x0D3957, 0xECA3B2, 0x96223C, + 0xC1080D, 0x087D47, 0x7D7576, 0xA614B1, 0x42A4B6, 0xAA173C, + 0xE217E5, 0xFDCD34, 0x279D5F, 0x39AACA, 0x1CA8DF, 0x8B6633, + 0x5C49E4, 0xB56803, 0x1E7938, 0x741FDC, 0x4CB19B, 0xCECC3B, + 0x921EB7, 0x7C0FC3, 0x361F23, 0xF9EE22, 0xBA4235, 0xA5FCA3, + 0xBD4680, 0xFCDF65, 0xFC96AD, 0x31C90C, 0x919EEB, 0xFE0FB7, + 0x75B4B0, 0x693961, 0x75BCAA, 0xEB6F39, 0xA343C0, 0xD16FF2, + 0x33DAD0, 0xC1E095, 0x053182, 0x11E4A1, 0x40F943, 0x32D314, + 0xAF1B98, 0xE1B05A, 0xE5F3AD, 0x6E633F, 0x363D14, 0xA3777C, + 0xC8C6EE, 0x001E18, 0x0D180C, 0xAA1369, 0xEDFBA2, 0x998A9D, + 0x16E799, 0x693B75, 0x90EF50, 0x938DD4, 0xFB7ACD, 0x67CEEB, + 0x249DE3, 0x9B9B52, 0xD8CDAC, 0xC31A54, 0x855FBF, 0x848591, + 0x0954B0, 0x946B8C, 0xA4C7B4, 0x9A9E51, 0xF20425, 0xAA2637, + 0xFC6657, 0x7D8625, 0x620B74, 0x8B578D, 0xEC9A05, 0xDEF24F, + 0x7F19B0, 0xFC2544, 0x1DA0F1, 0x23790C, 0xC4294D, 0x6D3C32, + 0x66FE56, 0xD45562, 0x66264F, 0xA24162, 0x13E930, 0xB0E7C0, + 0xFA0E97, 0xBFC62C, 0x0E663F, 0x90F33B, 0x55E73C, 0xD791F7, + 0xD3F00D, 0xAB01C7, 0x40CF8F, 0xA593BA, 0xE627D5, 0x4A8308, + 0x32DC06, 0x80C876, 0x1C3DB5, 0xB5489F, 0x632CDF, 0xB02517, + 0xD17EFA, 0x92570F, 0xFAED44, 0x8F8536, 0x27069B, 0xC014DC, + 0x997D48, 0x961D61, 0x7A960B, 0x31B622, 0xD3C425, 0xA69520, + 0x98D29E, 0xF1C973, 0x5483D7, 0x99611E, 0xEAFF5F, 0x7DEFF1, + 0x98475C, 0x91C787, 0x537E17, 0x068C65, 0xF05E52, 0x942F04, + 0x37CF92, 0xEF4223, 0xC4C52F, 0x521DAA, 0xBAAF97, 0x972236, + 0xA2B3D3, 0x62C921, 0x8D3A8B, 0x2B3302, 0x6061B9, 0x0CBE94, + 0x75F451, 0xBD06DE, 0x86042D, 0xFB61ED, 0x4C8869, 0x590232, + 0x479963, 0x23518D, 0xAF5D28, 0x60C9DE, 0x473DB0, 0x9DE009, + 0xD8FC4C, 0xE96991, 0x9CA455, 0x800BC8, 0x977CE0, 0xDCBFA6, + 0x19D249, 0xA0F76D, 0x5F9B2F, 0x452BB3, 0x77E091, 0xB6383A, + 0x7BE9C2, 0x4BF7C1, 0x8A5EBF, 0xEB0D55, 0x9AF4DC, 0x275CA0, + 0xED09D0, 0xE50A7F, 0xBEF42C, 0x4803AF, 0x56139F, 0xD58848, + 0x797D96, 0xB8352E, 0x49D90D, 0x7607E0, 0xC99256, 0x75F530, + 0xB72237, 0x1AF080, 0xC2E813, 0x06CFA9, 0xB9DF8E, 0x919C38, + 0x89D97E, 0x0464D5, 0xB12EEF, 0xD14165, 0x365A72, 0x550D35, + 0x3772D8, 0xF41B58, 0x0378A7, 0x2D5D7D, 0xD6E433, 0xDD2018, + 0x139FD7, 0x1B5621, 0x94E046, 0x97A323, 0x693176, 0x28DF59, + 0xD24273, 0x0E4E26, 0xA9A8F6, 0xF15B41, 0x450EE3, 0x57EA61, + 0x7DADA6, 0xF21086, 0x394BEE, 0x8F4813, 0x3FDEE9, 0xF3A53D, + 0xAB2F40, 0x8B1E2B, 0xA07FD4, 0x992CC4, 0x63532D, 0x9F35A2, + 0x6FA290, 0x0094DE, 0xD2A24D, 0x755B81, 0x79F9E1, 0xFE1D35, + 0xFEE8CC, 0x9224C5, 0x54E2CE, 0x41F31C, 0xF45138, 0xED6D10, + 0x6B439D, 0xD2BE46, 0xC327D4, 0x68BFB0, 0x46D5A5, 0x79B285, + 0x776D7C, 0xE18647, 0x00E32F, 0xEBB7F2, 0x5DE307, 0x5A8EA0, + 0x06CEFE, 0x20923C, 0x354CE1, 0xAD09C5, 0x56996D, 0xCFB124, + 0xEF7BC1, 0x76BF72, 0xF20753, 0x5BBAFA, 0xB8A2B2, 0x5914F2, + 0x5D834F, 0xE64A08, 0x14C3AB, 0x07796B, 0xF2212D, 0xC74049, + 0xB61C6A, 0x282CFC, 0x25070C, 0x315BF1, 0x6FEAD3, 0x2CD2E5, + 0xD10F9C, 0x1972BB, 0x908073, 0x0F368C, 0x69BE97, 0xA242B0, + 0x722DFE, 0xAFE6A2, 0x143D8B, 0x5C5699, 0x48232B, 0xFF49AC, + 0xB5FA62, 0x6AD778, 0x7A844D, 0x258AA0, 0x8EDE3D, 0x9A9496, + 0x49924E, 0xA33E97, 0x4F43FA, 0xC40741, 0x2F764A, 0x8EB2B1, + 0x8E67D3, 0x9FF324, 0x51B11B, 0x5D6E09, 0xE9AD3E, 0xFFA902, + 0xF48653, 0x0845D3, 0xDED33E, 0x32D30E, 0x6247CA, 0x7C586D, + 0x2EAF9E, 0x323A35, 0xAD11FB, 0x0F420C, 0x0E0685, 0x401B60, + 0xBB3D43, 0xF4D489, 0xBCDC4C, 0x40FFBA, 0x18AB08, 0x7AC72D, + 0x5E76DB, 0xE8344E, 0x3975A2, 0xF9611B, 0x1121F3, 0x3A429C, + 0x9B18EC, 0xF298B1, 0x8AEC78, 0x1C248B, 0x69108F, 0xDB2D37, + 0xA1A613, 0x910359, 0x521451, 0xD4441F, 0x0BB3B6, 0x50D9DB, + 0xBD589F, 0x62A62E, 0xA9B903, 0x935F63, 0x058BEC, 0x78BCB5, + 0x2CB460, 0x3A9037, 0x0291C4, 0x1FABC1, 0xBE7D05, 0xF948E7, + 0x6BA5CD, 0xF62A0A, 0x9AEA19, 0x2257AB, 0x2E0D7D, 0x9EB93F, + 0x5E3F77, 0xD4A13F, 0x08E3DB, 0xDFD689, 0x2B9B4E, 0xB58427, + 0x25424B, 0x1197FD, 0xCF298A, 0x314008, 0xD5687F, 0x0F0EAC, + 0x13C485, 0xF684B2, 0xED7EC7, 0x6E636D, 0x28C933, 0xE19058, + 0x688B6A, 0xC88905, 0xFB2F31, 0x61304C, 0xC19765, 0x60D81A, + 0x57F276, 0xC6EFC4, 0x048954, 0x303470, 0xDA6F6F, 0x93901A, + 0x911439, 0x363D12, 0x59E72B, 0x6F9F1E, 0x57C584, 0xDF0D23, + 0xBB743F, 0xADE99C, 0x546097, 0xFCC820, 0xCBB968, 0xDA9B5F, + 0x0DC271, 0x563337, 0x9ED662, 0xE7C44F, 0x3129F8, 0xF5EAF9, + 0xDAF7F2, 0xCD09FF, 0xA92535, 0x441C29, 0x7DF436, 0xE2B00A, + 0x36746F, 0xF1DC61, 0x9D3C9C, 0x63AB71, 0xB8F3BB, 0x1C80F6, + 0x62FF65, 0x5FFE5F, 0x3B2814, 0xBADE27, 0x1B384B, 0x268AA9, + 0xBD91EF, 0xCA436B, 0xABE107, 0x88DCA6, 0xC3AFC0, 0x85D155, + 0x464A48, 0xBFDAEB, 0xC6F389, 0x907C11, 0x0D3E41, 0xCD2197, + 0x549008, 0x817E4E, 0x8C7154, 0x1DC37F, 0x5E897E, 0xA9A2FE, + 0xEC6060, 0xCC0728, 0x430D3B, 0x62471C, 0xD3A4D3, 0x2BA57B, + 0xE5D15A, 0xD632F3, 0xF2B76F, 0xEC8498, 0xAE41C2, 0xAAF413, + 0xEAF5C0, 0xDD1B07, 0xB9A2A0, 0x59F230, 0xA3F61B, 0x8F8643, + 0x05DE6B, 0x1B5B8E, 0x63ECC5, 0xBFF01D, 0x8F1440, 0x3F8ADF, + 0x2E6539, 0xF3DB7A, 0x293FE5, 0x7EE714, 0x88E6D8, 0x2B2A6A, + 0xDF6E34, 0x8D4604, 0x4F6594, 0x639063, 0x6B51CC, 0x0D05CD, + 0x009607, 0xE7BF70, 0xC9A0EA, 0x0D80DD, 0xA1A065, 0x0DCB8F, + 0xA48430, 0x715934, 0x6FC8E4, 0x6FFC52, 0xEF8B05, 0xDE506A, + 0xE62BBC, 0x31480F, 0xEA64EA, 0x51E6FB, 0x9AE773, 0x21C54D, + 0xBFA080, 0x273D1E, 0x9FFD4E, 0x0C2CA8, 0x0690A5, 0xF8773B, + 0x4B2680, 0x6E3F56, 0xC8B89F, 0x0B7BD0, 0x71C8BF, 0x5AABD3, + 0x2BA93E, 0x9D2EE1, 0xCDF2FA, 0xEE57BE, 0x84A116, 0xDA756D, + 0x8FD6C0, 0x927153, 0xFF5EF3, 0x9F8331, 0x713411, 0xF945F3, + 0x0382B2, 0x8BAE30, 0xBC45A4, 0x630101, 0x5C9C3A, 0x643CFD, + 0x48115C, 0x17F03E, 0xB5F55E, 0x288DAF, 0x725660, 0xFB58E0, + 0xFC189E, 0x1ECA69, 0xFB19A6, 0xFA7A92, 0x7CC48E, 0x869372, + 0x58089A, 0x16DB5C, 0xADC0CD, 0x09D3D4, 0xD1108E, 0xDC64ED, + 0x3A999C, 0xAA8716, 0x5A3D8E, 0x7037FB, 0x1976AD, 0xE477D7, + 0x23782B, 0xC51F39, 0x4A5E9A, 0xDAD9DA, 0xE5B559, 0x08EF06, + 0x76E24F, 0x7361AD, 0x5F42A3, 0x9B70E5, 0xCE96C4, 0x552E99, + 0x6D7A6F, 0x804474, 0x4FA45B, 0x1D115B, 0x6D109E, 0x0A1A63, + 0x1084A6, 0xE18E5D, 0x2D8589, 0x203345, 0x4851AF, 0xA71EDC, + 0x03B6B1, 0x267970, 0xDEC908, 0x795BED, 0x7099B9, 0x209321, + 0x7FC2E7, 0x0F3E5E, 0xC7A4F4, 0x088129, 0x59AE63, 0x4E3251, + 0x344268, 0x79285D, 0x2B9494, 0xF1E2A2, 0xF7DA20, 0xDF6756, + 0xCA3BA3, 0x422489, 0xA2239C, 0x38724D, 0x2AC767, 0x601E9D, + 0xB47C6C, 0xA22481, 0xBBB655, 0x1EC0C4, 0xD84A97, 0xD449EE, + 0x162C9D, 0x782F29, 0xCEB4FA, 0xE317BC, 0x2FFDBD, 0xB342D2, + 0xB2CB19, 0x323AB9, 0x1AFF93, 0x13A8DF, 0x86B5A5, 0x5741D6, + 0xC54342, 0x3CAC29, 0xF7517C, 0x129A7A, 0xB2B8B4, 0x9B709F, + 0x3923C5, 0xEAFA6E, 0xDB9077, 0x29EEA0, 0x702D8C, 0x4DC14F, + 0xE46933, 0xA764E4, 0x754266, 0xFA4F98, 0x643DA5, 0xCA775C, + 0x7F1632, 0xE671A3, 0x4BF4C6, 0xA82378, 0xEFD317, 0xE62D38, + 0xD461C9, 0x8EEC80, 0xC89882, 0x4CC73C, 0x830F3F, 0xE4B200, + 0x582615, 0x6CD558, 0xA66727, 0xEF7975, 0xFEA5CE, 0x147A40, + 0x4796E4, 0xC07761, 0xF5D5B3, 0x6B65FB, 0xE4F14D, 0xA837CA, + 0x9A152A, 0x554E94, 0x83EC5F, 0xA62174, 0x85E2ED, 0xCCE71C, + 0x3540FF, 0x088A84, 0xBA2816, 0x293610, 0x4C3EE7, 0x8E55A9, + 0x49E5E5, 0x782178, 0x45D2AA, 0x9BB449, 0x00D282, 0xF61E67, + 0xE2F7DE, 0xCC6AA1, 0xCD1979, 0x52FEDB, 0x9A8776, 0x70A018, + 0x500271, 0x1273BA, 0xDE648E, 0x7AC7F7, 0x767725, 0xD0A457, + 0xF17250, 0xBC578C, 0x2DFD3A, 0x97F988, 0xA576C8, 0x8129BB, + 0x22D9C3, 0x0436ED, 0x650791, 0xA314EC, 0x42A0B3, 0x37A521, + 0x4BFB2B, 0x8C1B7F, 0x115E17, 0xF7C27F, 0xC1D5EB, 0x060487, + 0x8A28D6, 0x41330F, 0xBFAE67, 0x7774E8, 0x4CCC3C, 0x6B2F80, + 0x628BF2, 0x1E41A6, 0x8D0B22, 0xBC85BA, 0xCCF461, 0xBEC69C, + 0xDF8A10, 0x3C5E71, 0x2F8D5F, 0x63D3DA, 0x5934D1, 0x2CA35D, + 0xC687A2, 0x24E9B4, 0x1843D3, 0x5C9B97, 0x9B580C, 0x780B2C, + 0x59943D, 0x0744D0, 0x8DA6E3, 0x07AAF6, 0x2214D0, 0x72E8D7, + 0x54151B, 0x514DE9, 0x8DCC3B, 0x0CEB00, 0x2C4DE3, 0x5012AE, + 0xD7B72E, 0xB7DE9A, 0x641B2F, 0xF9CF17, 0x8BD282, 0x9F31A3, + 0xDED846, 0x467E05, 0x26CCEA, 0xF8E404, 0x65572E, 0x82C594, + 0xE572A9, 0x895653, 0xA1AA94, 0x8DD876, 0x5E9A61, 0x69EB1C, + 0x0385A9, 0x5BC844, 0x95B2DF, 0x6678F6, 0xFA7033, 0xE4F434, + 0x5584A9, 0x32C099, 0x9AD846, 0xB3FFD1, 0xA81C56, 0x4E54EF, + 0x54D173, 0xF191B4, 0x49B2A2, 0xB309D9, 0x546D8D, 0xC0A51E, + 0xCAFFC0, 0x785400, 0x05F69D, 0x894056, 0xC33098, 0xDFF6C2, + 0x908D97, 0x05CC96, 0x46484B, 0xBD7B9D, 0xB152F5, 0x5A7461, + 0x59CA20, 0x8F8EF5, 0xC9FF05, 0xF6F398, 0x856C97, 0x81E07C, + 0xAE5EDA, 0x51BDC9, 0xF26437, 0xBBC8CE, 0x091B52, 0x68B6A5, + 0x90750E, 0x925EF9, 0x3D9CB3, 0x46EA96, 0x97D648, 0x78BCC7, + 0xF4B488, 0x05275E, 0x6619DF, 0x56D4A0, 0x8C5C41, 0xDB345A, + 0x0B79DA, 0x496369, 0x96109B, 0x667664, 0xC40CF9, 0x91D7CA, + 0x119F1A, 0xA99272, 0xCBB529, 0xBB033E, 0x8F91C0, 0x570045, + 0xB845C2, 0x2B8E52, 0x687AFB, 0x0D0AA3, 0x200863, 0x043B83, + 0xF129DE, 0x49C2D6, 0x9641D2, 0xC4747C, 0x220804, 0x503F05, + 0x7E274F, 0xCA83D9, 0x9D6495, 0x0E5039, +}; +const int _TBL_ipio2l_53[] = { + 0xA2F983, 0x6E4E44, 0x16F3C4, 0xEA69B5, 0xD3E131, 0x60E1D2, + 0xD7982A, 0xC031F5, 0xD67BCC, 0xFD1375, 0x60919B, 0x3FA0BB, + 0x612ABB, 0x714F9B, 0x03DA8A, 0xC05948, 0xD023F4, 0x5AFA37, + 0x51631D, 0xCD7A90, 0xC0474A, 0xF6A6F3, 0x1A52E1, 0x5C3927, + 0x3ADA45, 0x4E2DB5, 0x64E8C4, 0x274A5B, 0xB74ADC, 0x1E6591, + 0x2822BE, 0x4771F5, 0x12A63F, 0x83BD35, 0x2488CA, 0x1FE1BE, + 0x42C21A, 0x682569, 0x2AFB91, 0x68ADE1, 0x4A42E5, 0x9BE357, + 0xB79675, 0xCE998A, 0x83AF8B, 0xE645E6, 0xDF0789, 0x9E9747, + 0xAA15FF, 0x358C3F, 0xAF3141, 0x72A3F7, 0x2BF1D4, 0xF3AD96, + 0x7D759F, 0x257FCE, 0x29FB69, 0xB1B42C, 0xC32DE1, 0x8C0BBD, + 0x31EC2F, 0x942026, 0x85DCE7, 0x653FF3, 0x136FA7, 0x0D7A5F, + 0x93FC61, 0x035287, 0xC77FCA, 0x73530A, 0xC6BC15, 0x0E4B0F, + 0x568FCE, 0x2D3456, 0x4D7FE1, 0xA12CD1, 0xB2CEA2, 0x531C62, + 0x70B4D2, 0x1BCE9A, 0x87704D, 0x6B83D7, 0xAA8121, 0x2530EA, + 0x2074BF, 0x28A071, 0x9D69C3, 0x406DD8, 0xF58783, 0x115D89, + 0x5E85F3, 0xAACDCC, 0x8C0B57, 0xD7DFFE, 0x550D96, 0xC43EB4, + 0x89ABA7, 0x94F595, 0x56F260, 0x06A4CD, 0x7FD2E2, 0x6FDFA8, + 0x3E9C98, 0xBFD682, 0xAD3A12, 0x23A8A6, 0x173A89, 0x5DE9BD, + 0x95A978, 0x28E484, 0x5964F3, 0x496AF0, 0x4B1DA9, 0x989061, + 0xBD2BF2, 0xE01A90, 0x0905B7, 0xAC39AC, 0x52D5B7, 0x109F25, + 0x3AE1DC, 0xF90A7C, 0x33F4E5, 0xF5DFDF, 0x1522D0, 0x562CE6, + 0x392CFF, 0xEB9032, 0x10A08E, 0x0B1D7F, 0x42B80A, 0x366DD2, + 0xC24F89, 0x02222E, 0x21494C, 0x985287, 0x87FD07, 0x2EE361, + 0xAD8D68, 0xE72273, 0x9E8D59, 0xD09999, 0x10F4A1, 0x1079A3, + 0xE9BEAF, 0x9C0887, 0x09C622, 0xEBCF06, 0x974532, 0x086A8F, + 0x6CEA05, 0x388C00, 0x74969E, 0xC85B16, 0x385A38, 0x9A2F35, + 0x670531, 0xABA6D0, 0xEFD3C1, 0x27AD92, 0xF4203E, 0x3D619F, + 0x4D05F4, 0x9AE7CC, 0x03B592, 0x41FF55, 0xCAFCA5, 0x1A0987, + 0x88AB79, 0x3627D4, 0x25B12A, 0x52594A, 0xA2BEB0, 0x25C3F2, + 0x4489DA, 0x7959A7, 0xEAEC89, 0xB34714, 0x960196, 0x1FC33A, + 0x7F0275, 0x32EF92, 0x0111CE, 0x8E4685, 0x6F5B34, 0xF6123A, + 0x5543B2, 0xE9A02A, 0x74E03F, 0x54D5A8, 0x086A2C, 0x4A9CD3, + 0x921191, 0x229764, 0x0A1A84, 0x9B45AE, 0xC653A5, 0xB15F33, + 0x100FD1, 0x7DD740, 0xB20CD3, 0x0A0786, 0xF506C3, 0x25EBF4, + 0x3AB39E, 0xE3BB24, 0x27646F, 0xEECE57, 0x706BFE, 0xC7A869, + 0x57ED51, 0x118C82, 0x2B0FF5, 0xC8E545, 0xC43D80, 0x2A3183, + 0x4C1BB9, 0xBC108A, 0x099779, 0xF9ECC8, 0x2A1063, 0x5D2F6A, + 0x8F2675, 0x12FF6D, 0x32EED9, 0xE4A245, 0x7392CF, 0x5C240B, + 0xC476FF, 0x97AFC7, 0xB76131, 0x665E05, 0x67BD57, 0x19E998, + 0x3A5863, 0x23B8AA, 0x5B5608, 0x8A66C6, 0x5F2AD3, 0x78BAFA, + 0x3516CE, 0xCBEA16, 0x6E40D4, 0xB463D4, 0xA6C12F, 0xABD3D7, + 0x32650A, 0x579D10, 0x3CB9E2, 0x1A02A7, 0xDF2FFA, 0x28C991, + 0xB2264C, 0x027870, 0x47BDD4, 0xF243B1, 0x39AE2C, 0x282EA4, + 0xAF1D98, 0x2AFD16, 0xABE7AF, 0x17CB67, 0x8FF93E, 0x793167, + 0x435F6B, 0x48058B, 0x417DA0, 0xE01217, 0x085A69, 0xB50E36, + 0x79A4CD, 0xD74907, 0x26C4B5, 0xB90054, 0x06C3AD, 0x5AB38F, + 0x585E91, 0xD04E4F, 0x2938CE, 0xD4EAA7, 0xA06DE5, 0x40BFE5, + 0xDE6849, 0xEF65F0, 0xF1D4BB, 0x94C21E, 0x66E978, 0x1B9B94, + 0x961043, 0x5961B8, 0xBAAA74, 0xD662EE, 0x9DABF6, 0x0AFE28, + 0x9587A4, 0xA632BC, 0x09149F, 0xDEA996, 0x2CAFD7, 0xBDE29B, + 0x7159E6, 0x1F7C49, 0xF2E2ED, 0xBFA992, 0x7C77EF, 0xC245D0, + 0xB2D129, 0x993E75, 0xAB4C0C, 0x5C84B6, 0x17F542, 0x45314E, + 0x1DEF1B, 0xE3BDCC, 0xB3AE86, 0x24522F, 0x918FC6, 0x2138D5, + 0x883646, 0x6858B6, 0x032762, 0x5170F8, 0x4974EA, 0x76BF77, + 0xECDA8A, 0x9EADDD, 0x2404EF, 0xC52A5D, 0xF2E858, 0xC42D60, + 0xD18C08, 0xDE59B2, 0x4CC3A6, 0x94D888, 0x4C4AF0, 0xCF1F8C, + 0xBF2F6F, 0x7B4535, 0x98B0DB, 0x2BE0CF, 0x4616A7, 0xA8D9FB, + 0x88CA7A, 0x5087E1, 0x18DD8A, 0x1A9F4F, 0x1DCECE, 0xF8609E, + 0xE2F0C8, 0x9AD7D4, 0xE3CDFE, 0xC6FDD5, 0x8FF3CD, 0x7D45AA, + 0xD34957, 0x7C1963, 0x6CE098, 0xB70215, 0x326BBF, 0x47B3A6, + 0xF9235D, 0x6F66F5, 0xC6E40C, 0xE7F50B, 0xFF2FDD, 0x5A1251, + 0xE95EF1, 0xDE8E67, 0xECEE9B, 0xC9F98E, 0x722224, 0x6DF750, + 0x81D08F, 0x2BFCF0, 0xDDC10D, 0x775314, 0xDB1D87, 0x41626B, + 0x9EDF31, 0x7738D9, 0x8D9EB4, 0x4F1C2A, 0xF3E795, 0xB69699, + 0xD9A56D, 0x31BB1B, 0x542975, 0xAB917B, 0x63927C, 0x9BB764, + 0x84A598, 0x0A0C51, 0x5E48C4, 0x7780E3, 0x87E156, 0x155972, + 0xE406F8, 0x48AB9E, 0x3CCDDA, 0x010F87, 0x683B70, 0x400CAD, + 0x5DE5C5, 0x7262FA, 0xFA248D, 0x013AF2, 0xE2E8B5, 0x995F7D, + 0x7F8C4B, 0x0E8B59, 0x1006F1, 0x40B6E9, 0x760654, 0xCBCC8C, + 0x086F40, 0xDC7F6F, 0xFCD0D4, 0xA47ADE, 0x5204FA, 0xF38A9D, + 0xE76C7C, 0x575207, 0x499BF1, 0x0DB01C, 0x09098E, 0x957A71, + 0xD53E0E, 0x61DF1D, 0xE6EF34, 0x5821EC, 0x96BCC0, 0xDC96CE, + 0xA9C0AE, 0x130B2C, 0xCCC589, 0x829BB9, 0x2A75BA, 0x97611C, + 0x0CEAB8, 0x165D9D, 0x35AD41, 0x82A805, 0x975628, 0x5601A6, + 0x074F08, 0x80A27D, 0xEFA64E, 0xD7BB4B, 0x5E6397, 0xC92FFC, + 0x4F3F7A, 0xBEA764, 0x0C9B7D, 0xC5DC74, 0xEAD216, 0x6DBBC0, + 0x913E3E, 0xABF50B, 0x95B24A, 0x3FC9C5, 0xE7BA15, 0x8C7F70, + 0xF81358, 0x774606, 0xCE8C0D, 0xB6B268, 0xB85BA6, 0xAC9B2E, + 0x1AAB05, 0x0C6C82, 0x6EC2AE, 0x606874, 0x8F60BF, 0x1FBC7B, + 0x58C97A, 0x448794, 0xBA48A0, 0x72E882, 0x6D3568, 0xE131FD, + 0x4745D0, 0x0BFA1E, 0x07B01D, 0x474D43, 0x59387E, 0x5B0AD5, + 0xC37A8C, 0x0474E8, 0x13D99D, 0x68A13C, 0xB69118, 0x89228C, + 0x6F7D83, 0x86D665, 0x5C7744, 0xDD183E, 0x1C2E17, 0x712F5E, + 0x4AACCB, 0xB69B68, 0xA1201F, 0x743C2B, 0xF6AD70, 0x92E024, + 0xF34FD8, 0x33712E, 0xFE1D73, 0x4471F0, 0x7D0526, 0x58AF47, + 0x7B11FE, 0x1FCE4F, 0x1356C9, 0x9CE3CA, 0xA843C0, 0x8EEA3C, + 0xABEEE4, 0xA5D495, 0xA407A4, 0x31BB4B, 0x0AA1E3, 0x518E7C, + 0xAA4A66, 0xD82CD8, 0x6EF8D2, 0x6F32E6, 0x1DC26B, 0x17AE59, + 0x4B683B, 0x8D48F7, 0xF4FBD8, 0xD4FE0A, 0xE961DE, 0x87BD37, + 0xE6CCD6, 0xCBD76D, 0x3E99DE, 0xB72E21, 0x54EB90, 0x6AB45D, + 0x600AFB, 0xA17B2F, 0xDA0421, 0xE6CA95, 0x35AAA2, 0x7D8FB1, + 0x3207BB, 0xBF82EE, 0x71F55F, 0xC661CB, 0xBD72A1, 0xBF5A64, + 0x6E39E8, 0x6C6DE2, 0x2BD178, 0xAF62A5, 0xA7D86E, 0xE7D0FE, + 0x84DB03, 0x67FDA2, 0x2D6809, 0x0F8B8F, 0x1B50E3, 0x234EF5, + 0x7325ED, 0x8F8F4C, 0xC1E426, 0x3066AD, 0x0759A4, 0xE03390, + 0x70CC9A, 0x524F77, 0xCDD489, 0x97DD24, 0xA81858, 0xF24513, + 0xA9C18E, 0x2A2F82, 0xC2C014, 0xB8E7F0, 0x934036, 0xD36E51, + 0xD9A089, 0xDBC587, 0xB30418, 0x969192, 0x0A5213, 0xE21841, + 0x2881EC, 0x9A293F, 0x0DF705, 0x85B497, 0xE430B9, 0xE90ECF, + 0xC15FDC, 0x9E8A7E, 0xC5472D, 0xB54FBD, 0x456AF2, 0xCA80B6, + 0xAE25FE, 0xA03B46, 0x6C6CFD, 0x78382A, 0x0E7877, 0x7F2D31, + 0x03C827, 0x61CF52, 0x339A2F, 0x2286A9, 0xE41DF0, 0x640F5C, + 0xBEF364, 0x010506, 0x6D2C21, 0x841EFF, 0x7F3B5D, 0xD98DC8, + 0x0F9421, 0xA25B0C, 0x4C2C44, 0x922392, 0xB98A8A, 0x6179B9, + 0xF7B419, 0x289AAF, 0xE92F47, 0x5E47A2, 0x82927F, 0xC7290E, + 0x6C925C, 0xBA5A3C, 0x8FB7F6, 0x9C4BEE, 0x02C529, 0x0CFCD7, + 0x5EBD8C, 0x7196E0, 0x4B917E, 0x6B9780, 0x6A1731, 0xA617FF, + 0x27A20D, 0x5A56A3, 0x43C4DB, 0xC62EA4, 0x637A84, 0x1C46F9, + 0x33C780, 0x61A278, 0x4915C9, 0xD6C776, 0x6A7C66, 0xD8DD0C, + 0xF87EB1, 0x124C43, 0x5B87E7, 0x097456, 0x3C2FA7, 0x307C4A, + 0x54267A, 0x30E34E, 0xC0CF98, 0xD75B19, 0xFADEDB, 0x12CBE8, + 0x29F24C, 0x579C7E, 0xBF3682, 0xDCB460, 0xAE08B3, 0xA524BC, + 0xC181C2, 0x5DAB90, 0x466602, 0x55345B, 0xA13941, 0x47D820, + 0x278066, 0x81B089, 0x165EFB, 0x4D27FD, 0x2BF9F4, 0x2E2FFB, + 0x6106B5, 0xE76806, 0x445A84, 0x0BDA0D, 0x49D7A4, 0x72650D, + 0xCDC55B, 0x3E16BC, 0x132F6F, 0x29E8FD, 0xE58428, 0x621E41, + 0x7D2AC4, 0xAB5697, 0xAC61EB, 0xE5DAF0, 0x654ED6, 0x8E77E3, + 0x0B2FBC, 0x2E63A3, 0xC8296A, 0x8B631F, 0x4ECCA6, 0x91859C, + 0x9E3E45, 0x0E3CC7, 0xC12454, 0xCCBCB6, 0x17979E, 0xD0D374, + 0xA489A2, 0xC6258F, 0xE8EF9E, 0x12EE26, 0xC614C2, 0x62E23E, + 0xCA8C5C, 0x409AC9, 0x511D05, 0xA88CE0, 0x195500, 0xF7144F, + 0x913BB7, 0x17D064, 0xF6C9CE, 0xAC5D11, 0xD0C313, 0xBCCCB6, + 0xAAD4FC, 0xE47B2C, 0xFE4362, 0xF2E712, 0x2D5EFF, 0x833822, + 0x58A1D7, 0x68377C, 0xE49B25, 0x22B179, 0x048796, 0x069400, + 0xE670D3, 0xD2CB85, 0x55FBE6, 0x67F281, 0xFE2DE0, 0x8CFAF2, + 0x9865BC, 0x210CD3, 0x86DD70, 0x43D00F, 0x55E279, 0x679252, + 0x8D4F58, 0xE17AC5, 0x6A6127, 0x1B0876, 0x5D8ED0, 0x701330, + 0xD5BD25, 0xC9A126, 0x57C571, 0xDC5C3F, 0xB6D34E, 0xB72383, + 0x001A9E, 0x7D36C0, 0x8151F6, 0x65D7C1, 0xE1F513, 0xCD372A, + 0xE69B0C, 0xD02685, 0x23C3EB, 0x3544CB, 0xF0BE31, 0x83F399, + 0xCB93F8, 0xFFC693, 0x908EC6, 0x8E5DE1, 0x315B7E, 0x67CE7B, + 0x40AAF7, 0x7FD285, 0x069B36, 0x03C00A, 0x13C7D5, 0x0DA14C, + 0x1EAAD4, 0x2B777F, 0x8E05C1, 0x5AD1AE, 0x60C398, 0xA4EA59, + 0x10BEED, 0x88F2FA, 0x69B941, 0xA54E70, 0xA817C3, 0xB96246, + 0xE8EEDC, 0x56D570, 0xBBEBB5, 0xD8F235, 0x201AB9, 0x9CC747, + 0x5BC2FB, 0xC877F3, 0x428CF6, 0x4EEF84, 0xBF85FD, 0xEE6D34, + 0x84C2DE, 0xC42F4C, 0x1A513B, 0x9AC41F, 0x87FFFA, 0x1CA431, + 0x714252, 0xC73FB9, 0x662D89, 0x3D83BA, 0xBDF046, 0x2E4F62, + 0x76B7C0, 0x81336C, 0xBE80A9, 0x4C9D72, 0x739A15, 0x47972C, + 0xA36A1B, 0xD31731, 0x54BA46, 0x2E8C72, 0xFEA5A5, 0x9A7E5F, + 0xC359ED, 0x8F0FFB, 0x1270DA, 0x5E9B08, 0xB0BFCB, 0x36974C, + 0x6CD8F9, 0xD02E1F, 0x1C3F2F, 0xFCF8F0, 0x4C2C6D, 0x0B2169, + 0x48B9CE, 0x42737D, 0xA8E974, 0x64062D, 0xA86C59, 0xEEC419, + 0x047C83, 0x996A23, 0xF2A4C8, 0x4BE1B8, 0x348286, 0xE84240, + 0x8337CB, 0xE55A2F, 0xC17750, 0xA4DA06, 0x64347F, 0x59A5A1, + 0xDFF53D, 0x62A571, 0xEECF3A, 0x886700, 0xC06DAF, 0x4E161F, + 0x12670E, 0xBDFE1A, 0xA72B38, 0x5BA22C, 0xFED227, 0x3FC814, + 0x150E5A, 0xE99B3A, 0x8EE9FC, 0xBC1845, 0x32373A, 0xBDA476, + 0xCEB88F, 0x7FAED3, 0xDB9116, 0x31CF72, 0x1A5136, 0xC4F362, + 0xDE4799, 0x768043, 0x386207, 0x8E5497, 0xB0EF6D, 0x6C57FB, + 0xF56664, 0xD24F05, 0xE0F702, 0x8A41EF, 0xA2EC53, 0x09731C, + 0x6157FE, 0xC5731C, 0xEF1A2E, 0x60EC10, 0xA67EFE, 0x486A73, + 0x8004F6, 0xC3F482, 0x63BA28, 0x107282, +}; +#endif diff --git a/usr/src/libm/src/LD/_TBL_sinl.c b/usr/src/libm/src/LD/_TBL_sinl.c new file mode 100644 index 0000000..4eb95a8 --- /dev/null +++ b/usr/src/libm/src/LD/_TBL_sinl.c @@ -0,0 +1,194 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)_TBL_sinl.c 1.9 06/01/31 SMI" + +/* + * For i = 0L, ..., 75 let x(i) be the extended precision number + * whose exponent is given by 0x3ffc + ((i + 8) >> 5) and whose + * five most significant fraction bits are given by (i + 8) & 0x1f. + * (The remaining fraction bits are zero and the integer bit is 1.) + * Then _TBL_sinl_hi[i] := sin(x(i)) rounded to extended precisionL, + * and _TBL_sinl_lo[i] ~ sin(x(i)) - _TBL_sinl_hi[i]. + */ + +#include "libm.h" + +const long double _TBL_sinl_hi[] = { + 1.5561499277355604121432509e-01L, + 1.5947245893184341994353297e-01L, + 1.6332749173661285085207024e-01L, + 1.6718003236480673437500555e-01L, + 1.7103002203139501927501524e-01L, + 1.7487740199027218989302670e-01L, + 1.7872211353515365937804412e-01L, + 1.8256409800047155539783929e-01L, + 1.8640329676226988454758749e-01L, + 1.9023965123909906176839606e-01L, + 1.9407310289290979115543571e-01L, + 1.9790359322994628465735775e-01L, + 2.0173106380163880472144652e-01L, + 2.0555545620549551765724079e-01L, + 2.0937671208599364370531084e-01L, + 2.1319477313546989061102989e-01L, + 2.1700958109501015675778940e-01L, + 2.2082107775533849055107655e-01L, + 2.2462920495770529235180901e-01L, + 2.2843390459477474541995223e-01L, + 2.3223511861151146241076006e-01L, + 2.3603278900606633373558587e-01L, + 2.3982685783066156443802536e-01L, + 2.4361726719247488600575847e-01L, + 2.4740395925452292959266856e-01L, + 2.5496596041587846749013231e-01L, + 2.6251239976915328146124702e-01L, + 2.7004281671858503154006088e-01L, + 2.7755675164633632592044860e-01L, + 2.8505374594054742458945975e-01L, + 2.9253334202332754361585744e-01L, + 2.9999508337868305117438275e-01L, + 3.0743851458038085066887951e-01L, + 3.1486318131974525087106269e-01L, + 3.2226863043338662567511427e-01L, + 3.2965440993086017192298214e-01L, + 3.3702006902225307624892253e-01L, + 3.4436515814569840820730424e-01L, + 3.5168922899481405922451731e-01L, + 3.5899183454606505366498749e-01L, + 3.6627252908604756136416898e-01L, + 3.7353086823869294642950362e-01L, + 3.8076640899239019207055991e-01L, + 3.8797870972702504604426484e-01L, + 3.9516733024093423623426119e-01L, + 4.0233183177777311122311904e-01L, + 4.0947177705329506611003562e-01L, + 4.1658673028204111924766885e-01L, + 4.2367625720393801036934428e-01L, + 4.3073992511080319721861361e-01L, + 4.3777730287275513286178799e-01L, + 4.4478796096452721142060563e-01L, + 4.5177147149168377657582618e-01L, + 4.5872740821673659236961014e-01L, + 4.6565534658516018269211988e-01L, + 4.7255486375130445115036980e-01L, + 4.7942553860420300028150759e-01L, + 4.9307868575392305727079882e-01L, + 5.0661145481425736764773474e-01L, + 5.2002054195372700474845132e-01L, + 5.3330267353602017331871271e-01L, + 5.4645460691920356440616155e-01L, + 5.5947313124736687740433047e-01L, + 5.7235506823450724037203458e-01L, + 5.8509727294046215482874185e-01L, + 5.9769663453870153121657086e-01L, + 6.1015007707579137127265265e-01L, + 6.2245456022234368301943030e-01L, + 6.3460708001526929683284300e-01L, + 6.4660466959115237050095826e-01L, + 6.5844439991056754159573505e-01L, + 6.7012338047316289465094724e-01L, + 6.8163876002333416675559724e-01L, + 6.9298772724631791026551897e-01L, + 7.0416751145453367277888060e-01L, +}; + +const long double _TBL_sinl_lo[] = { + -4.4044420388485708604352042e-21L, + -9.3658505779466794663857779e-22L, + -5.2040678607071393508410817e-21L, + -4.0395267481940078256007650e-21L, + 6.3327332576496468315469778e-21L, + 2.6586707822142093837984364e-21L, + -2.6878787450050744237345282e-21L, + 1.7063635662305595250654237e-21L, + 4.7924921282538555045455343e-21L, + -4.4101691066939302183010470e-21L, + 6.1948600915447822830980496e-22L, + -4.9638413649749502251618971e-21L, + 3.5916271597651546227926473e-21L, + -4.0777150323673712797756569e-22L, + 6.5799136599779898603647660e-21L, + 5.0431441802236271279596547e-21L, + 2.7886967636804383702412094e-21L, + 1.7797941915507094664564119e-21L, + -1.3804554392939635583829251e-21L, + 4.7855981187615466625152631e-21L, + 3.1708211390406997503004900e-21L, + -1.5157834044725652569873263e-22L, + 3.3438946731684019204631903e-21L, + 6.4724798056855877111175401e-21L, + 4.1801428671953314697839700e-21L, + -2.5757365367012227482016023e-21L, + -1.0297394515771810295074032e-20L, + 1.2694179637735656722464528e-20L, + 1.5748512781011179565308673e-21L, + -1.6967184859202905792705521e-21L, + 8.8448858652331336251731737e-21L, + -1.1134468969040340293241825e-20L, + 1.6234471791025321420471804e-21L, + -6.0263738196054484651751291e-21L, + 1.2631652295822646843414172e-20L, + -8.6644101687582762853694906e-21L, + 1.2359222174923859397271358e-20L, + -1.3219821587241831508027981e-22L, + -1.9324110998995296922101291e-21L, + 1.2722808830089214240915385e-20L, + 8.7403704479785940299212466e-21L, + -1.2663863629342751015966219e-20L, + -1.3359206065200525634208487e-20L, + 6.8148547822187652382727319e-21L, + 1.0571450573402892191582257e-20L, + -6.0134413552023063129130024e-21L, + 1.2658405457632407447211937e-20L, + 1.1443598275137284797608912e-20L, + -7.6602922503647693246330011e-21L, + -2.2920876394624080624512678e-21L, + -1.6901640257671788285214336e-22L, + 1.2450383440926973698285013e-20L, + 5.8625687909310643361252782e-21L, + 7.6848891207540014891539434e-21L, + -1.0920363727912466924531705e-20L, + -3.8184802762435242280438906e-21L, + -8.2196498741416868399433703e-21L, + -5.6622687407305065056015130e-21L, + -5.4387357437209102117877930e-21L, + 1.1762381857741709383097597e-20L, + 1.0418391756080576218864700e-20L, + -2.8119958331524728369894697e-21L, + -1.9486464776808433575964276e-20L, + 1.2919131320458122775352322e-20L, + -2.3342533395278737494836457e-20L, + 2.2076763147253802020227787e-20L, + 1.0897468372542621634126622e-21L, + 2.2496400209117994020651730e-20L, + 1.7466909662624346932394383e-20L, + 2.3083902445127091336067492e-20L, + -6.1510978111621596519832919e-21L, + 3.5843424075843715436394953e-21L, + -2.2355288181001597796661994e-20L, + 1.6296521874464521140945741e-20L, + 1.1789113655896899561477559e-21L, +}; diff --git a/usr/src/libm/src/LD/_TBL_tanl.c b/usr/src/libm/src/LD/_TBL_tanl.c new file mode 100644 index 0000000..1104207 --- /dev/null +++ b/usr/src/libm/src/LD/_TBL_tanl.c @@ -0,0 +1,194 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)_TBL_tanl.c 1.9 06/01/31 SMI" + +/* + * For i = 0L, ..., 75 let x(i) be the extended precision number + * whose exponent is given by 0x3ffc + ((i + 8) >> 5) and whose + * five most significant fraction bits are given by (i + 8) & 0x1f. + * (The remaining fraction bits are zero and the integer bit is 1.) + * Then _TBL_tanl_hi[i] := tan(x(i)) rounded to extended precisionL, + * and _TBL_tanl_lo[i] ~ tan(x(i)) - _TBL_tanl_hi[i]. + */ + +#include "libm.h" + +const long double _TBL_tanl_hi[] = { + 1.5753410732527161068790289e-01L, + 1.6153978404952147631388516e-01L, + 1.6555051927393397620861225e-01L, + 1.6956644521976651014845677e-01L, + 1.7358769476798152084980487e-01L, + 1.7761440147744672763405801e-01L, + 1.8164669960332142765752766e-01L, + 1.8568472411563441162006289e-01L, + 1.8972861071805913288790962e-01L, + 1.9377849586689186352228293e-01L, + 1.9783451679023866881187727e-01L, + 2.0189681150741713288741981e-01L, + 2.0596551884857887210688535e-01L, + 2.1004077847455898084587031e-01L, + 2.1412273089695866488913964e-01L, + 2.1821151749846743250413339e-01L, + 2.2230728055343133087249762e-01L, + 2.2641016324867383747423879e-01L, + 2.3052030970457614146129199e-01L, + 2.3463786499642367899603687e-01L, + 2.3876297517602592026663300e-01L, + 2.4289578729361654240565243e-01L, + 2.4703644942004126466383960e-01L, + 2.5118511066924076739260464e-01L, + 2.5534192122103626651019939e-01L, + 2.6368059641999679984405817e-01L, + 2.7205369865877088343545168e-01L, + 2.8046247014525140317325012e-01L, + 2.8890817244051472599780488e-01L, + 2.9739208726902458947518627e-01L, + 3.0591551735305926411887835e-01L, + 3.1447978727257151616261872e-01L, + 3.2308624435174552010563084e-01L, + 3.3173625957357276734381764e-01L, + 3.4043122852383038743446717e-01L, + 3.4917257236591035224446307e-01L, + 3.5796173884801699838350761e-01L, + 3.6680020334432342273152904e-01L, + 3.7568946993175484041940608e-01L, + 3.8463107250414922303567364e-01L, + 3.9362657592563275821902387e-01L, + 4.0267757722514021178576021e-01L, + 4.1178570683410847577655099e-01L, + 4.2095262986947582208789413e-01L, + 4.3018004746423004901363651e-01L, + 4.3946969814786624047050871e-01L, + 4.4882335927923970884728319e-01L, + 4.5824284853443236696884759e-01L, + 4.6773002545239179993303603e-01L, + 4.7728679304125226171028919e-01L, + 4.8691509944840632450355038e-01L, + 4.9661693969756562569970761e-01L, + 5.0639435749622981205141092e-01L, + 5.1624944711717514451250130e-01L, + 5.2618435535777914417981255e-01L, + 5.3620128358121603136601796e-01L, + 5.4630248984379051326943158e-01L, + 5.6676706558058644568054429e-01L, + 5.8759736759144322142123240e-01L, + 6.0881374032438072139072557e-01L, + 6.3043767383588476685765678e-01L, + 6.5249189792880799270563541e-01L, + 6.7500048514424290766085257e-01L, + 6.9798896362359925515245207e-01L, + 7.2148444099090441996918396e-01L, + 7.4551574055939199512374818e-01L, + 7.7011355134420870501661335e-01L, + 7.9531059356867418562312202e-01L, + 8.2114180158989412189243090e-01L, + 8.4764452644655265410892839e-01L, + 8.7485876055448234952464232e-01L, + 9.0282738745267350217570818e-01L, + 9.3159645994407246116005700e-01L, + 9.6121551049437041616208335e-01L, + 9.9173789836326868026407724e-01L, +}; + +const long double _TBL_tanl_lo[] = { + -2.6771159409105731701405510e-21L, + -4.6099226789741262900210606e-21L, + 5.3186644140375322820802458e-21L, + 2.5138405830938633735686839e-21L, + -5.1314617057806432706999694e-21L, + -2.3150818458524320771936317e-21L, + 7.4823150688409589857878346e-22L, + 6.5983384951777057330962451e-21L, + 3.1737465070309238679637904e-21L, + -6.2605330413009742107992404e-21L, + -3.4708968895421512574248288e-21L, + -3.3508177722855547163047103e-21L, + 1.8539761255947162282442845e-21L, + -4.3527863815358994574071238e-21L, + -3.0729582373746958079080308e-21L, + 1.7486583794617176080777995e-21L, + -2.0880427643688559927261666e-22L, + 3.4326156341633317484064051e-21L, + -5.8444712515543005993510667e-21L, + 3.3308393583864583403400180e-21L, + 1.5180609545016167494014088e-21L, + -4.5664864992230118395870971e-21L, + -3.4486635382887607253671356e-22L, + 6.4992471510018586950169590e-21L, + -5.7171552644357921603079772e-21L, + 1.0767820312749142840542796e-20L, + -8.8873094864264944929118678e-21L, + -3.6458345495736833933253427e-21L, + 3.7835691968285101289024150e-21L, + -7.9922577212991920007926665e-21L, + -1.1639426061963512311797196e-20L, + 1.0819496381458482697046145e-20L, + 1.2669812351932848585361942e-20L, + -4.3879352642165387665557942e-21L, + -6.2397232294970361376981025e-21L, + 1.0249894624181563425318369e-20L, + 4.8883545518509990780582976e-21L, + -1.0924217224719888561366811e-20L, + -1.0160304466598813882209781e-20L, + 5.1826415091471411711448075e-21L, + 1.0389918683332972349077236e-20L, + -7.1664776574714262163862363e-21L, + 1.2298884220333748071625466e-20L, + -1.3099990378137383497651040e-20L, + 6.6930911371536844477108605e-21L, + 1.3154437144468699485999317e-20L, + -6.7276672708135125503950130e-21L, + -9.6583948799780933132703713e-21L, + -1.1693327591353762422287158e-20L, + 1.2115072030396340314945014e-20L, + -4.8328734014430698289025015e-21L, + 1.0852973061445293626693228e-20L, + 1.9411831283588255256712679e-20L, + -2.0725962316575506668083850e-20L, + -9.1991091819589918968351350e-21L, + -1.8439030785497371079388971e-20L, + -1.4252114398617735096821730e-20L, + -3.6634999903039053547935623e-22L, + -2.7073538111310219812185487e-20L, + 2.1768400635771833866020006e-20L, + -5.0453509036808273670769239e-21L, + 1.8262326404957249986102613e-20L, + 2.3253788272891224529527726e-21L, + -2.6863465601726641017825874e-21L, + 2.0333919445169836552474035e-20L, + 1.2381983326738354735338055e-20L, + -1.0629693225258909983165405e-20L, + 2.2479666845586239075466463e-20L, + 1.8993064919061156630226362e-20L, + -1.8140078592138587341953739e-20L, + 1.5029592868184122759494625e-20L, + 2.0466189644006868146496769e-20L, + 5.1457594757697525471406575e-21L, + 2.3217272240793119168128789e-20L, + -7.2198528398134119662230907e-21L, +}; diff --git a/usr/src/libm/src/LD/__cosl.c b/usr/src/libm/src/LD/__cosl.c new file mode 100644 index 0000000..ddd9f50 --- /dev/null +++ b/usr/src/libm/src/LD/__cosl.c @@ -0,0 +1,143 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)__cosl.c 1.7 06/01/31 SMI" + +/* INDENT OFF */ +/* + * __k_cosl( long double x; long double y ) + * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * + * Table look up algorithm + * 1. by cos(-x) = cos(x), we may replace x by |x| + * 2. if x < 25/128 = [0x3ffc4000, 0] = 0.15625 , then + * if x < 2^-57 (hx < 0x3fc60000 0), return 1.0 with inexact if x!= 0 + * z = x*x; + * if x <= 1/128 = 2**-7 = 0.0078125 + * cos(x)=1.0+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5)))) + * else + * cos(x)=1.0+z*(q1+ ... z*q8) + * 3. else + * ht = (hx + 0x400)&0x7ffff800 (round x to a break point t) + * lt = 0 + * i = (hy-0x3ffc4000)>>11; (i<=64) + * x' = (x - t)+y (|x'| ~<= 2^-7 + * By + * cos(t+x') + * = cos(t)cos(x')-sin(t)sin(x') + * = cos(t)(1+z*(qq1+z*qq2))-[sin(t)]*x*(1+z*(pp1+z*pp2)) + * = cos(t) + [cos(t)]*(z*(qq1+z*qq2))- + * [sin(t)]*x*(1+z*(pp1+z*pp2)) + * + * Thus, + * let a= _TBL_cos_hi[i], b = _TBL_cos_lo[i], c= _TBL_sin_hi[i], + * x = (x-t)+y + * z = x*x; + * cos(t+x) = a+(b+ (-c*x*(1+z*(pp1+z*pp2))+a*(z*(qq1+z*qq2))) + */ + +#include "libm.h" + +extern const long double _TBL_cosl_hi[], _TBL_cosl_lo[], _TBL_sinl_hi[]; +static const long double +one = 1.0, +/* + * |sin(x) - (x+pp1*x^3+...+ pp5*x^11 )| <= 2^-122.32 for |x|<1/64 + */ +pp1 = -1.666666666666666666666666666586782940810e-0001L, +pp2 = 8.333333333333333333333003723660929317540e-0003L, +pp3 = -1.984126984126984076045903483778337804470e-0004L, +pp4 = 2.755731922361906641319723106210900949413e-0006L, +pp5 = -2.505198398570947019093998469135012057673e-0008L, +/* + * + * |cos(x) - (1+q1*x^2+...+q8*x^16)| <= 2^-117.11 for |x|<= 0.15625 + */ +q1 = -4.999999999999999999999999999999756416975e-0001L, +q2 = 4.166666666666666666666666664006066577258e-0002L, +q3 = -1.388888888888888888888877700363937169637e-0003L, +q4 = 2.480158730158730158494468463031814083559e-0005L, +q5 = -2.755731922398586276322819250356005542871e-0007L, +q6 = 2.087675698767424261441959760729854017855e-0009L, +q7 = -1.147074481239662089072452129010790774761e-0011L, +q8 = 4.777761647399651599730663422263531034782e-0014L, +/* + * + * |cos(x) - (1+qq1*x^2+...+ qq5*x^10)| <= 2^-123.84 for |x|<=1/128 + */ +qq1 = -4.999999999999999999999999999999378373641e-0001L, +qq2 = 4.166666666666666666666665478399327703130e-0002L, +qq3 = -1.388888888888888888058211230618051613494e-0003L, +qq4 = 2.480158730156105377771585658905303111866e-0005L, +qq5 = -2.755728099762526325736488376695157008736e-0007L; +/* INDENT ON */ +long double +__k_cosl(long double x, long double y) { + long double a, t, z, w; + int *pt = (int *) &t, *px = (int *) &x; + int i, j, hx, ix; + + t = 1.0; +#if !defined(__i386) && !defined(__amd64) + hx = px[0]; +#else + XTOI(px, hx); +#endif + ix = hx & 0x7fffffff; + if (ix < 0x3ffc4000) { + if (ix < 0x3fc60000) + if ((i = (int) x) == 0) + return (one); /* generate inexact */ + z = x * x; + + if (ix < 0x3ff80000) /* 0.0078125 */ + return (one + z * (qq1 + z * (qq2 + z * (qq3 + z * + (qq4 + z * qq5))))); + else + return (one + z * (q1 + z * (q2 + z * (q3 + z * (q4 + + z * (q5 + z * (q6 + z * (q7 + z * q8)))))))); + } + j = (ix + 0x400) & 0x7ffff800; + i = (j - 0x3ffc4000) >> 11; +#if !defined(__i386) && !defined(__amd64) + pt[0] = j; +#else + ITOX(j, pt); +#endif + if (hx > 0) + x = y - (t - x); + else + x = (-y) - (t + x); + a = _TBL_cosl_hi[i]; + z = x * x; + t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); + w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * + pp5))))); + t = _TBL_cosl_lo[i] - (_TBL_sinl_hi[i] * w - a * t); + return (a + t); +} diff --git a/usr/src/libm/src/LD/__lgammal.c b/usr/src/libm/src/LD/__lgammal.c new file mode 100644 index 0000000..ce59cfe --- /dev/null +++ b/usr/src/libm/src/LD/__lgammal.c @@ -0,0 +1,395 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)__lgammal.c 1.4 06/01/31 SMI" + +/* long double __k_lgammal(long double x, int *signgamlp); + * K.C. Ng, August, 1989. + * + * We choose [1.5,2.5] to be the primary interval. Our algorithms + * are mainly derived from + * + * + * zeta(2)-1 2 zeta(3)-1 3 + * lgamma(2+s) = s*(1-euler) + --------- * s - --------- * s + ... + * 2 3 + * + * + * Note 1. Since gamma(1+s)=s*gamma(s), hence + * lgamma(1+s) = log(s) + lgamma(s), or + * lgamma(s) = lgamma(1+s) - log(s). + * When s is really tiny (like roundoff), lgamma(1+s) ~ s(1-enler) + * Hence lgamma(s) ~ -log(s) for tiny s + * + */ + +#include "libm.h" +#include "libm_synonyms.h" +#include "longdouble.h" + +static long double neg(long double, int *); +static long double poly(long double, const long double *, int); +static long double polytail(long double); +static long double primary(long double); + +static const long double +c0 = 0.0L, +ch = 0.5L, +c1 = 1.0L, +c2 = 2.0L, +c3 = 3.0L, +c4 = 4.0L, +c5 = 5.0L, +c6 = 6.0L, +pi = 3.1415926535897932384626433832795028841971L, +tiny = 1.0e-40L; + +long double +__k_lgammal(long double x, int *signgamlp) { + long double t,y; + int i; + + /* purge off +-inf, NaN and negative arguments */ + if(!finitel(x)) return x*x; + *signgamlp = 1; + if(signbitl(x)) return(neg(x,signgamlp)); + + /* for x < 8.0 */ + if(x<8.0L) { + y = anintl(x); + i = (int) y; + switch(i) { + case 0: + if(x<1.0e-40L) return -logl(x); else + return (primary(x)-log1pl(x))-logl(x); + case 1: + return primary(x-y)-logl(x); + case 2: + return primary(x-y); + case 3: + return primary(x-y)+logl(x-c1); + case 4: + return primary(x-y)+logl((x-c1)*(x-c2)); + case 5: + return primary(x-y)+logl((x-c1)*(x-c2)*(x-c3)); + case 6: + return primary(x-y)+logl((x-c1)*(x-c2)*(x-c3)*(x-c4)); + case 7: + return primary(x-y)+logl((x-c1)*(x-c2)*(x-c3)*(x-c4)*(x-c5)); + case 8: + return primary(x-y)+ + logl((x-c1)*(x-c2)*(x-c3)*(x-c4)*(x-c5)*(x-c6)); + } + } + + /* 8.0 <= x < 1.0e40 */ + if (x < 1.0e40L) { + t = logl(x); + return x*(t-c1)-(ch*t-polytail(c1/x)); + } + + /* 1.0e40 <= x <= inf */ + return x*(logl(x)-c1); +} + +static const long double an1[] = { /* 20 terms */ + -0.0772156649015328606065120900824024309741L, + 3.224670334241132182362075833230130289059e-0001L, + -6.735230105319809513324605383668929964120e-0002L, + 2.058080842778454787900092432928910226297e-0002L, + -7.385551028673985266273054086081102125704e-0003L, + 2.890510330741523285758867304409628648727e-0003L, + -1.192753911703260976581414338096267498555e-0003L, + 5.096695247430424562831956662855697824035e-0004L, + -2.231547584535777978926798502084300123638e-0004L, + 9.945751278186384670278268034322157947635e-0005L, + -4.492623673665547726647838474125147631082e-0005L, + 2.050721280617796810096993154281561168706e-0005L, + -9.439487785617396552092393234044767313568e-0006L, + 4.374872903516051510689234173139793159340e-0006L, + -2.039156676413643091040459825776029327487e-0006L, + 9.555777181318621470466563543806211523634e-0007L, + -4.468344919709630637558538313482398989638e-0007L, + 2.216738086090045781773004477831059444178e-0007L, + -7.472783403418388455860445842543843485916e-0008L, + 8.777317930927149922056782132706238921648e-0008L, +}; + +static const long double an2[] = { /* 20 terms */ + -.0772156649015328606062692723698127607018L, + 3.224670334241132182635552349060279118047e-0001L, + -6.735230105319809367555642883133994818325e-0002L, + 2.058080842778459676880822202762143671813e-0002L, + -7.385551028672828216011343150077846918930e-0003L, + 2.890510330762060607399561536905727853178e-0003L, + -1.192753911419623262328187532759756368041e-0003L, + 5.096695278636456678258091134532258618614e-0004L, + -2.231547306817535743052975194022893369135e-0004L, + 9.945771461633313282744264853986643877087e-0005L, + -4.492503279458972037926876061257489481619e-0005L, + 2.051311416812082875492678651369394595613e-0005L, + -9.415778282365955203915850761537462941165e-0006L, + 4.452428829045147098722932981088650055919e-0006L, + -1.835024727987632579886951760650722695781e-0006L, + 1.379783080658545009579060714946381462565e-0006L, + 2.282637532109775156769736768748402175238e-0007L, + 1.002577375515900191362119718128149880168e-0006L, + 5.177028794262638311939991106423220002463e-0007L, + 3.127947245174847104122426445937830555755e-0007L, +}; + +static const long double an3[] = { /* 20 terms */ + -.0772156649015328227870646417729220690875L, + 3.224670334241156699881788955959915250365e-0001L, + -6.735230105312273571375431059744975563170e-0002L, + 2.058080842924464587662846071337083809005e-0002L, + -7.385551008677271654723604653956131791619e-0003L, + 2.890510536479782086197110272583833176602e-0003L, + -1.192752262076857692740571567808259138697e-0003L, + 5.096800771149805289371135155128380707889e-0004L, + -2.231000836682831335505058492409860123647e-0004L, + 9.968912171073936803871803966360595275047e-0005L, + -4.412020779327746243544387946167256187258e-0005L, + 2.281374113541454151067016632998630209049e-0005L, + -4.028361291428629491824694655287954266830e-0006L, + 1.470694920619518924598956849226530750139e-0005L, + 1.381686137617987197975289545582377713772e-0005L, + 2.012493539265777728944759982054970441601e-0005L, + 1.723917864208965490251560644681933675799e-0005L, + 1.202954035243788300138608765425123713395e-0005L, + 5.079851887558623092776296577030850938146e-0006L, + 1.220657945824153751555138592006604026282e-0006L, +}; + +static const long double an4[] = { /* 21 terms */ + -.0772156649015732285350261816697540392371L, + 3.224670334221752060691751340365212226097e-0001L, + -6.735230109744009693977755991488196368279e-0002L, + 2.058080778913037626909954141611580783216e-0002L, + -7.385557567931505621170483708950557506819e-0003L, + 2.890459838416254326340844289785254883436e-0003L, + -1.193059036207136762877351596966718455737e-0003L, + 5.081914708100372836613371356529568937869e-0004L, + -2.289855016133600313131553005982542045338e-0004L, + 8.053454537980585879620331053833498511491e-0005L, + -9.574620532104845821243493405855672438998e-0005L, + -9.269085628207107155601445001196317715686e-0005L, + -2.183276779859490461716196344776208220180e-0004L, + -3.134834305597571096452454999737269668868e-0004L, + -3.973878894951937437018305986901392888619e-0004L, + -3.953352414899222799161275564386488057119e-0004L, + -3.136740932204038779362660900621212816511e-0004L, + -1.884502253819634073946130825196078627664e-0004L, + -8.192655799958926853585332542123631379301e-0005L, + -2.292183750010571062891605074281744854436e-0005L, + -3.223980628729716864927724265781406614294e-0006L, +}; + +static const long double ap1[] = { /* 19 terms */ + -0.0772156649015328606065120900824024296961L, + 3.224670334241132182362075833230047956465e-0001L, + -6.735230105319809513324605382963943777301e-0002L, + 2.058080842778454787900092126606252375465e-0002L, + -7.385551028673985266272518231365020063941e-0003L, + 2.890510330741523285681704570797770736423e-0003L, + -1.192753911703260971285304221165990244515e-0003L, + 5.096695247430420878696018188830886972245e-0004L, + -2.231547584535654004647639737841526025095e-0004L, + 9.945751278137201960636098805852315982919e-0005L, + -4.492623672777606053587919463929044226280e-0005L, + 2.050721258703289487603702670753053765201e-0005L, + -9.439485626565616989352750672499008021041e-0006L, + 4.374838162403994645138200419356844574219e-0006L, + -2.038979492862555348577006944451002161496e-0006L, + 9.536763152382263548086981191378885102802e-0007L, + -4.426111214332434049863595231916564014913e-0007L, + 1.911148847512947464234633846270287546882e-0007L, + -5.788673944861923038157839080272303519671e-0008L, +}; + +static const long double ap2[] = { /* 19 terms */ + -0.077215664901532860606428624449354836087L, + 3.224670334241132182271948744265855440139e-0001L, + -6.735230105319809467356126599005051676203e-0002L, + 2.058080842778453315716389815213496002588e-0002L, + -7.385551028673653323064118422580096222959e-0003L, + 2.890510330735923572088003424849289006039e-0003L, + -1.192753911629952368606185543945790688144e-0003L, + 5.096695239806718875364547587043220998766e-0004L, + -2.231547520600616108991867127392089144886e-0004L, + 9.945746913898151120612322833059416008973e-0005L, + -4.492599307461977003570224943054585729684e-0005L, + 2.050609891889165453592046505651759999090e-0005L, + -9.435329866734193796540515247917165988579e-0006L, + 4.362267138522223236241016136585565144581e-0006L, + -2.008556356653246579300491601497510230557e-0006L, + 8.961498103387207161105347118042844354395e-0007L, + -3.614187228330216282235692806488341157741e-0007L, + 1.136978988247816860500420915014777753153e-0007L, + -2.000532786387196664019286514899782691776e-0008L, +}; + +static const long double ap3[] = { /* 19 terms */ + -0.077215664901532859888521470795348856446L, + 3.224670334241131733364048614484228443077e-0001L, + -6.735230105319676541660495145259038151576e-0002L, + 2.058080842775975461837768839015444273830e-0002L, + -7.385551028347615729728618066663566606906e-0003L, + 2.890510327517954083379032008643080256676e-0003L, + -1.192753886919470728001821137439430882603e-0003L, + 5.096693728898932234814903769146577482912e-0004L, + -2.231540055048827662528594010961874258037e-0004L, + 9.945446210018649311491619999438833843723e-0005L, + -4.491608206598064519190236245753867697750e-0005L, + 2.047939071322271016498065052853746466669e-0005L, + -9.376824046522786006677541036631536790762e-0006L, + 4.259329829498149111582277209189150127347e-0006L, + -1.866064770421594266702176289764212873428e-0006L, + 7.462066721137579592928128104534957135669e-0007L, + -2.483546217529077735074007138457678727371e-0007L, + 5.915166576378161473299324673649144297574e-0008L, + -7.334139641706988966966252333759604701905e-0009L, +}; + +static const long double ap4[] = { /* 19 terms */ + -0.0772156649015326785569313252637238673675L, + 3.224670334241051435008842685722468344822e-0001L, + -6.735230105302832007479431772160948499254e-0002L, + 2.058080842553481183648529360967441889912e-0002L, + -7.385551007602909242024706804659879199244e-0003L, + 2.890510182473907253939821312248303471206e-0003L, + -1.192753098427856770847894497586825614450e-0003L, + 5.096659636418811568063339214203693550804e-0004L, + -2.231421144004355691166194259675004483639e-0004L, + 9.942073842343832132754332881883387625136e-0005L, + -4.483809261973204531263252655050701205397e-0005L, + 2.033260142610284888319116654931994447173e-0005L, + -9.153539544026646699870528191410440585796e-0006L, + 3.988460469925482725894144688699584997971e-0006L, + -1.609692980087029172567957221850825977621e-0006L, + 5.634916377249975825399706694496688803488e-0007L, + -1.560065465929518563549083208482591437696e-0007L, + 2.961350193868935325526962209019387821584e-0008L, + -2.834602215195368130104649234505033159842e-0009L, +}; + +static long double +primary(long double s) { /* assume |s|<=0.5 */ + int i; + + i = (int) (8.0L * (s + 0.5L)); + switch(i) { + case 0: return ch*s+s*poly(s,an4,21); + case 1: return ch*s+s*poly(s,an3,20); + case 2: return ch*s+s*poly(s,an2,20); + case 3: return ch*s+s*poly(s,an1,20); + case 4: return ch*s+s*poly(s,ap1,19); + case 5: return ch*s+s*poly(s,ap2,19); + case 6: return ch*s+s*poly(s,ap3,19); + case 7: return ch*s+s*poly(s,ap4,19); + } + /* NOTREACHED */ +} + +static long double +poly(long double s, const long double *p, int n) { + long double y; + int i; + y = p[n-1]; + for (i=n-2;i>=0;i--) y = p[i]+s*y; + return y; +} + +static const long double pt[] = { + 9.189385332046727417803297364056176804663e-0001L, + 8.333333333333333333333333333331286969123e-0002L, + -2.777777777777777777777777553194796036402e-0003L, + 7.936507936507936507927283071433584248176e-0004L, + -5.952380952380952362351042163192634108297e-0004L, + 8.417508417508395661774286645578379460131e-0004L, + -1.917526917525263651186066417934685675649e-0003L, + 6.410256409395203164659292973142293199083e-0003L, + -2.955065327248303301763594514012418438188e-0002L, + 1.796442830099067542945998615411893822886e-0001L, + -1.392413465829723742489974310411118662919e+0000L, + 1.339984238037267658352656597960492029261e+0001L, + -1.564707657605373662425785904278645727813e+0002L, + 2.156323807499211356127813962223067079300e+0003L, + -3.330486427626223184647299834137041307569e+0004L, + 5.235535072011889213611369254140123518699e+0005L, + -7.258160984602220710491988573430212593080e+0006L, + 7.316526934569686459641438882340322673357e+0007L, + -3.806450279064900548836571789284896711473e+0008L, +}; + +static long double +polytail(long double s) { + long double t,z; + int i; + z = s*s; + t = pt[18]; + for (i=17;i>=1;i--) t = pt[i]+z*t; + return pt[0]+s*t; +} + +static long double +neg(long double z, int *signgamlp) { + long double t,p; + + /* + * written by K.C. Ng, Feb 2, 1989. + * + * Since + * -z*G(-z)*G(z) = pi/sin(pi*z), + * we have + * G(-z) = -pi/(sin(pi*z)*G(z)*z) + * = pi/(sin(pi*(-z))*G(z)*z) + * Algorithm + * z = |z| + * t = sinpi(z); ...note that when z>2**112, z is an int + * and hence t=0. + * + * if(t==0.0) return 1.0/0.0; + * if(t< 0.0) *signgamlp = -1; else t= -t; + * if(z<1.0e-40) ...tiny z + * return -log(z); + * else + * return log(pi/(t*z))-lgamma(z); + * + */ + + t = sinpil(z); /* t := sin(pi*z) */ + if (t==c0) /* return 1.0/0.0 = +INF */ + return c1/c0; + + z = -z; + if(z<=tiny) + p = -logl(z); + else + p = logl(pi/(fabsl(t)*z))-__k_lgammal(z,signgamlp); + if(t<c0) *signgamlp = -1; + return p; +} diff --git a/usr/src/libm/src/LD/__poly_libmq.c b/usr/src/libm/src/LD/__poly_libmq.c new file mode 100644 index 0000000..e150eb6 --- /dev/null +++ b/usr/src/libm/src/LD/__poly_libmq.c @@ -0,0 +1,40 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)__poly_libmq.c 1.5 06/01/31 SMI" + +#include "libm.h" +#include "libm_synonyms.h" + +long double __poly_libmq(x,n,p) +long double x,p[]; +int n; +{ + long double t; int i; + t = p[n-1]; + for(i=n-2;i>=0;i--) t = p[i] + x*t; + return t; +} diff --git a/usr/src/libm/src/LD/__rem_pio2l.c b/usr/src/libm/src/LD/__rem_pio2l.c new file mode 100644 index 0000000..9d61169 --- /dev/null +++ b/usr/src/libm/src/LD/__rem_pio2l.c @@ -0,0 +1,77 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)__rem_pio2l.c 1.10 06/01/31 SMI" + +/* __rem_pio2l(x,y) + * + * return the remainder of x rem pi/2 in y[0]+y[1] + * by calling __rem_pio2m + */ + +#include "libm.h" + +extern const int _TBL_ipio2l_inf[]; + +static const long double + two24l = 16777216.0L, + pio4 = 0.7853981633974483096156608458198757210495L; + +int +__rem_pio2l(long double x, long double *y) +{ + long double z, w; + double t[3], v[5]; + int e0, i, nx, n, sign; + + sign = signbitl(x); + z = fabsl(x); + if (z <= pio4) { + y[0] = x; + y[1] = 0; + return (0); + } + e0 = ilogbl(z) - 23; + z = scalbnl(z, -e0); + for (i = 0; i < 3; i++) { + t[i] = (double)((int)(z)); + z = (z - (long double)t[i]) * two24l; + } + nx = 3; + while (t[nx-1] == 0.0) + nx--; /* omit trailing zeros */ + n = __rem_pio2m(t, v, e0, nx, 2, _TBL_ipio2l_inf); + z = (long double)v[1]; + w = (long double)v[0]; + y[0] = z + w; + y[1] = z - (y[0] - w); + if (sign == 1) { + y[0] = -y[0]; + y[1] = -y[1]; + return (-n); + } + return (n); +} diff --git a/usr/src/libm/src/LD/__sincosl.c b/usr/src/libm/src/LD/__sincosl.c new file mode 100644 index 0000000..7960081 --- /dev/null +++ b/usr/src/libm/src/LD/__sincosl.c @@ -0,0 +1,151 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)__sincosl.c 1.7 06/01/31 SMI" + +/* INDENT OFF */ +/* + * long double __k_sincos( long double x, long double y, long double *c ) + * kernel sincosl function on [-pi/4, pi/4], pi/4 ~ 0.785398164 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * return sinl(x) with *c = cosl(x) + * + * Table look up algorithm + * see __k_sinl() and __k_cosl() + */ + +#include "libm.h" + +extern const long double _TBL_sinl_hi[], _TBL_sinl_lo[], _TBL_cosl_hi[], + _TBL_cosl_lo[]; +static const long double +one = 1.0, +/* + * |sin(x) - (x+pp1*x^3+...+pp5*x^11)| <= 2^-122.32 for |x|<1/64 + */ +pp1 = -1.666666666666666666666666666586782940810e-0001L, +pp2 = 8.333333333333333333333003723660929317540e-0003L, +pp3 = -1.984126984126984076045903483778337804470e-0004L, +pp4 = 2.755731922361906641319723106210900949413e-0006L, +pp5 = -2.505198398570947019093998469135012057673e-0008L, +/* + * |(sin(x) - (x+p1*x^3+...+p8*x^17)| + * |------------------------------- | <= 2^-116.17 for |x|<0.1953125 + * | x | + */ +p1 = -1.666666666666666666666666666666211262297e-0001L, +p2 = 8.333333333333333333333333301497876908541e-0003L, +p3 = -1.984126984126984126984041302881180621922e-0004L, +p4 = 2.755731922398589064100587351307269621093e-0006L, +p5 = -2.505210838544163129378906953765595393873e-0008L, +p6 = 1.605904383643244375050998243778534074273e-0010L, +p7 = -7.647162722800685516901456114270824622699e-0013L, +p8 = 2.810046428661902961725428841068844462603e-0015L, +/* + * + * |cos(x) - (1+qq1*x^2+...+ qq5*x^10)| <= 2^-123.84 for |x|<=1/128 + */ +qq1 = -4.999999999999999999999999999999378373641e-0001L, +qq2 = 4.166666666666666666666665478399327703130e-0002L, +qq3 = -1.388888888888888888058211230618051613494e-0003L, +qq4 = 2.480158730156105377771585658905303111866e-0005L, +qq5 = -2.755728099762526325736488376695157008736e-0007L, +/* + * + * |cos(x) - (1+q1*x^2+...+ q8*x^16)| <= 2^-117.11 for |x|<= 0.15625 + */ +q1 = -4.999999999999999999999999999999756416975e-0001L, +q2 = 4.166666666666666666666666664006066577258e-0002L, +q3 = -1.388888888888888888888877700363937169637e-0003L, +q4 = 2.480158730158730158494468463031814083559e-0005L, +q5 = -2.755731922398586276322819250356005542871e-0007L, +q6 = 2.087675698767424261441959760729854017855e-0009L, +q7 = -1.147074481239662089072452129010790774761e-0011L, +q8 = 4.777761647399651599730663422263531034782e-0014L; +/* INDENT ON */ +long double +__k_sincosl(long double x, long double y, long double *c) { + long double a1, a2, t, t1, t2, z, w; + int *pt = (int *) &t, *px = (int *) &x; + int i, j, hx, ix; + + t = 1.0; +#if !defined(__i386) && !defined(__amd64) + hx = px[0]; +#else + XTOI(px, hx); +#endif + ix = hx & 0x7fffffff; + if (ix < 0x3ffc4000) { + if (ix < 0x3fc60000) + if (((int) x) == 0) { + *c = one; + return (x); + } /* generate inexact */ + z = x * x; + + if (ix < 0x3ff80000) { + *c = one + z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + + z * qq5)))); + t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 + + z * p6))))); + } else { + *c = one + z * (q1 + z * (q2 + z * (q3 + z * (q4 + z * + (q5 + z * (q6 + z * (q7 + z * q8))))))); + t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 + + z * (p6 + z * (p7 + z * p8))))))); + } + + t = y + x * t; + return (x + t); + } + j = (ix + 0x400) & 0x7ffff800; + i = (j - 0x3ffc4000) >> 11; +#if !defined(__i386) && !defined(__amd64) + pt[0] = j; +#else + ITOX(j, pt); +#endif + if (hx > 0) + x = y - (t - x); + else + x = (-y) - (t + x); + a1 = _TBL_sinl_hi[i]; + z = x * x; + t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); + w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * + pp5))))); + a2 = _TBL_cosl_hi[i]; + t2 = _TBL_cosl_lo[i] - (a1 * w - a2 * t); + *c = a2 + t2; + t1 = a2 * w + a1 * t; + t1 += _TBL_sinl_lo[i]; + if (hx < 0) + return (-a1 - t1); + else + return (a1 + t1); +} diff --git a/usr/src/libm/src/LD/__sinl.c b/usr/src/libm/src/LD/__sinl.c new file mode 100644 index 0000000..375aca0 --- /dev/null +++ b/usr/src/libm/src/LD/__sinl.c @@ -0,0 +1,145 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)__sinl.c 1.8 06/01/31 SMI" + +/* INDENT OFF */ +/* + * __k_sinl( long double x; long double y ) + * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.785398164 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * + * Table look up algorithm + * 1. by sin(-x) = -sin(x), need only to consider positive x + * 2. if x < 25/128 = [0x3ffc9000,0,0,0] = 0.1953125 , then + * if x < 2^-57 (hx < 0x3fc60000,0,0,0), return x (inexact if x!= 0) + * z = x*x; + * if x <= 1/64 = 2**-6 + * sin(x) = x + (y+(x*z)*(p1 + z*p2)) + * else + * sin(x) = x + (y+(x*z)*(p1 + z*(p2 + z*(p3 + z*p4)))) + * 3. else + * ht = (hx + 0x400)&0x7ffff800 (round x to a break point t) + * lt = 0 + * i = (hy-0x3ffc4000)>>11; (i<=64) + * x' = (x - t)+y (|x'| ~<= 2^-7 + * By + * sin(t+x') + * = sin(t)cos(x')+cos(t)sin(x') + * = sin(t)(1+z*(qq1+z*qq2))+[cos(t)]*x*(1+z*(pp1+z*pp2)) + * = sin(t) + [sin(t)]*(z*(qq1+z*qq2))+ + * [cos(t)]*x*(1+z*(pp1+z*pp2)) + * + * Thus, + * let a= _TBL_sin_hi[i], b = _TBL_sin_lo[i], c= _TBL_cos_hi[i], + * x = (x-t)+y + * z = x*x; + * sin(t+x) = a+(b+ ((c*x)*(1+z*(pp1+z*pp2))+a*(z*(qq1+z*qq2))) + */ + +#include "libm.h" + +extern const long double _TBL_sinl_hi[], _TBL_sinl_lo[], _TBL_cosl_hi[]; +static const long double +one = 1.0, +/* + * |sin(x) - (x+pp1*x^3+...+ pp5*x^11)| <= 2^-122.32 for |x|<1/64 + */ +pp1 = -1.666666666666666666666666666586782940810e-0001L, +pp2 = 8.333333333333333333333003723660929317540e-0003L, +pp3 = -1.984126984126984076045903483778337804470e-0004L, +pp4 = 2.755731922361906641319723106210900949413e-0006L, +pp5 = -2.505198398570947019093998469135012057673e-0008L, +/* + * |(sin(x) - (x+p1*x^3+...+p8*x^17)| + * |------------------------------- | <= 2^-116.17 for |x|<0.1953125 + * | x | + */ +p1 = -1.666666666666666666666666666666211262297e-0001L, +p2 = 8.333333333333333333333333301497876908541e-0003L, +p3 = -1.984126984126984126984041302881180621922e-0004L, +p4 = 2.755731922398589064100587351307269621093e-0006L, +p5 = -2.505210838544163129378906953765595393873e-0008L, +p6 = 1.605904383643244375050998243778534074273e-0010L, +p7 = -7.647162722800685516901456114270824622699e-0013L, +p8 = 2.810046428661902961725428841068844462603e-0015L, +/* + * 2 10 -123.84 + * |cos(x) - (1+qq1*x +...+ qq5*x )| <= 2 for |x|<=1/128 + */ +qq1 = -4.999999999999999999999999999999378373641e-0001L, +qq2 = 4.166666666666666666666665478399327703130e-0002L, +qq3 = -1.388888888888888888058211230618051613494e-0003L, +qq4 = 2.480158730156105377771585658905303111866e-0005L, +qq5 = -2.755728099762526325736488376695157008736e-0007L; +/* INDENT ON */ +long double +__k_sinl(long double x, long double y) { + long double a, t, z, w; + int *pt = (int *) &t, *px = (int *) &x; + int i, j, hx, ix; + + t = 1.0L; +#if !defined(__i386) && !defined(__amd64) + hx = px[0]; +#else + XTOI(px, hx); +#endif + ix = hx & 0x7fffffff; + if (ix < 0x3ffc9000) { + if (ix < 0x3fc60000) + if (((int) x) == 0) + return (x); /* generate inexact */ + z = x * x; + t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 + z * + (p6 + z * (p7 + z * p8))))))); + t = y + x * t; + return (x + t); + } + j = (ix + 0x400) & 0x7ffff800; + i = (j - 0x3ffc4000) >> 11; +#if !defined(__i386) && !defined(__amd64) + pt[0] = j; +#else + ITOX(j, pt); +#endif + if (hx > 0) + x = y - (t - x); + else + x = (-y) - (t + x); + a = _TBL_sinl_hi[i]; + z = x * x; + t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); + w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * + pp5))))); + t = _TBL_cosl_hi[i] * w + a * t; + t += _TBL_sinl_lo[i]; + if (hx < 0) + return (-a - t); + else + return (a + t); +} diff --git a/usr/src/libm/src/LD/__tanl.c b/usr/src/libm/src/LD/__tanl.c new file mode 100644 index 0000000..d32299c --- /dev/null +++ b/usr/src/libm/src/LD/__tanl.c @@ -0,0 +1,168 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)__tanl.c 1.7 06/01/31 SMI" + +/* INDENT OFF */ +/* + * __k_tanl( long double x; long double y; int k ) + * kernel tan/cotan function on [-pi/4, pi/4], pi/4 ~ 0.785398164 + * Input x is assumed to be bounded by ~pi/4 in magnitude. + * Input y is the tail of x. + * Input k indicate -- tan if k=0; else -1/tan + * + * Table look up algorithm + * 1. by tan(-x) = -tan(x), need only to consider positive x + * 2. if x < 5/32 = [0x3ffc4000, 0] = 0.15625 , then + * if x < 2^-57 (hx < 0x3fc40000 0), set w=x with inexact if x!= 0 + * else + * z = x*x; + * w = x + (y+(x*z)*(t1+z*(t2+z*(t3+z*(t4+z*(t5+z*t6)))))) + * return (k == 0 ? w : 1/w); + * 3. else + * ht = (hx + 0x400)&0x7ffff800 (round x to a break point t) + * lt = 0 + * i = (hy-0x3ffc4000)>>11; (i<=64) + * x' = (x - t)+y (|x'| ~<= 2^-7) + * By + * tan(t+x') + * = (tan(t)+tan(x'))/(1-tan(x')tan(t)) + * We have + * sin(x')+tan(t)*(tan(t)*sin(x')) + * = tan(t) + ------------------------------- for k=0 + * cos(x') - tan(t)*sin(x') + * + * cos(x') - tan(t)*sin(x') + * = - -------------------------------------- for k=1 + * tan(t) + tan(t)*(cos(x')-1) + sin(x') + * + * + * where tan(t) is from the table, + * sin(x') = x + pp1*x^3 + ...+ pp5*x^11 + * cos(x') = 1 + qq1*x^2 + ...+ qq5*x^10 + */ + +#include "libm.h" + +extern const long double _TBL_tanl_hi[], _TBL_tanl_lo[]; +static const long double +one = 1.0, +/* + * |sin(x) - (x+pp1*x^3+...+ pp5*x^11)| <= 2^-122.32 for |x|<1/64 + */ +pp1 = -1.666666666666666666666666666586782940810e-0001L, +pp2 = 8.333333333333333333333003723660929317540e-0003L, +pp3 = -1.984126984126984076045903483778337804470e-0004L, +pp4 = 2.755731922361906641319723106210900949413e-0006L, +pp5 = -2.505198398570947019093998469135012057673e-0008L, +/* + * 2 10 -123.84 + * |cos(x) - (1+qq1*x +...+ qq5*x )| <= 2 for |x|<=1/128 + */ +qq1 = -4.999999999999999999999999999999378373641e-0001L, +qq2 = 4.166666666666666666666665478399327703130e-0002L, +qq3 = -1.388888888888888888058211230618051613494e-0003L, +qq4 = 2.480158730156105377771585658905303111866e-0005L, +qq5 = -2.755728099762526325736488376695157008736e-0007L, +/* + * |tan(x) - (x+t1*x^3+...+t6*x^13)| + * |------------------------------ | <= 2^-59.73 for |x|<0.15625 + * | x | + */ +t1 = 3.333333333333333333333333333333423342490e-0001L, +t2 = 1.333333333333333333333333333093838744537e-0001L, +t3 = 5.396825396825396825396827906318682662250e-0002L, +t4 = 2.186948853615520282185576976994418486911e-0002L, +t5 = 8.863235529902196573354554519991152936246e-0003L, +t6 = 3.592128036572480064652191427543994878790e-0003L, +t7 = 1.455834387051455257856833807581901305474e-0003L, +t8 = 5.900274409318599857829983256201725587477e-0004L, +t9 = 2.391291152117265181501116961901122362937e-0004L, +t10 = 9.691533169382729742394024173194981882375e-0005L, +t11 = 3.927994733186415603228178184225780859951e-0005L, +t12 = 1.588300018848323824227640064883334101288e-0005L, +t13 = 6.916271223396808311166202285131722231723e-0006L; +/* INDENT ON */ +long double +__k_tanl(long double x, long double y, int k) { + long double a, t, z, w, s, c; + int *pt = (int *) &t, *px = (int *) &x; + int i, j, hx, ix; + + t = 1.0; +#if !defined(__i386) && !defined(__amd64) + hx = px[0]; +#else + XTOI(px, hx); +#endif + ix = hx & 0x7fffffff; + if (ix < 0x3ffc4000) { + if (ix < 0x3fc60000) { + if ((i = (int) x) == 0) /* generate inexact */ + w = x; + } else { + z = x * x; + if (ix < 0x3ff30000) /* 2**-12 */ + t = z * (t1 + z * (t2 + z * (t3 + z * t4))); + else + t = z * (t1 + z * (t2 + z * (t3 + z * (t4 + + z * (t5 + z * (t6 + z * (t7 + z * + (t8 + z * (t9 + z * (t10 + z * (t11 + + z * (t12 + z * t13)))))))))))); + t = y + x * t; + w = x + t; + } + return (k == 0 ? w : -one / w); + } + j = (ix + 0x400) & 0x7ffff800; + i = (j - 0x3ffc4000) >> 11; +#if !defined(__i386) && !defined(__amd64) + pt[0] = j; +#else + ITOX(j, pt); +#endif + if (hx > 0) + x = y - (t - x); + else + x = (-y) - (t + x); + a = _TBL_tanl_hi[i]; + z = x * x; + /* cos(x)-1 */ + t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); + /* sin(x) */ + s = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * + pp5))))); + if (k == 0) { + w = a * s; + t = _TBL_tanl_lo[i] + (s + a * w) / (one - (w - t)); + return (hx < 0 ? -a - t : a + t); + } else { + w = s + a * t; + c = w + _TBL_tanl_lo[i]; + z = (one - (a * s - t)); + return (hx >= 0 ? z / (-a - c) : z / (a + c)); + } +} diff --git a/usr/src/libm/src/LD/acoshl.c b/usr/src/libm/src/LD/acoshl.c new file mode 100644 index 0000000..be53cc4 --- /dev/null +++ b/usr/src/libm/src/LD/acoshl.c @@ -0,0 +1,56 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)acoshl.c 1.6 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak acoshl = __acoshl +#endif + +#include "libm.h" + +static const long double + zero = 0.0L, + ln2 = 6.931471805599453094172321214581765680755e-0001L, + one = 1.0L, + big = 1.e+20L; + +long double +acoshl(long double x) { + long double t; + + if (isnanl(x)) + return (x + x); + else if (x > big) + return (logl(x) + ln2); + else if (x > one) { + t = sqrtl(x - one); + return (log1pl(t * (t + sqrtl(x + one)))); + } else if (x == one) + return (zero); + else + return ((x - x) / (x - x)); +} diff --git a/usr/src/libm/src/LD/asinhl.c b/usr/src/libm/src/LD/asinhl.c new file mode 100644 index 0000000..453bcef --- /dev/null +++ b/usr/src/libm/src/LD/asinhl.c @@ -0,0 +1,58 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)asinhl.c 1.6 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak asinhl = __asinhl +#endif + +#include "libm.h" + +static const long double + ln2 = 6.931471805599453094172321214581765680755e-0001L, + one = 1.0L, + big = 1.0e+20L, + tiny = 1.0e-20L; + +long double +asinhl(long double x) { + long double t, w; + + w = fabsl(x); + if (isnanl(x)) + return (x + x); /* x is NaN */ + if (w < tiny) { +#ifndef lint + volatile long double dummy = x + big; /* inexact if x != 0 */ +#endif + return (x); /* tiny x */ + } else if (w < big) { + t = one / w; + return (copysignl(log1pl(w + w / (t + sqrtl(one + t * t))), x)); + } else + return (copysignl(logl(w) + ln2, x)); +} diff --git a/usr/src/libm/src/LD/atan2pil.c b/usr/src/libm/src/LD/atan2pil.c new file mode 100644 index 0000000..1d1c58f --- /dev/null +++ b/usr/src/libm/src/LD/atan2pil.c @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)atan2pil.c 1.5 06/01/31 SMI" + +#pragma weak atan2pil = __atan2pil + +#include "libm.h" +#include "libm_synonyms.h" + +#define GENERIC long double +#define ATAN2PI atan2pil +#define ATAN2 atan2l + +/* ATAN2PI(y,x) + * + * ATAN2PI(y,x) = ATAN2(y,x)/pi + */ + +extern GENERIC ATAN2(); + +static GENERIC +invpi = (GENERIC) 3.183098861837906715377675267450287240689e-0001L; + +GENERIC ATAN2PI(y,x) +GENERIC y,x; +{ + return ATAN2(y,x)*invpi; +} diff --git a/usr/src/libm/src/LD/atanhl.c b/usr/src/libm/src/LD/atanhl.c new file mode 100644 index 0000000..d37bcf5 --- /dev/null +++ b/usr/src/libm/src/LD/atanhl.c @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)atanhl.c 1.5 06/01/31 SMI" + +#pragma weak atanhl = __atanhl + +#include "libm.h" +#include "libm_synonyms.h" + +#define GENERIC long double +#define ATANH atanhl + +/* ATANH(x) + * 1 2x x + * ATANH(x) = --- * LOG(1 + -------) = 0.5 * LOG1P(2 * --------) + * 2 1 - x 1 - x + * Note: to guarantee ATANH(-x) = -ATANH(x), we use + * sign(x) |x| + * ATANH(x) = ------- * LOG1P(2*-------). + * 2 1 - |x| + * + * Special cases: + * ATANH(x) is NaN if |x| > 1 with signal; + * ATANH(NaN) is that NaN with no signal; + * ATANH(+-1) is +-INF with signal. + * + */ + +#define FABS fabsl +#define LOG1P log1pl +#define COPYSIGN copysignl + + +extern GENERIC FABS(),LOG1P(),COPYSIGN(); + +static GENERIC +zero = (GENERIC) 0.0, +half = (GENERIC) 0.5, +one = (GENERIC) 1.0; + +GENERIC ATANH(x) +GENERIC x; +{ + GENERIC t; + t = FABS(x); + if(t==one) return x/zero; + t = t/(one-t); + return COPYSIGN(half,x)*LOG1P(t+t); +} diff --git a/usr/src/libm/src/LD/cbrtl.c b/usr/src/libm/src/LD/cbrtl.c new file mode 100644 index 0000000..918c9b7 --- /dev/null +++ b/usr/src/libm/src/LD/cbrtl.c @@ -0,0 +1,73 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)cbrtl.c 1.6 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak cbrtl = __cbrtl +#endif + +#include "libm.h" + +static const double d_one = 1.0; + +long double +cbrtl(long double x) { + long double s, t, r, w, y; + double dx, dy; + int *py = (int *) &dy; + int n, m, m3, n0, sx; + + if (!finitel(x)) + return (x + x); + if (iszerol(x)) + return (x); + n0 = 0; + if (*((int *) &d_one) == 0) + n0 = 1; + sx = signbitl(x); + x = fabsl(x); + n = ilogbl(x); + m = n / 3; + m3 = m + m + m; + y = scalbnl(x, -m3); + dx = (double) y; + dy = cbrt(dx); + py[1 - n0] += 2; + if (py[1 - n0] == 0) + py[n0] += 1; + + /* one step newton iteration to 113 bits with error < 0.667ulps */ + t = (long double) dy; + t = scalbnl(t, m); + s = t * t; + r = x / s; + w = t + t; + r = (r - t) / (w + r); + t += t * r; + + return (sx == 0 ? t : -t); +} diff --git a/usr/src/libm/src/LD/coshl.c b/usr/src/libm/src/LD/coshl.c new file mode 100644 index 0000000..93604fc --- /dev/null +++ b/usr/src/libm/src/LD/coshl.c @@ -0,0 +1,107 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)coshl.c 1.7 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak coshl = __coshl +#endif + +#include "libm.h" + +/* + * COSH(X) + * RETURN THE HYPERBOLIC COSINE OF X + * + * Method : + * 1. Replace x by |x| (COSH(x) = COSH(-x)). + * 2. + * [ EXP(x) - 1 ]^2 + * 0 <= x <= 0.3465 : COSH(x) := 1 + ------------------- + * 2*EXP(x) + * + * EXP(x) + 1/EXP(x) + * 0.3465 <= x <= thresh : COSH(x) := ------------------- + * 2 + * thresh <= x <= lnovft : COSH(x) := EXP(x)/2 + * lnovft <= x < INF : COSH(x) := SCALBN(EXP(x-MEP1*ln2),ME) + * + * + * here + * 0.3465 a number that is near one half of ln2. + * thresh a number such that + * EXP(thresh)+EXP(-thresh)=EXP(thresh) + * lnovft logarithm of the overflow threshold + * = MEP1*ln2 chopped to machine precision. + * ME maximum exponent + * MEP1 maximum exponent plus 1 + * + * Special cases: + * COSH(x) is |x| if x is +INF, -INF, or NaN. + * only COSH(0)=1 is exact for finite x. + */ + +static const long double C[] = { + 0.5L, + 1.0L, + 0.3465L, + 45.0L, + 1.135652340629414394879149e+04L, + 7.004447686242549087858985e-16L, + 2.710505431213761085018632e-20L, /* 2^-65 */ +}; + +#define half C[0] +#define one C[1] +#define thr1 C[2] +#define thr2 C[3] +#define lnovft C[4] +#define lnovlo C[5] +#define tinyl C[6] + +long double +coshl(long double x) { + long double w, t; + + w = fabsl(x); + if (!finitel(w)) + return (w + w); /* x is INF or NaN */ + if (w < thr1) { + if (w < tinyl) + return (one + w); /* inexact+directed rounding */ + t = expm1l(w); + w = one + t; + w = one + (t * t) / (w + w); + return (w); + } + if (w < thr2) { + t = expl(w); + return (half * (t + one / t)); + } + if (w <= lnovft) + return (half * expl(w)); + return (scalbnl(expl((w - lnovft) - lnovlo), 16383)); +} diff --git a/usr/src/libm/src/LD/cosl.c b/usr/src/libm/src/LD/cosl.c new file mode 100644 index 0000000..69d4239 --- /dev/null +++ b/usr/src/libm/src/LD/cosl.c @@ -0,0 +1,105 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)cosl.c 1.9 06/01/31 SMI" + +#pragma weak cosl = __cosl + +/* INDENT OFF */ +/* cosl(x) + * Table look-up algorithm by K.C. Ng, November, 1989. + * + * kernel function: + * __k_sinl ... sin function on [-pi/4,pi/4] + * __k_cosl ... cos function on [-pi/4,pi/4] + * __rem_pio2l ... argument reduction routine + * + * Method. + * Let S and C denote the sin and cos respectively on [-PI/4, +PI/4]. + * 1. Assume the argument x is reduced to y1+y2 = x-k*pi/2 in + * [-pi/2 , +pi/2], and let n = k mod 4. + * 2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C S/C + * 1 C -S -C/S + * 2 -S -C S/C + * 3 -C S -C/S + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * computer TRIG(x) returns trig(x) nearly rounded. + */ +/* INDENT ON */ + +#include "libm.h" +#include "libm_synonyms.h" +#include "longdouble.h" + +long double +cosl(long double x) { + long double y[2], z = 0.0L; + int n, ix; + int *px = (int *) &x; + + /* trig(Inf or NaN) is NaN */ + if (!finitel(x)) + return x - x; + + /* High word of x. */ +#if !defined(__i386) + ix = px[0]; +#else + XTOI(px, ix); +#endif + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if (ix <= 0x3ffe9220) + return __k_cosl(x, z); + + /* argument reduction needed */ + else { + n = __rem_pio2l(x, y); + switch (n & 3) { + case 0: + return __k_cosl(y[0], y[1]); + case 1: + return -__k_sinl(y[0], y[1]); + case 2: + return -__k_cosl(y[0], y[1]); + case 3: + return __k_sinl(y[0], y[1]); + /* NOTREACHED */ + } + } +} diff --git a/usr/src/libm/src/LD/erfl.c b/usr/src/libm/src/LD/erfl.c new file mode 100644 index 0000000..6305691 --- /dev/null +++ b/usr/src/libm/src/LD/erfl.c @@ -0,0 +1,347 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)erfl.c 1.8 06/01/31 SMI" + +/* long double function erf,erfc (long double x) + * K.C. Ng, September, 1989. + * x + * 2 |\ + * erf(x) = --------- | exp(-t*t)dt + * sqrt(pi) \| + * 0 + * + * erfc(x) = 1-erf(x) + * + * method: + * Since erf(-x) = -erf(x), we assume x>=0. + * For x near 0, we have the expansion + * + * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....). + * + * Since 2/sqrt(pi) = 1.128379167095512573896158903121545171688, + * we use x + x*P(x^2) to approximate erf(x). This formula will + * guarantee the error less than one ulp where x is not too far + * away from 0. We note that erf(x)=x at x = 0.6174...... After + * some experiment, we choose the following approximation on + * interval [0,0.84375]. + * + * For x in [0,0.84375] + * 2 2 4 40 + * P = P(x ) = (p0 + p1 * x + p2 * x + ... + p20 * x ) + * + * erf(x) = x + x*P + * erfc(x) = 1 - erf(x) if x<=0.25 + * = 0.5 + ((0.5-x)-x*P) if x in [0.25,0.84375] + * precision: |P(x^2)-(erf(x)-x)/x| <= 2**-122.50 + * + * For x in [0.84375,1.25], let s = x - 1, and + * c = 0.84506291151 rounded to single (24 bits) + * erf(x) = c + P1(s)/Q1(s) + * erfc(x) = (1-c) - P1(s)/Q1(s) + * precision: |P1/Q1 - (erf(x)-c)| <= 2**-118.41 + * + * + * For x in [1.25,1.75], let s = x - 1.5, and + * c = 0.95478588343 rounded to single (24 bits) + * erf(x) = c + P2(s)/Q2(s) + * erfc(x) = (1-c) - P2(s)/Q2(s) + * precision: |P1/Q1 - (erf(x)-c)| <= 2**-123.83 + * + * + * For x in [1.75,16/3] + * erfc(x) = exp(-x*x)*(1/x)*R1(1/x)/S1(1/x) + * erf(x) = 1 - erfc(x) + * precision: absolute error of R1/S1 is bounded by 2**-124.03 + * + * For x in [16/3,107] + * erfc(x) = exp(-x*x)*(1/x)*R2(1/x)/S2(1/x) + * erf(x) = 1 - erfc(x) (if x>=9 simple return erf(x)=1 with inexact) + * precision: absolute error of R2/S2 is bounded by 2**-120.07 + * + * Else if inf > x >= 107 + * erf(x) = 1 with inexact + * erfc(x) = 0 with underflow + * + * Special case: + * erf(inf) = 1 + * erfc(inf) = 0 + */ + +#pragma weak erfl = __erfl +#pragma weak erfcl = __erfcl + +#include "libm.h" +#include "longdouble.h" + +static long double +tiny = 1e-40L, +nearunfl = 1e-4000L, +half = 0.5L, +one = 1.0L, +onehalf = 1.5L, +L16_3 = 16.0L/3.0L; +/* + * Coefficients for even polynomial P for erf(x)=x+x*P(x^2) on [0,0.84375] + */ +static long double P[] = { /* 21 coeffs */ + 1.283791670955125738961589031215451715556e-0001L, + -3.761263890318375246320529677071815594603e-0001L, + 1.128379167095512573896158903121205899135e-0001L, + -2.686617064513125175943235483344625046092e-0002L, + 5.223977625442187842111846652980454568389e-0003L, + -8.548327023450852832546626271083862724358e-0004L, + 1.205533298178966425102164715902231976672e-0004L, + -1.492565035840625097674944905027897838996e-0005L, + 1.646211436588924733604648849172936692024e-0006L, + -1.636584469123491976815834704799733514987e-0007L, + 1.480719281587897445302529007144770739305e-0008L, + -1.229055530170782843046467986464722047175e-0009L, + 9.422759064320307357553954945760654341633e-0011L, + -6.711366846653439036162105104991433380926e-0012L, + 4.463224090341893165100275380693843116240e-0013L, + -2.783513452582658245422635662559779162312e-0014L, + 1.634227412586960195251346878863754661546e-0015L, + -9.060782672889577722765711455623117802795e-0017L, + 4.741341801266246873412159213893613602354e-0018L, + -2.272417596497826188374846636534317381203e-0019L, + 8.069088733716068462496835658928566920933e-0021L, +}; + +/* + * Rational erf(x) = ((float)0.84506291151) + P1(x-1)/Q1(x-1) on [0.84375,1.25] + */ +static long double C1 = (long double)((float)0.84506291151); +static long double P1[] = { /* 12 top coeffs */ + -2.362118560752659955654364917390741930316e-0003L, + 4.129623379624420034078926610650759979146e-0001L, + -3.973857505403547283109417923182669976904e-0002L, + 4.357503184084022439763567513078036755183e-0002L, + 8.015593623388421371247676683754171456950e-0002L, + -1.034459310403352486685467221776778474602e-0002L, + 5.671850295381046679675355719017720821383e-0003L, + 1.219262563232763998351452194968781174318e-0003L, + 5.390833481581033423020320734201065475098e-0004L, + -1.978853912815115495053119023517805528300e-0004L, + 6.184234513953600118335017885706420552487e-0005L, + -5.331802711697810861017518515816271808286e-0006L, +}; +static long double Q1[] = { /* 12 bottom coeffs with leading 1.0 hidden */ + 9.081506296064882195280178373107623196655e-0001L, + 6.821049531968204097604392183650687642520e-0001L, + 4.067869178233539502315055970743271822838e-0001L, + 1.702332233546316765818144723063881095577e-0001L, + 7.498098377690553934266423088708614219356e-0002L, + 2.050154396918178697056927234366372760310e-0002L, + 7.012988534031999899054782333851905939379e-0003L, + 1.149904787014400354649843451234570731076e-0003L, + 3.185620255011299476196039491205159718620e-0004L, + 1.273405072153008775426376193374105840517e-0005L, + 4.753866999959432971956781228148402971454e-0006L, + -1.002287602111660026053981728549540200683e-0006L, +}; +/* + * Rational erf(x) = ((float)0.95478588343) + P2(x-1.5)/Q2(x-1.5) + * on [1.25,1.75] + */ +static long double C2 = (long double)((float)0.95478588343); +static long double P2[] = { /* 12 top coeffs */ + 1.131926304864446730135126164594785863512e-0002L, + 1.273617996967754151544330055186210322832e-0001L, + -8.169980734667512519897816907190281143423e-0002L, + 9.512267486090321197833634271787944271746e-0002L, + -2.394251569804872160005274999735914368170e-0002L, + 1.108768660227528667525252333184520222905e-0002L, + 3.527435492933902414662043314373277494221e-0004L, + 4.946116273341953463584319006669474625971e-0004L, + -4.289851942513144714600285769022420962418e-0005L, + 8.304719841341952705874781636002085119978e-0005L, + -1.040460226177309338781902252282849903189e-0005L, + 2.122913331584921470381327583672044434087e-0006L, +}; +static long double Q2[] = { /* 13 bottom coeffs with leading 1.0 hidden */ + 7.448815737306992749168727691042003832150e-0001L, + 7.161813850236008294484744312430122188043e-0001L, + 3.603134756584225766144922727405641236121e-0001L, + 1.955811609133766478080550795194535852653e-0001L, + 7.253059963716225972479693813787810711233e-0002L, + 2.752391253757421424212770221541238324978e-0002L, + 7.677654852085240257439050673446546828005e-0003L, + 2.141102244555509687346497060326630061069e-0003L, + 4.342123013830957093949563339130674364271e-0004L, + 8.664587895570043348530991997272212150316e-0005L, + 1.109201582511752087060167429397033701988e-0005L, + 1.357834375781831062713347000030984364311e-0006L, + 4.957746280594384997273090385060680016451e-0008L, +}; +/* + * erfc(x) = exp(-x*x)/x * R1(1/x)/S1(1/x) on [1.75, 16/3] + */ +static long double R1[] = { /* 14 top coeffs */ + 4.630195122654315016370705767621550602948e+0006L, + 1.257949521746494830700654204488675713628e+0007L, + 1.704153822720260272814743497376181625707e+0007L, + 1.502600568706061872381577539537315739943e+0007L, + 9.543710793431995284827024445387333922861e+0006L, + 4.589344808584091011652238164935949522427e+0006L, + 1.714660662941745791190907071920671844289e+0006L, + 5.034802147768798894307672256192466283867e+0005L, + 1.162286400443554670553152110447126850725e+0005L, + 2.086643834548901681362757308058660399137e+0004L, + 2.839793161868140305907004392890348777338e+0003L, + 2.786687241658423601778258694498655680778e+0002L, + 1.779177837102695602425897452623985786464e+0001L, + 5.641895835477470769043614623819144434731e-0001L, +}; +static long double S1[] = { /* 15 bottom coeffs with leading 1.0 hidden */ + 4.630195122654331529595606896287596843110e+0006L, + 1.780411093345512024324781084220509055058e+0007L, + 3.250113097051800703707108623715776848283e+0007L, + 3.737857099176755050912193712123489115755e+0007L, + 3.029787497516578821459174055870781168593e+0007L, + 1.833850619965384765005769632103205777227e+0007L, + 8.562719999736915722210391222639186586498e+0006L, + 3.139684562074658971315545539760008136973e+0006L, + 9.106421313731384880027703627454366930945e+0005L, + 2.085108342384266508613267136003194920001e+0005L, + 3.723126272693120340730491416449539290600e+0004L, + 5.049169878567344046145695360784436929802e+0003L, + 4.944274532748010767670150730035392093899e+0002L, + 3.153510608818213929982940249162268971412e+0001L, + 1.0e00L, +}; + +/* + * erfc(x) = exp(-x*x)/x * R2(1/x)/S2(1/x) on [16/3, 107] + */ +static long double R2[] = { /* 15 top coeffs in reverse order!!*/ + 2.447288012254302966796326587537136931669e+0005L, + 8.768592567189861896653369912716538739016e+0005L, + 1.552293152581780065761497908005779524953e+0006L, + 1.792075924835942935864231657504259926729e+0006L, + 1.504001463155897344947500222052694835875e+0006L, + 9.699485556326891411801230186016013019935e+0005L, + 4.961449933661807969863435013364796037700e+0005L, + 2.048726544693474028061176764716228273791e+0005L, + 6.891532964330949722479061090551896886635e+0004L, + 1.888014709010307507771964047905823237985e+0004L, + 4.189692064988957745054734809642495644502e+0003L, + 7.362346487427048068212968889642741734621e+0002L, + 9.980359714211411423007641056580813116207e+0001L, + 9.426910895135379181107191962193485174159e+0000L, + 5.641895835477562869480794515623601280429e-0001L, +}; +static long double S2[] = { /* 16 coefficients */ + 2.447282203601902971246004716790604686880e+0005L, + 1.153009852759385309367759460934808489833e+0006L, + 2.608580649612639131548966265078663384849e+0006L, + 3.766673917346623308850202792390569025740e+0006L, + 3.890566255138383910789924920541335370691e+0006L, + 3.052882073900746207613166259994150527732e+0006L, + 1.885574519970380988460241047248519418407e+0006L, + 9.369722034759943185851450846811445012922e+0005L, + 3.792278350536686111444869752624492443659e+0005L, + 1.257750606950115799965366001773094058720e+0005L, + 3.410830600242369370645608634643620355058e+0004L, + 7.513984469742343134851326863175067271240e+0003L, + 1.313296320593190002554779998138695507840e+0003L, + 1.773972700887629157006326333696896516769e+0002L, + 1.670876451822586800422009013880457094162e+0001L, + 1.000L, +}; + +long double erfl(x) +long double x; +{ + long double erfcl(long double),s,y,t; + + if(!finitel(x)) { + if(x!=x) return x+x; /* NaN */ + return copysignl(one,x); /* return +-1.0 is x=Inf */ + } + + y = fabsl(x); + if(y <= 0.84375L) { + if(y<=tiny) return x+P[0]*x; + s = y*y; + t = __poly_libmq(s,21,P); + return x+x*t; + } + if(y<=1.25L) { + s = y-one; + t = C1+__poly_libmq(s,12,P1)/(one+s*__poly_libmq(s,12,Q1)); + return (signbitl(x))? -t: t; + } else if(y<=1.75L) { + s = y-onehalf; + t = C2+__poly_libmq(s,12,P2)/(one+s*__poly_libmq(s,13,Q2)); + return (signbitl(x))? -t: t; + } + if(y<=9.0L) t = erfcl(y); else t = tiny; + return (signbitl(x))? t-one: one-t; +} + +long double erfcl(x) +long double x; +{ + long double erfl(long double),s,y,t; + + if(!finitel(x)) { + if(x!=x) return x+x; /* NaN */ + /* return 2.0 if x= -inf + 0.0 if x= +inf */ + if(x<0.0L) return 2.0L; else return 0.0L; + } + + if(x <= 0.84375L) { + if(x<=0.25) return one-erfl(x); + s = x*x; + t = half-x; + t = t - x*__poly_libmq(s,21,P); + return half+t; + } + if(x<=1.25L) { + s = x-one; + t = one-C1; + return t - __poly_libmq(s,12,P1)/(one+s*__poly_libmq(s,12,Q1)); + } else if(x<=1.75L) { + s = x-onehalf; + t = one-C2; + return t - __poly_libmq(s,12,P2)/(one+s*__poly_libmq(s,13,Q2)); + } + if(x>=107.0L) return nearunfl*nearunfl; /* underflow */ + else if(x >= L16_3) { + y = __poly_libmq(x,15,R2); + t = y/__poly_libmq(x,16,S2); + } else { + y = __poly_libmq(x,14,R1); + t = y/__poly_libmq(x,15,S1); + } + /* see comment in ../Q/erfl.c */ + y = x; + *(int*)&y = 0; + t *= expl(-y*y)*expl(-(x-y)*(x+y)); + return t; +} diff --git a/usr/src/libm/src/LD/finitel.c b/usr/src/libm/src/LD/finitel.c new file mode 100644 index 0000000..2b355d3 --- /dev/null +++ b/usr/src/libm/src/LD/finitel.c @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)finitel.c 1.3 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak finitel = __finitel +#endif + +#include "libm.h" + +#if defined(__sparc) +int +finitel(long double x) { + int *px = (int *) &x; + return ((px[0] & ~0x80000000) < 0x7fff0000); +} +#elif defined(__i386) +int +finitel(long double x) { + int *px = (int *) &x, t = px[2] & 0x7fff; +#if defined(HANDLE_UNSUPPORTED) + return (t != 0x7fff && ((px[1] & 0x80000000) != 0 || t == 0)); +#else + return (t != 0x7fff); +#endif +} +#endif /* defined(__sparc) || defined(__i386) */ diff --git a/usr/src/libm/src/LD/gammal.c b/usr/src/libm/src/LD/gammal.c new file mode 100644 index 0000000..5293e40 --- /dev/null +++ b/usr/src/libm/src/LD/gammal.c @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)gammal.c 1.6 06/01/31 SMI" +#pragma weak gammal = __gammal + +/* + * long double gammal(long double x); + */ + +#include "libm.h" +#include "libm_synonyms.h" +#include "longdouble.h" + +extern int signgam; +extern int signgaml; + +long double +gammal(long double x) { + long double y = __k_lgammal(x, &signgaml); + + signgam = signgaml; /* SUSv3 requires the setting of signgam */ + return y; +} diff --git a/usr/src/libm/src/LD/gammal_r.c b/usr/src/libm/src/LD/gammal_r.c new file mode 100644 index 0000000..f58766c --- /dev/null +++ b/usr/src/libm/src/LD/gammal_r.c @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)gammal_r.c 1.4 06/01/31 SMI" + +/* + * long double gammal_r(long double x, int *signgamlp); + */ + +#pragma weak gammal_r = __gammal_r + +#include "libm.h" +#include "longdouble.h" + +long double +gammal_r(long double x, int *signgamlp) { + return __k_lgammal(x, signgamlp); +} diff --git a/usr/src/libm/src/LD/hypotl.c b/usr/src/libm/src/LD/hypotl.c new file mode 100644 index 0000000..e2e6a54 --- /dev/null +++ b/usr/src/libm/src/LD/hypotl.c @@ -0,0 +1,146 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)hypotl.c 1.9 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak hypotl = __hypotl +#endif + +/* + * hypotl(x,y) + * Method : + * If z=x*x+y*y has error less than sqrt(2)/2 ulp than sqrt(z) has + * error less than 1 ulp. + * So, compute sqrt(x*x+y*y) with some care as follows: + * Assume x>y>0; + * 1. save and set rounding to round-to-nearest + * 2. if x > 2y use + * x1*x1+(y*y+(x2*(x+x2))) for x*x+y*y + * where x1 = x with lower 32 bits cleared, x2 = x-x1; else + * 3. if x <= 2y use + * t1*y1+((x-y)*(x-y)+(t1*y2+t2*y)) + * where t1 = 2x with lower 64 bits cleared, t2 = 2x-t1, y1= y with + * lower 32 bits cleared, y2 = y-y1. + * + * NOTE: DO NOT remove parenthsis! + * + * Special cases: + * hypot(x,y) is INF if x or y is +INF or -INF; else + * hypot(x,y) is NAN if x or y is NAN. + * + * Accuracy: + * hypot(x,y) returns sqrt(x^2+y^2) with error less than 1 ulps (units + * in the last place) + */ + +#include "libm.h" + +#if defined(__i386) +extern enum fp_direction_type __swap87RD(enum fp_direction_type); + +#define k 0x7fff + +long double +hypotl(long double x, long double y) { + long double t1, t2, y1, y2, w; + int *px = (int *) &x, *py = (int *) &y; + int *pt1 = (int *) &t1, *py1 = (int *) &y1; + enum fp_direction_type rd; + int j, nx, ny, nz; + + px[2] &= 0x7fff; /* clear sign bit and padding bits of x and y */ + py[2] &= 0x7fff; + nx = px[2]; /* biased exponent of x and y */ + ny = py[2]; + if (ny > nx) { + w = x; + x = y; + y = w; + nz = ny; + ny = nx; + nx = nz; + } /* force nx >= ny */ + if (nx - ny >= 66) + return (x + y); /* x / y >= 2**65 */ + if (nx < 0x5ff3 && ny > 0x205b) { /* medium x,y */ + /* save and set RD to Rounding to nearest */ + rd = __swap87RD(fp_nearest); + w = x - y; + if (w > y) { + pt1[2] = px[2]; + pt1[1] = px[1]; + pt1[0] = 0; + t2 = x - t1; + x = sqrtl(t1 * t1 - (y * (-y) - t2 * (x + t1))); + } else { + x += x; + py1[2] = py[2]; + py1[1] = py[1]; + py1[0] = 0; + y2 = y - y1; + pt1[2] = px[2]; + pt1[1] = px[1]; + pt1[0] = 0; + t2 = x - t1; + x = sqrtl(t1 * y1 - (w * (-w) - (t2 * y1 + y2 * x))); + } + if (rd != fp_nearest) + __swap87RD(rd); /* restore rounding mode */ + return (x); + } else { + if (nx == k || ny == k) { /* x or y is INF or NaN */ + /* since nx >= ny; nx is always k within this block */ + if (px[1] == 0x80000000 && px[0] == 0) + return (x); + else if (ny == k && py[1] == 0x80000000 && py[0] == 0) + return (y); + else + return (x + y); + } + if (ny == 0) { + if (y == 0.L || x == 0.L) + return (x + y); + pt1[2] = 0x3fff + 16381; + pt1[1] = 0x80000000; + pt1[0] = 0; + py1[2] = 0x3fff - 16381; + py1[1] = 0x80000000; + py1[0] = 0; + x *= t1; + y *= t1; + return (y1 * hypotl(x, y)); + } + j = nx - 0x3fff; + px[2] -= j; + py[2] -= j; + pt1[2] = nx; + pt1[1] = 0x80000000; + pt1[0] = 0; + return (t1 * hypotl(x, y)); + } +} +#endif diff --git a/usr/src/libm/src/LD/isnanl.c b/usr/src/libm/src/LD/isnanl.c new file mode 100644 index 0000000..98035d8 --- /dev/null +++ b/usr/src/libm/src/LD/isnanl.c @@ -0,0 +1,53 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)isnanl.c 1.3 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak isnanl = __isnanl +#endif + +#include "libm.h" + +#if defined(__sparc) +int +isnanl(long double x) { + int *px = (int *) &x; + return ((px[0] & ~0x80000000) >= 0x7fff0000 && + ((px[0] & ~0xffff0000) | px[1] | px[2] | px[3]) != 0); +} +#elif defined(__i386) +int +isnanl(long double x) { + int *px = (int *) &x, t = px[2] & 0x7fff; +#if defined(HANDLE_UNSUPPORTED) + return (t == 0x7fff && ((px[1] & ~0x80000000) | px[0]) != 0 || + t != 0 && (px[1] & 0x80000000) == 0); +#else + return (t == 0x7fff && ((px[1] & ~0x80000000) | px[0]) != 0); +#endif +} +#endif /* defined(__sparc) || defined(__i386) */ diff --git a/usr/src/libm/src/LD/j0l.c b/usr/src/libm/src/LD/j0l.c new file mode 100644 index 0000000..5628f03 --- /dev/null +++ b/usr/src/libm/src/LD/j0l.c @@ -0,0 +1,731 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)j0l.c 1.8 06/01/31 SMI" + +/* + * Floating point Bessel's function of the first and second kinds + * of order zero: j0(x),y0(x); + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + */ + +#pragma weak j0l = __j0l +#pragma weak y0l = __y0l + +#include "libm.h" +#include "libm_synonyms.h" +#include <math.h> +#include <sunmath.h> + +#define GENERIC long double +static GENERIC +zero = 0.0L, +small = 1.0e-9L, +tiny = 1.0e-38L, +one = 1.0L, +five = 5.0L, +eight = 8.0L, +invsqrtpi= 5.641895835477562869480794515607725858441e-0001L, +tpi = 0.636619772367581343075535053490057448L; + +static GENERIC pzero(), qzero(); +static GENERIC r0[7] = { + -2.499999999999999999999999999999998934492e-0001L, + 1.272657927360049786327618451133763714880e-0002L, + -2.694499763712963276900636693400659600898e-0004L, + 2.724877475058977576903234070919616447883e-0006L, + -1.432617103214330236967477495393076320281e-0008L, + 3.823248804080079168706683540513792224471e-0011L, + -4.183174277567983647337568504286313665065e-0014L, +}; +static GENERIC s0[7] = { + 1.0e0L, + 1.159368290559800854689526195462884666395e-0002L, + 6.629397597394973383009743876169946772559e-0005L, + 2.426779981394054406305431142501735094340e-0007L, + 6.097663491248511069094400469635449749883e-0010L, + 1.017019133340929220238747413216052224036e-0012L, + 9.012593179306197579518374581969371278481e-0016L, +}; + +GENERIC +j0l(x) GENERIC x;{ + GENERIC z, s, c, ss, cc, r, u, v; + int i; + + if(isnanl(x)) return x+x; + x = fabsl(x); + if(x > 1.28L){ + if(!finitel(x)) return zero; + s = sinl(x); + c = cosl(x); + /* j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0)) + * where x0 = x-pi/4 + * Better formula: + * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) + * = 1/sqrt(2) * (cos(x) + sin(x)) + * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if(x>1.0e2450L) { /* x+x may overflow */ + ss = s-c; + cc = s+c; + } else if(signbitl(s)!=signbitl(c)) { + ss = s - c; + cc = -cosl(x+x)/ss; + } else { + cc = s + c; + ss = -cosl(x+x)/cc; + } + /* + * j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x) + * y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x) + */ + if(x>1.0e120L) return (invsqrtpi*cc)/sqrtl(x); + u = pzero(x); v = qzero(x); + return invsqrtpi*(u*cc-v*ss)/sqrtl(x); + } + if(x<=small) { + if(x<=tiny) return one-x; + else return one-x*x*0.25L; + } + z = x*x; + r = r0[6]; s = s0[6]; + for(i=5;i>=0;i--) { + r = r*z + r0[i]; + s = s*z + s0[i]; + } + return(one+z*(r/s)); +} + +static GENERIC u0[8] = { + -7.380429510868722527434392794848301631220e-0002L, + 1.766855559625940791857536949301981816513e-0001L, + -1.386470722701047923235553251240162839408e-0002L, + 3.520149242724811578636970811631224862615e-0004L, + -3.978599663243790049853642275624951870025e-0006L, + 2.228801153263957224547222556806915479763e-0008L, + -6.121246764298785018658597179498837316177e-0011L, + 6.677103629722678833475965810525587396596e-0014L, +}; +static GENERIC v0[8] = { + 1.0e0L, + 1.247164416539111311571676766127767127970e-0002L, + 7.829144749639791500052900281489367443576e-0005L, + 3.247126540422245330511218321013360336606e-0007L, + 9.750516724789499678567062572549568447869e-0010L, + 2.156713223173591212250543390258458098776e-0012L, + 3.322169561597890004231482431236452752624e-0015L, + 2.821213295314000924252226486305726805093e-0018L, +}; + +GENERIC +y0l(x) GENERIC x;{ + GENERIC z, d, s, c, ss, cc, u, v; + int i; + + if(isnanl(x)) return x+x; + if(x <= zero){ + if(x==zero) + d= -one/(x-x); + else + d = zero/(x-x); + } + if(x > 1.28L){ + if(!finitel(x)) return zero; + s = sinl(x); + c = cosl(x); + /* j0(x) = sqrt(2/(pi*x))*(p0(x)*cos(x0)-q0(x)*sin(x0)) + * where x0 = x-pi/4 + * Better formula: + * cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4) + * = 1/sqrt(2) * (cos(x) + sin(x)) + * sin(x0) = sin(x)cos(pi/4)-cos(x)sin(pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if(x>1.0e2450L) { /* x+x may overflow */ + ss = s-c; + cc = s+c; + } else if(signbitl(s)!=signbitl(c)) { + ss = s - c; + cc = -cosl(x+x)/ss; + } else { + cc = s + c; + ss = -cosl(x+x)/cc; + } + /* + * j0(x) = 1/sqrt(pi*x) * (P(0,x)*cc - Q(0,x)*ss) + * y0(x) = 1/sqrt(pi*x) * (P(0,x)*ss + Q(0,x)*cc) + */ + if(x>1.0e120L) return (invsqrtpi*ss)/sqrtl(x); + return invsqrtpi*(pzero(x)*ss+qzero(x)*cc)/sqrtl(x); + + } + if(x<=tiny) { + return(u0[0] + tpi*logl(x)); + } + z = x*x; + u = u0[7]; v = v0[7]; + for(i=6;i>=0;i--){ + u = u*z + u0[i]; + v = v*z + v0[i]; + } + return(u/v + tpi*(j0l(x)*logl(x))); +} + +static GENERIC pr0[12] = { /* [16 -- inf] */ + 9.999999999999999999999999999999999997515e-0001L, + 1.065981615377273376425365823967550598358e+0003L, + 4.390991200927588978306374718984240719130e+0005L, + 9.072086218607986711847069407339321363103e+0007L, + 1.022552886177375367408408501046461671528e+0010L, + 6.420766912243658241570635854089597269031e+0011L, + 2.206451725126933913591080211081242266908e+0013L, + 3.928369596816895077363705478743346298368e+0014L, + 3.258159928874124597286701119721482876596e+0015L, + 1.025715808134188978860679130140685101348e+0016L, + 7.537170874795721255796001687024031280685e+0015L, + -1.579413901450157332307745586004207687796e+0014L, +}; +static GENERIC ps0[11] = { + 1.0e0L, + 1.066051927877273376425365823967550512687e+0003L, + 4.391739647168381592399173804329266353038e+0005L, + 9.075162261801343671805658294123888867884e+0007L, + 1.023186118519904751819581912075985995058e+0010L, + 6.427861860414223746340515376512730275061e+0011L, + 2.210861503237823589735481303627993406235e+0013L, + 3.943247335784292905915956840901818177989e+0014L, + 3.283720976777545142150200110647270004481e+0015L, + 1.045346918812754048903645641538728986759e+0016L, + 8.043455468065618900750599584291193680463e+0015L, +}; +static GENERIC pr1[12] = { /* [8 -- 16] */ + 9.999999999999999999999784422701108683618e-0001L, + 6.796098532948334207755488692777907062894e+0002L, + 1.840036112605722168824530758797169836042e+0005L, + 2.598490483191916637264894340635847598122e+0007L, + 2.105774863242707025525730249472054578523e+0009L, + 1.015822044230542426666314997796944979959e+0011L, + 2.931557457008110436764077699944189071875e+0012L, + 4.962885121125457633655259224179322808824e+0013L, + 4.705424055148223269155430598563351566279e+0014L, + 2.294439854910747229152056080910427001110e+0015L, + 4.905531843137486691500950019322475458629e+0015L, + 3.187543169710339218793442542845735994565e+0015L, +}; +static GENERIC ps1[14] = { + 1.0e0L, + 6.796801657948334207754571576066758180288e+0002L, + 1.840512891201300567325421059826676366447e+0005L, + 2.599777028312918975306252167127695075221e+0007L, + 2.107582572771047636846811284634244892537e+0009L, + 1.017275794694156108975782763889979940348e+0011L, + 2.938487645192463845428059755454762316011e+0012L, + 4.982512164735557054521042916182317924466e+0013L, + 4.737639900153703274792677468264564361437e+0014L, + 2.323398719123742743524249528275097100646e+0015L, + 5.033419107069210577868909797896984419391e+0015L, + 3.409036105931068609601317076759804716059e+0015L, + 7.505655364352679737585745147753521662166e+0013L, + -9.976837153983688250780198248297109118313e+0012L, +}; +static GENERIC pr2[12] = { /* [5 -- 8 ] */ + 9.999999999999999937857236789277366320220e-0001L, + 3.692848765268649571651602420376358849214e+0002L, + 5.373022067535476576926715900057760985410e+0004L, + 4.038738891191314969971504035057219430725e+0006L, + 1.728285706306940523397385566659762646999e+0008L, + 4.375400819645889911158688737206054788534e+0009L, + 6.598950418204912408375591217782088567076e+0010L, + 5.827182039183238492480275401520072793783e+0011L, + 2.884222642913492390887572414999490975844e+0012L, + 7.373278873797767721932837830628688632775e+0012L, + 8.338295457568973761205077964397969230489e+0012L, + 2.911383183467288345772308817209806922143e+0012L, +}; +static GENERIC ps2[14] = { + 1.0e0L, + 3.693551890268649477288896267171993213102e+0002L, + 5.375607880998361502474715133828068514297e+0004L, + 4.042477764024108249744998862572786367328e+0006L, + 1.731069838737016956685839588670132939513e+0008L, + 4.387147674049898778738226585935491417728e+0009L, + 6.628058659620653765349556940567715258165e+0010L, + 5.869659904164177740471685856367322160664e+0011L, + 2.919839445622817017058977559638969436383e+0012L, + 7.535314897696671402628203718612309253907e+0012L, + 8.696355561452933775773309859748610658935e+0012L, + 3.216155103141537221173601557697083216257e+0012L, + 4.756857081068942248246880159213789086363e+0010L, + -3.496356619666608032231074866481472824067e+0009L, +}; +static GENERIC pr3[13] = { /* [3.5 -- 5 ] */ + 9.999999999999916693107285612398196588247e-0001L, + 2.263975921282917721194425320484974336945e+0002L, + 1.994358386744245848889492762781484199966e+0004L, + 8.980067458430542243559962493831661323168e+0005L, + 2.282213787521372663705567756420087553508e+0007L, + 3.409784374889063618250288699908375135923e+0008L, + 3.024380857401448589254343517589811711108e+0009L, + 1.571110368046740246895071721443082286379e+0010L, + 4.603187020243604632153685300463160593768e+0010L, + 7.087196453409712719449549280664058793403e+0010L, + 5.046196021776346356803687409644239065041e+0010L, + 1.287758439080165765709154276618854799932e+0010L, + 5.900679773415023433787846658096813590784e+0008L, +}; +static GENERIC ps3[13] = { + 1.0e0L, + 2.264679046282855061328604619231774747116e+0002L, + 1.995939523988944553755653255389812103448e+0004L, + 8.993853144706348727038389967490183236820e+0005L, + 2.288326099634588843906989983704795468773e+0007L, + 3.424967100255240885169240956804790118282e+0008L, + 3.046311797972463991368023759640028910016e+0009L, + 1.589614961932826812790222479700797224003e+0010L, + 4.692406624527744816497089139325073939927e+0010L, + 7.320486495902008912866462849073108323948e+0010L, + 5.345945972828978289935309597742981360994e+0010L, + 1.444033091910423754121309915092247171008e+0010L, + 7.987714685115314668378957273824383610525e+0008L, +}; +static GENERIC pr4[13] = { /* [2.5 , 3.5] */ + 9.999999999986736677961118722747757712260e-0001L, + 1.453824980703800559037873123568378845663e+0002L, + 8.097327216430682288267610447006508661032e+0003L, + 2.273847252038264370231169686380192662135e+0005L, + 3.561056728046211111354759998976985449622e+0006L, + 3.244933588800096378434627029369680378599e+0007L, + 1.740112392860717950376210038908476792588e+0008L, + 5.426170187455893285197878563881579269524e+0008L, + 9.490107486454362321004377336020526281371e+0008L, + 8.688872439428470049801714121070005313806e+0008L, + 3.673315853166437222811910656900123215515e+0008L, + 5.577770470359303305164877446339693270239e+0007L, + 1.540438642031689641308197880181291865714e+0006L, +}; +static GENERIC ps4[13] = { /* [2.5 , 3.5] */ + 1.0e0L, + 1.454528105698159439773035951959131799816e+0002L, + 8.107442215200392397172179900434987859618e+0003L, + 2.279390393778242887574177096606328994140e+0005L, + 3.576251625592252008424781111770934135844e+0006L, + 3.267909499056932631405942058670933813863e+0007L, + 1.760021515330805537499778238099704648805e+0008L, + 5.525553787667353981242060222587465726729e+0008L, + 9.769870295912820457889384082671269328511e+0008L, + 9.110582071004774279226905629624018008454e+0008L, + 3.981857678621955599371967680343918454345e+0008L, + 6.482404686230769399073192961667697036706e+0007L, + 2.210046943095878402443535460329391782298e+0006L, +}; +static GENERIC pr5[13] = { /* [1.777..., 2.5] */ + 9.999999999114986107951817871144655880699e-0001L, + 9.252583736048588342568344570315435947614e+0001L, + 3.218726757856078715214631502407386264637e+0003L, + 5.554009964621111656479588505862577040831e+0004L, + 5.269993115643664338253196944523510290175e+0005L, + 2.874613773778430691192912190618220544575e+0006L, + 9.133538151103658353874146919613442436035e+0006L, + 1.673067041410338922825193013077354249193e+0007L, + 1.706913873848398011744790289200151840498e+0007L, + 9.067766583853288534551600235576747618679e+0006L, + 2.216746733457884568532695355036338655872e+0006L, + 1.945753880802872541235703812722344514405e+0005L, + 3.132374412921948071539195638885330951749e+0003L, +}; +static GENERIC ps5[13] = { /* [1.777..., 2.5] */ + 1.0e0L, + 9.259614983862181118883831670990340052982e+0001L, + 3.225125275462903384842124075132609290304e+0003L, + 5.575705362829101545292760055941855246492e+0004L, + 5.306049863037087855496170121958448492522e+0005L, + 2.907060758873509564309729903109018597215e+0006L, + 9.298059206584995898298257827131208539289e+0006L, + 1.720391071006963176836108026556547062980e+0007L, + 1.782614812922865190479394509487941920612e+0007L, + 9.708016389605273153536452032839879950155e+0006L, + 2.476495084688170096480215640962175140027e+0006L, + 2.363200660365585759668077790194604917187e+0005L, + 4.803239569848196077121203575704356936731e+0003L, +}; +static GENERIC pr6[13] = { /* [1.28, 1.777...] */ + 9.999999969777095495998606925524322559556e-0001L, + 5.825486719466194430503283824096872219216e+0001L, + 1.248155491637757281915184824965379905380e+0003L, + 1.302093199842358609321338417071710477615e+0004L, + 7.353835804186292782840961999810543016039e+0004L, + 2.356471661113686180549195092555751341757e+0005L, + 4.350553267429009581632987060942780847101e+0005L, + 4.588762661876600638719159826652389418235e+0005L, + 2.675796398548523436544221045225290128611e+0005L, + 8.077649557108971388298292919988449940464e+0004L, + 1.117640459221306873519068741664054573776e+0004L, + 5.544400072396814695175787511557757885585e+0002L, + 5.072550541191480498431289089905822910718e+0000L, +}; +static GENERIC ps6[13] = { /* [1.28, 1.777...] */ + 1.0e0L, + 5.832517925357165050639075848183613063291e+0001L, + 1.252144364743592128171256104364976466898e+0003L, + 1.310300234342216813579118022415585740772e+0004L, + 7.434667697093812197817292154032863632923e+0004L, + 2.398706595587719165726469002404004614711e+0005L, + 4.472737517625103157004869372427480602511e+0005L, + 4.786313523337761975294171429067037723611e+0005L, + 2.851161872872731228472536061865365370192e+0005L, + 8.891648269899148412331918021801385815586e+0004L, + 1.297097489535351517572978123584751042287e+0004L, + 7.096761640545975756202184143400469812618e+0002L, + 8.378049338590233325977702401733340820351e+0000L, +}; +static GENERIC sixteen = 16.0L; +static GENERIC huge = 1.0e30L; + +static GENERIC pzero(x) +GENERIC x; +{ + GENERIC s,r,t,z; + int i; + if(x>huge) return one; + t = one/x; z = t*t; + if(x>sixteen) { + r = z*pr0[11]+pr0[10]; s = ps0[10]; + for(i=9;i>=0;i--) { + r = z*r + pr0[i]; + s = z*s + ps0[i]; + } + } else if (x > eight){ + r = pr1[11]; s = ps1[11]+z*(ps1[12]+z*ps1[13]); + for(i=10;i>=0;i--) { + r = z*r + pr1[i]; + s = z*s + ps1[i]; + } + } else if (x > five){ /* x > 5.0 */ + r = pr2[11]; s = ps2[11]+z*(ps2[12]+z*ps2[13]); + for(i=10;i>=0;i--) { + r = z*r + pr2[i]; + s = z*s + ps2[i]; + } + } else if( x>3.5L) { + r = pr3[12]; s = ps3[12]; + for(i=11;i>=0;i--) { + r = z*r + pr3[i]; + s = z*s + ps3[i]; + } + } else if( x>2.5L) { + r = pr4[12]; s = ps4[12]; + for(i=11;i>=0;i--) { + r = z*r + pr4[i]; + s = z*s + ps4[i]; + } + } else if( x> (1.0L/0.5625L)){ + r = pr5[12]; s = ps5[12]; + for(i=11;i>=0;i--) { + r = z*r + pr5[i]; + s = z*s + ps5[i]; + } + } else { /* assume x > 1.28 */ + r = pr6[12]; s = ps6[12]; + for(i=11;i>=0;i--) { + r = z*r + pr6[i]; + s = z*s + ps6[i]; + } + } + return r/s; +} + + +static GENERIC qr0[12] = { /* [16, inf] */ + -1.249999999999999999999999999999999972972e-0001L, + -1.425179595545670577414395762503991596897e+0002L, + -6.312499645625970845534460257936222407219e+0004L, + -1.411374326457208384315121243698814446848e+0007L, + -1.735034212758873581410984757860787252842e+0009L, + -1.199777647512789489421826342485055280680e+0011L, + -4.596025334081655714499860409699100373644e+0012L, + -9.262525628201284107792924477031653399187e+0013L, + -8.858394728685039245344398842180662867639e+0014L, + -3.267527953687534887623740622709505972113e+0015L, + -2.664222971186311967587129347029450062019e+0015L, + 3.442464060723987869585180095344504100204e+0014L, +}; +static GENERIC qs0[11] = { + 1.0e0L, + 1.140729613936536461931516610003185687881e+0003L, + 5.056665510442299351009198186490085803580e+0005L, + 1.132041763825642787943941650522718199115e+0008L, + 1.394570111872581606392620678214246479767e+0010L, + 9.677945218152264789534431079563744378421e+0011L, + 3.731140327851536828225143058896348502096e+0013L, + 7.612785951064869291722846681020881676410e+0014L, + 7.476077016406764891730191004811863975940e+0015L, + 2.951246482613592035421503427100393831709e+0016L, + 3.108361803691811711136854587074302034901e+0016L, +}; +static GENERIC qr1[12] = { /* [8, 16 ] */ + -1.249999999999999999997949010383433818157e-0001L, + -9.051215166393822640636752244895124126934e+0001L, + -2.620782703428148837671179031904208303947e+0004L, + -3.975571261553504457766177974508785790884e+0006L, + -3.479029330759311306270072218074074994090e+0008L, + -1.823955008124268573036216746186239829089e+0010L, + -5.765932697111801375765156029221568664435e+0011L, + -1.079843680798742592954002192417934779114e+0013L, + -1.146893630504592739082205764611581332897e+0014L, + -6.367016059683898464936104447282880704182e+0014L, + -1.583109041961213490464459111903484209098e+0015L, + -1.230149555764242473103128650135795639412e+0015L, +}; +static GENERIC qs1[14] = { + 1.0e0L, + 7.246831508115058112438579847778014458432e+0002L, + 2.100854184439168518399383786306927037611e+0005L, + 3.192636418837951507430188285940994235122e+0007L, + 2.801558443383354674538443461124434216152e+0009L, + 1.475026997664373739293483927250653467487e+0011L, + 4.694486824913954608552363821799927145318e+0012L, + 8.890350100919200250838438709601547334021e+0013L, + 9.626844429082905144874701068760469752067e+0014L, + 5.541110744600460773528263862687521642140e+0015L, + 1.486500494789452556727470329232123096563e+0016L, + 1.415840104845959400365430773732093899210e+0016L, + 1.780866095241517418081312567239682336483e+0015L, + -2.359230917384889357887631544079990129494e+0014L, +}; +static GENERIC qr2[12] = { /* [5, 8] */ + -1.249999999999999531937744362527772181614e-0001L, + -4.944373897356969774839375977239241573966e+0001L, + -7.728449175433465285314261650078450473909e+0003L, + -6.262574329612752346336901434651220705903e+0005L, + -2.900948220220943306027235217424380672732e+0007L, + -7.988719647634192770463917157562874119535e+0008L, + -1.318228171927181389547760026626357012375e+0010L, + -1.282439773983029245309263271945424928196e+0011L, + -7.050925570827818040186149940257918845138e+0011L, + -2.021751882573871990004205616874202684429e+0012L, + -2.592939962400668552384333900573812635658e+0012L, + -1.038267109518891262840601514932972850326e+0012L, +}; +static GENERIC qs2[14] = { + 1.0e0L, + 3.961358492885570003202784022894248952116e+0002L, + 6.205788738864701882828752634586510926968e+0004L, + 5.045715603932670286550673813011764406749e+0006L, + 2.349248611362658323353343389430968751429e+0008L, + 6.520244524415828635917683553721880063911e+0009L, + 1.089111211223507719337067159886281887722e+0011L, + 1.080406000905359867958779409414903018610e+0012L, + 6.135645280895514703514154680623769562148e+0012L, + 1.862433040246625874245867151368643668215e+0013L, + 2.667780805786648888840777888702193708994e+0013L, + 1.394401107289087774765300711809313112824e+0013L, + 1.093247500616320375562898297156722445484e+0012L, + -7.228875530378928722826604216491493780775e+0010L, +}; +static GENERIC qr3[13] = { /* [3.5 5] */ + -1.249999999999473067748420379578481661075e-0001L, + -3.044549048635289351913574324803250977998e+0001L, + -2.890081140649769078496693003524681440869e+0003L, + -1.404922456817202235879343275330529107684e+0005L, + -3.862746614385573443518177403617349281869e+0006L, + -6.257517309110249049201133708911155047689e+0007L, + -6.031451330920839916987079782727323477520e+0008L, + -3.411542405173830611454025765755854382346e+0009L, + -1.089392478149726672133014498723021526099e+0010L, + -1.824934078420210941290140903415956782726e+0010L, + -1.400780278304358710423481070486939531139e+0010L, + -3.716484136064917363926635716743771092093e+0009L, + -1.397591075296425529970434890954904331580e+0008L, +}; +static GENERIC qs3[13] = { + 1.0e0L, + 2.441498613904962049391000187014945858042e+0002L, + 2.326188882072370711500164222341514337043e+0004L, + 1.137138213121231338494977104659239578165e+0006L, + 3.152918070735662728722998452605364253517e+0007L, + 5.172877993426507259314270488444013595108e+0008L, + 5.083086439731669807455961078856470774115e+0009L, + 2.961842732066434123119325521139476909941e+0010L, + 9.912185866862440735829781856081353151390e+0010L, + 1.793560561251622234430564181567297983598e+0011L, + 1.577090119341228122525265108497940403073e+0011L, + 5.509910306780166194333889999985463681636e+0010L, + 4.761691134078874491202320181517936758141e+0009L, +}; +static GENERIC qr4[13] = { /* [2.5 3.5] */ + -1.249999999928567734339745043490705340835e-0001L, + -1.967201748731419063051601624435565528481e+0001L, + -1.186329146714562236407099740615528170707e+0003L, + -3.607736959222941810356301491152457934060e+0004L, + -6.119200717978104904932828468575194267125e+0005L, + -6.037847781158358226670305078652205586384e+0006L, + -3.503558153336140359700536720393565984740e+0007L, + -1.180196478268225718757218523746787309773e+0008L, + -2.221860232085134915841426363505169680528e+0008L, + -2.173372505452747585296176761701746236760e+0008L, + -9.649364865061237558517730539506568013963e+0007L, + -1.465429227847933034546039640094862650385e+0007L, + -3.083003197920262085170581866246663380607e+0005L, +}; +static GENERIC qs4[13] = { /* [2.5 3.5] */ + 1.0e0L, + 1.579620773732259142752614142139986854055e+0002L, + 9.581372220329138733203879503753685054968e+0003L, + 2.939598672379108095776114131010825885308e+0005L, + 5.052183049314542218630341818692588448168e+0006L, + 5.083497695595206639433839326338971980149e+0007L, + 3.036385361800553388049719014005099206516e+0008L, + 1.067826481452753409910563785161661492137e+0009L, + 2.145644125557118044720741775125319669272e+0009L, + 2.324115615959719949363946673491552216799e+0009L, + 1.223262962112070757966959855619847011146e+0009L, + 2.569765553318495423738478585947110270709e+0008L, + 1.354744744299227127897905787732636565504e+0007L, +}; +static GENERIC qr5[13] = { /* [1.777.., 2.5] */ + -1.249999995936639697637680428174576069971e-0001L, + -1.260846055371311453485891923426489068315e+0001L, + -4.772398467544467480801174330290141578895e+0002L, + -8.939852599990298486613760833996490599724e+0003L, + -9.184070787149542050979542226446134243197e+0004L, + -5.406038945018274458362637897739280435171e+0005L, + -1.845896544705190261018653728678171084418e+0006L, + -3.613616990680809501878667570653308071547e+0006L, + -3.908782978135693252252557720414348623779e+0006L, + -2.173711022517323927109138170588442768176e+0006L, + -5.431253130679918485836408549007856244495e+0005L, + -4.591098546452684510082591587275940765959e+0004L, + -5.244711364168207806835520057792229646578e+0002L, +}; +static GENERIC qs5[13] = { /* [1.777.., 2.5] */ + 1.0e0L, + 1.014536210851290878350892750972474861447e+0002L, + 3.875547510687135314064434160096139681076e+0003L, + 7.361913122670079814955259281995617732580e+0004L, + 7.720288944218771126581086539585529314636e+0005L, + 4.681529554446752496404431433608306558038e+0006L, + 1.667882621940503925455031252308367745820e+0007L, + 3.469403153761399881888272620855305156241e+0007L, + 4.096992047964210711867089384719947863019e+0007L, + 2.596804755829217449311530735959560630554e+0007L, + 7.983933774697889238154465064019410763845e+0006L, + 9.818133816979900819087242425280757938152e+0005L, + 3.061083930868694396013541535670745443560e+0004L, +}; + +static GENERIC qr6[13] = { /* [1.28, 1.777..] */ + -1.249999881577289001807137282824929082771e-0001L, + -7.998273510053110759610810594119533619282e+0000L, + -1.872481955335172543369089617771565632719e+0002L, + -2.122116786726300805079874003303799646812e+0003L, + -1.293850285839529282503178263484773478457e+0004L, + -4.445024742266316181033354192262529356093e+0004L, + -8.730161378334357767668344467356505347070e+0004L, + -9.706222895172078442801444972505315054736e+0004L, + -5.896325518259858270165531513618195321041e+0004L, + -1.823172034368108822276420827074668832233e+0004L, + -2.509304178635055926638833040337472387175e+0003L, + -1.156608965715779237316769828941729964099e+0002L, + -7.028005789650731396887346826397785210442e-0001L, +}; +static GENERIC qs6[13] = { /* [1.28, 1.777..] */ + 1.0e0L, + 6.457211085058064845601261321277721075900e+0001L, + 1.534005216588011210342824555136008682950e+0003L, + 1.777217999176441782593357660462379097171e+0004L, + 1.118372652642469468091084810263231199696e+0005L, + 4.015242433858461813142365748386473605294e+0005L, + 8.377081045517098645448616514388280497673e+0005L, + 1.011495020008010352575398009604164287337e+0006L, + 6.886722075290430568652227875200208955970e+0005L, + 2.504735189948021472047157148613171956537e+0005L, + 4.408138920171044846941001844352009817062e+0004L, + 3.105572178072115145673058722853640854884e+0003L, + 5.588294821118916113437396504573817033678e+0001L, +}; +static GENERIC qzero(x) +GENERIC x; +{ + GENERIC s,r,t,z; + int i; + if(x>huge) return -0.125L/x; + t = one/x; z = t*t; + if(x>sixteen) { + r = z*qr0[11]+qr0[10]; s = qs0[10]; + for(i=9;i>=0;i--) { + r = z*r + qr0[i]; + s = z*s + qs0[i]; + } + } else if(x>eight) { + r = qr1[11]; s = qs1[11]+z*(qs1[12]+z*qs1[13]); + for(i=10;i>=0;i--) { + r = z*r + qr1[i]; + s = z*s + qs1[i]; + } + } else if(x>five){ /* assume x > 5.0 */ + r = qr2[11]; s = qs2[11]+z*(qs2[12]+z*qs2[13]); + for(i=10;i>=0;i--) { + r = z*r + qr2[i]; + s = z*s + qs2[i]; + } + } else if(x>3.5L) { + r = qr3[12]; s = qs3[12]; + for(i=11;i>=0;i--) { + r = z*r + qr3[i]; + s = z*s + qs3[i]; + } + } else if(x>2.5L) { + r = qr4[12]; s = qs4[12]; + for(i=11;i>=0;i--) { + r = z*r + qr4[i]; + s = z*s + qs4[i]; + } + } else if(x> (1.0L/0.5625L)) { + r = qr5[12]; s = qs5[12]; + for(i=11;i>=0;i--) { + r = z*r + qr5[i]; + s = z*s + qs5[i]; + } + } else { /* assume x > 1.28 */ + r = qr6[12]; s = qs6[12]; + for(i=11;i>=0;i--) { + r = z*r + qr6[i]; + s = z*s + qs6[i]; + } + } + return t*(r/s); +} diff --git a/usr/src/libm/src/LD/j1l.c b/usr/src/libm/src/LD/j1l.c new file mode 100644 index 0000000..7941a29 --- /dev/null +++ b/usr/src/libm/src/LD/j1l.c @@ -0,0 +1,731 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)j1l.c 1.9 06/01/31 SMI" + +/* + * floating point Bessel's function of the first and second kinds + * of order zero: j1(x),y1(x); + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + */ + +#pragma weak j1l = __j1l +#pragma weak y1l = __y1l + +#include "libm.h" +#include "libm_synonyms.h" +#include <math.h> +#include <sunmath.h> + +#define GENERIC long double +static GENERIC +zero = 0.0L, +small = 1.0e-9L, +tiny = 1.0e-38L, +one = 1.0L, +five = 5.0L, +invsqrtpi= 5.641895835477562869480794515607725858441e-0001L, +tpi = 0.636619772367581343075535053490057448L; + +static GENERIC pone(), qone(); +static GENERIC r0[7] = { + -6.249999999999999999999999999999999627320e-0002L, + 1.940606727194041716205384618494641565464e-0003L, + -3.005630423155733701856481469986459043883e-0005L, + 2.345586219403918667468341047369572169358e-0007L, + -9.976809285885253587529010109133336669724e-0010L, + 2.218743258363623946078958783775107473381e-0012L, + -2.071079656218700604767650924103578046280e-0015L, +}; +static GENERIC s0[7] = { + 1.0e0L, + 1.061695903156199920738051277075003059555e-0002L, + 5.521860513111180371566951179398862692060e-0005L, + 1.824214367413754193524107877084979441407e-0007L, + 4.098957778439576834818838198039029353925e-0010L, + 6.047735079699666389853240090925264056197e-0013L, + 4.679044728878836197247923279512047035041e-0016L, +}; + +GENERIC +j1l(x) GENERIC x;{ + GENERIC z, d, s, c, ss, cc, r; + int i, sgn; + + if(!finitel(x)) return one/x; + sgn = signbitl(x); + x = fabsl(x); + if(x > 1.28L){ + s = sinl(x); + c = cosl(x); + /* j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x0)-q1(x)*sin(x0)) + * where x0 = x-3pi/4 + * Better formula: + * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = -1/sqrt(2) * (cos(x) + sin(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if(x>1.0e2450L) { /* x+x may overflow */ + ss = -s-c; + cc = s-c; + } else if(signbitl(s)!=signbitl(c)) { + cc = s - c; + ss = cosl(x+x)/cc; + } else { + ss = -s-c; + cc = cosl(x+x)/ss; + } + /* + * j1(x) = 1/sqrt(pi*x) * (P(1,x)*cc - Q(1,x)*ss) + * y1(x) = 1/sqrt(pi*x) * (P(1,x)*ss + Q(1,x)*cc) + */ + if(x>1.0e120L) return (invsqrtpi*cc)/sqrtl(x); + d = invsqrtpi*(pone(x)*cc-qone(x)*ss)/sqrtl(x); + if(sgn==0) return d; else return -d; + } + if(x<=small) { + if(x<=tiny) d = 0.5L*x; + else d = x*(0.5L-x*x*0.125L); + if(sgn==0) return d; else return -d; + } + z = x*x; + r = r0[6]; + s = s0[6]; + for(i=5;i>=0;i--) { + r = r*z + r0[i]; + s = s*z + s0[i]; + } + d = x*0.5L+x*(z*(r/s)); + if(sgn==0) return d; else return -d; +} + +static GENERIC u0[7] = { + -1.960570906462389484060557273467558703503e-0001L, + 5.166389353148318460304315890665450006495e-0002L, + -2.229699464105910913337190798743451115604e-0003L, + 3.625437034548863342715657067759078267158e-0005L, + -2.689902826993117212255524537353883987171e-0007L, + 9.304570592456930912969387719010256018466e-0010L, + -1.234878126794286643318321347997500346131e-0012L, +}; +static GENERIC v0[8] = { + 1.0e0L, + 1.369394302535807332517110204820556695644e-0002L, + 9.508438148097659501433367062605935379588e-0005L, + 4.399007309420092056052714797296467565655e-0007L, + 1.488083087443756398305819693177715000787e-0009L, + 3.751609832625793536245746965768587624922e-0012L, + 6.680926434086257291872903276124244131448e-0015L, + 6.676602383908906988160099057991121446058e-0018L, +}; + +GENERIC +y1l(x) GENERIC x;{ + GENERIC z, s, c, ss, cc, u, v; + int i; + + if(isnanl(x)) return x+x; + if(x <= zero){ + if(x==zero) + return -one/zero; + else + return zero/zero; + } + if(x > 1.28L){ + if(!finitel(x)) return zero; + s = sinl(x); + c = cosl(x); + /* j1(x) = sqrt(2/(pi*x))*(p1(x)*cos(x0)-q1(x)*sin(x0)) + * where x0 = x-3pi/4 + * Better formula: + * cos(x0) = cos(x)cos(3pi/4)+sin(x)sin(3pi/4) + * = 1/sqrt(2) * (sin(x) - cos(x)) + * sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4) + * = -1/sqrt(2) * (cos(x) + sin(x)) + * To avoid cancellation, use + * sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x)) + * to compute the worse one. + */ + if(x>1.0e2450L) { /* x+x may overflow */ + ss = -s-c; + cc = s-c; + } else if(signbitl(s)!=signbitl(c)) { + cc = s - c; + ss = cosl(x+x)/cc; + } else { + ss = -s-c; + cc = cosl(x+x)/ss; + } + /* + * j1(x) = 1/sqrt(pi*x) * (P(1,x)*cc - Q(1,x)*ss) + * y1(x) = 1/sqrt(pi*x) * (P(1,x)*ss + Q(1,x)*cc) + */ + if(x>1.0e91L) return (invsqrtpi*ss)/sqrtl(x); + return invsqrtpi*(pone(x)*ss+qone(x)*cc)/sqrtl(x); + } + if(x<=tiny) { + return(-tpi/x); + } + z = x*x; + u = u0[6]; v = v0[6]+z*v0[7]; + for(i=5;i>=0;i--){ + u = u*z + u0[i]; + v = v*z + v0[i]; + } + return(x*(u/v) + tpi*(j1l(x)*logl(x)-one/x)); +} + +static GENERIC pr0[12] = { + 1.000000000000000000000000000000000000267e+0000L, + 1.060717875045891455602180843276758003035e+0003L, + 4.344347542892127024446687712181105852335e+0005L, + 8.915680220724007016377924252717410457094e+0007L, + 9.969502259938406062809873257569171272819e+0009L, + 6.200290193138613035646510338707386316595e+0011L, + 2.105978548788015119851815854422247330118e+0013L, + 3.696635772784601239371730810311998368948e+0014L, + 3.015913097920694682057958412534134515156e+0015L, + 9.370298471339353098123277427328592725921e+0015L, + 7.190349005196335967340799265074029443057e+0015L, + 2.736097786240689996880391074927552517982e+0014L, +}; +static GENERIC ps0[11] = { + 1.0e0L, + 1.060600687545891455602180843276758095107e+0003L, + 4.343106093416975589147153906505338900961e+0005L, + 8.910605869002176566582072242244353399059e+0007L, + 9.959122058635087888690713917622056540190e+0009L, + 6.188744967234948231792482949171041843894e+0011L, + 2.098863976953783506401759873801990304907e+0013L, + 3.672870357018063196746729751479938908450e+0014L, + 2.975538419246824921049011529574385888420e+0015L, + 9.063657659995043205018686029284479837091e+0015L, + 6.401953344314747916729366441508892711691e+0015L, +}; +static GENERIC pr1[12] = { + 1.000000000000000000000023667524130660984e+0000L, + 6.746154419979618754354803488126452971204e+0002L, + 1.811210781083390154857018330296145970502e+0005L, + 2.533098390379924268038005329095287842244e+0007L, + 2.029683619805342145252338570875424600729e+0009L, + 9.660859662192711465301069401598929980319e+0010L, + 2.743396238644831519934098967716621316316e+0012L, + 4.553097354140854377931023170263455246288e+0013L, + 4.210245069852219757476169864974870720374e+0014L, + 1.987334056229596485076645967176169801727e+0015L, + 4.067120052787096893838970455751338930462e+0015L, + 2.486539606380406398310845264910691398133e+0015L, +}; +static GENERIC ps1[14] = { + 1.0e0L, + 6.744982544979618754355808680196859521782e+0002L, + 1.810421795396966762032155290441364740350e+0005L, + 2.530986460644310651529583759699988435573e+0007L, + 2.026743276048023121360249288818290224145e+0009L, + 9.637461924407405935245269407052641341836e+0010L, + 2.732378628423766417402292797028314160831e+0012L, + 4.522345274960527124354844364012184278488e+0013L, + 4.160650668341743132685335758415469856545e+0014L, + 1.943730242988858208243492424892435901211e+0015L, + 3.880228532692127989901131618598067450001e+0015L, + 2.178020816161154615841000173683302999728e+0015L, + -8.994062666842225551554346698171600634173e+0013L, + 1.368520368508851253495764806934619574990e+0013L, +}; +static GENERIC pr2[12] = { + 1.000000000000000006938651621840396237282e+0000L, + 3.658416291850404981407101077037948144698e+0002L, + 5.267073772170356547709794670602812447537e+0004L, + 3.912012101226837463014925210735894620442e+0006L, + 1.651295648974103957193874928714180765625e+0008L, + 4.114901144480797609972484998142146783499e+0009L, + 6.092524309766036681542980572526335147672e+0010L, + 5.263913178071282616719249969074134570577e+0011L, + 2.538408581124324223367341020538081330994e+0012L, + 6.288607929360291027895126983015365677648e+0012L, + 6.848330048211148419047055075386525945280e+0012L, + 2.290309646838867941423178163991423244690e+0012L, +}; +static GENERIC ps2[14] = { + 1.0e0L, + 3.657244416850405086459410165762319861856e+0002L, + 5.262802358425023243992387075861237306312e+0004L, + 3.905896813959919648136295861661483848364e+0006L, + 1.646791907791461220742694842108202772763e+0008L, + 4.096132803064256022224954120208201437344e+0009L, + 6.046665195915950447544429445730680236759e+0010L, + 5.198061739781991313414052212328653295168e+0011L, + 2.484233851814333966401527626421254279796e+0012L, + 6.047868806925315879339651539434315255940e+0012L, + 6.333103831254091652501642567294101813354e+0012L, + 1.875143098754284994467609936924685024968e+0012L, + -5.238330920563392692965412762508813601534e+0010L, + 4.656888609439364725427789198383779259957e+0009L, +}; +static GENERIC pr3[13] = { + 1.000000000000009336887318068056137842897e+0000L, + 2.242719942728459588488051572002835729183e+0002L, + 1.955450611382026550266257737331095691092e+0004L, + 8.707143293993619899395400562409175590739e+0005L, + 2.186267894487004565948324289010954505316e+0007L, + 3.224328510541957792360691585667502864688e+0008L, + 2.821057355151380597331792896882741364897e+0009L, + 1.445371387295422404365584793796028979840e+0010L, + 4.181743160669891357783011002656658107864e+0010L, + 6.387371088767993119325536137794535513922e+0010L, + 4.575619999412716078064070587767416436396e+0010L, + 1.228415651211639160620284441690503550842e+0010L, + 7.242170349875563053436050532153112882072e+0008L, +}; +static GENERIC ps3[13] = { + 1.0e0L, + 2.241548067728529551049804610486061401070e+0002L, + 1.952838216795552145132137932931237181307e+0004L, + 8.684574926493185744628127341069974575526e+0005L, + 2.176357771067037962940853412819852189164e+0007L, + 3.199958682356132977319258783167122100567e+0008L, + 2.786218931525334687844675219914201872570e+0009L, + 1.416283776951741549631417572317916039767e+0010L, + 4.042962659271567948735676834609348842922e+0010L, + 6.028168462646694510083847222968444402161e+0010L, + 4.118410226794641413833887606580085281111e+0010L, + 9.918735736297038430744161253338202230263e+0009L, + 4.092967198238098023219124487437130332038e+0008L, +}; +static GENERIC pr4[13] = { + 1.000000000001509220978157399042059553390e+0000L, + 1.437551868378147851133499996323782607787e+0002L, + 7.911335537418177296041518061404505428004e+0003L, + 2.193710939115317214716518908935756104804e+0005L, + 3.390662495136730962513489796538274984382e+0006L, + 3.048655347929348891006070609293884274789e+0007L, + 1.613781633489496606354045161527450975195e+0008L, + 4.975089835037230277110156150038482159988e+0008L, + 8.636047087015115403880904418339566323264e+0008L, + 7.918202912328366140110671223076949101509e+0008L, + 3.423294665798984733439650311722794853294e+0008L, + 5.621904953441963961040503934782662613621e+0007L, + 2.086303543310240260758670404509484499793e+0006L, +}; +static GENERIC ps4[13] = { + 1.0e0L, + 1.436379993384532371670493319591847362304e+0002L, + 7.894647154785430678061053848847436659499e+0003L, + 2.184659753392097529008981741550878586174e+0005L, + 3.366109083305465176803513738147049499361e+0006L, + 3.011911545968996817697665866587226343186e+0007L, + 1.582262913779689851316760148459414895301e+0008L, + 4.819268809494937919217938589530138201770e+0008L, + 8.201355762990450679702837123432527154830e+0008L, + 7.268232093982510937417446421282341425212e+0008L, + 2.950911909015572933262131323934036480462e+0008L, + 4.242839924305934423010858966540621219396e+0007L, + 1.064387620445090779182117666330405186866e+0006L, +}; +static GENERIC pr5[13] = { + 1.000000000102434805241171427253847353861e+0000L, + 9.129332257083629259060502249025963234821e+0001L, + 3.132238483586953037576119377504557191413e+0003L, + 5.329782528269307971278943122454171107861e+0004L, + 4.988460157184117790692873002103052944145e+0005L, + 2.686602071615786816147010334256047469378e+0006L, + 8.445418526028961197703799808701268301831e+0006L, + 1.536575358646141157475725889907900827390e+0007L, + 1.568405818236523821796862770586544811945e+0007L, + 8.450876239888770102387618667362302173547e+0006L, + 2.154414900139567328424026827163203446077e+0006L, + 2.105656926565043898888460254808062352205e+0005L, + 4.739165011023396507022134303736862812975e+0003L, +}; +static GENERIC ps5[13] = { + 1.0e0L, + 9.117613509595327476509152673394703847793e+0001L, + 3.121697972484015639301279229281770795147e+0003L, + 5.294447222735893568040911873834576440255e+0004L, + 4.930368882192772335798256684110887882807e+0005L, + 2.634854685641165298302167435798357437768e+0006L, + 8.185462775400326393555896157031818280918e+0006L, + 1.462417423080215192609668642663030667086e+0007L, + 1.450624993985851675982860844153954896015e+0007L, + 7.460467647561995283219086567162006113864e+0006L, + 1.754210981405612478869227142579056338965e+0006L, + 1.463286721155271971526264914524746699596e+0005L, + 2.155894725796702015341211116579827039459e+0003L, +}; +static GENERIC pr6[13] = { + 1.000000003564855546741735920315743157129e+0000L, + 5.734003934862540458119423509909510288366e+0001L, + 1.209572491935850486086559692291796887976e+0003L, + 1.243398391422281247933674779163660286838e+0004L, + 6.930996755181437937258220998601708278787e+0004L, + 2.198067659532757598646722249966767620099e+0005L, + 4.033659432712058633933179115820576858455e+0005L, + 4.257759657219008027016047206574574358678e+0005L, + 2.511917395876004349480721277445763916389e+0005L, + 7.813756153070623654178731651381881953552e+0004L, + 1.152069173381127881385588092905864352891e+0004L, + 6.548580782804088553777816037551523398082e+0002L, + 8.668725370116906132327542766127938496880e+0000L, +}; +static GENERIC ps6[13] = { + 1.0e0L, + 5.722285236357114566499221525736286205184e+0001L, + 1.203010842878317935444582950620339570506e+0003L, + 1.230058335378583550155825502172435371208e+0004L, + 6.800998550607861288865300438648089894412e+0004L, + 2.130767829599304262987769347536850885921e+0005L, + 3.840483466643916681759936972992155310026e+0005L, + 3.947432373459225542861819148108081160393e+0005L, + 2.237816239393081111481588434457838526738e+0005L, + 6.545820495124419723398946273790921540774e+0004L, + 8.729563630320892741500726213278834737196e+0003L, + 4.130762660291894753450174794196998813709e+0002L, + 3.480368898672684645130335786015075595598e+0000L, +}; +static GENERIC sixteen = 16.0L; +static GENERIC eight = 8.0L; +static GENERIC huge = 1.0e30L; + +static GENERIC pone(x) +GENERIC x; +{ + GENERIC s,r,t,z; + int i; + if(x>huge) return one; + t = one/x; z = t*t; + if(x>sixteen) { + r = z*pr0[11]+pr0[10]; s = ps0[10]; + for(i=9;i>=0;i--) { + r = z*r + pr0[i]; + s = z*s + ps0[i]; + } + } else if(x>eight) { + r = pr1[11]; s = ps1[11]+z*(ps1[12]+z*ps1[13]); + for(i=10;i>=0;i--) { + r = z*r + pr1[i]; + s = z*s + ps1[i]; + } + } else if(x>five) { + r = pr2[11]; s = ps2[11]+z*(ps2[12]+z*ps2[13]); + for(i=10;i>=0;i--) { + r = z*r + pr2[i]; + s = z*s + ps2[i]; + } + } else if( x>3.5L) { + r = pr3[12]; s = ps3[12]; + for(i=11;i>=0;i--) { + r = z*r + pr3[i]; + s = z*s + ps3[i]; + } + } else if( x>2.5L) { + r = pr4[12]; s = ps4[12]; + for(i=11;i>=0;i--) { + r = z*r + pr4[i]; + s = z*s + ps4[i]; + } + } else if( x> (1.0L/0.5625L)){ + r = pr5[12]; s = ps5[12]; + for(i=11;i>=0;i--) { + r = z*r + pr5[i]; + s = z*s + ps5[i]; + } + } else { /* assume x > 1.28 */ + r = pr6[12]; s = ps6[12]; + for(i=11;i>=0;i--) { + r = z*r + pr6[i]; + s = z*s + ps6[i]; + } + } + return r/s; +} + + +static GENERIC qr0[12] = { + 3.749999999999999999999999999999999971033e-0001L, + 4.256726035237050601607682277433094262226e+0002L, + 1.875976490812878489192409978945401066066e+0005L, + 4.170314268048041914273603680317745592790e+0007L, + 5.092750132543855817293451118974555746551e+0009L, + 3.494749676278488654103505795794139483404e+0011L, + 1.327062148257437316997667817096694173709e+0013L, + 2.648993138273427226907503742066551150490e+0014L, + 2.511695665909547412222430494473998127684e+0015L, + 9.274694506662289043224310499164702306096e+0015L, + 8.150904170663663829331320302911792892002e+0015L, + -5.001918733707662355772037829620388765122e+0014L, +}; +static GENERIC qs0[11] = { + 1.0e0L, + 1.135400380229880160428715273982155760093e+0003L, + 5.005701183877126164326765545516590744360e+0005L, + 1.113444200113712167984337603933040102987e+0008L, + 1.361074819925223062778717565699039471124e+0010L, + 9.355750985802849484438933905325982809653e+0011L, + 3.563462786008988825003965543857998084828e+0013L, + 7.155145113900094163648726863803802910454e+0014L, + 6.871266835834472758055559013851843654113e+0015L, + 2.622030899226736712644974988157345234092e+0016L, + 2.602912729172876330650077021706139707746e+0016L, +}; +static GENERIC qr1[12] = { + 3.749999999999999999997762458207284405806e-0001L, + 2.697883998881706839929255517498189980485e+0002L, + 7.755195925781028489386938870473834411019e+0004L, + 1.166777762104017777198211072895528968355e+0007L, + 1.011504772984321168320010084520261069362e+0009L, + 5.246007703574156853577754571720205550010e+0010L, + 1.637692549885592683166116551691266537647e+0012L, + 3.022303623698185669912990310925039382495e+0013L, + 3.154769927290655684846107030265909987946e+0014L, + 1.715819913441554770089730934808123360921e+0015L, + 4.165044355759732622273534445131736188510e+0015L, + 3.151381420874174705643100381708086287596e+0015L, +}; +static GENERIC qs1[14] = { + 1.0e0L, + 7.197091705351218239785633172408276982828e+0002L, + 2.070012799599548685544883041297609861055e+0005L, + 3.117014815317656221871840152778458754516e+0007L, + 2.705719678902554974863325877025902971727e+0009L, + 1.406113614727345726925060648750867264098e+0011L, + 4.403777536067131320363005978631674817359e+0012L, + 8.170725690209322283061499386703167242894e+0013L, + 8.609458844975495289227794126964431210566e+0014L, + 4.766766367015473481257280600694952920204e+0015L, + 1.202286587943342194863557940888115641650e+0016L, + 1.012474328306200909525063936061756024120e+0016L, + 6.183552022678917858273222879615824070703e+0014L, + -9.756731548558226997573737400988225722740e+0013L, +}; +static GENERIC qr2[12] = { + 3.749999999999999481245647262226994293189e-0001L, + 1.471366807289771354491181140167359026735e+0002L, + 2.279432486768448220142080962843526951250e+0004L, + 1.828943048523771225163804043356958285893e+0006L, + 8.379828388647823135832220596417725010837e+0007L, + 2.279814029335044024585393671278378022053e+0009L, + 3.711653952257118120832817785271466441420e+0010L, + 3.557650914518554549916730572553105048068e+0011L, + 1.924583483146095896259774329498934160650e+0012L, + 5.424386256063736390759567088291887140278e+0012L, + 6.839325621241776786206509704671746841737e+0012L, + 2.702169563144001166291686452305436313971e+0012L, +}; +static GENERIC qs2[14] = { + 1.0e0L, + 3.926379194439388135703211933895203191089e+0002L, + 6.089148804106598297488336063007609312276e+0004L, + 4.893546162973278583711376356041614150645e+0006L, + 2.247571119114497845046388801813832219404e+0008L, + 6.137635663350177751290469334200757872645e+0009L, + 1.005115019784102856424493519524998953678e+0011L, + 9.725664462014503832860151384604677240620e+0011L, + 5.345525100485511116148634192844434636072e+0012L, + 1.549944007398946691720862738173956994779e+0013L, + 2.067148441178952625710302124163264760362e+0013L, + 9.401565402641963611295119487242595462301e+0012L, + 3.548217088622398274748837287769709374385e+0011L, + -2.934470341719047120076509938432417352365e+0010L, +}; +static GENERIC qr3[13] = { + 3.749999999999412724084579833297451472091e-0001L, + 9.058478580291706212422978492938435582527e+0001L, + 8.524056033161038750461083666711724381171e+0003L, + 4.105967158629109427753434569223631014730e+0005L, + 1.118326603378531348259783091972623333657e+0007L, + 1.794636683403578918528064904714132329343e+0008L, + 1.714314157463635959556133236004368896724e+0009L, + 9.622092032236084846572067257267661456030e+0009L, + 3.057759524485859159957762858780768355020e+0010L, + 5.129306780754798531609621454415938890020e+0010L, + 3.999122002794961070680636194346316041352e+0010L, + 1.122298454643493485989721564358100345388e+0010L, + 5.603981987645989709668830968522362582221e+0008L, +}; +static GENERIC qs3[13] = { + 1.0e0L, + 2.418328663076578169836155170053634419922e+0002L, + 2.279620205900121042587523541281272875520e+0004L, + 1.100984222585729521470129014992217092794e+0006L, + 3.010743223679247091004262516286654516282e+0007L, + 4.860925542827367817289619265215599433996e+0008L, + 4.686668111035348691982715864307839581243e+0009L, + 2.668701788405102017427214705946730894074e+0010L, + 8.677395746106802640390580944836650584903e+0010L, + 1.511936455574951790658498795945106643036e+0011L, + 1.260845604432623478002018696873608353093e+0011L, + 4.052692278419853853911440231600864589805e+0010L, + 2.965516519212226064983267822243329694729e+0009L, +}; +static GENERIC qr4[13] = { + 3.749999999919234164154669754440123072618e-0001L, + 5.844218580776819864791168253485055101858e+0001L, + 3.489273514092912982675669411371435670220e+0003L, + 1.050523637774575684509663430018995479594e+0005L, + 1.764549172059701565500717319792780115289e+0006L, + 1.725532438844133795028063102681497371154e+0007L, + 9.938114847359778539965140247590176334874e+0007L, + 3.331710808184595545396883770200772842314e+0008L, + 6.271970557641881511609560444872797282698e+0008L, + 6.188529798677357075020774923903737913285e+0008L, + 2.821905302742849974509982167877885011629e+0008L, + 4.615467358646911976773290256984329814896e+0007L, + 1.348140608731546467396685802693380693275e+0006L, +}; +static GENERIC qs4[13] = { + 1.0e0L, + 1.561192663112345185261418296389902133372e+0002L, + 9.346678031144098270547225423124213083072e+0003L, + 2.825851246482293547838023847601704751590e+0005L, + 4.776572711622156091710902891124911556293e+0006L, + 4.715106953717135402977938048006267859302e+0007L, + 2.753962350894311316439652227611209035193e+0008L, + 9.428501434615463207768964787500411575223e+0008L, + 1.832650858775206787088236896454141572617e+0009L, + 1.901697378939743226948920874296595242257e+0009L, + 9.433322226854293780627188599226380812725e+0008L, + 1.808520540608671608680284520798858587370e+0008L, + 7.983342331736662753157217446919462398008e+0006L, +}; +static GENERIC qr5[13] = { + 3.749999995331364437028988850515190446719e-0001L, + 3.739356381766559882677514593041627547911e+0001L, + 1.399562500629413529355265462912819802551e+0003L, + 2.594154053098947925345332218062210111753e+0004L, + 2.640149879297408640394163979394594318371e+0005L, + 1.542471854873199142031889093591449397995e+0006L, + 5.242272868972053374067572098992335425895e+0006L, + 1.025834487769410221329633071426044839935e+0007L, + 1.116553924239448940142230579060124209622e+0007L, + 6.318076065595910176374916303525884653514e+0006L, + 1.641218086168640408527639735915512881785e+0006L, + 1.522369793529178644168813882912134706444e+0005L, + 2.526530541062297200914180060208669584055e+0003L, +}; +static GENERIC qs5[13] = { + 1.0e0L, + 9.998960735935075380397545659016287506660e+0001L, + 3.758767417842043742686475060540416737562e+0003L, + 7.013652806952306520121959742519780781653e+0004L, + 7.208949808818615099246529616211730446850e+0005L, + 4.272753927109614455417836186072202009252e+0006L, + 1.482524411356470699336129814111025434703e+0007L, + 2.988750366665678233425279237627700803473e+0007L, + 3.396957890261080492694709150553619185065e+0007L, + 2.050652487738593004111578091156304540386e+0007L, + 5.900504120811732547616511555946279451316e+0006L, + 6.563391409260160897024498082273183468347e+0005L, + 1.692629845012790205348966731477187041419e+0004L, +}; +static GENERIC qr6[13] = { + 3.749999861516664133157566870858975421296e-0001L, + 2.367863756747764863120797431599473468918e+0001L, + 5.476715802114976248882067325630793143777e+0002L, + 6.143190357869842894025012945444096170251e+0003L, + 3.716250534677997850513733595140463851730e+0004L, + 1.270883463823876752138326905022875657430e+0005L, + 2.495301449636814481646371665429083801388e+0005L, + 2.789578988212952248340486296254398601942e+0005L, + 1.718247946911109055931819087137397324634e+0005L, + 5.458973214011665714330326732204106364229e+0004L, + 7.912102686687948786048943339759596652813e+0003L, + 4.077961006160866935722030715149087938091e+0002L, + 3.765206972770245085551057237882528510428e+0000L, +}; +static GENERIC qs6[13] = { + 1.0e0L, + 6.341646532940517305641893852673926809601e+0001L, + 1.477058277414040790932597537920671025359e+0003L, + 1.674406564031044491436044253393536487604e+0004L, + 1.028516501369755949895050806908994650768e+0005L, + 3.593620042532885295087463507733285434207e+0005L, + 7.267924991381020915185873399453724799625e+0005L, + 8.462277510768818399961191426205006083088e+0005L, + 5.514399892230892163373611895645500250514e+0005L, + 1.898084241009259353540620272932188102299e+0005L, + 3.102941242117739015721984123081026253068e+0004L, + 1.958971184431466907681440650181421086143e+0003L, + 2.878853357310495087181721613889455121867e+0001L, +}; +static GENERIC qone(x) +GENERIC x; +{ + GENERIC s,r,t,z; + int i; + if(x>huge) return 0.375L/x; + t = one/x; z = t*t; + if(x>sixteen) { + r = z*qr0[11]+qr0[10]; s = qs0[10]; + for(i=9;i>=0;i--) { + r = z*r + qr0[i]; + s = z*s + qs0[i]; + } + } else if(x>eight) { + r = qr1[11]; s = qs1[11]+z*(qs1[12]+z*qs1[13]); + for(i=10;i>=0;i--) { + r = z*r + qr1[i]; + s = z*s + qs1[i]; + } + } else if (x>five) { /* x > 5.0 */ + r = qr2[11]; s = qs2[11]+z*(qs2[12]+z*qs2[13]); + for(i=10;i>=0;i--) { + r = z*r + qr2[i]; + s = z*s + qs2[i]; + } + } else if(x>3.5L) { + r = qr3[12]; s = qs3[12]; + for(i=11;i>=0;i--) { + r = z*r + qr3[i]; + s = z*s + qs3[i]; + } + } else if(x>2.5L) { + r = qr4[12]; s = qs4[12]; + for(i=11;i>=0;i--) { + r = z*r + qr4[i]; + s = z*s + qs4[i]; + } + } else if(x> (1.0L/0.5625L)) { + r = qr5[12]; s = qs5[12]; + for(i=11;i>=0;i--) { + r = z*r + qr5[i]; + s = z*s + qs5[i]; + } + } else { /* assume x > 1.28 */ + r = qr6[12]; s = qs6[12]; + for(i=11;i>=0;i--) { + r = z*r + qr6[i]; + s = z*s + qs6[i]; + } + } + return t*(r/s); +} diff --git a/usr/src/libm/src/LD/jnl.c b/usr/src/libm/src/LD/jnl.c new file mode 100644 index 0000000..04fb096 --- /dev/null +++ b/usr/src/libm/src/LD/jnl.c @@ -0,0 +1,266 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)jnl.c 1.10 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak jnl = __jnl +#pragma weak ynl = __ynl +#endif + +/* + * floating point Bessel's function of the 1st and 2nd kind + * of order n: jn(n,x),yn(n,x); + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + * Note 2. About jn(n,x), yn(n,x) + * For n=0, j0(x) is called, + * for n=1, j1(x) is called, + * for n<x, forward recursion us used starting + * from values of j0(x) and j1(x). + * for n>x, a continued fraction approximation to + * j(n,x)/j(n-1,x) is evaluated and then backward + * recursion is used starting from a supposed value + * for j(n,x). The resulting value of j(0,x) is + * compared with the actual value to correct the + * supposed value of j(n,x). + * + * yn(n,x) is similar in all respects, except + * that forward recursion is used for all + * values of n>1. + * + */ + +#include "libm.h" +#include <float.h> /* LDBL_MAX */ + +#define GENERIC long double + +static const GENERIC +invsqrtpi= 5.641895835477562869480794515607725858441e-0001L, +two = 2.0L, +zero = 0.0L, +one = 1.0L; + +GENERIC +jnl(n,x) int n; GENERIC x;{ + int i, sgn; + GENERIC a, b, temp, z, w; + + /* J(-n,x) = (-1)^n * J(n, x), J(n, -x) = (-1)^n * J(n, x) + * Thus, J(-n,x) = J(n,-x) + */ + if(n<0){ + n = -n; + x = -x; + } + if(n==0) return(j0l(x)); + if(n==1) return(j1l(x)); + if(x!=x) return x+x; + if((n&1)==0) + sgn=0; /* even n */ + else + sgn = signbitl(x); /* old n */ + x = fabsl(x); + if(x == zero||!finitel(x)) b = zero; + else if((GENERIC)n<=x) { /* Safe to use + J(n+1,x)=2n/x *J(n,x)-J(n-1,x) + */ + if(x>1.0e91L) { /* x >> n**2 + Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + Let s=sin(x), c=cos(x), + xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + + n sin(xn)*sqt2 cos(xn)*sqt2 + ---------------------------------- + 0 s-c c+s + 1 -s-c -c+s + 2 -s+c -c-s + 3 s+c c-s + */ + switch(n&3) { + case 0: temp = cosl(x)+sinl(x); break; + case 1: temp = -cosl(x)+sinl(x); break; + case 2: temp = -cosl(x)-sinl(x); break; + case 3: temp = cosl(x)-sinl(x); break; + } + b = invsqrtpi*temp/sqrtl(x); + } else { + a = j0l(x); + b = j1l(x); + for(i=1;i<n;i++){ + temp = b; + b = b*((GENERIC)(i+i)/x) - a; /* avoid underflow */ + a = temp; + } + } + } else { + if(x<1e-17L) { /* use J(n,x) = 1/n!*(x/2)^n */ + b = powl(0.5L*x,(GENERIC) n); + if (b!=zero) { + for(a=one,i=1;i<=n;i++) a *= (GENERIC)i; + b = b/a; + } + } else { + /* use backward recurrence */ + /* x x^2 x^2 + * J(n,x)/J(n-1,x) = ---- ------ ------ ..... + * 2n - 2(n+1) - 2(n+2) + * + * 1 1 1 + * (for large x) = ---- ------ ------ ..... + * 2n 2(n+1) 2(n+2) + * -- - ------ - ------ - + * x x x + * + * Let w = 2n/x and h=2/x, then the above quotient + * is equal to the continued fraction: + * 1 + * = ----------------------- + * 1 + * w - ----------------- + * 1 + * w+h - --------- + * w+2h - ... + * + * To determine how many terms needed, let + * Q(0) = w, Q(1) = w(w+h) - 1, + * Q(k) = (w+k*h)*Q(k-1) - Q(k-2), + * When Q(k) > 1e4 good for single + * When Q(k) > 1e9 good for double + * When Q(k) > 1e17 good for quaduple + */ + /* determin k */ + GENERIC t,v; + double q0,q1,h,tmp; int k,m; + w = (n+n)/(double)x; h = 2.0/(double)x; + q0 = w; z = w+h; q1 = w*z - 1.0; k=1; + while(q1<1.0e17) { + k += 1; z += h; + tmp = z*q1 - q0; + q0 = q1; + q1 = tmp; + } + m = n+n; + for(t=zero, i = 2*(n+k); i>=m; i -= 2) t = one/(i/x-t); + a = t; + b = one; + /* estimate log((2/x)^n*n!) = n*log(2/x)+n*ln(n) + hence, if n*(log(2n/x)) > ... + single 8.8722839355e+01 + double 7.09782712893383973096e+02 + long double 1.1356523406294143949491931077970765006170e+04 + then recurrent value may overflow and the result is + likely underflow to zero + */ + tmp = n; + v = two/x; + tmp = tmp*logl(fabsl(v*tmp)); + if(tmp<1.1356523406294143949491931077970765e+04L) { + for(i=n-1;i>0;i--){ + temp = b; + b = ((i+i)/x)*b - a; + a = temp; + } + } else { + for(i=n-1;i>0;i--){ + temp = b; + b = ((i+i)/x)*b - a; + a = temp; + if(b>1e1000L) { + a /= b; + t /= b; + b = 1.0; + } + } + } + b = (t*j0l(x)/b); + } + } + if(sgn==1) return -b; else return b; +} + +GENERIC ynl(n,x) +int n; GENERIC x;{ + int i; + int sign; + GENERIC a, b, temp; + + if(x!=x) return x+x; + if (x <= zero) + if(x==zero) + return -one/zero; + else + return zero/zero; + sign = 1; + if(n<0){ + n = -n; + if((n&1) == 1) sign = -1; + } + if(n==0) return(y0l(x)); + if(n==1) return(sign*y1l(x)); + if(!finitel(x)) return zero; + + if(x>1.0e91L) { /* x >> n**2 + Jn(x) = cos(x-(2n+1)*pi/4)*sqrt(2/x*pi) + Yn(x) = sin(x-(2n+1)*pi/4)*sqrt(2/x*pi) + Let s=sin(x), c=cos(x), + xn=x-(2n+1)*pi/4, sqt2 = sqrt(2),then + + n sin(xn)*sqt2 cos(xn)*sqt2 + ---------------------------------- + 0 s-c c+s + 1 -s-c -c+s + 2 -s+c -c-s + 3 s+c c-s + */ + switch(n&3) { + case 0: temp = sinl(x)-cosl(x); break; + case 1: temp = -sinl(x)-cosl(x); break; + case 2: temp = -sinl(x)+cosl(x); break; + case 3: temp = sinl(x)+cosl(x); break; + } + b = invsqrtpi*temp/sqrtl(x); + } else { + a = y0l(x); + b = y1l(x); + /* + * fix 1262058 and take care of non-default rounding + */ + for (i = 1; i < n; i++) { + temp = b; + b *= (GENERIC) (i + i) / x; + if (b <= -LDBL_MAX) + break; + b -= a; + a = temp; + } + } + if(sign>0) return b; else return -b; +} diff --git a/usr/src/libm/src/LD/lgammal.c b/usr/src/libm/src/LD/lgammal.c new file mode 100644 index 0000000..159ea47 --- /dev/null +++ b/usr/src/libm/src/LD/lgammal.c @@ -0,0 +1,48 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)lgammal.c 1.11 06/01/31 SMI" + +#pragma weak lgammal = __lgammal + +/* + * long double lgammal(long double x); + */ + +#include "libm.h" +#include "libm_synonyms.h" +#include "longdouble.h" + +extern int signgam; +extern int signgaml; + +long double +lgammal(long double x) { + long double y = __k_lgammal(x, &signgaml); + + signgam = signgaml; /* SUSv3 requires the setting of signgam */ + return y; +} diff --git a/usr/src/libm/src/LD/lgammal_r.c b/usr/src/libm/src/LD/lgammal_r.c new file mode 100644 index 0000000..373ccaf --- /dev/null +++ b/usr/src/libm/src/LD/lgammal_r.c @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)lgammal_r.c 1.4 06/01/31 SMI" + +/* + * long double lgammal_r(long double x, int *signgamlp); + */ + +#pragma weak lgammal_r = __lgammal_r + +#include "libm.h" +#include "longdouble.h" + +long double +lgammal_r(long double x, int *signgamlp) { + return __k_lgammal(x, signgamlp); +} diff --git a/usr/src/libm/src/LD/log1pl.c b/usr/src/libm/src/LD/log1pl.c new file mode 100644 index 0000000..6391623 --- /dev/null +++ b/usr/src/libm/src/LD/log1pl.c @@ -0,0 +1,64 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)log1pl.c 1.7 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak log1pl = __log1pl +#endif + +/* + * log1pl(x) + * Kahan's trick based on log(1+x)/x being a slow varying function. + */ + +#include "libm.h" + +#if defined(__i386) +#define __swapRD __swap87RD +#endif +extern enum fp_direction_type __swapRD(enum fp_direction_type); + +long double +log1pl(long double x) { + long double y; + enum fp_direction_type rd; + + if (x != x) + return (x + x); + if (x < -1.L) + return (logl(x)); + rd = __swapRD(fp_nearest); + y = 1.L + x; + if (y != 1.L) + if (y == x) + x = logl(x); + else + x *= logl(y) / (y - 1.L); + if (rd != fp_nearest) + (void) __swapRD(rd); + return (x); +} diff --git a/usr/src/libm/src/LD/logbl.c b/usr/src/libm/src/LD/logbl.c new file mode 100644 index 0000000..52b4dc6 --- /dev/null +++ b/usr/src/libm/src/LD/logbl.c @@ -0,0 +1,82 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)logbl.c 1.10 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak logbl = __logbl +#endif + +#include "libm.h" +#include "xpg6.h" /* __xpg6 */ +#define _C99SUSv3_logb _C99SUSv3_logb_subnormal_is_like_ilogb + +#if defined(__sparc) +#define ISNORMALL(k, x) (k != 0x7fff) /* assuming k != 0 */ +#define X86PDNRM(k, x) +#define XSCALE_OFFSET 0x406f /* 0x3fff + 112 */ +static const long double xscale = 5192296858534827628530496329220096.0L; + /* 2^112 */ +#elif defined(__i386) +/* + * if pseudo-denormal, replace by the equivalent normal + */ +#define X86PDNRM(k, x) if (k == 0 && (((int *) &x)[1] & 0x80000000) != 0) \ + ((int *) &x)[2] |= k = 1 +#if defined(HANDLE_UNSUPPORTED) /* assuming k != 0 */ +#define ISNORMALL(k, x) (k != 0x7fff && (((int *) &x)[1] & 0x80000000) != 0) +#else +#define ISNORMALL(k, x) (k != 0x7fff) +#endif +#define XSCALE_OFFSET 0x403e /* 0x3fff + 63 */ +static const long double xscale = 9223372036854775808.0L; /* 2^63 */ +#endif + +static long double +raise_division(long double v) { +#pragma STDC FENV_ACCESS ON + static const long double zero = 0.0L; + return (v / zero); +} + +long double +logbl(long double x) { + int k = XBIASED_EXP(x); + + X86PDNRM(k, x); + if (k == 0) { + if (ISZEROL(x)) + return (raise_division(-1.0L)); + else if ((__xpg6 & _C99SUSv3_logb) != 0) { + x *= xscale; /* scale up by 2^112 or 2^63 */ + return (long double) (XBIASED_EXP(x) - XSCALE_OFFSET); + } else + return ((long double) (-16382)); + } else if (ISNORMALL(k, x)) + return ((long double) (k - 0x3fff)); + else + return (x * x); +} diff --git a/usr/src/libm/src/LD/longdouble.h b/usr/src/libm/src/LD/longdouble.h new file mode 100644 index 0000000..0a0c878 --- /dev/null +++ b/usr/src/libm/src/LD/longdouble.h @@ -0,0 +1,155 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)longdouble.h 1.8 06/01/31 SMI" + +#include <sys/ieeefp.h> + +extern long double __k_cosl(long double, long double); +extern long double __k_lgammal(long double, int *); +extern long double __k_sincosl(long double, long double, long double *); +extern long double __k_sinl(long double, long double); +extern long double __k_tanl(long double, long double, int); +extern long double __poly_libmq(long double, int, long double *); +extern int __rem_pio2l(long double, long double *); + +extern long double acosdl(long double); +extern long double acoshl(long double); +extern long double acosl(long double); +extern long double acospil(long double); +extern long double acospl(long double); +extern long double aintl(long double); +extern long double anintl(long double); +extern long double annuityl(long double, long double); +extern long double asindl(long double); +extern long double asinhl(long double); +extern long double asinl(long double); +extern long double asinpil(long double); +extern long double asinpl(long double); +extern long double atan2dl(long double, long double); +extern long double atan2l(long double, long double); +extern long double atan2pil(long double, long double); +extern long double atandl(long double); +extern long double atanhl(long double); +extern long double atanl(long double); +extern long double atanpil(long double); +extern long double atanpl(long double); +extern long double cbrtl(long double); +extern long double ceill(long double); +extern long double compoundl(long double, long double); +extern long double copysignl(long double, long double); +extern long double cosdl(long double); +extern long double coshl(long double); +extern long double cosl(long double); +extern long double cospil(long double); +extern long double cospl(long double); +extern long double erfcl(long double); +extern long double erfl(long double); +extern long double exp10l(long double); +extern long double exp2l(long double); +extern long double expl(long double); +extern long double expm1l(long double); +extern long double fabsl(long double); +extern int finitel(long double); +extern long double floorl(long double); +extern long double fmodl(long double, long double); +extern enum fp_class_type fp_classl(long double); +extern long double gammal(long double); +extern long double hypotl(long double, long double); +extern int ilogbl(long double); +extern long double infinityl(void); +extern int irintl(long double); +extern int isinfl(long double); +extern int isnanl(long double); +extern int isnormall(long double); +extern int issubnormall(long double); +extern int iszerol(long double); +extern long double j0l(long double); +extern long double j1l(long double); +extern long double jnl(int, long double); +extern long double lgammal(long double); +extern long double log10l(long double); +extern long double log1pl(long double); +extern long double log2l(long double); +extern long double logbl(long double); +extern long double logl(long double); +extern long double max_normall(void); +extern long double max_subnormall(void); +extern long double min_normall(void); +extern long double min_subnormall(void); +extern long double nextafterl(long double, long double); +extern int nintl(long double); +extern long double pow_li(long double *, int *); +extern long double powl(long double, long double); +extern long double quiet_nanl(long); +extern long double remainderl(long double, long double); +extern long double rintl(long double); +extern long double scalbl(long double, long double); +extern long double scalbnl(long double, int); +extern long double signaling_nanl(long); +extern int signbitl(long double); +extern long double significandl(long double); +extern void sincosdl(long double, long double *, long double *); +extern void sincosl(long double, long double *, long double *); +extern void sincospil(long double, long double *, long double *); +extern void sincospl(long double, long double *, long double *); +extern long double sindl(long double); +extern long double sinhl(long double); +extern long double sinl(long double); +extern long double sinpil(long double); +extern long double sinpl(long double); +extern long double sqrtl(long double); +extern long double tandl(long double); +extern long double tanhl(long double); +extern long double tanl(long double); +extern long double tanpil(long double); +extern long double tanpl(long double); +extern long double y0l(long double); +extern long double y1l(long double); +extern long double ynl(int, long double); + +extern long double q_copysign_(long double *, long double *); +extern long double q_fabs_(long double *); +extern int iq_finite_(long double *); +extern long double q_fmod_(long double *, long double *); +extern enum fp_class_type iq_fp_class_(long double *); +extern int iq_ilogb_(long double *); +extern long double q_infinity_(void); +extern int iq_isinf_(long double *); +extern int iq_isnan_(long double *); +extern int iq_isnormal_(long double *); +extern int iq_issubnormal_(long double *); +extern int iq_iszero_(long double *); +extern long double q_max_normal_(void); +extern long double q_max_subnormal_(void); +extern long double q_min_normal_(void); +extern long double q_min_subnormal_(void); +extern long double q_nextafter_(long double *, long double *); +extern long double q_quiet_nan_(long *); +extern long double q_remainder_(long double *, long double *); +extern long double q_scalbn_(long double *, int *); +extern long double q_signaling_nan_(long *); +extern int iq_signbit_(long double *); diff --git a/usr/src/libm/src/LD/nextafterl.c b/usr/src/libm/src/LD/nextafterl.c new file mode 100644 index 0000000..f1d042f --- /dev/null +++ b/usr/src/libm/src/LD/nextafterl.c @@ -0,0 +1,118 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)nextafterl.c 1.3 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak nextafterl = __nextafterl +#endif + +#include "libm.h" +#include <float.h> /* LDBL_MAX, LDBL_MIN */ + +#if defined(__sparc) +#define n0 0 +#define n1 1 +#define n2 2 +#define n3 3 +#define X86PDNRM1(x) +#define INC(px) { \ + if (++px[n3] == 0) \ + if (++px[n2] == 0) \ + if (++px[n1] == 0) \ + ++px[n0]; \ + } +#define DEC(px) { \ + if (--px[n3] == 0xffffffff) \ + if (--px[n2] == 0xffffffff) \ + if (--px[n1] == 0xffffffff) \ + --px[n0]; \ + } +#elif defined(__i386) +#define n0 2 +#define n1 1 +#define n2 0 +#define n3 0 +/* + * if pseudo-denormal, replace by the equivalent normal + */ +#define X86PDNRM1(x) if (XBIASED_EXP(x) == 0 && (((int *) &x)[1] & \ + 0x80000000) != 0) \ + ((int *) &x)[2] |= 1 +#define INC(px) { \ + if (++px[n2] == 0) \ + if ((++px[n1] & ~0x80000000) == 0) \ + px[n1] = 0x80000000, ++px[n0]; \ + } +#define DEC(px) { \ + if (--px[n2] == 0xffffffff) \ + if (--px[n1] == 0x7fffffff) \ + if ((--px[n0] & 0x7fff) != 0) \ + px[n1] |= 0x80000000; \ + } +#endif + +long double +nextafterl(long double x, long double y) { + int *px = (int *) &x; + int *py = (int *) &y; + + if (x == y) + return (y); /* C99 requirement */ + if (x != x || y != y) + return (x * y); + + if (ISZEROL(x)) { /* x == 0.0 */ + px[n0] = py[n0] & XSGNMSK; + px[n1] = px[n2] = 0; + px[n3] = 1; + } else { + X86PDNRM1(x); + if ((px[n0] & XSGNMSK) == 0) { /* x > 0.0 */ + if (x > y) /* x > y */ + DEC(px) + else + INC(px) + } else { + if (x < y) /* x < y */ + DEC(px) + else + INC(px) + } + } +#ifndef lint + { + volatile long double dummy; + int k = XBIASED_EXP(x); + + if (k == 0) + dummy = LDBL_MIN * copysignl(LDBL_MIN, x); + else if (k == 0x7fff) + dummy = LDBL_MAX * copysignl(LDBL_MAX, x); + } +#endif + return (x); +} diff --git a/usr/src/libm/src/LD/scalbl.c b/usr/src/libm/src/LD/scalbl.c new file mode 100644 index 0000000..b49ec2d --- /dev/null +++ b/usr/src/libm/src/LD/scalbl.c @@ -0,0 +1,69 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)scalbl.c 1.8 06/01/31 SMI" + +#pragma weak scalbl = __scalbl + +/* + * scalbl(x,n): return x * 2**n by manipulating exponent. + */ + +#include "libm.h" +#include "longdouble.h" + +long double +scalbl(long double x, long double fn) { + int *py = (int *) &fn, n; + long double z; + + if (isnanl(x) || isnanl(fn)) + return x * fn; + + /* fn is +/-Inf */ +#if !defined(__i386) + if ((py[0] & 0x7fff0000) == 0x7fff0000) + if ((py[0] & 0x80000000) != 0) +#else + if ((py[2] & 0x7fff) == 0x7fff) + if ((py[2] & 0x8000) != 0) +#endif + return x / (-fn); + else + return x * fn; + + if (rintl(fn) != fn) + return (fn - fn) / (fn - fn); + if (fn > 65000.0L) + z = scalbnl(x, 65000); + else if (-fn > 65000.0L) + z = scalbnl(x, -65000); + else { + n = (int) fn; + z = scalbnl(x, n); + } + return z; +} diff --git a/usr/src/libm/src/LD/signgaml.c b/usr/src/libm/src/LD/signgaml.c new file mode 100644 index 0000000..a11970c --- /dev/null +++ b/usr/src/libm/src/LD/signgaml.c @@ -0,0 +1,35 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)signgaml.c 1.4 06/01/31 SMI" + +#pragma weak signgaml = __signgaml + +#include "libm.h" +#include "libm_synonyms.h" +#include "longdouble.h" + +int signgaml = 0; diff --git a/usr/src/libm/src/LD/significandl.c b/usr/src/libm/src/LD/significandl.c new file mode 100644 index 0000000..8c31902 --- /dev/null +++ b/usr/src/libm/src/LD/significandl.c @@ -0,0 +1,41 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)significandl.c 1.8 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak significandl = __significandl +#endif + +#include "libm.h" + +long double +significandl(long double x) { + if (ISZEROL(x) || XBIASED_EXP(x) == 0x7fff) /* 0/+-Inf/NaN */ + return (x + x); + else + return (scalbnl(x, -ilogbl(x))); +} diff --git a/usr/src/libm/src/LD/sincosl.c b/usr/src/libm/src/LD/sincosl.c new file mode 100644 index 0000000..1cf0205 --- /dev/null +++ b/usr/src/libm/src/LD/sincosl.c @@ -0,0 +1,112 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)sincosl.c 1.9 06/01/31 SMI" + +#pragma weak sincosl = __sincosl + +/* INDENT OFF */ +/* cosl(x) + * Table look-up algorithm by K.C. Ng, November, 1989. + * + * kernel function: + * __k_sincosl ... sin and cos function on [-pi/4,pi/4] + * __rem_pio2l ... argument reduction routine + * + * Method. + * Let S and C denote the sin and cos respectively on [-PI/4, +PI/4]. + * 1. Assume the argument x is reduced to y1+y2 = x-k*pi/2 in + * [-pi/2 , +pi/2], and let n = k mod 4. + * 2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C S/C + * 1 C -S -C/S + * 2 -S -C S/C + * 3 -C S -C/S + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * computer TRIG(x) returns trig(x) nearly rounded. + */ +/* INDENT ON */ + +#include "libm.h" +#include "libm_synonyms.h" +#include "longdouble.h" + +void +sincosl(long double x, long double *s, long double *c) { + long double y[2], z = 0.0L; + int n, ix; +#if defined(__i386) + int *px = (int *) &x; +#endif + + /* trig(Inf or NaN) is NaN */ + if (!finitel(x)) { + *s = *c = x - x; + return; + } + + /* High word of x. */ +#if !defined(__i386) + ix = *(int *) &x; +#else + XTOI(px, ix); +#endif + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if (ix <= 0x3ffe9220) + *s = __k_sincosl(x, z, c); + + /* argument reduction needed */ + else { + n = __rem_pio2l(x, y); + switch (n & 3) { + case 0: + *s = __k_sincosl(y[0], y[1], c); + break; + case 1: + *c = -__k_sincosl(y[0], y[1], s); + break; + case 2: + *s = -__k_sincosl(y[0], y[1], c); + *c = -*c; + break; + case 3: + *c = __k_sincosl(y[0], y[1], s); + *s = -*s; + } + } +} diff --git a/usr/src/libm/src/LD/sincospil.c b/usr/src/libm/src/LD/sincospil.c new file mode 100644 index 0000000..d454aaf --- /dev/null +++ b/usr/src/libm/src/LD/sincospil.c @@ -0,0 +1,205 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)sincospil.c 1.11 06/01/31 SMI" + +#pragma weak sincospil = __sincospil + +/* + * void sincospil(long double x, long double *s, long double *c) + * *s = sinl(pi*x); *c = cosl(pi*x); + * + * Algorithm, 10/17/2002, K.C. Ng + * ------------------------------ + * Let y = |4x|, z = floor(y), and n = (int)(z mod 8.0) (displayed in binary). + * 1. If y==z, then x is a multiple of pi/4. Return the following values: + * --------------------------------------------------- + * n x mod 2 sin(x*pi) cos(x*pi) tan(x*pi) + * --------------------------------------------------- + * 000 0.00 +0 ___ +1 ___ +0 + * 001 0.25 +\/0.5 +\/0.5 +1 + * 010 0.50 +1 ___ +0 ___ +inf + * 011 0.75 +\/0.5 -\/0.5 -1 + * 100 1.00 -0 ___ -1 ___ +0 + * 101 1.25 -\/0.5 -\/0.5 +1 + * 110 1.50 -1 ___ -0 ___ +inf + * 111 1.75 -\/0.5 +\/0.5 -1 + * --------------------------------------------------- + * 2. Otherwise, + * --------------------------------------------------- + * n t sin(x*pi) cos(x*pi) tan(x*pi) + * --------------------------------------------------- + * 000 (y-z)/4 sinpi(t) cospi(t) tanpi(t) + * 001 (z+1-y)/4 cospi(t) sinpi(t) 1/tanpi(t) + * 010 (y-z)/4 cospi(t) -sinpi(t) -1/tanpi(t) + * 011 (z+1-y)/4 sinpi(t) -cospi(t) -tanpi(t) + * 100 (y-z)/4 -sinpi(t) -cospi(t) tanpi(t) + * 101 (z+1-y)/4 -cospi(t) -sinpi(t) 1/tanpi(t) + * 110 (y-z)/4 -cospi(t) sinpi(t) -1/tanpi(t) + * 111 (z+1-y)/4 -sinpi(t) cospi(t) -tanpi(t) + * --------------------------------------------------- + * + * NOTE. This program compute sinpi/cospi(t<0.25) by __k_sin/cos(pi*t, 0.0). + * This will return a result with error slightly more than one ulp (but less + * than 2 ulp). If one wants accurate result, one may break up pi*t in + * high (tpi_h) and low (tpi_l) parts and call __k_sin/cos(tip_h, tip_lo) + * instead. + */ + +#include "libm.h" +#include "libm_synonyms.h" +#include "longdouble.h" + +#define I(q, m) ((int *) &(q))[m] +#define U(q, m) ((unsigned *) &(q))[m] +#if defined(__LITTLE_ENDIAN) || defined(__i386) +#define LDBL_MOST_SIGNIF_I(ld) ((I(ld, 2) << 16) | (0xffff & (I(ld, 1) >> 15))) +#define LDBL_LEAST_SIGNIF_U(ld) U(ld, 0) +#define PREC 64 +#define PRECM1 63 +#define PRECM2 62 +static const long double twoPRECM2 = 9.223372036854775808000000000000000e+18L; +#else +#define LDBL_MOST_SIGNIF_I(ld) I(ld, 0) +#define LDBL_LEAST_SIGNIF_U(ld) U(ld, sizeof(long double) / sizeof(int) - 1) +#define PREC 113 +#define PRECM1 112 +#define PRECM2 111 +static const long double twoPRECM2 = 5.192296858534827628530496329220096e+33L; +#endif + +static const long double +zero = 0.0L, +quater = 0.25L, +one = 1.0L, +pi = 3.141592653589793238462643383279502884197e+0000L, +sqrth = 0.707106781186547524400844362104849039284835937688474, +tiny = 1.0e-100; + +void +sincospil(long double x, long double *s, long double *c) { + long double y, z, t; + int hx, n, k; + unsigned lx; + + hx = LDBL_MOST_SIGNIF_I(x); + lx = LDBL_LEAST_SIGNIF_U(x); + k = ((hx & 0x7fff0000) >> 16) - 0x3fff; + if (k >= PRECM2) { /* |x| >= 2**(Prec-2) */ + if (k >= 16384) { + *s = *c = x - x; + } + else { + if (k >= PREC) { + *s = zero; + *c = one; + } + else if (k == PRECM1) { + if ((lx & 1) == 0) { + *s = zero; + *c = one; + } + else { + *s = -zero; + *c = -one; + } + } + else { /* k = Prec - 2 */ + if ((lx & 1) == 0) { + *s = zero; + *c = one; + } + else { + *s = one; + *c = zero; + } + if ((lx & 2) != 0) { + *s = -*s; + *c = -*c; + } + } + } + } + else if (k < -2) /* |x| < 0.25 */ + *s = __k_sincosl(pi * fabsl(x), zero, c); + else { + /* y = |4x|, z = floor(y), and n = (int)(z mod 8.0) */ + y = 4.0L * fabsl(x); + if (k < PRECM2) { + z = y + twoPRECM2; + n = LDBL_LEAST_SIGNIF_U(z) & 7; /* 3 LSb of z */ + t = z - twoPRECM2; + k = 0; + if (t == y) + k = 1; + else if (t > y) { + n -= 1; + t = quater + (y - t) * quater; + } + else + t = (y - t) * quater; + } + else { /* k = Prec-3 */ + n = LDBL_LEAST_SIGNIF_U(y) & 7; /* 3 LSb of z */ + k = 1; + } + if (k) { /* x = N/4 */ + if((n & 1) != 0) + *s = *c = sqrth + tiny; + else + if ((n & 2) == 0) { + *s = zero; + *c = one; + } + else { + *s = one; + *c = zero; + } + if ((n & 4) != 0) + *s = -*s; + if (((n + 1) & 4) != 0) + *c = -*c; + } + else { + if ((n & 1) != 0) + t = quater - t; + if (((n + (n & 1)) & 2) == 0) + *s = __k_sincosl(pi * t, zero, c); + else + *c = __k_sincosl(pi * t, zero, s); + if ((n & 4) != 0) + *s = -*s; + if (((n + 2) & 4) != 0) + *c = -*c; + } + } + if (hx < 0) + *s = -*s; +} +#undef U +#undef LDBL_LEAST_SIGNIF_U +#undef I +#undef LDBL_MOST_SIGNIF_I diff --git a/usr/src/libm/src/LD/sinhl.c b/usr/src/libm/src/LD/sinhl.c new file mode 100644 index 0000000..cde48f3 --- /dev/null +++ b/usr/src/libm/src/LD/sinhl.c @@ -0,0 +1,86 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)sinhl.c 1.7 06/01/31 SMI" + +#pragma weak sinhl = __sinhl + +#include "libm.h" + +/* SINH(X) + * RETURN THE HYPERBOLIC SINE OF X + * + * Method : + * 1. reduce x to non-negative by SINH(-x) = - SINH(x). + * 2. + * + * EXPM1(x) + EXPM1(x)/(EXPM1(x)+1) + * 0 <= x <= lnovft : SINH(x) := -------------------------------- + * 2 + * + * lnovft <= x < INF : SINH(x) := EXP(x-MEP1*ln2)*2**ME + * + * here + * lnovft logarithm of the overflow threshold + * = MEP1*ln2 chopped to machine precision. + * ME maximum exponent + * MEP1 maximum exponent plus 1 + * + * Special cases: + * SINH(x) is x if x is +INF, -INF, or NaN. + * only SINH(0)=0 is exact for finite argument. + * + */ + +static const long double C[] = { + 0.5L, + 1.0L, + 1.135652340629414394879149e+04L, + 7.004447686242549087858985e-16L +}; + +#define half C[0] +#define one C[1] +#define lnovft C[2] +#define lnovlo C[3] + +long double +sinhl(long double x) +{ + long double r, t; + + if (!finitel(x)) + return (x + x); /* x is INF or NaN */ + r = fabsl(x); + if (r < lnovft) { + t = expm1l(r); + r = copysignl((t + t / (one + t)) * half, x); + } else { + r = copysignl(expl((r - lnovft) - lnovlo), x); + r = scalbnl(r, 16383); + } + return (r); +} diff --git a/usr/src/libm/src/LD/sinl.c b/usr/src/libm/src/LD/sinl.c new file mode 100644 index 0000000..ebeb5da --- /dev/null +++ b/usr/src/libm/src/LD/sinl.c @@ -0,0 +1,107 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)sinl.c 1.9 06/01/31 SMI" + +#pragma weak sinl = __sinl + +/* INDENT OFF */ +/* sinl(x) + * Table look-up algorithm by K.C. Ng, November, 1989. + * + * kernel function: + * __k_sinl ... sin function on [-pi/4,pi/4] + * __k_cosl ... cos function on [-pi/4,pi/4] + * __rem_pio2l ... argument reduction routine + * + * Method. + * Let S and C denote the sin and cos respectively on [-PI/4, +PI/4]. + * 1. Assume the argument x is reduced to y1+y2 = x-k*pi/2 in + * [-pi/2 , +pi/2], and let n = k mod 4. + * 2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C S/C + * 1 C -S -C/S + * 2 -S -C S/C + * 3 -C S -C/S + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * computer TRIG(x) returns trig(x) nearly rounded. + */ +/* INDENT ON */ + +#include "libm.h" +#include "libm_synonyms.h" +#include "longdouble.h" + +long double +sinl(long double x) { + long double y[2], z = 0.0L; + int n, ix; +#if defined(__i386) + int *px = (int *) &x; +#endif + + /* sin(Inf or NaN) is NaN */ + if (!finitel(x)) + return x - x; + + /* High word of x. */ +#if !defined(__i386) + ix = *(int *) &x; +#else + XTOI(px, ix); +#endif + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if (ix <= 0x3ffe9220) + return __k_sinl(x, z); + + /* argument reduction needed */ + else { + n = __rem_pio2l(x, y); + switch (n & 3) { + case 0: + return __k_sinl(y[0], y[1]); + case 1: + return __k_cosl(y[0], y[1]); + case 2: + return -__k_sinl(y[0], y[1]); + case 3: + return -__k_cosl(y[0], y[1]); + /* NOTREACHED */ + } + } +} diff --git a/usr/src/libm/src/LD/sinpil.c b/usr/src/libm/src/LD/sinpil.c new file mode 100644 index 0000000..9114037 --- /dev/null +++ b/usr/src/libm/src/LD/sinpil.c @@ -0,0 +1,172 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)sinpil.c 1.11 06/01/31 SMI" + +#pragma weak sinpil = __sinpil + +/* long double sinpil(long double x), + * return long double precision sinl(pi*x). + * + * Algorithm, 10/17/2002, K.C. Ng + * ------------------------------ + * Let y = |4x|, z = floor(y), and n = (int)(z mod 8.0) (displayed in binary). + * 1. If y==z, then x is a multiple of pi/4. Return the following values: + * --------------------------------------------------- + * n x mod 2 sin(x*pi) cos(x*pi) tan(x*pi) + * --------------------------------------------------- + * 000 0.00 +0 ___ +1 ___ +0 + * 001 0.25 +\/0.5 +\/0.5 +1 + * 010 0.50 +1 ___ +0 ___ +inf + * 011 0.75 +\/0.5 -\/0.5 -1 + * 100 1.00 -0 ___ -1 ___ +0 + * 101 1.25 -\/0.5 -\/0.5 +1 + * 110 1.50 -1 ___ -0 ___ +inf + * 111 1.75 -\/0.5 +\/0.5 -1 + * --------------------------------------------------- + * 2. Otherwise, + * --------------------------------------------------- + * n t sin(x*pi) cos(x*pi) tan(x*pi) + * --------------------------------------------------- + * 000 (y-z)/4 sinpi(t) cospi(t) tanpi(t) + * 001 (z+1-y)/4 cospi(t) sinpi(t) 1/tanpi(t) + * 010 (y-z)/4 cospi(t) -sinpi(t) -1/tanpi(t) + * 011 (z+1-y)/4 sinpi(t) -cospi(t) -tanpi(t) + * 100 (y-z)/4 -sinpi(t) -cospi(t) tanpi(t) + * 101 (z+1-y)/4 -cospi(t) -sinpi(t) 1/tanpi(t) + * 110 (y-z)/4 -cospi(t) sinpi(t) -1/tanpi(t) + * 111 (z+1-y)/4 -sinpi(t) cospi(t) -tanpi(t) + * --------------------------------------------------- + * + * NOTE. This program compute sinpi/cospi(t<0.25) by __k_sin/cos(pi*t, 0.0). + * This will return a result with error slightly more than one ulp (but less + * than 2 ulp). If one wants accurate result, one may break up pi*t in + * high (tpi_h) and low (tpi_l) parts and call __k_sin/cos(tip_h, tip_lo) + * instead. + */ + +#include "libm.h" +#include "libm_synonyms.h" +#include "longdouble.h" + +#define I(q, m) ((int *) &(q))[m] +#define U(q, m) ((unsigned *) &(q))[m] +#if defined(__LITTLE_ENDIAN) || defined(__i386) +#define LDBL_MOST_SIGNIF_I(ld) ((I(ld, 2) << 16) | (0xffff & (I(ld, 1) >> 15))) +#define LDBL_LEAST_SIGNIF_U(ld) U(ld, 0) +#define PREC 64 +#define PRECM1 63 +#define PRECM2 62 +static const long double twoPRECM2 = 9.223372036854775808000000000000000e+18L; +#else +#define LDBL_MOST_SIGNIF_I(ld) I(ld, 0) +#define LDBL_LEAST_SIGNIF_U(ld) U(ld, sizeof(long double) / sizeof(int) - 1) +#define PREC 113 +#define PRECM1 112 +#define PRECM2 111 +static const long double twoPRECM2 = 5.192296858534827628530496329220096e+33L; +#endif + +static const long double +zero = 0.0L, +quater = 0.25L, +one = 1.0L, +pi = 3.141592653589793238462643383279502884197e+0000L, +sqrth = 0.707106781186547524400844362104849039284835937688474, +tiny = 1.0e-100; + +long double +sinpil(long double x) { + long double y, z, t; + int hx, n, k; + unsigned lx; + + hx = LDBL_MOST_SIGNIF_I(x); + lx = LDBL_LEAST_SIGNIF_U(x); + k = ((hx & 0x7fff0000) >> 16) - 0x3fff; + if (k >= PRECM2) { /* |x| >= 2**(Prec-2) */ + if (k >= 16384) + y = x - x; + else { + if (k >= PREC) + y = zero; + else if (k == PRECM1) + y = (lx & 1) == 0 ? zero: -zero; + else { /* k = Prec - 2 */ + y = (lx & 1) == 0 ? zero : one; + if ((lx & 2) != 0) + y = -y; + } + } + } + else if (k < -2) /* |x| < 0.25 */ + y = __k_sinl(pi * fabsl(x), zero); + else { + /* y = |4x|, z = floor(y), and n = (int)(z mod 8.0) */ + y = 4.0L * fabsl(x); + if (k < PRECM2) { + z = y + twoPRECM2; + n = LDBL_LEAST_SIGNIF_U(z) & 7; /* 3 LSb of z */ + t = z - twoPRECM2; + k = 0; + if (t == y) + k = 1; + else if (t > y) { + n -= 1; + t = quater + (y - t) * quater; + } + else + t = (y - t) * quater; + } + else { /* k = Prec-3 */ + n = LDBL_LEAST_SIGNIF_U(y) & 7; /* 3 LSb of z */ + k = 1; + } + if (k) { /* x = N/4 */ + if((n & 1) != 0) + y = sqrth + tiny; + else + y = (n & 2) == 0 ? zero : one; + if ((n & 4) != 0) + y = -y; + } + else { + if ((n & 1) != 0) + t = quater - t; + if (((n + (n & 1)) & 2) == 0) + y = __k_sinl(pi * t, zero); + else + y = __k_cosl(pi * t, zero); + if ((n & 4) != 0) + y = -y; + } + } + return hx >= 0 ? y : -y; +} +#undef U +#undef LDBL_LEAST_SIGNIF_U +#undef I +#undef LDBL_MOST_SIGNIF_I diff --git a/usr/src/libm/src/LD/tanhl.c b/usr/src/libm/src/LD/tanhl.c new file mode 100644 index 0000000..a9ffad7 --- /dev/null +++ b/usr/src/libm/src/LD/tanhl.c @@ -0,0 +1,97 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)tanhl.c 1.7 06/01/31 SMI" + +#if defined(ELFOBJ) +#pragma weak tanhl = __tanhl +#endif + +/* + * tanhl(x) returns the hyperbolic tangent of x + * + * Method : + * 1. reduce x to non-negative: tanhl(-x) = - tanhl(x). + * 2. + * 0 < x <= small : tanhl(x) := x + * -expm1l(-2x) + * small < x <= 1 : tanhl(x) := -------------- + * expm1l(-2x) + 2 + * 2 + * 1 <= x <= threshold : tanhl(x) := 1 - --------------- + * expm1l(2x) + 2 + * threshold < x <= INF : tanhl(x) := 1. + * + * where + * single : small = 1.e-5 threshold = 11.0 + * double : small = 1.e-10 threshold = 22.0 + * quad : small = 1.e-20 threshold = 45.0 + * + * Note: threshold was chosen so that + * fl(1.0+2/(expm1(2*threshold)+2)) == 1. + * + * Special cases: + * tanhl(NaN) is NaN; + * only tanhl(0.0)=0.0 is exact for finite argument. + */ + +#include "libm.h" + +static const long double small = 1.0e-20L, one = 1.0, two = 2.0, +#ifndef lint + big = 1.0e+20L, +#endif + threshold = 45.0L; + +long double +tanhl(long double x) { + long double t, y, z; + int signx; + + if (isnanl(x)) + return (x + x); /* x is NaN */ + signx = signbitl(x); + t = fabsl(x); + z = one; + if (t <= threshold) { + if (t > one) + z = one - two / (expm1l(t + t) + two); + else if (t > small) { + y = expm1l(-t - t); + z = -y / (y + two); + } else { +#ifndef lint + volatile long double dummy = t + big; + /* inexact if t != 0 */ +#endif + return (x); + } + } else if (!finitel(t)) + return (copysignl(one, x)); + else + return (signx ? -z + small * small : z - small * small); + return (signx ? -z : z); +} diff --git a/usr/src/libm/src/LD/tanl.c b/usr/src/libm/src/LD/tanl.c new file mode 100644 index 0000000..8231612 --- /dev/null +++ b/usr/src/libm/src/LD/tanl.c @@ -0,0 +1,96 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "@(#)tanl.c 1.9 06/01/31 SMI" + +#pragma weak tanl = __tanl + +/* INDENT OFF */ +/* cosl(x) + * Table look-up algorithm by K.C. Ng, November, 1989. + * + * kernel function: + * __k_tanl ... tangent function on [-pi/4,pi/4] + * __rem_pio2l ... argument reduction routine + * + * Method. + * Let S and C denote the sin and cos respectively on [-PI/4, +PI/4]. + * 1. Assume the argument x is reduced to y1+y2 = x-k*pi/2 in + * [-pi/2 , +pi/2], and let n = k mod 4. + * 2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have + * + * n sin(x) cos(x) tan(x) + * ---------------------------------------------------------- + * 0 S C S/C + * 1 C -S -C/S + * 2 -S -C S/C + * 3 -C S -C/S + * ---------------------------------------------------------- + * + * Special cases: + * Let trig be any of sin, cos, or tan. + * trig(+-INF) is NaN, with signals; + * trig(NaN) is that NaN; + * + * Accuracy: + * computer TRIG(x) returns trig(x) nearly rounded. + */ +/* INDENT ON */ + +#include "libm.h" +#include "libm_synonyms.h" +#include "longdouble.h" + +long double +tanl(long double x) { + long double y[2], z = 0.0L; + int n, ix; +#if defined(__i386) + int *px = (int *) &x; +#endif + + /* trig(Inf or NaN) is NaN */ + if (!finitel(x)) + return x - x; + + /* High word of x. */ +#if !defined(__i386) + ix = *(int *) &x; +#else + XTOI(px, ix); +#endif + + /* |x| ~< pi/4 */ + ix &= 0x7fffffff; + if (ix <= 0x3ffe9220) + return __k_tanl(x, z, 0); + + /* argument reduction needed */ + else { + n = __rem_pio2l(x, y); + return __k_tanl(y[0], y[1], n & 1); + } +} |