1425bb815Sopenharmony_ci/* Copyright JS Foundation and other contributors, http://js.foundation 2425bb815Sopenharmony_ci * 3425bb815Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4425bb815Sopenharmony_ci * you may not use this file except in compliance with the License. 5425bb815Sopenharmony_ci * You may obtain a copy of the License at 6425bb815Sopenharmony_ci * 7425bb815Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8425bb815Sopenharmony_ci * 9425bb815Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10425bb815Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS 11425bb815Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12425bb815Sopenharmony_ci * See the License for the specific language governing permissions and 13425bb815Sopenharmony_ci * limitations under the License. 14425bb815Sopenharmony_ci * 15425bb815Sopenharmony_ci * This file is based on work under the following copyright and permission 16425bb815Sopenharmony_ci * notice: 17425bb815Sopenharmony_ci * 18425bb815Sopenharmony_ci * Copyright (C) 1993, 2004 by Sun Microsystems, Inc. All rights reserved. 19425bb815Sopenharmony_ci * 20425bb815Sopenharmony_ci * Developed at SunSoft, a Sun Microsystems, Inc. business. 21425bb815Sopenharmony_ci * Permission to use, copy, modify, and distribute this 22425bb815Sopenharmony_ci * software is freely granted, provided that this notice 23425bb815Sopenharmony_ci * is preserved. 24425bb815Sopenharmony_ci * 25425bb815Sopenharmony_ci * @(#)k_rem_pio2.c 1.3 95/01/18 26425bb815Sopenharmony_ci * @(#)e_rem_pio2.c 1.4 95/01/18 27425bb815Sopenharmony_ci * @(#)k_sin.c 1.3 95/01/18 28425bb815Sopenharmony_ci * @(#)k_cos.c 1.3 95/01/18 29425bb815Sopenharmony_ci * @(#)k_tan.c 1.5 04/04/22 30425bb815Sopenharmony_ci * @(#)s_sin.c 1.3 95/01/18 31425bb815Sopenharmony_ci * @(#)s_cos.c 1.3 95/01/18 32425bb815Sopenharmony_ci * @(#)s_tan.c 1.3 95/01/18 33425bb815Sopenharmony_ci */ 34425bb815Sopenharmony_ci 35425bb815Sopenharmony_ci#include "jerry-libm-internal.h" 36425bb815Sopenharmony_ci 37425bb815Sopenharmony_ci#define zero 0.00000000000000000000e+00 /* 0x00000000, 0x00000000 */ 38425bb815Sopenharmony_ci#define half 5.00000000000000000000e-01 /* 0x3FE00000, 0x00000000 */ 39425bb815Sopenharmony_ci#define one 1.00000000000000000000e+00 /* 0x3FF00000, 0x00000000 */ 40425bb815Sopenharmony_ci#define two24 1.67772160000000000000e+07 /* 0x41700000, 0x00000000 */ 41425bb815Sopenharmony_ci#define twon24 5.96046447753906250000e-08 /* 0x3E700000, 0x00000000 */ 42425bb815Sopenharmony_ci 43425bb815Sopenharmony_ci/* __kernel_rem_pio2(x,y,e0,nx,prec) 44425bb815Sopenharmony_ci * double x[],y[]; int e0,nx,prec; 45425bb815Sopenharmony_ci * 46425bb815Sopenharmony_ci * __kernel_rem_pio2 return the last three digits of N with 47425bb815Sopenharmony_ci * y = x - N*pi/2 48425bb815Sopenharmony_ci * so that |y| < pi/2. 49425bb815Sopenharmony_ci * 50425bb815Sopenharmony_ci * The method is to compute the integer (mod 8) and fraction parts of 51425bb815Sopenharmony_ci * (2/pi)*x without doing the full multiplication. In general we 52425bb815Sopenharmony_ci * skip the part of the product that are known to be a huge integer ( 53425bb815Sopenharmony_ci * more accurately, = 0 mod 8 ). Thus the number of operations are 54425bb815Sopenharmony_ci * independent of the exponent of the input. 55425bb815Sopenharmony_ci * 56425bb815Sopenharmony_ci * (2/pi) is represented by an array of 24-bit integers in ipio2[]. 57425bb815Sopenharmony_ci * 58425bb815Sopenharmony_ci * Input parameters: 59425bb815Sopenharmony_ci * x[] The input value (must be positive) is broken into nx 60425bb815Sopenharmony_ci * pieces of 24-bit integers in double precision format. 61425bb815Sopenharmony_ci * x[i] will be the i-th 24 bit of x. The scaled exponent 62425bb815Sopenharmony_ci * of x[0] is given in input parameter e0 (i.e., x[0]*2^e0 63425bb815Sopenharmony_ci * match x's up to 24 bits. 64425bb815Sopenharmony_ci * 65425bb815Sopenharmony_ci * Example of breaking a double positive z into x[0]+x[1]+x[2]: 66425bb815Sopenharmony_ci * e0 = ilogb(z)-23 67425bb815Sopenharmony_ci * z = scalbn(z,-e0) 68425bb815Sopenharmony_ci * for i = 0,1,2 69425bb815Sopenharmony_ci * x[i] = floor(z) 70425bb815Sopenharmony_ci * z = (z-x[i])*2**24 71425bb815Sopenharmony_ci * 72425bb815Sopenharmony_ci * y[] ouput result in an array of double precision numbers. 73425bb815Sopenharmony_ci * The dimension of y[] is: 74425bb815Sopenharmony_ci * 24-bit precision 1 75425bb815Sopenharmony_ci * 53-bit precision 2 76425bb815Sopenharmony_ci * 64-bit precision 2 77425bb815Sopenharmony_ci * 113-bit precision 3 78425bb815Sopenharmony_ci * The actual value is the sum of them. Thus for 113-bit 79425bb815Sopenharmony_ci * precison, one may have to do something like: 80425bb815Sopenharmony_ci * 81425bb815Sopenharmony_ci * long double t,w,r_head, r_tail; 82425bb815Sopenharmony_ci * t = (long double)y[2] + (long double)y[1]; 83425bb815Sopenharmony_ci * w = (long double)y[0]; 84425bb815Sopenharmony_ci * r_head = t+w; 85425bb815Sopenharmony_ci * r_tail = w - (r_head - t); 86425bb815Sopenharmony_ci * 87425bb815Sopenharmony_ci * e0 The exponent of x[0] 88425bb815Sopenharmony_ci * 89425bb815Sopenharmony_ci * nx dimension of x[] 90425bb815Sopenharmony_ci * 91425bb815Sopenharmony_ci * prec an integer indicating the precision: 92425bb815Sopenharmony_ci * 0 24 bits (single) 93425bb815Sopenharmony_ci * 1 53 bits (double) 94425bb815Sopenharmony_ci * 2 64 bits (extended) 95425bb815Sopenharmony_ci * 3 113 bits (quad) 96425bb815Sopenharmony_ci * 97425bb815Sopenharmony_ci * External function: 98425bb815Sopenharmony_ci * double scalbn(), floor(); 99425bb815Sopenharmony_ci * 100425bb815Sopenharmony_ci * Here is the description of some local variables: 101425bb815Sopenharmony_ci * 102425bb815Sopenharmony_ci * ipio2[] integer array, contains the (24*i)-th to (24*i+23)-th 103425bb815Sopenharmony_ci * bit of 2/pi after binary point. The corresponding 104425bb815Sopenharmony_ci * floating value is 105425bb815Sopenharmony_ci * 106425bb815Sopenharmony_ci * ipio2[i] * 2^(-24(i+1)). 107425bb815Sopenharmony_ci * 108425bb815Sopenharmony_ci * jk jk+1 is the initial number of terms of ipio2[] needed 109425bb815Sopenharmony_ci * in the computation. The recommended value is 2,3,4, 110425bb815Sopenharmony_ci * 6 for single, double, extended,and quad. 111425bb815Sopenharmony_ci * 112425bb815Sopenharmony_ci * jz local integer variable indicating the number of 113425bb815Sopenharmony_ci * terms of ipio2[] used. 114425bb815Sopenharmony_ci * 115425bb815Sopenharmony_ci * jx nx - 1 116425bb815Sopenharmony_ci * 117425bb815Sopenharmony_ci * jv index for pointing to the suitable ipio2[] for the 118425bb815Sopenharmony_ci * computation. In general, we want 119425bb815Sopenharmony_ci * ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8 120425bb815Sopenharmony_ci * is an integer. Thus 121425bb815Sopenharmony_ci * e0-3-24*jv >= 0 or (e0-3)/24 >= jv 122425bb815Sopenharmony_ci * Hence jv = max(0,(e0-3)/24). 123425bb815Sopenharmony_ci * 124425bb815Sopenharmony_ci * jp jp+1 is the number of terms in PIo2[] needed, jp = jk. 125425bb815Sopenharmony_ci * 126425bb815Sopenharmony_ci * q[] double array with integral value, representing the 127425bb815Sopenharmony_ci * 24-bits chunk of the product of x and 2/pi. 128425bb815Sopenharmony_ci * 129425bb815Sopenharmony_ci * q0 the corresponding exponent of q[0]. Note that the 130425bb815Sopenharmony_ci * exponent for q[i] would be q0-24*i. 131425bb815Sopenharmony_ci * 132425bb815Sopenharmony_ci * PIo2[] double precision array, obtained by cutting pi/2 133425bb815Sopenharmony_ci * into 24 bits chunks. 134425bb815Sopenharmony_ci * 135425bb815Sopenharmony_ci * f[] ipio2[] in floating point 136425bb815Sopenharmony_ci * 137425bb815Sopenharmony_ci * iq[] integer array by breaking up q[] in 24-bits chunk. 138425bb815Sopenharmony_ci * 139425bb815Sopenharmony_ci * fq[] final product of x*(2/pi) in fq[0],..,fq[jk] 140425bb815Sopenharmony_ci * 141425bb815Sopenharmony_ci * ih integer. If >0 it indicates q[] is >= 0.5, hence 142425bb815Sopenharmony_ci * it also indicates the *sign* of the result. 143425bb815Sopenharmony_ci */ 144425bb815Sopenharmony_ci 145425bb815Sopenharmony_ci/* 146425bb815Sopenharmony_ci * Constants: 147425bb815Sopenharmony_ci * The hexadecimal values are the intended ones for the following 148425bb815Sopenharmony_ci * constants. The decimal values may be used, provided that the 149425bb815Sopenharmony_ci * compiler will convert from decimal to binary accurately enough 150425bb815Sopenharmony_ci * to produce the hexadecimal values shown. 151425bb815Sopenharmony_ci */ 152425bb815Sopenharmony_ci 153425bb815Sopenharmony_ci/* initial value for jk */ 154425bb815Sopenharmony_cistatic const int init_jk[] = 155425bb815Sopenharmony_ci{ 156425bb815Sopenharmony_ci 2, 3, 4, 6 157425bb815Sopenharmony_ci}; 158425bb815Sopenharmony_ci 159425bb815Sopenharmony_cistatic const double PIo2[] = 160425bb815Sopenharmony_ci{ 161425bb815Sopenharmony_ci 1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */ 162425bb815Sopenharmony_ci 7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */ 163425bb815Sopenharmony_ci 5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */ 164425bb815Sopenharmony_ci 3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */ 165425bb815Sopenharmony_ci 1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */ 166425bb815Sopenharmony_ci 1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */ 167425bb815Sopenharmony_ci 2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */ 168425bb815Sopenharmony_ci 2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */ 169425bb815Sopenharmony_ci}; 170425bb815Sopenharmony_ci 171425bb815Sopenharmony_ci/* 172425bb815Sopenharmony_ci * Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi 173425bb815Sopenharmony_ci */ 174425bb815Sopenharmony_cistatic const int ipio2[] = 175425bb815Sopenharmony_ci{ 176425bb815Sopenharmony_ci 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 177425bb815Sopenharmony_ci 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A, 178425bb815Sopenharmony_ci 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, 179425bb815Sopenharmony_ci 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41, 180425bb815Sopenharmony_ci 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, 181425bb815Sopenharmony_ci 0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF, 182425bb815Sopenharmony_ci 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, 183425bb815Sopenharmony_ci 0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, 184425bb815Sopenharmony_ci 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, 185425bb815Sopenharmony_ci 0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, 186425bb815Sopenharmony_ci 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B, 187425bb815Sopenharmony_ci}; 188425bb815Sopenharmony_ci 189425bb815Sopenharmony_cistatic int 190425bb815Sopenharmony_ci__kernel_rem_pio2 (double *x, double *y, int e0, int nx, int prec) 191425bb815Sopenharmony_ci{ 192425bb815Sopenharmony_ci int jz, jx, jv, jp, jk, carry, n, iq[20], i, j, k, m, q0, ih; 193425bb815Sopenharmony_ci double z, fw, f[20], fq[20], q[20]; 194425bb815Sopenharmony_ci 195425bb815Sopenharmony_ci /* initialize jk */ 196425bb815Sopenharmony_ci jk = init_jk[prec]; 197425bb815Sopenharmony_ci jp = jk; 198425bb815Sopenharmony_ci 199425bb815Sopenharmony_ci /* determine jx, jv, q0, note that 3 > q0 */ 200425bb815Sopenharmony_ci jx = nx - 1; 201425bb815Sopenharmony_ci jv = (e0 - 3) / 24; 202425bb815Sopenharmony_ci if (jv < 0) 203425bb815Sopenharmony_ci { 204425bb815Sopenharmony_ci jv = 0; 205425bb815Sopenharmony_ci } 206425bb815Sopenharmony_ci q0 = e0 - 24 * (jv + 1); 207425bb815Sopenharmony_ci 208425bb815Sopenharmony_ci /* set up f[0] to f[jx + jk] where f[jx + jk] = ipio2[jv + jk] */ 209425bb815Sopenharmony_ci j = jv - jx; 210425bb815Sopenharmony_ci m = jx + jk; 211425bb815Sopenharmony_ci for (i = 0; i <= m; i++, j++) 212425bb815Sopenharmony_ci { 213425bb815Sopenharmony_ci f[i] = (j < 0) ? zero : (double) ipio2[j]; 214425bb815Sopenharmony_ci } 215425bb815Sopenharmony_ci 216425bb815Sopenharmony_ci /* compute q[0], q[1], ... q[jk] */ 217425bb815Sopenharmony_ci for (i = 0; i <= jk; i++) 218425bb815Sopenharmony_ci { 219425bb815Sopenharmony_ci for (j = 0, fw = 0.0; j <= jx; j++) 220425bb815Sopenharmony_ci { 221425bb815Sopenharmony_ci fw += x[j] * f[jx + i - j]; 222425bb815Sopenharmony_ci } 223425bb815Sopenharmony_ci q[i] = fw; 224425bb815Sopenharmony_ci } 225425bb815Sopenharmony_ci 226425bb815Sopenharmony_ci jz = jk; 227425bb815Sopenharmony_cirecompute: 228425bb815Sopenharmony_ci /* distill q[] into iq[] reversingly */ 229425bb815Sopenharmony_ci for (i = 0, j = jz, z = q[jz]; j > 0; i++, j--) 230425bb815Sopenharmony_ci { 231425bb815Sopenharmony_ci fw = (double) ((int) (twon24 * z)); 232425bb815Sopenharmony_ci iq[i] = (int) (z - two24 * fw); 233425bb815Sopenharmony_ci z = q[j - 1] + fw; 234425bb815Sopenharmony_ci } 235425bb815Sopenharmony_ci 236425bb815Sopenharmony_ci /* compute n */ 237425bb815Sopenharmony_ci z = scalbn (z, q0); /* actual value of z */ 238425bb815Sopenharmony_ci z -= 8.0 * floor (z * 0.125); /* trim off integer >= 8 */ 239425bb815Sopenharmony_ci n = (int) z; 240425bb815Sopenharmony_ci z -= (double) n; 241425bb815Sopenharmony_ci ih = 0; 242425bb815Sopenharmony_ci if (q0 > 0) /* need iq[jz - 1] to determine n */ 243425bb815Sopenharmony_ci { 244425bb815Sopenharmony_ci i = (iq[jz - 1] >> (24 - q0)); 245425bb815Sopenharmony_ci n += i; 246425bb815Sopenharmony_ci iq[jz - 1] -= i << (24 - q0); 247425bb815Sopenharmony_ci ih = iq[jz - 1] >> (23 - q0); 248425bb815Sopenharmony_ci } 249425bb815Sopenharmony_ci else if (q0 == 0) 250425bb815Sopenharmony_ci { 251425bb815Sopenharmony_ci ih = iq[jz - 1] >> 23; 252425bb815Sopenharmony_ci } 253425bb815Sopenharmony_ci else if (z >= 0.5) 254425bb815Sopenharmony_ci { 255425bb815Sopenharmony_ci ih = 2; 256425bb815Sopenharmony_ci } 257425bb815Sopenharmony_ci 258425bb815Sopenharmony_ci if (ih > 0) /* q > 0.5 */ 259425bb815Sopenharmony_ci { 260425bb815Sopenharmony_ci n += 1; 261425bb815Sopenharmony_ci carry = 0; 262425bb815Sopenharmony_ci for (i = 0; i < jz; i++) /* compute 1 - q */ 263425bb815Sopenharmony_ci { 264425bb815Sopenharmony_ci j = iq[i]; 265425bb815Sopenharmony_ci if (carry == 0) 266425bb815Sopenharmony_ci { 267425bb815Sopenharmony_ci if (j != 0) 268425bb815Sopenharmony_ci { 269425bb815Sopenharmony_ci carry = 1; 270425bb815Sopenharmony_ci iq[i] = 0x1000000 - j; 271425bb815Sopenharmony_ci } 272425bb815Sopenharmony_ci } 273425bb815Sopenharmony_ci else 274425bb815Sopenharmony_ci { 275425bb815Sopenharmony_ci iq[i] = 0xffffff - j; 276425bb815Sopenharmony_ci } 277425bb815Sopenharmony_ci } 278425bb815Sopenharmony_ci if (q0 > 0) /* rare case: chance is 1 in 12 */ 279425bb815Sopenharmony_ci { 280425bb815Sopenharmony_ci switch (q0) 281425bb815Sopenharmony_ci { 282425bb815Sopenharmony_ci case 1: 283425bb815Sopenharmony_ci { 284425bb815Sopenharmony_ci iq[jz - 1] &= 0x7fffff; 285425bb815Sopenharmony_ci break; 286425bb815Sopenharmony_ci } 287425bb815Sopenharmony_ci case 2: 288425bb815Sopenharmony_ci { 289425bb815Sopenharmony_ci iq[jz - 1] &= 0x3fffff; 290425bb815Sopenharmony_ci break; 291425bb815Sopenharmony_ci } 292425bb815Sopenharmony_ci } 293425bb815Sopenharmony_ci } 294425bb815Sopenharmony_ci if (ih == 2) 295425bb815Sopenharmony_ci { 296425bb815Sopenharmony_ci z = one - z; 297425bb815Sopenharmony_ci if (carry != 0) 298425bb815Sopenharmony_ci { 299425bb815Sopenharmony_ci z -= scalbn (one, q0); 300425bb815Sopenharmony_ci } 301425bb815Sopenharmony_ci } 302425bb815Sopenharmony_ci } 303425bb815Sopenharmony_ci 304425bb815Sopenharmony_ci /* check if recomputation is needed */ 305425bb815Sopenharmony_ci if (z == zero) 306425bb815Sopenharmony_ci { 307425bb815Sopenharmony_ci j = 0; 308425bb815Sopenharmony_ci for (i = jz - 1; i >= jk; i--) 309425bb815Sopenharmony_ci { 310425bb815Sopenharmony_ci j |= iq[i]; 311425bb815Sopenharmony_ci } 312425bb815Sopenharmony_ci if (j == 0) /* need recomputation */ 313425bb815Sopenharmony_ci { 314425bb815Sopenharmony_ci for (k = 1; iq[jk - k] == 0; k++) /* k = no. of terms needed */ 315425bb815Sopenharmony_ci { 316425bb815Sopenharmony_ci } 317425bb815Sopenharmony_ci 318425bb815Sopenharmony_ci for (i = jz + 1; i <= jz + k; i++) /* add q[jz + 1] to q[jz + k] */ 319425bb815Sopenharmony_ci { 320425bb815Sopenharmony_ci f[jx + i] = (double) ipio2[jv + i]; 321425bb815Sopenharmony_ci for (j = 0, fw = 0.0; j <= jx; j++) 322425bb815Sopenharmony_ci { 323425bb815Sopenharmony_ci fw += x[j] * f[jx + i - j]; 324425bb815Sopenharmony_ci } 325425bb815Sopenharmony_ci q[i] = fw; 326425bb815Sopenharmony_ci } 327425bb815Sopenharmony_ci jz += k; 328425bb815Sopenharmony_ci goto recompute; 329425bb815Sopenharmony_ci } 330425bb815Sopenharmony_ci } 331425bb815Sopenharmony_ci 332425bb815Sopenharmony_ci /* chop off zero terms */ 333425bb815Sopenharmony_ci if (z == 0.0) 334425bb815Sopenharmony_ci { 335425bb815Sopenharmony_ci jz -= 1; 336425bb815Sopenharmony_ci q0 -= 24; 337425bb815Sopenharmony_ci while (iq[jz] == 0) 338425bb815Sopenharmony_ci { 339425bb815Sopenharmony_ci jz--; 340425bb815Sopenharmony_ci q0 -= 24; 341425bb815Sopenharmony_ci } 342425bb815Sopenharmony_ci } 343425bb815Sopenharmony_ci else 344425bb815Sopenharmony_ci { /* break z into 24-bit if necessary */ 345425bb815Sopenharmony_ci z = scalbn (z, -q0); 346425bb815Sopenharmony_ci if (z >= two24) 347425bb815Sopenharmony_ci { 348425bb815Sopenharmony_ci fw = (double) ((int) (twon24 * z)); 349425bb815Sopenharmony_ci iq[jz] = (int) (z - two24 * fw); 350425bb815Sopenharmony_ci jz += 1; 351425bb815Sopenharmony_ci q0 += 24; 352425bb815Sopenharmony_ci iq[jz] = (int) fw; 353425bb815Sopenharmony_ci } 354425bb815Sopenharmony_ci else 355425bb815Sopenharmony_ci { 356425bb815Sopenharmony_ci iq[jz] = (int) z; 357425bb815Sopenharmony_ci } 358425bb815Sopenharmony_ci } 359425bb815Sopenharmony_ci 360425bb815Sopenharmony_ci /* convert integer "bit" chunk to floating-point value */ 361425bb815Sopenharmony_ci fw = scalbn (one, q0); 362425bb815Sopenharmony_ci for (i = jz; i >= 0; i--) 363425bb815Sopenharmony_ci { 364425bb815Sopenharmony_ci q[i] = fw * (double) iq[i]; 365425bb815Sopenharmony_ci fw *= twon24; 366425bb815Sopenharmony_ci } 367425bb815Sopenharmony_ci 368425bb815Sopenharmony_ci /* compute PIo2[0, ..., jp] * q[jz, ..., 0] */ 369425bb815Sopenharmony_ci for (i = jz; i >= 0; i--) 370425bb815Sopenharmony_ci { 371425bb815Sopenharmony_ci for (fw = 0.0, k = 0; k <= jp && k <= jz - i; k++) 372425bb815Sopenharmony_ci { 373425bb815Sopenharmony_ci fw += PIo2[k] * q[i + k]; 374425bb815Sopenharmony_ci } 375425bb815Sopenharmony_ci fq[jz - i] = fw; 376425bb815Sopenharmony_ci } 377425bb815Sopenharmony_ci 378425bb815Sopenharmony_ci /* compress fq[] into y[] */ 379425bb815Sopenharmony_ci switch (prec) 380425bb815Sopenharmony_ci { 381425bb815Sopenharmony_ci case 0: 382425bb815Sopenharmony_ci { 383425bb815Sopenharmony_ci fw = 0.0; 384425bb815Sopenharmony_ci for (i = jz; i >= 0; i--) 385425bb815Sopenharmony_ci { 386425bb815Sopenharmony_ci fw += fq[i]; 387425bb815Sopenharmony_ci } 388425bb815Sopenharmony_ci y[0] = (ih == 0) ? fw : -fw; 389425bb815Sopenharmony_ci break; 390425bb815Sopenharmony_ci } 391425bb815Sopenharmony_ci case 1: 392425bb815Sopenharmony_ci case 2: 393425bb815Sopenharmony_ci { 394425bb815Sopenharmony_ci fw = 0.0; 395425bb815Sopenharmony_ci for (i = jz; i >= 0; i--) 396425bb815Sopenharmony_ci { 397425bb815Sopenharmony_ci fw += fq[i]; 398425bb815Sopenharmony_ci } 399425bb815Sopenharmony_ci y[0] = (ih == 0) ? fw : -fw; 400425bb815Sopenharmony_ci fw = fq[0] - fw; 401425bb815Sopenharmony_ci for (i = 1; i <= jz; i++) 402425bb815Sopenharmony_ci { 403425bb815Sopenharmony_ci fw += fq[i]; 404425bb815Sopenharmony_ci } 405425bb815Sopenharmony_ci y[1] = (ih == 0) ? fw : -fw; 406425bb815Sopenharmony_ci break; 407425bb815Sopenharmony_ci } 408425bb815Sopenharmony_ci case 3: /* painful */ 409425bb815Sopenharmony_ci { 410425bb815Sopenharmony_ci for (i = jz; i > 0; i--) 411425bb815Sopenharmony_ci { 412425bb815Sopenharmony_ci fw = fq[i - 1] + fq[i]; 413425bb815Sopenharmony_ci fq[i] += fq[i - 1] - fw; 414425bb815Sopenharmony_ci fq[i - 1] = fw; 415425bb815Sopenharmony_ci } 416425bb815Sopenharmony_ci for (i = jz; i > 1; i--) 417425bb815Sopenharmony_ci { 418425bb815Sopenharmony_ci fw = fq[i - 1] + fq[i]; 419425bb815Sopenharmony_ci fq[i] += fq[i - 1] - fw; 420425bb815Sopenharmony_ci fq[i - 1] = fw; 421425bb815Sopenharmony_ci } 422425bb815Sopenharmony_ci for (fw = 0.0, i = jz; i >= 2; i--) 423425bb815Sopenharmony_ci { 424425bb815Sopenharmony_ci fw += fq[i]; 425425bb815Sopenharmony_ci } 426425bb815Sopenharmony_ci if (ih == 0) 427425bb815Sopenharmony_ci { 428425bb815Sopenharmony_ci y[0] = fq[0]; 429425bb815Sopenharmony_ci y[1] = fq[1]; 430425bb815Sopenharmony_ci y[2] = fw; 431425bb815Sopenharmony_ci } 432425bb815Sopenharmony_ci else 433425bb815Sopenharmony_ci { 434425bb815Sopenharmony_ci y[0] = -fq[0]; 435425bb815Sopenharmony_ci y[1] = -fq[1]; 436425bb815Sopenharmony_ci y[2] = -fw; 437425bb815Sopenharmony_ci } 438425bb815Sopenharmony_ci } 439425bb815Sopenharmony_ci } 440425bb815Sopenharmony_ci return n & 7; 441425bb815Sopenharmony_ci} /* __kernel_rem_pio2 */ 442425bb815Sopenharmony_ci 443425bb815Sopenharmony_ci/* __ieee754_rem_pio2(x,y) 444425bb815Sopenharmony_ci * return the remainder of x rem pi/2 in y[0]+y[1] 445425bb815Sopenharmony_ci * use __kernel_rem_pio2() 446425bb815Sopenharmony_ci */ 447425bb815Sopenharmony_ci 448425bb815Sopenharmony_cistatic const int npio2_hw[] = 449425bb815Sopenharmony_ci{ 450425bb815Sopenharmony_ci 0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C, 451425bb815Sopenharmony_ci 0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C, 452425bb815Sopenharmony_ci 0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A, 453425bb815Sopenharmony_ci 0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C, 454425bb815Sopenharmony_ci 0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB, 455425bb815Sopenharmony_ci 0x404858EB, 0x404921FB, 456425bb815Sopenharmony_ci}; 457425bb815Sopenharmony_ci 458425bb815Sopenharmony_ci/* 459425bb815Sopenharmony_ci * invpio2: 53 bits of 2/pi 460425bb815Sopenharmony_ci * pio2_1: first 33 bit of pi/2 461425bb815Sopenharmony_ci * pio2_1t: pi/2 - pio2_1 462425bb815Sopenharmony_ci * pio2_2: second 33 bit of pi/2 463425bb815Sopenharmony_ci * pio2_2t: pi/2 - (pio2_1 + pio2_2) 464425bb815Sopenharmony_ci * pio2_3: third 33 bit of pi/2 465425bb815Sopenharmony_ci * pio2_3t: pi/2 - (pio2_1 + pio2_2 + pio2_3) 466425bb815Sopenharmony_ci */ 467425bb815Sopenharmony_ci#define invpio2 6.36619772367581382433e-01 /* 0x3FE45F30, 0x6DC9C883 */ 468425bb815Sopenharmony_ci#define pio2_1 1.57079632673412561417e+00 /* 0x3FF921FB, 0x54400000 */ 469425bb815Sopenharmony_ci#define pio2_1t 6.07710050650619224932e-11 /* 0x3DD0B461, 0x1A626331 */ 470425bb815Sopenharmony_ci#define pio2_2 6.07710050630396597660e-11 /* 0x3DD0B461, 0x1A600000 */ 471425bb815Sopenharmony_ci#define pio2_2t 2.02226624879595063154e-21 /* 0x3BA3198A, 0x2E037073 */ 472425bb815Sopenharmony_ci#define pio2_3 2.02226624871116645580e-21 /* 0x3BA3198A, 0x2E000000 */ 473425bb815Sopenharmony_ci#define pio2_3t 8.47842766036889956997e-32 /* 0x397B839A, 0x252049C1 */ 474425bb815Sopenharmony_ci 475425bb815Sopenharmony_cistatic int 476425bb815Sopenharmony_ci__ieee754_rem_pio2 (double x, double *y) 477425bb815Sopenharmony_ci{ 478425bb815Sopenharmony_ci double_accessor z; 479425bb815Sopenharmony_ci double w, t, r, fn; 480425bb815Sopenharmony_ci double tx[3]; 481425bb815Sopenharmony_ci int e0, i, j, nx, n, ix, hx; 482425bb815Sopenharmony_ci 483425bb815Sopenharmony_ci hx = __HI (x); /* high word of x */ 484425bb815Sopenharmony_ci ix = hx & 0x7fffffff; 485425bb815Sopenharmony_ci if (ix <= 0x3fe921fb) /* |x| ~<= pi/4 , no need for reduction */ 486425bb815Sopenharmony_ci { 487425bb815Sopenharmony_ci y[0] = x; 488425bb815Sopenharmony_ci y[1] = 0; 489425bb815Sopenharmony_ci return 0; 490425bb815Sopenharmony_ci } 491425bb815Sopenharmony_ci if (ix < 0x4002d97c) /* |x| < 3pi/4, special case with n = +-1 */ 492425bb815Sopenharmony_ci { 493425bb815Sopenharmony_ci if (hx > 0) 494425bb815Sopenharmony_ci { 495425bb815Sopenharmony_ci z.dbl = x - pio2_1; 496425bb815Sopenharmony_ci if (ix != 0x3ff921fb) /* 33 + 53 bit pi is good enough */ 497425bb815Sopenharmony_ci { 498425bb815Sopenharmony_ci y[0] = z.dbl - pio2_1t; 499425bb815Sopenharmony_ci y[1] = (z.dbl - y[0]) - pio2_1t; 500425bb815Sopenharmony_ci } 501425bb815Sopenharmony_ci else /* near pi/2, use 33 + 33 + 53 bit pi */ 502425bb815Sopenharmony_ci { 503425bb815Sopenharmony_ci z.dbl -= pio2_2; 504425bb815Sopenharmony_ci y[0] = z.dbl - pio2_2t; 505425bb815Sopenharmony_ci y[1] = (z.dbl - y[0]) - pio2_2t; 506425bb815Sopenharmony_ci } 507425bb815Sopenharmony_ci return 1; 508425bb815Sopenharmony_ci } 509425bb815Sopenharmony_ci else /* negative x */ 510425bb815Sopenharmony_ci { 511425bb815Sopenharmony_ci z.dbl = x + pio2_1; 512425bb815Sopenharmony_ci if (ix != 0x3ff921fb) /* 33 + 53 bit pi is good enough */ 513425bb815Sopenharmony_ci { 514425bb815Sopenharmony_ci y[0] = z.dbl + pio2_1t; 515425bb815Sopenharmony_ci y[1] = (z.dbl - y[0]) + pio2_1t; 516425bb815Sopenharmony_ci } 517425bb815Sopenharmony_ci else /* near pi/2, use 33 + 33 + 53 bit pi */ 518425bb815Sopenharmony_ci { 519425bb815Sopenharmony_ci z.dbl += pio2_2; 520425bb815Sopenharmony_ci y[0] = z.dbl + pio2_2t; 521425bb815Sopenharmony_ci y[1] = (z.dbl - y[0]) + pio2_2t; 522425bb815Sopenharmony_ci } 523425bb815Sopenharmony_ci return -1; 524425bb815Sopenharmony_ci } 525425bb815Sopenharmony_ci } 526425bb815Sopenharmony_ci if (ix <= 0x413921fb) /* |x| ~<= 2^19 * (pi/2), medium size */ 527425bb815Sopenharmony_ci { 528425bb815Sopenharmony_ci t = fabs (x); 529425bb815Sopenharmony_ci n = (int) (t * invpio2 + half); 530425bb815Sopenharmony_ci fn = (double) n; 531425bb815Sopenharmony_ci r = t - fn * pio2_1; 532425bb815Sopenharmony_ci w = fn * pio2_1t; /* 1st round good to 85 bit */ 533425bb815Sopenharmony_ci if (n < 32 && ix != npio2_hw[n - 1]) 534425bb815Sopenharmony_ci { 535425bb815Sopenharmony_ci y[0] = r - w; /* quick check no cancellation */ 536425bb815Sopenharmony_ci } 537425bb815Sopenharmony_ci else 538425bb815Sopenharmony_ci { 539425bb815Sopenharmony_ci j = ix >> 20; 540425bb815Sopenharmony_ci y[0] = r - w; 541425bb815Sopenharmony_ci i = j - (((__HI (y[0])) >> 20) & 0x7ff); 542425bb815Sopenharmony_ci if (i > 16) /* 2nd iteration needed, good to 118 */ 543425bb815Sopenharmony_ci { 544425bb815Sopenharmony_ci t = r; 545425bb815Sopenharmony_ci w = fn * pio2_2; 546425bb815Sopenharmony_ci r = t - w; 547425bb815Sopenharmony_ci w = fn * pio2_2t - ((t - r) - w); 548425bb815Sopenharmony_ci y[0] = r - w; 549425bb815Sopenharmony_ci i = j - (((__HI (y[0])) >> 20) & 0x7ff); 550425bb815Sopenharmony_ci if (i > 49) /* 3rd iteration need, 151 bits acc, will cover all possible cases */ 551425bb815Sopenharmony_ci { 552425bb815Sopenharmony_ci t = r; 553425bb815Sopenharmony_ci w = fn * pio2_3; 554425bb815Sopenharmony_ci r = t - w; 555425bb815Sopenharmony_ci w = fn * pio2_3t - ((t - r) - w); 556425bb815Sopenharmony_ci y[0] = r - w; 557425bb815Sopenharmony_ci } 558425bb815Sopenharmony_ci } 559425bb815Sopenharmony_ci } 560425bb815Sopenharmony_ci y[1] = (r - y[0]) - w; 561425bb815Sopenharmony_ci if (hx < 0) 562425bb815Sopenharmony_ci { 563425bb815Sopenharmony_ci y[0] = -y[0]; 564425bb815Sopenharmony_ci y[1] = -y[1]; 565425bb815Sopenharmony_ci return -n; 566425bb815Sopenharmony_ci } 567425bb815Sopenharmony_ci else 568425bb815Sopenharmony_ci { 569425bb815Sopenharmony_ci return n; 570425bb815Sopenharmony_ci } 571425bb815Sopenharmony_ci } 572425bb815Sopenharmony_ci /* 573425bb815Sopenharmony_ci * all other (large) arguments 574425bb815Sopenharmony_ci */ 575425bb815Sopenharmony_ci if (ix >= 0x7ff00000) /* x is inf or NaN */ 576425bb815Sopenharmony_ci { 577425bb815Sopenharmony_ci y[0] = y[1] = x - x; 578425bb815Sopenharmony_ci return 0; 579425bb815Sopenharmony_ci } 580425bb815Sopenharmony_ci /* set z = scalbn(|x|, ilogb(x) - 23) */ 581425bb815Sopenharmony_ci z.as_int.lo = __LO (x); 582425bb815Sopenharmony_ci e0 = (ix >> 20) - 1046; /* e0 = ilogb(z) - 23; */ 583425bb815Sopenharmony_ci z.as_int.hi = ix - (e0 << 20); 584425bb815Sopenharmony_ci for (i = 0; i < 2; i++) 585425bb815Sopenharmony_ci { 586425bb815Sopenharmony_ci tx[i] = (double) ((int) (z.dbl)); 587425bb815Sopenharmony_ci z.dbl = (z.dbl - tx[i]) * two24; 588425bb815Sopenharmony_ci } 589425bb815Sopenharmony_ci tx[2] = z.dbl; 590425bb815Sopenharmony_ci nx = 3; 591425bb815Sopenharmony_ci while (tx[nx - 1] == zero) /* skip zero term */ 592425bb815Sopenharmony_ci { 593425bb815Sopenharmony_ci nx--; 594425bb815Sopenharmony_ci } 595425bb815Sopenharmony_ci n = __kernel_rem_pio2 (tx, y, e0, nx, 2); 596425bb815Sopenharmony_ci if (hx < 0) 597425bb815Sopenharmony_ci { 598425bb815Sopenharmony_ci y[0] = -y[0]; 599425bb815Sopenharmony_ci y[1] = -y[1]; 600425bb815Sopenharmony_ci return -n; 601425bb815Sopenharmony_ci } 602425bb815Sopenharmony_ci return n; 603425bb815Sopenharmony_ci} /* __ieee754_rem_pio2 */ 604425bb815Sopenharmony_ci 605425bb815Sopenharmony_ci/* __kernel_sin( x, y, iy) 606425bb815Sopenharmony_ci * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854 607425bb815Sopenharmony_ci * Input x is assumed to be bounded by ~pi/4 in magnitude. 608425bb815Sopenharmony_ci * Input y is the tail of x. 609425bb815Sopenharmony_ci * Input iy indicates whether y is 0. (if iy=0, y assume to be 0). 610425bb815Sopenharmony_ci * 611425bb815Sopenharmony_ci * Algorithm 612425bb815Sopenharmony_ci * 1. Since sin(-x) = -sin(x), we need only to consider positive x. 613425bb815Sopenharmony_ci * 2. if x < 2^-27 (hx<0x3e400000 0), return x with inexact if x!=0. 614425bb815Sopenharmony_ci * 3. sin(x) is approximated by a polynomial of degree 13 on 615425bb815Sopenharmony_ci * [0,pi/4] 616425bb815Sopenharmony_ci * 3 13 617425bb815Sopenharmony_ci * sin(x) ~ x + S1*x + ... + S6*x 618425bb815Sopenharmony_ci * where 619425bb815Sopenharmony_ci * 620425bb815Sopenharmony_ci * |sin(x) 2 4 6 8 10 12 | -58 621425bb815Sopenharmony_ci * |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2 622425bb815Sopenharmony_ci * | x | 623425bb815Sopenharmony_ci * 624425bb815Sopenharmony_ci * 4. sin(x+y) = sin(x) + sin'(x')*y 625425bb815Sopenharmony_ci * ~ sin(x) + (1-x*x/2)*y 626425bb815Sopenharmony_ci * For better accuracy, let 627425bb815Sopenharmony_ci * 3 2 2 2 2 628425bb815Sopenharmony_ci * r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6)))) 629425bb815Sopenharmony_ci * then 3 2 630425bb815Sopenharmony_ci * sin(x) = x + (S1*x + (x *(r-y/2)+y)) 631425bb815Sopenharmony_ci */ 632425bb815Sopenharmony_ci 633425bb815Sopenharmony_ci#define S1 -1.66666666666666324348e-01 /* 0xBFC55555, 0x55555549 */ 634425bb815Sopenharmony_ci#define S2 8.33333333332248946124e-03 /* 0x3F811111, 0x1110F8A6 */ 635425bb815Sopenharmony_ci#define S3 -1.98412698298579493134e-04 /* 0xBF2A01A0, 0x19C161D5 */ 636425bb815Sopenharmony_ci#define S4 2.75573137070700676789e-06 /* 0x3EC71DE3, 0x57B1FE7D */ 637425bb815Sopenharmony_ci#define S5 -2.50507602534068634195e-08 /* 0xBE5AE5E6, 0x8A2B9CEB */ 638425bb815Sopenharmony_ci#define S6 1.58969099521155010221e-10 /* 0x3DE5D93A, 0x5ACFD57C */ 639425bb815Sopenharmony_ci 640425bb815Sopenharmony_cistatic double 641425bb815Sopenharmony_ci__kernel_sin (double x, double y, int iy) 642425bb815Sopenharmony_ci{ 643425bb815Sopenharmony_ci double z, r, v; 644425bb815Sopenharmony_ci int ix; 645425bb815Sopenharmony_ci 646425bb815Sopenharmony_ci ix = __HI (x) & 0x7fffffff; /* high word of x */ 647425bb815Sopenharmony_ci if (ix < 0x3e400000) /* |x| < 2**-27 */ 648425bb815Sopenharmony_ci { 649425bb815Sopenharmony_ci if ((int) x == 0) 650425bb815Sopenharmony_ci { 651425bb815Sopenharmony_ci return x; /* generate inexact */ 652425bb815Sopenharmony_ci } 653425bb815Sopenharmony_ci } 654425bb815Sopenharmony_ci z = x * x; 655425bb815Sopenharmony_ci v = z * x; 656425bb815Sopenharmony_ci r = S2 + z * (S3 + z * (S4 + z * (S5 + z * S6))); 657425bb815Sopenharmony_ci if (iy == 0) 658425bb815Sopenharmony_ci { 659425bb815Sopenharmony_ci return x + v * (S1 + z * r); 660425bb815Sopenharmony_ci } 661425bb815Sopenharmony_ci else 662425bb815Sopenharmony_ci { 663425bb815Sopenharmony_ci return x - ((z * (half * y - v * r) - y) - v * S1); 664425bb815Sopenharmony_ci } 665425bb815Sopenharmony_ci} /* __kernel_sin */ 666425bb815Sopenharmony_ci 667425bb815Sopenharmony_ci/* 668425bb815Sopenharmony_ci * __kernel_cos( x, y ) 669425bb815Sopenharmony_ci * kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164 670425bb815Sopenharmony_ci * Input x is assumed to be bounded by ~pi/4 in magnitude. 671425bb815Sopenharmony_ci * Input y is the tail of x. 672425bb815Sopenharmony_ci * 673425bb815Sopenharmony_ci * Algorithm 674425bb815Sopenharmony_ci * 1. Since cos(-x) = cos(x), we need only to consider positive x. 675425bb815Sopenharmony_ci * 2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0. 676425bb815Sopenharmony_ci * 3. cos(x) is approximated by a polynomial of degree 14 on 677425bb815Sopenharmony_ci * [0,pi/4] 678425bb815Sopenharmony_ci * 4 14 679425bb815Sopenharmony_ci * cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x 680425bb815Sopenharmony_ci * where the remez error is 681425bb815Sopenharmony_ci * 682425bb815Sopenharmony_ci * | 2 4 6 8 10 12 14 | -58 683425bb815Sopenharmony_ci * |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2 684425bb815Sopenharmony_ci * | | 685425bb815Sopenharmony_ci * 686425bb815Sopenharmony_ci * 4 6 8 10 12 14 687425bb815Sopenharmony_ci * 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then 688425bb815Sopenharmony_ci * cos(x) = 1 - x*x/2 + r 689425bb815Sopenharmony_ci * since cos(x+y) ~ cos(x) - sin(x)*y 690425bb815Sopenharmony_ci * ~ cos(x) - x*y, 691425bb815Sopenharmony_ci * a correction term is necessary in cos(x) and hence 692425bb815Sopenharmony_ci * cos(x+y) = 1 - (x*x/2 - (r - x*y)) 693425bb815Sopenharmony_ci * For better accuracy when x > 0.3, let qx = |x|/4 with 694425bb815Sopenharmony_ci * the last 32 bits mask off, and if x > 0.78125, let qx = 0.28125. 695425bb815Sopenharmony_ci * Then 696425bb815Sopenharmony_ci * cos(x+y) = (1-qx) - ((x*x/2-qx) - (r-x*y)). 697425bb815Sopenharmony_ci * Note that 1-qx and (x*x/2-qx) is EXACT here, and the 698425bb815Sopenharmony_ci * magnitude of the latter is at least a quarter of x*x/2, 699425bb815Sopenharmony_ci * thus, reducing the rounding error in the subtraction. 700425bb815Sopenharmony_ci */ 701425bb815Sopenharmony_ci 702425bb815Sopenharmony_ci#define C1 4.16666666666666019037e-02 /* 0x3FA55555, 0x5555554C */ 703425bb815Sopenharmony_ci#define C2 -1.38888888888741095749e-03 /* 0xBF56C16C, 0x16C15177 */ 704425bb815Sopenharmony_ci#define C3 2.48015872894767294178e-05 /* 0x3EFA01A0, 0x19CB1590 */ 705425bb815Sopenharmony_ci#define C4 -2.75573143513906633035e-07 /* 0xBE927E4F, 0x809C52AD */ 706425bb815Sopenharmony_ci#define C5 2.08757232129817482790e-09 /* 0x3E21EE9E, 0xBDB4B1C4 */ 707425bb815Sopenharmony_ci#define C6 -1.13596475577881948265e-11 /* 0xBDA8FAE9, 0xBE8838D4 */ 708425bb815Sopenharmony_ci 709425bb815Sopenharmony_cistatic double 710425bb815Sopenharmony_ci__kernel_cos (double x, double y) 711425bb815Sopenharmony_ci{ 712425bb815Sopenharmony_ci double a, hz, z, r; 713425bb815Sopenharmony_ci int ix; 714425bb815Sopenharmony_ci 715425bb815Sopenharmony_ci ix = __HI (x) & 0x7fffffff; /* ix = |x|'s high word */ 716425bb815Sopenharmony_ci if (ix < 0x3e400000) /* if x < 2**27 */ 717425bb815Sopenharmony_ci { 718425bb815Sopenharmony_ci if (((int) x) == 0) 719425bb815Sopenharmony_ci { 720425bb815Sopenharmony_ci return one; /* generate inexact */ 721425bb815Sopenharmony_ci } 722425bb815Sopenharmony_ci } 723425bb815Sopenharmony_ci z = x * x; 724425bb815Sopenharmony_ci r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6))))); 725425bb815Sopenharmony_ci if (ix < 0x3FD33333) /* if |x| < 0.3 */ 726425bb815Sopenharmony_ci { 727425bb815Sopenharmony_ci return one - (0.5 * z - (z * r - x * y)); 728425bb815Sopenharmony_ci } 729425bb815Sopenharmony_ci else 730425bb815Sopenharmony_ci { 731425bb815Sopenharmony_ci double_accessor qx; 732425bb815Sopenharmony_ci if (ix > 0x3fe90000) /* x > 0.78125 */ 733425bb815Sopenharmony_ci { 734425bb815Sopenharmony_ci qx.dbl = 0.28125; 735425bb815Sopenharmony_ci } 736425bb815Sopenharmony_ci else 737425bb815Sopenharmony_ci { 738425bb815Sopenharmony_ci qx.as_int.hi = ix - 0x00200000; /* x / 4 */ 739425bb815Sopenharmony_ci qx.as_int.lo = 0; 740425bb815Sopenharmony_ci } 741425bb815Sopenharmony_ci hz = 0.5 * z - qx.dbl; 742425bb815Sopenharmony_ci a = one - qx.dbl; 743425bb815Sopenharmony_ci return a - (hz - (z * r - x * y)); 744425bb815Sopenharmony_ci } 745425bb815Sopenharmony_ci} /* __kernel_cos */ 746425bb815Sopenharmony_ci 747425bb815Sopenharmony_ci/* __kernel_tan( x, y, k ) 748425bb815Sopenharmony_ci * kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854 749425bb815Sopenharmony_ci * Input x is assumed to be bounded by ~pi/4 in magnitude. 750425bb815Sopenharmony_ci * Input y is the tail of x. 751425bb815Sopenharmony_ci * Input k indicates whether tan (if k = 1) or -1/tan (if k = -1) is returned. 752425bb815Sopenharmony_ci * 753425bb815Sopenharmony_ci * Algorithm 754425bb815Sopenharmony_ci * 1. Since tan(-x) = -tan(x), we need only to consider positive x. 755425bb815Sopenharmony_ci * 2. if x < 2^-28 (hx<0x3e300000 0), return x with inexact if x!=0. 756425bb815Sopenharmony_ci * 3. tan(x) is approximated by a odd polynomial of degree 27 on 757425bb815Sopenharmony_ci * [0,0.67434] 758425bb815Sopenharmony_ci * 3 27 759425bb815Sopenharmony_ci * tan(x) ~ x + T1*x + ... + T13*x 760425bb815Sopenharmony_ci * where 761425bb815Sopenharmony_ci * 762425bb815Sopenharmony_ci * |tan(x) 2 4 26 | -59.2 763425bb815Sopenharmony_ci * |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2 764425bb815Sopenharmony_ci * | x | 765425bb815Sopenharmony_ci * 766425bb815Sopenharmony_ci * Note: tan(x+y) = tan(x) + tan'(x)*y 767425bb815Sopenharmony_ci * ~ tan(x) + (1+x*x)*y 768425bb815Sopenharmony_ci * Therefore, for better accuracy in computing tan(x+y), let 769425bb815Sopenharmony_ci * 3 2 2 2 2 770425bb815Sopenharmony_ci * r = x *(T2+x *(T3+x *(...+x *(T12+x *T13)))) 771425bb815Sopenharmony_ci * then 772425bb815Sopenharmony_ci * 3 2 773425bb815Sopenharmony_ci * tan(x+y) = x + (T1*x + (x *(r+y)+y)) 774425bb815Sopenharmony_ci * 775425bb815Sopenharmony_ci * 4. For x in [0.67434,pi/4], let y = pi/4 - x, then 776425bb815Sopenharmony_ci * tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y)) 777425bb815Sopenharmony_ci * = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y))) 778425bb815Sopenharmony_ci */ 779425bb815Sopenharmony_ci 780425bb815Sopenharmony_ci#define T0 3.33333333333334091986e-01 /* 3FD55555, 55555563 */ 781425bb815Sopenharmony_ci#define T1 1.33333333333201242699e-01 /* 3FC11111, 1110FE7A */ 782425bb815Sopenharmony_ci#define T2 5.39682539762260521377e-02 /* 3FABA1BA, 1BB341FE */ 783425bb815Sopenharmony_ci#define T3 2.18694882948595424599e-02 /* 3F9664F4, 8406D637 */ 784425bb815Sopenharmony_ci#define T4 8.86323982359930005737e-03 /* 3F8226E3, E96E8493 */ 785425bb815Sopenharmony_ci#define T5 3.59207910759131235356e-03 /* 3F6D6D22, C9560328 */ 786425bb815Sopenharmony_ci#define T6 1.45620945432529025516e-03 /* 3F57DBC8, FEE08315 */ 787425bb815Sopenharmony_ci#define T7 5.88041240820264096874e-04 /* 3F4344D8, F2F26501 */ 788425bb815Sopenharmony_ci#define T8 2.46463134818469906812e-04 /* 3F3026F7, 1A8D1068 */ 789425bb815Sopenharmony_ci#define T9 7.81794442939557092300e-05 /* 3F147E88, A03792A6 */ 790425bb815Sopenharmony_ci#define T10 7.14072491382608190305e-05 /* 3F12B80F, 32F0A7E9 */ 791425bb815Sopenharmony_ci#define T11 -1.85586374855275456654e-05 /* BEF375CB, DB605373 */ 792425bb815Sopenharmony_ci#define T12 2.59073051863633712884e-05 /* 3EFB2A70, 74BF7AD4 */ 793425bb815Sopenharmony_ci#define pio4 7.85398163397448278999e-01 /* 3FE921FB, 54442D18 */ 794425bb815Sopenharmony_ci#define pio4lo 3.06161699786838301793e-17 /* 3C81A626, 33145C07 */ 795425bb815Sopenharmony_ci 796425bb815Sopenharmony_cistatic double 797425bb815Sopenharmony_ci__kernel_tan (double x, double y, int iy) 798425bb815Sopenharmony_ci{ 799425bb815Sopenharmony_ci double_accessor z; 800425bb815Sopenharmony_ci double r, v, w, s; 801425bb815Sopenharmony_ci int ix, hx; 802425bb815Sopenharmony_ci 803425bb815Sopenharmony_ci hx = __HI (x); /* high word of x */ 804425bb815Sopenharmony_ci ix = hx & 0x7fffffff; /* high word of |x| */ 805425bb815Sopenharmony_ci if (ix < 0x3e300000) /* x < 2**-28 */ 806425bb815Sopenharmony_ci { 807425bb815Sopenharmony_ci if ((int) x == 0) /* generate inexact */ 808425bb815Sopenharmony_ci { 809425bb815Sopenharmony_ci if (((ix | __LO (x)) | (iy + 1)) == 0) 810425bb815Sopenharmony_ci { 811425bb815Sopenharmony_ci return one / fabs (x); 812425bb815Sopenharmony_ci } 813425bb815Sopenharmony_ci else 814425bb815Sopenharmony_ci { 815425bb815Sopenharmony_ci if (iy == 1) 816425bb815Sopenharmony_ci { 817425bb815Sopenharmony_ci return x; 818425bb815Sopenharmony_ci } 819425bb815Sopenharmony_ci else /* compute -1 / (x + y) carefully */ 820425bb815Sopenharmony_ci { 821425bb815Sopenharmony_ci double a; 822425bb815Sopenharmony_ci double_accessor t; 823425bb815Sopenharmony_ci 824425bb815Sopenharmony_ci z.dbl = w = x + y; 825425bb815Sopenharmony_ci z.as_int.lo = 0; 826425bb815Sopenharmony_ci v = y - (z.dbl - x); 827425bb815Sopenharmony_ci t.dbl = a = -one / w; 828425bb815Sopenharmony_ci t.as_int.lo = 0; 829425bb815Sopenharmony_ci s = one + t.dbl * z.dbl; 830425bb815Sopenharmony_ci return t.dbl + a * (s + t.dbl * v); 831425bb815Sopenharmony_ci } 832425bb815Sopenharmony_ci } 833425bb815Sopenharmony_ci } 834425bb815Sopenharmony_ci } 835425bb815Sopenharmony_ci if (ix >= 0x3FE59428) /* |x| >= 0.6744 */ 836425bb815Sopenharmony_ci { 837425bb815Sopenharmony_ci if (hx < 0) 838425bb815Sopenharmony_ci { 839425bb815Sopenharmony_ci x = -x; 840425bb815Sopenharmony_ci y = -y; 841425bb815Sopenharmony_ci } 842425bb815Sopenharmony_ci z.dbl = pio4 - x; 843425bb815Sopenharmony_ci w = pio4lo - y; 844425bb815Sopenharmony_ci x = z.dbl + w; 845425bb815Sopenharmony_ci y = 0.0; 846425bb815Sopenharmony_ci } 847425bb815Sopenharmony_ci z.dbl = x * x; 848425bb815Sopenharmony_ci w = z.dbl * z.dbl; 849425bb815Sopenharmony_ci /* 850425bb815Sopenharmony_ci * Break x^5 * (T[1] + x^2 * T[2] + ...) into 851425bb815Sopenharmony_ci * x^5 (T[1] + x^4 * T[3] + ... + x^20 * T[11]) + 852425bb815Sopenharmony_ci * x^5 (x^2 * (T[2] + x^4 * T[4] + ... + x^22 * [T12])) 853425bb815Sopenharmony_ci */ 854425bb815Sopenharmony_ci r = T1 + w * (T3 + w * (T5 + w * (T7 + w * (T9 + w * T11)))); 855425bb815Sopenharmony_ci v = z.dbl * (T2 + w * (T4 + w * (T6 + w * (T8 + w * (T10 + w * T12))))); 856425bb815Sopenharmony_ci s = z.dbl * x; 857425bb815Sopenharmony_ci r = y + z.dbl * (s * (r + v) + y); 858425bb815Sopenharmony_ci r += T0 * s; 859425bb815Sopenharmony_ci w = x + r; 860425bb815Sopenharmony_ci if (ix >= 0x3FE59428) 861425bb815Sopenharmony_ci { 862425bb815Sopenharmony_ci v = (double) iy; 863425bb815Sopenharmony_ci return (double) (1 - ((hx >> 30) & 2)) * (v - 2.0 * (x - (w * w / (w + v) - r))); 864425bb815Sopenharmony_ci } 865425bb815Sopenharmony_ci if (iy == 1) 866425bb815Sopenharmony_ci { 867425bb815Sopenharmony_ci return w; 868425bb815Sopenharmony_ci } 869425bb815Sopenharmony_ci else 870425bb815Sopenharmony_ci { 871425bb815Sopenharmony_ci /* 872425bb815Sopenharmony_ci * if allow error up to 2 ulp, simply return 873425bb815Sopenharmony_ci * -1.0 / (x + r) here 874425bb815Sopenharmony_ci */ 875425bb815Sopenharmony_ci /* compute -1.0 / (x + r) accurately */ 876425bb815Sopenharmony_ci double a; 877425bb815Sopenharmony_ci double_accessor t; 878425bb815Sopenharmony_ci 879425bb815Sopenharmony_ci z.dbl = w; 880425bb815Sopenharmony_ci z.as_int.lo = 0; 881425bb815Sopenharmony_ci v = r - (z.dbl - x); /* z + v = r + x */ 882425bb815Sopenharmony_ci t.dbl = a = -1.0 / w; /* a = -1.0 / w */ 883425bb815Sopenharmony_ci t.as_int.lo = 0; 884425bb815Sopenharmony_ci s = 1.0 + t.dbl * z.dbl; 885425bb815Sopenharmony_ci return t.dbl + a * (s + t.dbl * v); 886425bb815Sopenharmony_ci } 887425bb815Sopenharmony_ci} /* __kernel_tan */ 888425bb815Sopenharmony_ci 889425bb815Sopenharmony_ci/* Method: 890425bb815Sopenharmony_ci * Let S,C and T denote the sin, cos and tan respectively on 891425bb815Sopenharmony_ci * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 892425bb815Sopenharmony_ci * in [-pi/4 , +pi/4], and let n = k mod 4. 893425bb815Sopenharmony_ci * We have 894425bb815Sopenharmony_ci * 895425bb815Sopenharmony_ci * n sin(x) cos(x) tan(x) 896425bb815Sopenharmony_ci * ---------------------------------------------------------- 897425bb815Sopenharmony_ci * 0 S C T 898425bb815Sopenharmony_ci * 1 C -S -1/T 899425bb815Sopenharmony_ci * 2 -S -C T 900425bb815Sopenharmony_ci * 3 -C S -1/T 901425bb815Sopenharmony_ci * ---------------------------------------------------------- 902425bb815Sopenharmony_ci * 903425bb815Sopenharmony_ci * Special cases: 904425bb815Sopenharmony_ci * Let trig be any of sin, cos, or tan. 905425bb815Sopenharmony_ci * trig(+-INF) is NaN, with signals; 906425bb815Sopenharmony_ci * trig(NaN) is that NaN; 907425bb815Sopenharmony_ci * 908425bb815Sopenharmony_ci * Accuracy: 909425bb815Sopenharmony_ci * TRIG(x) returns trig(x) nearly rounded 910425bb815Sopenharmony_ci */ 911425bb815Sopenharmony_ci 912425bb815Sopenharmony_ci/* sin(x) 913425bb815Sopenharmony_ci * Return sine function of x. 914425bb815Sopenharmony_ci * 915425bb815Sopenharmony_ci * kernel function: 916425bb815Sopenharmony_ci * __kernel_sin ... sine function on [-pi/4,pi/4] 917425bb815Sopenharmony_ci * __kernel_cos ... cose function on [-pi/4,pi/4] 918425bb815Sopenharmony_ci * __ieee754_rem_pio2 ... argument reduction routine 919425bb815Sopenharmony_ci */ 920425bb815Sopenharmony_cidouble 921425bb815Sopenharmony_cisin (double x) 922425bb815Sopenharmony_ci{ 923425bb815Sopenharmony_ci double y[2], z = 0.0; 924425bb815Sopenharmony_ci int n, ix; 925425bb815Sopenharmony_ci 926425bb815Sopenharmony_ci /* High word of x. */ 927425bb815Sopenharmony_ci ix = __HI (x); 928425bb815Sopenharmony_ci 929425bb815Sopenharmony_ci /* |x| ~< pi/4 */ 930425bb815Sopenharmony_ci ix &= 0x7fffffff; 931425bb815Sopenharmony_ci if (ix <= 0x3fe921fb) 932425bb815Sopenharmony_ci { 933425bb815Sopenharmony_ci return __kernel_sin (x, z, 0); 934425bb815Sopenharmony_ci } 935425bb815Sopenharmony_ci 936425bb815Sopenharmony_ci /* sin(Inf or NaN) is NaN */ 937425bb815Sopenharmony_ci else if (ix >= 0x7ff00000) 938425bb815Sopenharmony_ci { 939425bb815Sopenharmony_ci return x - x; 940425bb815Sopenharmony_ci } 941425bb815Sopenharmony_ci 942425bb815Sopenharmony_ci /* argument reduction needed */ 943425bb815Sopenharmony_ci else 944425bb815Sopenharmony_ci { 945425bb815Sopenharmony_ci n = __ieee754_rem_pio2 (x, y); 946425bb815Sopenharmony_ci switch (n & 3) 947425bb815Sopenharmony_ci { 948425bb815Sopenharmony_ci case 0: 949425bb815Sopenharmony_ci { 950425bb815Sopenharmony_ci return __kernel_sin (y[0], y[1], 1); 951425bb815Sopenharmony_ci } 952425bb815Sopenharmony_ci case 1: 953425bb815Sopenharmony_ci { 954425bb815Sopenharmony_ci return __kernel_cos (y[0], y[1]); 955425bb815Sopenharmony_ci } 956425bb815Sopenharmony_ci case 2: 957425bb815Sopenharmony_ci { 958425bb815Sopenharmony_ci return -__kernel_sin (y[0], y[1], 1); 959425bb815Sopenharmony_ci } 960425bb815Sopenharmony_ci default: 961425bb815Sopenharmony_ci { 962425bb815Sopenharmony_ci return -__kernel_cos (y[0], y[1]); 963425bb815Sopenharmony_ci } 964425bb815Sopenharmony_ci } 965425bb815Sopenharmony_ci } 966425bb815Sopenharmony_ci} /* sin */ 967425bb815Sopenharmony_ci 968425bb815Sopenharmony_ci/* cos(x) 969425bb815Sopenharmony_ci * Return cosine function of x. 970425bb815Sopenharmony_ci * 971425bb815Sopenharmony_ci * kernel function: 972425bb815Sopenharmony_ci * __kernel_sin ... sine function on [-pi/4,pi/4] 973425bb815Sopenharmony_ci * __kernel_cos ... cosine function on [-pi/4,pi/4] 974425bb815Sopenharmony_ci * __ieee754_rem_pio2 ... argument reduction routine 975425bb815Sopenharmony_ci */ 976425bb815Sopenharmony_ci 977425bb815Sopenharmony_cidouble 978425bb815Sopenharmony_cicos (double x) 979425bb815Sopenharmony_ci{ 980425bb815Sopenharmony_ci double y[2], z = 0.0; 981425bb815Sopenharmony_ci int n, ix; 982425bb815Sopenharmony_ci 983425bb815Sopenharmony_ci /* High word of x. */ 984425bb815Sopenharmony_ci ix = __HI (x); 985425bb815Sopenharmony_ci 986425bb815Sopenharmony_ci /* |x| ~< pi/4 */ 987425bb815Sopenharmony_ci ix &= 0x7fffffff; 988425bb815Sopenharmony_ci if (ix <= 0x3fe921fb) 989425bb815Sopenharmony_ci { 990425bb815Sopenharmony_ci return __kernel_cos (x, z); 991425bb815Sopenharmony_ci } 992425bb815Sopenharmony_ci 993425bb815Sopenharmony_ci /* cos(Inf or NaN) is NaN */ 994425bb815Sopenharmony_ci else if (ix >= 0x7ff00000) 995425bb815Sopenharmony_ci { 996425bb815Sopenharmony_ci return x - x; 997425bb815Sopenharmony_ci } 998425bb815Sopenharmony_ci 999425bb815Sopenharmony_ci /* argument reduction needed */ 1000425bb815Sopenharmony_ci else 1001425bb815Sopenharmony_ci { 1002425bb815Sopenharmony_ci n = __ieee754_rem_pio2 (x, y); 1003425bb815Sopenharmony_ci switch (n & 3) 1004425bb815Sopenharmony_ci { 1005425bb815Sopenharmony_ci case 0: 1006425bb815Sopenharmony_ci { 1007425bb815Sopenharmony_ci return __kernel_cos (y[0], y[1]); 1008425bb815Sopenharmony_ci } 1009425bb815Sopenharmony_ci case 1: 1010425bb815Sopenharmony_ci { 1011425bb815Sopenharmony_ci return -__kernel_sin (y[0], y[1], 1); 1012425bb815Sopenharmony_ci } 1013425bb815Sopenharmony_ci case 2: 1014425bb815Sopenharmony_ci { 1015425bb815Sopenharmony_ci return -__kernel_cos (y[0], y[1]); 1016425bb815Sopenharmony_ci } 1017425bb815Sopenharmony_ci default: 1018425bb815Sopenharmony_ci { 1019425bb815Sopenharmony_ci return __kernel_sin (y[0], y[1], 1); 1020425bb815Sopenharmony_ci } 1021425bb815Sopenharmony_ci } 1022425bb815Sopenharmony_ci } 1023425bb815Sopenharmony_ci} /* cos */ 1024425bb815Sopenharmony_ci 1025425bb815Sopenharmony_ci/* tan(x) 1026425bb815Sopenharmony_ci * Return tangent function of x. 1027425bb815Sopenharmony_ci * 1028425bb815Sopenharmony_ci * kernel function: 1029425bb815Sopenharmony_ci * __kernel_tan ... tangent function on [-pi/4,pi/4] 1030425bb815Sopenharmony_ci * __ieee754_rem_pio2 ... argument reduction routine 1031425bb815Sopenharmony_ci */ 1032425bb815Sopenharmony_ci 1033425bb815Sopenharmony_cidouble 1034425bb815Sopenharmony_citan (double x) 1035425bb815Sopenharmony_ci{ 1036425bb815Sopenharmony_ci double y[2], z = 0.0; 1037425bb815Sopenharmony_ci int n, ix; 1038425bb815Sopenharmony_ci 1039425bb815Sopenharmony_ci /* High word of x. */ 1040425bb815Sopenharmony_ci ix = __HI (x); 1041425bb815Sopenharmony_ci 1042425bb815Sopenharmony_ci /* |x| ~< pi/4 */ 1043425bb815Sopenharmony_ci ix &= 0x7fffffff; 1044425bb815Sopenharmony_ci if (ix <= 0x3fe921fb) 1045425bb815Sopenharmony_ci { 1046425bb815Sopenharmony_ci return __kernel_tan (x, z, 1); 1047425bb815Sopenharmony_ci } 1048425bb815Sopenharmony_ci 1049425bb815Sopenharmony_ci /* tan(Inf or NaN) is NaN */ 1050425bb815Sopenharmony_ci else if (ix >= 0x7ff00000) 1051425bb815Sopenharmony_ci { 1052425bb815Sopenharmony_ci return x - x; /* NaN */ 1053425bb815Sopenharmony_ci } 1054425bb815Sopenharmony_ci 1055425bb815Sopenharmony_ci /* argument reduction needed */ 1056425bb815Sopenharmony_ci else 1057425bb815Sopenharmony_ci { 1058425bb815Sopenharmony_ci n = __ieee754_rem_pio2 (x, y); 1059425bb815Sopenharmony_ci return __kernel_tan (y[0], y[1], 1 - ((n & 1) << 1)); /* 1 -- n even, -1 -- n odd */ 1060425bb815Sopenharmony_ci } 1061425bb815Sopenharmony_ci} /* tan */ 1062425bb815Sopenharmony_ci 1063425bb815Sopenharmony_ci#undef zero 1064425bb815Sopenharmony_ci#undef half 1065425bb815Sopenharmony_ci#undef one 1066425bb815Sopenharmony_ci#undef two24 1067425bb815Sopenharmony_ci#undef twon24 1068425bb815Sopenharmony_ci#undef invpio2 1069425bb815Sopenharmony_ci#undef pio2_1 1070425bb815Sopenharmony_ci#undef pio2_1t 1071425bb815Sopenharmony_ci#undef pio2_2 1072425bb815Sopenharmony_ci#undef pio2_2t 1073425bb815Sopenharmony_ci#undef pio2_3 1074425bb815Sopenharmony_ci#undef pio2_3t 1075425bb815Sopenharmony_ci#undef S1 1076425bb815Sopenharmony_ci#undef S2 1077425bb815Sopenharmony_ci#undef S3 1078425bb815Sopenharmony_ci#undef S4 1079425bb815Sopenharmony_ci#undef S5 1080425bb815Sopenharmony_ci#undef S6 1081425bb815Sopenharmony_ci#undef C1 1082425bb815Sopenharmony_ci#undef C2 1083425bb815Sopenharmony_ci#undef C3 1084425bb815Sopenharmony_ci#undef C4 1085425bb815Sopenharmony_ci#undef C5 1086425bb815Sopenharmony_ci#undef C6 1087425bb815Sopenharmony_ci#undef T0 1088425bb815Sopenharmony_ci#undef T1 1089425bb815Sopenharmony_ci#undef T2 1090425bb815Sopenharmony_ci#undef T3 1091425bb815Sopenharmony_ci#undef T4 1092425bb815Sopenharmony_ci#undef T5 1093425bb815Sopenharmony_ci#undef T6 1094425bb815Sopenharmony_ci#undef T7 1095425bb815Sopenharmony_ci#undef T8 1096425bb815Sopenharmony_ci#undef T9 1097425bb815Sopenharmony_ci#undef T10 1098425bb815Sopenharmony_ci#undef T11 1099425bb815Sopenharmony_ci#undef T12 1100425bb815Sopenharmony_ci#undef pio4 1101425bb815Sopenharmony_ci#undef pio4lo 1102