/usr/lib/ats-anairiats-0.2.11/libc/CATS/complex.cats is in ats-lang-anairiats 0.2.11-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | /************************************************************************/
/* */
/* Applied Type System */
/* */
/* Hongwei Xi */
/* */
/************************************************************************/
/*
** ATS - Unleashing the Potential of Types!
**
** Copyright (C) 2002-2008 Hongwei Xi.
**
** ATS is free software; you can redistribute it and/or modify it under
** the terms of the GNU General Public License as published by the Free
** Software Foundation; either version 2.1, or (at your option) any later
** version.
**
** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
** WARRANTY; without even the implied warranty of MERCHANTABILITY or
** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
** for more details.
**
** You should have received a copy of the GNU General Public License
** along with ATS; see the file COPYING. If not, please write to the
** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
** 02110-1301, USA.
*/
/* ****** ****** */
/* author: Hongwei Xi (hwxi AT cs DOT bu DOT edu) */
/* ****** ****** */
#ifndef ATS_LIBC_COMPLEX_CATS
#define ATS_LIBC_COMPLEX_CATS
/* ****** ****** */
#include <stdio.h>
// extern FILE *stdout ; // declared in [stdio.h]
// extern FILE *stderr ; // declared in [stdio.h]
/* ****** ****** */
#include <math.h>
#include <complex.h>
/* ****** ****** */
typedef float complex ats_fcomplex_type ;
typedef double complex ats_dcomplex_type ;
typedef long double complex ats_lcomplex_type ;
/* ****** ****** */
extern float sinf (float) ; // should be in [math.h]
extern float cosf (float) ; // should be in [math.h]
/* ****** ****** */
/*
** complex numbers of single precision
*/
/* ****** ****** */
ATSinline()
ats_fcomplex_type
atslib_ccmplx_of_int (ats_int_type i) { return i ; }
ATSinline()
ats_fcomplex_type
atslib_ccmplx_of_float (ats_float_type f) { return f ; }
ATSinline()
ats_fcomplex_type
atslib_ccmplx_make_cart
(ats_float_type r, ats_float_type i) {
return (r + i * I) ;
}
ATSinline()
ats_fcomplex_type
atslib_ccmplx_make_polar
(ats_float_type r, ats_float_type t) {
return (r * cosf(t)) + (r * sinf(t)) * I ;
}
/* ****** ****** */
ATSinline()
ats_float_type
atslib_crealf (ats_fcomplex_type c) { return crealf(c) ; }
ATSinline()
ats_float_type
atslib_cimagf (ats_fcomplex_type c) { return cimagf(c) ; }
/* ****** ****** */
ATSinline()
ats_fcomplex_type
atslib_neg_ccmplx (ats_fcomplex_type c) { return (-c) ; }
/* ****** ****** */
ATSinline()
ats_fcomplex_type
atslib_add_ccmplx_ccmplx
(ats_fcomplex_type c1, ats_fcomplex_type c2) {
return (c1 + c2) ;
} /* end of [atslib_add_ccmplx_ccmplx] */
ATSinline()
ats_fcomplex_type
atslib_sub_ccmplx_ccmplx
(ats_fcomplex_type c1, ats_fcomplex_type c2) {
return (c1 - c2) ;
} /* end of [atslib_sub_ccmplx_ccmplx] */
ATSinline()
ats_fcomplex_type
atslib_mul_ccmplx_ccmplx
(ats_fcomplex_type c1, ats_fcomplex_type c2) {
return (c1 * c2) ;
} /* end of [atslib_mul_ccmplx_ccmplx] */
ATSinline()
ats_fcomplex_type
atslib_div_ccmplx_ccmplx
(ats_fcomplex_type c1, ats_fcomplex_type c2) {
return (c1 / c2) ;
} /* end of [atslib_div_ccmplx_ccmplx] */
/* ****** ****** */
ATSinline()
ats_bool_type
atslib_eq_ccmplx_ccmplx
(ats_fcomplex_type c1, ats_fcomplex_type c2) {
return (c1 == c2 ? ats_true_bool : ats_false_bool) ;
} /* end of [atslib_eq_ccmplx_ccmplx] */
ATSinline()
ats_bool_type
atslib_neq_ccmplx_ccmplx
(ats_fcomplex_type c1, ats_fcomplex_type c2) {
return (c1 != c2 ? ats_true_bool : ats_false_bool) ;
} /* end of [atslib_neq_ccmplx_ccmplx] */
/* ****** ****** */
ATSinline()
ats_float_type
atslib_cabsf (ats_fcomplex_type c) { return cabsf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_csqrtf (ats_fcomplex_type c) { return csqrtf(c) ; }
/* ****** ****** */
ATSinline()
ats_float_type
atslib_cargf (ats_fcomplex_type c) { return cargf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_conjf (ats_fcomplex_type c) { return conjf(c) ; }
/* ****** ****** */
ATSinline()
ats_fcomplex_type
atslib_csinf (ats_fcomplex_type c) { return csinf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_ccosf (ats_fcomplex_type c) { return ccosf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_ctanf (ats_fcomplex_type c) { return ctanf(c) ; }
/* ****** ****** */
ATSinline()
ats_fcomplex_type
atslib_casinf (ats_fcomplex_type c) { return casinf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_cacosf (ats_fcomplex_type c) { return cacosf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_catanf (ats_fcomplex_type c) { return catanf(c) ; }
/* ****** ****** */
ATSinline()
ats_fcomplex_type
atslib_csinhf (ats_fcomplex_type c) { return csinhf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_ccoshf (ats_fcomplex_type c) { return ccoshf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_ctanhf (ats_fcomplex_type c) { return ctanhf(c) ; }
/* ****** ****** */
ATSinline()
ats_fcomplex_type
atslib_casinhf (ats_fcomplex_type c) { return casinhf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_cacoshf (ats_fcomplex_type c) { return cacoshf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_catanhf (ats_fcomplex_type c) { return catanhf(c) ; }
/* ****** ****** */
ATSinline()
ats_fcomplex_type
atslib_cexpf (ats_fcomplex_type c) { return cexpf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_clogf (ats_fcomplex_type c) { return clogf(c) ; }
ATSinline()
ats_fcomplex_type
atslib_cpowf (
ats_fcomplex_type c1
, ats_fcomplex_type c2
) {
return cpowf(c1, c2) ;
} /* end of [atslib_cpowf] */
#define atslib_pow_ccmplx_float(c1, c2) atslib_cpowf(c1,(ats_fcomplex_type)c2)
/* ****** ****** */
ATSinline()
ats_float_type
atslib_cprojf (ats_fcomplex_type c) { return cprojf(c) ; }
/* ****** ****** */
/*
** complex numbers of double precision
*/
/* ****** ****** */
ATSinline()
ats_dcomplex_type
atslib_zcmplx_of_int (ats_int_type i) { return i ; }
ATSinline()
ats_dcomplex_type
atslib_zcmplx_of_double (ats_double_type d) { return d ; }
ATSinline()
ats_dcomplex_type
atslib_zcmplx_make_cart
(ats_double_type r, ats_double_type i) {
return (r + i * I) ;
}
ATSinline()
ats_dcomplex_type
atslib_zcmplx_make_polar
(ats_double_type r, ats_double_type t) {
return (r * cos(t)) + (r * sin(t)) * I ;
}
/* ****** ****** */
ATSinline()
ats_double_type
atslib_creal (ats_dcomplex_type z) { return creal(z) ; }
ATSinline()
ats_double_type
atslib_cimag (ats_dcomplex_type z) { return cimag(z) ; }
/* ****** ****** */
ATSinline()
ats_dcomplex_type
atslib_neg_zcmplx (ats_dcomplex_type z) { return (-z) ; }
/* ****** ****** */
ATSinline()
ats_dcomplex_type
atslib_add_zcmplx_zcmplx
(ats_dcomplex_type z1, ats_dcomplex_type z2) {
return (z1 + z2) ;
} /* end of [atslib_add_zcmplx_zcmplx] */
ATSinline()
ats_dcomplex_type
atslib_sub_zcmplx_zcmplx
(ats_dcomplex_type z1, ats_dcomplex_type z2) {
return (z1 - z2) ;
} /* end of [atslib_sub_zcmplx_zcmplx] */
ATSinline()
ats_dcomplex_type
atslib_mul_zcmplx_zcmplx
(ats_dcomplex_type z1, ats_dcomplex_type z2) {
return (z1 * z2) ;
} /* end of [atslib_mul_zcmplx_zcmplx] */
ATSinline()
ats_dcomplex_type
atslib_div_zcmplx_zcmplx
(ats_dcomplex_type z1, ats_dcomplex_type z2) {
return (z1 / z2) ;
} /* end of [atslib_div_zcmplx_zcmplx] */
/* ****** ****** */
ATSinline()
ats_bool_type
atslib_eq_zcmplx_zcmplx
(ats_dcomplex_type c1, ats_dcomplex_type c2) {
return (c1 == c2 ? ats_true_bool : ats_false_bool) ;
} /* end of [atslib_eq_zcmplx_zcmplx] */
ATSinline()
ats_bool_type
atslib_neq_zcmplx_zcmplx
(ats_dcomplex_type c1, ats_dcomplex_type c2) {
return (c1 != c2 ? ats_true_bool : ats_false_bool) ;
} /* end of [atslib_neq_zcmplx_zcmplx] */
/* ****** ****** */
ATSinline()
ats_double_type
atslib_cabs (ats_dcomplex_type z) { return cabs(z) ; }
ATSinline()
ats_dcomplex_type
atslib_csqrt (ats_dcomplex_type z) { return csqrt(z) ; }
/* ****** ****** */
ATSinline()
ats_double_type
atslib_carg (ats_dcomplex_type z) { return carg(z) ; }
ATSinline()
ats_dcomplex_type
atslib_conj (ats_dcomplex_type z) { return conj(z) ; }
/* ****** ****** */
ATSinline()
ats_dcomplex_type
atslib_csin (ats_dcomplex_type z) { return csin(z) ; }
ATSinline()
ats_dcomplex_type
atslib_ccos (ats_dcomplex_type z) { return ccos(z) ; }
ATSinline()
ats_dcomplex_type
atslib_ctan (ats_dcomplex_type z) { return ctan(z) ; }
/* ****** ****** */
ATSinline()
ats_dcomplex_type
atslib_casin (ats_dcomplex_type z) { return casin(z) ; }
ATSinline()
ats_dcomplex_type
atslib_cacos (ats_dcomplex_type z) { return cacos(z) ; }
ATSinline()
ats_dcomplex_type
atslib_catan (ats_dcomplex_type z) { return catan(z) ; }
/* ****** ****** */
ATSinline()
ats_dcomplex_type
atslib_csinh (ats_dcomplex_type z) { return csinh(z) ; }
ATSinline()
ats_dcomplex_type
atslib_ccosh (ats_dcomplex_type z) { return ccosh(z) ; }
ATSinline()
ats_dcomplex_type
atslib_ctanh (ats_dcomplex_type z) { return ctanh(z) ; }
/* ****** ****** */
ATSinline()
ats_dcomplex_type
atslib_casinh (ats_dcomplex_type z) { return casinh(z) ; }
ATSinline()
ats_dcomplex_type
atslib_cacosh (ats_dcomplex_type z) { return cacosh(z) ; }
ATSinline()
ats_dcomplex_type
atslib_catanh (ats_dcomplex_type z) { return catanh(z) ; }
/* ****** ****** */
ATSinline()
ats_dcomplex_type
atslib_cexp (ats_dcomplex_type z) { return cexp(z) ; }
ATSinline()
ats_dcomplex_type
atslib_clog (ats_dcomplex_type z) { return clog(z) ; }
ATSinline()
ats_dcomplex_type
atslib_cpow (
ats_dcomplex_type z1
, ats_dcomplex_type z2
) {
return cpow(z1, z2) ;
} /* end of [atslib_cpow] */
#define atslib_pow_zcmplx_double(z1, z2) atslib_cpow(z1,(ats_dcomplex_type)z2)
/* ****** ****** */
ATSinline()
ats_double_type
atslib_cproj (ats_dcomplex_type z) { return cproj(z) ; }
/* ****** ****** */
#endif /* ATS_LIBC_COMPLEX_CATS */
/* end of [complex.cats] */
|