1 // 2 // complex.h 3 // 4 // Copyright (c) Microsoft Corporation. All rights reserved. 5 // 6 // The complex math library. 7 // 8 #pragma once 9 #ifndef _COMPLEX 10 #define _COMPLEX 11 12 #include <corecrt.h> 13 14 #if (_CRT_HAS_CXX17 == 1) && !defined(_CRT_USE_C_COMPLEX_H) 15 #include <ccomplex> 16 #else // ^^^^ /std:c++17 ^^^^ // vvvv _CRT_USE_C_COMPLEX_H vvvv 17 18 #pragma warning(push) 19 #pragma warning(disable: _UCRT_DISABLED_WARNINGS) 20 _UCRT_DISABLE_CLANG_WARNINGS 21 22 _CRT_BEGIN_C_HEADER 23 24 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 // 26 // Types 27 // 28 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 29 #ifndef _C_COMPLEX_T 30 #define _C_COMPLEX_T 31 typedef struct _C_double_complex 32 { 33 double _Val[2]; 34 } _C_double_complex; 35 36 typedef struct _C_float_complex 37 { 38 float _Val[2]; 39 } _C_float_complex; 40 41 typedef struct _C_ldouble_complex 42 { 43 long double _Val[2]; 44 } _C_ldouble_complex; 45 #endif 46 47 typedef _C_double_complex _Dcomplex; 48 typedef _C_float_complex _Fcomplex; 49 typedef _C_ldouble_complex _Lcomplex; 50 51 52 53 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 54 // 55 // Macros 56 // 57 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 58 #define _DCOMPLEX_(re, im) _Cbuild(re, im) 59 #define _FCOMPLEX_(re, im) _FCbuild(re, im) 60 #define _LCOMPLEX_(re, im) _LCbuild(re, im) 61 62 #define _Complex_I _FCbuild(0.0F, 1.0F) 63 #define I _Complex_I 64 65 66 67 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 68 // 69 // Functions 70 // 71 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 72 _ACRTIMP double __cdecl cabs(_In_ _Dcomplex _Z); 73 _ACRTIMP _Dcomplex __cdecl cacos(_In_ _Dcomplex _Z); 74 _ACRTIMP _Dcomplex __cdecl cacosh(_In_ _Dcomplex _Z); 75 _ACRTIMP double __cdecl carg(_In_ _Dcomplex _Z); 76 _ACRTIMP _Dcomplex __cdecl casin(_In_ _Dcomplex _Z); 77 _ACRTIMP _Dcomplex __cdecl casinh(_In_ _Dcomplex _Z); 78 _ACRTIMP _Dcomplex __cdecl catan(_In_ _Dcomplex _Z); 79 _ACRTIMP _Dcomplex __cdecl catanh(_In_ _Dcomplex _Z); 80 _ACRTIMP _Dcomplex __cdecl ccos(_In_ _Dcomplex _Z); 81 _ACRTIMP _Dcomplex __cdecl ccosh(_In_ _Dcomplex _Z); 82 _ACRTIMP _Dcomplex __cdecl cexp(_In_ _Dcomplex _Z); 83 _ACRTIMP double __cdecl cimag(_In_ _Dcomplex _Z); 84 _ACRTIMP _Dcomplex __cdecl clog(_In_ _Dcomplex _Z); 85 _ACRTIMP _Dcomplex __cdecl clog10(_In_ _Dcomplex _Z); 86 _ACRTIMP _Dcomplex __cdecl conj(_In_ _Dcomplex _Z); 87 _ACRTIMP _Dcomplex __cdecl cpow(_In_ _Dcomplex _X, _In_ _Dcomplex _Y); 88 _ACRTIMP _Dcomplex __cdecl cproj(_In_ _Dcomplex _Z); 89 _ACRTIMP double __cdecl creal(_In_ _Dcomplex _Z); 90 _ACRTIMP _Dcomplex __cdecl csin(_In_ _Dcomplex _Z); 91 _ACRTIMP _Dcomplex __cdecl csinh(_In_ _Dcomplex _Z); 92 _ACRTIMP _Dcomplex __cdecl csqrt(_In_ _Dcomplex _Z); 93 _ACRTIMP _Dcomplex __cdecl ctan(_In_ _Dcomplex _Z); 94 _ACRTIMP _Dcomplex __cdecl ctanh(_In_ _Dcomplex _Z); 95 _ACRTIMP double __cdecl norm(_In_ _Dcomplex _Z); 96 97 _ACRTIMP float __cdecl cabsf(_In_ _Fcomplex _Z); 98 _ACRTIMP _Fcomplex __cdecl cacosf(_In_ _Fcomplex _Z); 99 _ACRTIMP _Fcomplex __cdecl cacoshf(_In_ _Fcomplex _Z); 100 _ACRTIMP float __cdecl cargf(_In_ _Fcomplex _Z); 101 _ACRTIMP _Fcomplex __cdecl casinf(_In_ _Fcomplex _Z); 102 _ACRTIMP _Fcomplex __cdecl casinhf(_In_ _Fcomplex _Z); 103 _ACRTIMP _Fcomplex __cdecl catanf(_In_ _Fcomplex _Z); 104 _ACRTIMP _Fcomplex __cdecl catanhf(_In_ _Fcomplex _Z); 105 _ACRTIMP _Fcomplex __cdecl ccosf(_In_ _Fcomplex _Z); 106 _ACRTIMP _Fcomplex __cdecl ccoshf(_In_ _Fcomplex _Z); 107 _ACRTIMP _Fcomplex __cdecl cexpf(_In_ _Fcomplex _Z); 108 _ACRTIMP float __cdecl cimagf(_In_ _Fcomplex _Z); 109 _ACRTIMP _Fcomplex __cdecl clogf(_In_ _Fcomplex _Z); 110 _ACRTIMP _Fcomplex __cdecl clog10f(_In_ _Fcomplex _Z); 111 _ACRTIMP _Fcomplex __cdecl conjf(_In_ _Fcomplex _Z); 112 _ACRTIMP _Fcomplex __cdecl cpowf(_In_ _Fcomplex _X, _In_ _Fcomplex _Y); 113 _ACRTIMP _Fcomplex __cdecl cprojf(_In_ _Fcomplex _Z); 114 _ACRTIMP float __cdecl crealf(_In_ _Fcomplex _Z); 115 _ACRTIMP _Fcomplex __cdecl csinf(_In_ _Fcomplex _Z); 116 _ACRTIMP _Fcomplex __cdecl csinhf(_In_ _Fcomplex _Z); 117 _ACRTIMP _Fcomplex __cdecl csqrtf(_In_ _Fcomplex _Z); 118 _ACRTIMP _Fcomplex __cdecl ctanf(_In_ _Fcomplex _Z); 119 _ACRTIMP _Fcomplex __cdecl ctanhf(_In_ _Fcomplex _Z); 120 _ACRTIMP float __cdecl normf(_In_ _Fcomplex _Z); 121 122 _ACRTIMP long double __cdecl cabsl(_In_ _Lcomplex _Z); 123 _ACRTIMP _Lcomplex __cdecl cacosl(_In_ _Lcomplex _Z); 124 _ACRTIMP _Lcomplex __cdecl cacoshl(_In_ _Lcomplex _Z); 125 _ACRTIMP long double __cdecl cargl(_In_ _Lcomplex _Z); 126 _ACRTIMP _Lcomplex __cdecl casinl(_In_ _Lcomplex _Z); 127 _ACRTIMP _Lcomplex __cdecl casinhl(_In_ _Lcomplex _Z); 128 _ACRTIMP _Lcomplex __cdecl catanl(_In_ _Lcomplex _Z); 129 _ACRTIMP _Lcomplex __cdecl catanhl(_In_ _Lcomplex _Z); 130 _ACRTIMP _Lcomplex __cdecl ccosl(_In_ _Lcomplex _Z); 131 _ACRTIMP _Lcomplex __cdecl ccoshl(_In_ _Lcomplex _Z); 132 _ACRTIMP _Lcomplex __cdecl cexpl(_In_ _Lcomplex _Z); 133 _ACRTIMP long double __cdecl cimagl(_In_ _Lcomplex _Z); 134 _ACRTIMP _Lcomplex __cdecl clogl(_In_ _Lcomplex _Z); 135 _ACRTIMP _Lcomplex __cdecl clog10l(_In_ _Lcomplex _Z); 136 _ACRTIMP _Lcomplex __cdecl conjl(_In_ _Lcomplex _Z); 137 _ACRTIMP _Lcomplex __cdecl cpowl(_In_ _Lcomplex _X, _In_ _Lcomplex _Y); 138 _ACRTIMP _Lcomplex __cdecl cprojl(_In_ _Lcomplex _Z); 139 _ACRTIMP long double __cdecl creall(_In_ _Lcomplex _Z); 140 _ACRTIMP _Lcomplex __cdecl csinl(_In_ _Lcomplex _Z); 141 _ACRTIMP _Lcomplex __cdecl csinhl(_In_ _Lcomplex _Z); 142 _ACRTIMP _Lcomplex __cdecl csqrtl(_In_ _Lcomplex _Z); 143 _ACRTIMP _Lcomplex __cdecl ctanl(_In_ _Lcomplex _Z); 144 _ACRTIMP _Lcomplex __cdecl ctanhl(_In_ _Lcomplex _Z); 145 _ACRTIMP long double __cdecl norml(_In_ _Lcomplex _Z); 146 147 _ACRTIMP _Dcomplex __cdecl _Cbuild(_In_ double _Re, _In_ double _Im); 148 _ACRTIMP _Dcomplex __cdecl _Cmulcc(_In_ _Dcomplex _X, _In_ _Dcomplex _Y); 149 _ACRTIMP _Dcomplex __cdecl _Cmulcr(_In_ _Dcomplex _X, _In_ double _Y); 150 151 _ACRTIMP _Fcomplex __cdecl _FCbuild(_In_ float _Re, _In_ float _Im); 152 _ACRTIMP _Fcomplex __cdecl _FCmulcc(_In_ _Fcomplex _X, _In_ _Fcomplex _Y); 153 _ACRTIMP _Fcomplex __cdecl _FCmulcr(_In_ _Fcomplex _X, _In_ float _Y); 154 155 _ACRTIMP _Lcomplex __cdecl _LCbuild(_In_ long double _Re, _In_ long double _Im); 156 _ACRTIMP _Lcomplex __cdecl _LCmulcc(_In_ _Lcomplex _X, _In_ _Lcomplex _Y); 157 _ACRTIMP _Lcomplex __cdecl _LCmulcr(_In_ _Lcomplex _X, _In_ long double _Y); 158 159 160 161 #ifdef __cplusplus 162 extern "C++" 163 { 164 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 165 // 166 // double complex overloads 167 // 168 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 169 inline _Dcomplex __CRTDECL acos(_In_ _Dcomplex _X) throw() 170 { 171 return cacos(_X); 172 } 173 174 inline _Dcomplex __CRTDECL acosh(_In_ _Dcomplex _X) throw() 175 { 176 return cacosh(_X); 177 } 178 179 inline _Dcomplex __CRTDECL asin(_In_ _Dcomplex _X) throw() 180 { 181 return casin(_X); 182 } 183 184 inline _Dcomplex __CRTDECL asinh(_In_ _Dcomplex _X) throw() 185 { 186 return casinh(_X); 187 } 188 189 inline _Dcomplex __CRTDECL atan(_In_ _Dcomplex _X) throw() 190 { 191 return catan(_X); 192 } 193 194 inline _Dcomplex __CRTDECL atanh(_In_ _Dcomplex _X) throw() 195 { 196 return catanh(_X); 197 } 198 199 inline _Dcomplex __CRTDECL cos(_In_ _Dcomplex _X) throw() 200 { 201 return ccos(_X); 202 } 203 204 inline _Dcomplex __CRTDECL cosh(_In_ _Dcomplex _X) throw() 205 { 206 return ccosh(_X); 207 } 208 209 inline _Dcomplex __CRTDECL proj(_In_ _Dcomplex _X) throw() 210 { 211 return cproj(_X); 212 } 213 214 inline _Dcomplex __CRTDECL exp(_In_ _Dcomplex _X) throw() 215 { 216 return cexp(_X); 217 } 218 219 inline _Dcomplex __CRTDECL log(_In_ _Dcomplex _X) throw() 220 { 221 return clog(_X); 222 } 223 224 inline _Dcomplex __CRTDECL log10(_In_ _Dcomplex _X) throw() 225 { 226 return clog10(_X); 227 } 228 229 inline _Dcomplex __CRTDECL pow(_In_ _Dcomplex _X, _In_ _Dcomplex _Y) throw() 230 { 231 return cpow(_X, _Y); 232 } 233 234 inline _Dcomplex __CRTDECL sin(_In_ _Dcomplex _X) throw() 235 { 236 return csin(_X); 237 } 238 239 inline _Dcomplex __CRTDECL sinh(_In_ _Dcomplex _X) throw() 240 { 241 return csinh(_X); 242 } 243 244 inline _Dcomplex __CRTDECL sqrt(_In_ _Dcomplex _X) throw() 245 { 246 return csqrt(_X); 247 } 248 249 inline _Dcomplex __CRTDECL tan(_In_ _Dcomplex _X) throw() 250 { 251 return ctan(_X); 252 } 253 254 inline _Dcomplex __CRTDECL tanh(_In_ _Dcomplex _X) throw() 255 { 256 return ctanh(_X); 257 } 258 259 inline double __CRTDECL abs(_In_ _Dcomplex _X) throw() 260 { 261 return cabs(_X); 262 } 263 264 inline double __CRTDECL arg(_In_ _Dcomplex _X) throw() 265 { 266 return carg(_X); 267 } 268 269 inline double __CRTDECL imag(_In_ _Dcomplex _X) throw() 270 { 271 return cimag(_X); 272 } 273 274 inline double __CRTDECL real(_In_ _Dcomplex _X) throw() 275 { 276 return creal(_X); 277 } 278 279 280 281 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 282 // 283 // float complex overloads 284 // 285 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 286 inline _Fcomplex __CRTDECL acos(_In_ _Fcomplex _X) throw() 287 { 288 return cacosf(_X); 289 } 290 291 inline _Fcomplex __CRTDECL acosh(_In_ _Fcomplex _X) throw() 292 { 293 return cacoshf(_X); 294 } 295 296 inline _Fcomplex __CRTDECL asin(_In_ _Fcomplex _X) throw() 297 { 298 return casinf(_X); 299 } 300 301 inline _Fcomplex __CRTDECL asinh(_In_ _Fcomplex _X) throw() 302 { 303 return casinhf(_X); 304 } 305 306 inline _Fcomplex __CRTDECL atan(_In_ _Fcomplex _X) throw() 307 { 308 return catanf(_X); 309 } 310 311 inline _Fcomplex __CRTDECL atanh(_In_ _Fcomplex _X) throw() 312 { 313 return catanhf(_X); 314 } 315 316 inline _Fcomplex __CRTDECL conj(_In_ _Fcomplex _X) throw() 317 { 318 return conjf(_X); 319 } 320 321 inline _Fcomplex __CRTDECL cos(_In_ _Fcomplex _X) throw() 322 { 323 return ccosf(_X); 324 } 325 326 inline _Fcomplex __CRTDECL cosh(_In_ _Fcomplex _X) throw() 327 { 328 return ccoshf(_X); 329 } 330 331 inline _Fcomplex __CRTDECL cproj(_In_ _Fcomplex _X) throw() 332 { 333 return cprojf(_X); 334 } 335 336 inline _Fcomplex __CRTDECL proj(_In_ _Fcomplex _X) throw() 337 { 338 return cprojf(_X); 339 } 340 341 inline _Fcomplex __CRTDECL exp(_In_ _Fcomplex _X) throw() 342 { 343 return cexpf(_X); 344 } 345 346 inline _Fcomplex __CRTDECL log(_In_ _Fcomplex _X) throw() 347 { 348 return clogf(_X); 349 } 350 351 inline _Fcomplex __CRTDECL log10(_In_ _Fcomplex _X) throw() 352 { 353 return clog10f(_X); 354 } 355 356 inline float __CRTDECL norm(_In_ _Fcomplex _X) throw() 357 { 358 return normf(_X); 359 } 360 361 inline _Fcomplex __CRTDECL pow(_In_ _Fcomplex _X, _In_ _Fcomplex _Y) throw() 362 { 363 return cpowf(_X, _Y); 364 } 365 366 inline _Fcomplex __CRTDECL sin(_In_ _Fcomplex _X) throw() 367 { 368 return csinf(_X); 369 } 370 371 inline _Fcomplex __CRTDECL sinh(_In_ _Fcomplex _X) throw() 372 { 373 return csinhf(_X); 374 } 375 376 inline _Fcomplex __CRTDECL sqrt(_In_ _Fcomplex _X) throw() 377 { 378 return csqrtf(_X); 379 } 380 381 inline _Fcomplex __CRTDECL tan(_In_ _Fcomplex _X) throw() 382 { 383 return ctanf(_X); 384 } 385 386 inline _Fcomplex __CRTDECL tanh(_In_ _Fcomplex _X) throw() 387 { 388 return ctanhf(_X); 389 } 390 391 inline float __CRTDECL abs(_In_ _Fcomplex _X) throw() 392 { 393 return cabsf(_X); 394 } 395 396 inline float __CRTDECL arg(_In_ _Fcomplex _X) throw() 397 { 398 return cargf(_X); 399 } 400 401 inline float __CRTDECL carg(_In_ _Fcomplex _X) throw() 402 { 403 return cargf(_X); 404 } 405 406 inline float __CRTDECL cimag(_In_ _Fcomplex _X) throw() 407 { 408 return cimagf(_X); 409 } 410 411 inline float __CRTDECL creal(_In_ _Fcomplex _X) throw() 412 { 413 return crealf(_X); 414 } 415 416 inline float __CRTDECL imag(_In_ _Fcomplex _X) throw() 417 { 418 return cimagf(_X); 419 } 420 421 inline float __CRTDECL real(_In_ _Fcomplex _X) throw() 422 { 423 return crealf(_X); 424 } 425 426 427 428 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 429 // 430 // long double complex overloads 431 // 432 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 433 inline _Lcomplex __CRTDECL acos(_In_ _Lcomplex _X) throw() 434 { 435 return cacosl(_X); 436 } 437 438 inline _Lcomplex __CRTDECL acosh(_In_ _Lcomplex _X) throw() 439 { 440 return cacoshl(_X); 441 } 442 443 inline _Lcomplex __CRTDECL asin(_In_ _Lcomplex _X) throw() 444 { 445 return casinl(_X); 446 } 447 448 inline _Lcomplex __CRTDECL asinh(_In_ _Lcomplex _X) throw() 449 { 450 return casinhl(_X); 451 } 452 453 inline _Lcomplex __CRTDECL atan(_In_ _Lcomplex _X) throw() 454 { 455 return catanl(_X); 456 } 457 458 inline _Lcomplex __CRTDECL atanh(_In_ _Lcomplex _X) throw() 459 { 460 return catanhl(_X); 461 } 462 463 inline _Lcomplex __CRTDECL conj(_In_ _Lcomplex _X) throw() 464 { 465 return conjl(_X); 466 } 467 468 inline _Lcomplex __CRTDECL cos(_In_ _Lcomplex _X) throw() 469 { 470 return ccosl(_X); 471 } 472 473 inline _Lcomplex __CRTDECL cosh(_In_ _Lcomplex _X) throw() 474 { 475 return ccoshl(_X); 476 } 477 478 inline _Lcomplex __CRTDECL cproj(_In_ _Lcomplex _X) throw() 479 { 480 return cprojl(_X); 481 } 482 483 inline _Lcomplex __CRTDECL proj(_In_ _Lcomplex _X) throw() 484 { 485 return cprojl(_X); 486 } 487 488 inline _Lcomplex __CRTDECL exp(_In_ _Lcomplex _X) throw() 489 { 490 return cexpl(_X); 491 } 492 493 inline _Lcomplex __CRTDECL log(_In_ _Lcomplex _X) throw() 494 { 495 return clogl(_X); 496 } 497 498 inline _Lcomplex __CRTDECL log10(_In_ _Lcomplex _X) throw() 499 { 500 return clog10l(_X); 501 } 502 503 inline long double __CRTDECL norm(_In_ _Lcomplex _X) throw() 504 { 505 return norml(_X); 506 } 507 508 inline _Lcomplex __CRTDECL pow(_In_ _Lcomplex _X, _In_ _Lcomplex _Y) throw() 509 { 510 return cpowl(_X, _Y); 511 } 512 513 inline _Lcomplex __CRTDECL sin(_In_ _Lcomplex _X) throw() 514 { 515 return csinl(_X); 516 } 517 518 inline _Lcomplex __CRTDECL sinh(_In_ _Lcomplex _X) throw() 519 { 520 return csinhl(_X); 521 } 522 523 inline _Lcomplex __CRTDECL sqrt(_In_ _Lcomplex _X) throw() 524 { 525 return csqrtl(_X); 526 } 527 528 inline _Lcomplex __CRTDECL tan(_In_ _Lcomplex _X) throw() 529 { 530 return ctanl(_X); 531 } 532 533 inline _Lcomplex __CRTDECL tanh(_In_ _Lcomplex _X) throw() 534 { 535 return ctanhl(_X); 536 } 537 538 inline long double __CRTDECL abs(_In_ _Lcomplex _X) throw() 539 { 540 return cabsl(_X); 541 } 542 543 inline long double __CRTDECL arg(_In_ _Lcomplex _X) throw() 544 { 545 return cargl(_X); 546 } 547 548 inline long double __CRTDECL carg(_In_ _Lcomplex _X) throw() 549 { 550 return cargl(_X); 551 } 552 553 inline long double __CRTDECL cimag(_In_ _Lcomplex _X) throw() 554 { 555 return cimagl(_X); 556 } 557 558 inline long double __CRTDECL creal(_In_ _Lcomplex _X) throw() 559 { 560 return creall(_X); 561 } 562 563 inline long double __CRTDECL imag(_In_ _Lcomplex _X) throw() 564 { 565 return cimagl(_X); 566 } 567 568 inline long double __CRTDECL real(_In_ _Lcomplex _X) throw() 569 { 570 return creall(_X); 571 } 572 573 } // extern "C++" 574 #endif // __cplusplus 575 576 _CRT_END_C_HEADER 577 _UCRT_RESTORE_CLANG_WARNINGS 578 #pragma warning(pop) // _UCRT_DISABLED_WARNINGS 579 #endif // (_CRT_HAS_CXX17 == 1) && !defined(_CRT_USE_C_COMPLEX_H) 580 #endif // _COMPLEX 581