| 1 | #cxx . . $ `<file>/external/clapack/f2cP.h`/ifndef _f2cP_h_ |
| 2 | #define _f2cP_h_cxx . . $ `external/clapack/f2cP.h:2:9`! |
| 3 | /* f2cP.h |
| 4 | * |
| 5 | * Copyright (C) 2020 David Weenink, 2026 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "melder.h"cxx . . $ `<file>/melder/melder.h`/ |
| 22 | #include "cblas.h"cxx . . $ `<file>/external/clapack/cblas.h`/ |
| 23 | |
| 24 | static inline double d_abscxx . . $ d_abs(a5c8eef512f28486). (double *x) { |
| 25 | return abscxx . . $ abs(447c67c6676f75c3). (*x); |
| 26 | } |
| 27 | |
| 28 | static inline double d_acoscxx . . $ d_acos(a5c8eef512f28486). (double *x) { |
| 29 | return acoscxx . . $ acos(fee4f1d22bc8e617). (*x); |
| 30 | } |
| 31 | |
| 32 | static inline double d_asincxx . . $ d_asin(a5c8eef512f28486). (double *x) { |
| 33 | return asincxx . . $ asin(fee4f1d22bc8e617). (*x); |
| 34 | } |
| 35 | |
| 36 | static inline double d_atancxx . . $ d_atan(a5c8eef512f28486). (double *x) { |
| 37 | return atancxx . . $ atan(fee4f1d22bc8e617). (*x); |
| 38 | } |
| 39 | |
| 40 | static inline double d_atn2cxx . . $ d_atn2(8fcf9002b7f393aa). (double *x, double *y) { |
| 41 | return atan2cxx . . $ atan2(b71928d39fde4295). (*x,*y); |
| 42 | } |
| 43 | |
| 44 | static inline double d_coscxx . . $ d_cos(a5c8eef512f28486). (double *x) { |
| 45 | return coscxx . . $ cos(fee4f1d22bc8e617). (*x); |
| 46 | } |
| 47 | |
| 48 | static inline double d_coshcxx . . $ d_cosh(a5c8eef512f28486). (double *x) { |
| 49 | return coshcxx . . $ cosh(fee4f1d22bc8e617). (*x); |
| 50 | } |
| 51 | |
| 52 | static inline double d_dimcxx . . $ d_dim(8fcf9002b7f393aa). (double *a, double *b) { |
| 53 | return ( *a > *b ? *a - *b : 0 ); |
| 54 | } |
| 55 | |
| 56 | static inline double d_expcxx . . $ d_exp(a5c8eef512f28486). (double *x) { |
| 57 | return expcxx . . $ exp(fee4f1d22bc8e617). (*x); |
| 58 | } |
| 59 | |
| 60 | static inline double d_intcxx . . $ d_int(a5c8eef512f28486). (double *x) { |
| 61 | return ( *x>0 ? floorcxx . . $ floor(fee4f1d22bc8e617).(*x) : -floorcxx . . $ floor(fee4f1d22bc8e617).(- *x) ); |
| 62 | } |
| 63 | |
| 64 | static inline double d_lg10cxx . . $ d_lg10(a5c8eef512f28486). (double *x) { |
| 65 | return log10cxx . . $ log10(fee4f1d22bc8e617). (*x); |
| 66 | } |
| 67 | |
| 68 | static inline double d_logcxx . . $ d_log(a5c8eef512f28486). (double *x) { |
| 69 | return logcxx . . $ log(fee4f1d22bc8e617). (*x); |
| 70 | } |
| 71 | |
| 72 | // TODO djmw is this std::fmod (*x, *y) ?? |
| 73 | static inline double d_modcxx . . $ d_mod(8fcf9002b7f393aa). (double *x, double *y) { |
| 74 | #ifdef IEEE_drem |
| 75 | double ya = *y; |
| 76 | if (ya < 0.0) |
| 77 | ya = -ya; |
| 78 | double xa = *x; |
| 79 | double z = drem (xa, ya); |
| 80 | if (xa > 0) { |
| 81 | if (z < 0) |
| 82 | z += ya; |
| 83 | } |
| 84 | else if (z > 0) |
| 85 | z -= ya; |
| 86 | return z; |
| 87 | #else |
| 88 | double quotient = *x / *y; |
| 89 | if (quotient >= 0) |
| 90 | quotient = floorcxx . . $ floor(fee4f1d22bc8e617). (quotient); |
| 91 | else |
| 92 | quotient = -floorcxx . . $ floor(fee4f1d22bc8e617).(-quotient); |
| 93 | return (*x - (*y) * quotient ); |
| 94 | #endif |
| 95 | } |
| 96 | |
| 97 | static inline double d_prodcxx . . $ d_prod(fe2355fbfbb8ada0). (float *x, float *y) { |
| 98 | return (*x) * (*y); |
| 99 | } |
| 100 | |
| 101 | static inline double d_signcxx . . $ d_sign(8fcf9002b7f393aa). (double *a, double *b) { |
| 102 | double x = (*a >= 0 ? *a : - *a); |
| 103 | return ( *b >= 0 ? x : -x ); |
| 104 | } |
| 105 | |
| 106 | static inline double d_sincxx . . $ d_sin(a5c8eef512f28486). (double *x) { |
| 107 | return sincxx . . $ sin(fee4f1d22bc8e617). (*x); |
| 108 | } |
| 109 | |
| 110 | static inline double d_sinhcxx . . $ d_sinh(a5c8eef512f28486). (double *x) { |
| 111 | return sinhcxx . . $ sinh(fee4f1d22bc8e617). (*x); |
| 112 | } |
| 113 | |
| 114 | static inline double d_sqrtcxx . . $ d_sqrt(a5c8eef512f28486). (double *x) { |
| 115 | return sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (*x); |
| 116 | } |
| 117 | |
| 118 | static inline double d_tancxx . . $ d_tan(a5c8eef512f28486). (double *x) { |
| 119 | return tancxx . . $ tan(fee4f1d22bc8e617). (*x); |
| 120 | } |
| 121 | |
| 122 | static inline double d_tanhcxx . . $ d_tanh(a5c8eef512f28486). (double *x) { |
| 123 | return tanhcxx . . $ tanh(fee4f1d22bc8e617). (*x); |
| 124 | } |
| 125 | |
| 126 | static inline double derf_cxx . . $ derf_(a5c8eef512f28486). (double *x) { |
| 127 | return erfcxx . . $ erf(fee4f1d22bc8e617). (*x); |
| 128 | } |
| 129 | |
| 130 | static inline double derfc_cxx . . $ derfc_(a5c8eef512f28486). (double *x) { |
| 131 | return erfccxx . . $ erfc(fee4f1d22bc8e617). (*x); |
| 132 | } |
| 133 | |
| 134 | static inline integercxx . . $ integer# i_dnntcxx . . $ i_dnnt(f8b5159c7b4ff18d). (double *x) { |
| 135 | return (integercxx . . $ integer#)(*x >= 0. ? floorcxx . . $ floor(fee4f1d22bc8e617). (*x + .5) : -floorcxx . . $ floor(fee4f1d22bc8e617).(.5 - *x)); |
| 136 | } |
| 137 | |
| 138 | static inline integercxx . . $ integer# i_nintcxx . . $ i_nint(12ef83d884a7b4d3). (float *x) { |
| 139 | return (integercxx . . $ integer#)(*x >= 0.0 ? floorcxx . . $ floor(fee4f1d22bc8e617).(*x + 0.5) : -floorcxx . . $ floor(fee4f1d22bc8e617).(0.5 - *x)); |
| 140 | } |
| 141 | |
| 142 | bool lsame_cxx . . $ lsame_(b7a7aa4a824b7595).(const char *ca, const char *cb); |
| 143 | |
| 144 | bool lsamen_cxx . . $ lsamen_(d58bea366a34b71).(integercxx . . $ integer# *n, const char *ca, const char *cb); |
| 145 | |
| 146 | static inline double pow_ddcxx . . $ pow_dd(8fcf9002b7f393aa). (double *ap, double *bp) { |
| 147 | return powcxx . . $ pow(b71928d39fde4295). (*ap, *bp); |
| 148 | } |
| 149 | |
| 150 | static inline double pow_dicxx . . $ pow_di(d073b4717a6ff874). (double *ap, integercxx . . $ integer# *bp) { |
| 151 | double pow = 1.0; |
| 152 | double x = *ap; |
| 153 | integercxx . . $ integer# n = *bp; |
| 154 | if (n != 0) { |
| 155 | if (n < 0) { |
| 156 | n = -n; |
| 157 | x = 1.0 / x; |
| 158 | } |
| 159 | for(unsigned long u = n; ; ) { |
| 160 | if (u & 01) |
| 161 | pow *= x; |
| 162 | if (u >>= 1) |
| 163 | x *= x; |
| 164 | else |
| 165 | break; |
| 166 | } |
| 167 | } |
| 168 | return pow; |
| 169 | } |
| 170 | |
| 171 | static inline integercxx . . $ integer# pow_iicxx . . $ pow_ii(45a2278c581c1c1c). (integercxx . . $ integer# *ap, integercxx . . $ integer# *bp) { |
| 172 | integercxx . . $ integer# pow, x = *ap, n = *bp; |
| 173 | |
| 174 | if (n <= 0) { |
| 175 | if (n == 0 || x == 1) |
| 176 | return 1; |
| 177 | if (x != -1) |
| 178 | return x == 0 ? 1/x : 0; |
| 179 | n = -n; |
| 180 | } |
| 181 | unsigned long u = n; |
| 182 | for (pow = 1; ; ) { |
| 183 | if(u & 01) |
| 184 | pow *= x; |
| 185 | if(u >>= 1) |
| 186 | x *= x; |
| 187 | else |
| 188 | break; |
| 189 | } |
| 190 | return pow; |
| 191 | } |
| 192 | |
| 193 | static inline double pow_ricxx . . $ pow_ri(bb75cddf4c193c8d). (float *ap, integercxx . . $ integer# *bp) { |
| 194 | double pow = 1.0, x = *ap; |
| 195 | integercxx . . $ integer# n = *bp; |
| 196 | if (n != 0) { |
| 197 | if (n < 0) { |
| 198 | n = -n; |
| 199 | x = 1/x; |
| 200 | } |
| 201 | for (unsigned long u = n; ; ) { |
| 202 | if(u & 01) |
| 203 | pow *= x; |
| 204 | if(u >>= 1) |
| 205 | x *= x; |
| 206 | else |
| 207 | break; |
| 208 | } |
| 209 | } |
| 210 | return pow; |
| 211 | } |
| 212 | |
| 213 | /* |
| 214 | Unless compiled with -DNO_OVERWRITE, this variant of s_copy allows the |
| 215 | target of an assignment to appear on its right-hand side (contrary |
| 216 | to the Fortran 77 Standard, but in accordance with Fortran 90), as in a(2:5) = a(4:7). |
| 217 | */ |
| 218 | static inline void s_copycxx . . $ s_copy(4e088a15d86a2b38). (char *a, const char *b, integercxx . . $ integer# la, integercxx . . $ integer# lb) { |
| 219 | char *aend = a + la; |
| 220 | if(la <= lb) |
| 221 | #ifndef NO_OVERWRITE |
| 222 | if (a <= b || a >= b + la) |
| 223 | #endif |
| 224 | while(a < aend) |
| 225 | *a++ = *b++; |
| 226 | #ifndef NO_OVERWRITE |
| 227 | else |
| 228 | for(b += la; a < aend; ) |
| 229 | *--aend = *--b; |
| 230 | #endif |
| 231 | |
| 232 | else { |
| 233 | char *bend = const_cast<char *>(b) + lb; |
| 234 | #ifndef NO_OVERWRITE |
| 235 | if (a <= b || a >= bend) |
| 236 | #endif |
| 237 | while(b < bend) |
| 238 | *a++ = *b++; |
| 239 | #ifndef NO_OVERWRITE |
| 240 | else { |
| 241 | a += lb; |
| 242 | while(b < bend) |
| 243 | *--a = *--bend; |
| 244 | a += lb; |
| 245 | } |
| 246 | #endif |
| 247 | while(a < aend) |
| 248 | *a++ = ' '; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | static inline void s_catcxx . . $ s_cat(b5bdb090c7d6401c). (char *lp, char *rpp[], integercxx . . $ integer# rnp [], integercxx . . $ integer# *np, integercxx . . $ integer# ll) { |
| 253 | char *rp; |
| 254 | integercxx . . $ integer# n = *np; |
| 255 | #ifndef NO_OVERWRITE |
| 256 | integercxx . . $ integer# L, m; |
| 257 | char *lp0, *lp1; |
| 258 | |
| 259 | lp0 = 0; |
| 260 | lp1 = lp; |
| 261 | L = ll; |
| 262 | integercxx . . $ integer# i = 0; |
| 263 | while (i < n) { |
| 264 | rp = rpp [i]; |
| 265 | m = rnp [i++]; |
| 266 | if (rp >= lp1 || rp + m <= lp) { |
| 267 | if ((L -= m) <= 0) { |
| 268 | n = i; |
| 269 | break; |
| 270 | } |
| 271 | lp1 += m; |
| 272 | continue; |
| 273 | } |
| 274 | lp0 = lp; |
| 275 | lp = lp1 = Melder_malloc_fcxx . . $ `melder/melder_alloc.h:30:9`! (char, L = ll); |
| 276 | break; |
| 277 | } |
| 278 | lp1 = lp; |
| 279 | #endif /* NO_OVERWRITE */ |
| 280 | for(i = 0 ; i < n ; ++ i) { |
| 281 | integercxx . . $ integer# nc = ll; |
| 282 | if(rnp [i] < nc) |
| 283 | nc = rnp [i]; |
| 284 | ll -= nc; |
| 285 | rp = rpp [i]; |
| 286 | while(--nc >= 0) |
| 287 | *lp++ = *rp++; |
| 288 | } |
| 289 | while(--ll >= 0) |
| 290 | *lp++ = ' '; |
| 291 | #ifndef NO_OVERWRITE |
| 292 | if (lp0) { |
| 293 | memcpy(lp0, lp1, L); |
| 294 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (lp1); |
| 295 | } |
| 296 | #endif |
| 297 | } |
| 298 | |
| 299 | static inline integercxx . . $ integer# s_cmpcxx . . $ s_cmp(f1c417271aca73c2). (const char *a0, const char *b0, integercxx . . $ integer# la, integercxx . . $ integer# lb) { |
| 300 | unsigned char *a = (unsigned char *)a0; |
| 301 | unsigned char *b = (unsigned char *)b0; |
| 302 | unsigned char *aend = a + la; |
| 303 | unsigned char *bend = b + lb; |
| 304 | if(la <= lb) { |
| 305 | while(a < aend) |
| 306 | if(*a != *b) |
| 307 | return( *a - *b ); |
| 308 | else { |
| 309 | ++a; |
| 310 | ++b; |
| 311 | } |
| 312 | while(b < bend) |
| 313 | if(*b != ' ') |
| 314 | return( ' ' - *b ); |
| 315 | else ++b; |
| 316 | } |
| 317 | return 0; |
| 318 | } |
| 319 | |
| 320 | static inline void xerbla_cxx . . $ xerbla_(588303ff9e9b5ad6). (const char *src, integercxx . . $ integer# *info) { |
| 321 | Melder_throwcxx . . $ Melder_appendError(6298c93241566110). (Melder_peek8to32_u (src), U": parameter ", *info, U" not correct!"); |
| 322 | } |
| 323 | |
| 324 | #endif /* _f2cP_h_ */ |