ucomplex.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //**********************************************************************************//
  2. // Copyright (C) 2009-2015 Ovidio Pena <ovidio@bytesfall.com> //
  3. // //
  4. // This file is part of scattnlay //
  5. // //
  6. // This program is free software: you can redistribute it and/or modify //
  7. // it under the terms of the GNU General Public License as published by //
  8. // the Free Software Foundation, either version 3 of the License, or //
  9. // (at your option) any later version. //
  10. // //
  11. // This program is distributed in the hope that it will be useful, //
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of //
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
  14. // GNU General Public License for more details. //
  15. // //
  16. // The only additional remark is that we expect that all publications //
  17. // describing work using this software, or all commercial products //
  18. // using it, cite the following reference: //
  19. // [1] O. Pena and U. Pal, "Scattering of electromagnetic radiation by //
  20. // a multilayered sphere," Computer Physics Communications, //
  21. // vol. 180, Nov. 2009, pp. 2348-2354. //
  22. // //
  23. // You should have received a copy of the GNU General Public License //
  24. // along with this program. If not, see <http://www.gnu.org/licenses/>. //
  25. //**********************************************************************************//
  26. typedef struct COMPLEX {double r,i;} complex;
  27. // Complex functions
  28. complex Cadd(complex z1, complex z2); // addition
  29. complex Csub(complex z1, complex z2); // substraction
  30. complex Cmul(complex z1, complex z2); // multiplication
  31. complex RCmul(double r, complex z); // double*complex
  32. complex Cdiv(complex z1, complex z2); // division
  33. complex Complex(double r, double i); // convert to double
  34. complex Conjg(complex z); // conjuge
  35. complex Cinv(complex z); // inverse function 1/z
  36. // Complex functions with double return values
  37. double Cabs(complex z); // module
  38. double Carc(complex z); // argument : z1 / z = p.e^ia
  39. // Elementary functions
  40. complex Cexp(complex z); // exponential
  41. complex Clog(complex z); // natural logarithm
  42. complex Csqrt(complex z); // square root
  43. // Complex trigonometric functions
  44. complex Ccos(complex z); // cosinus
  45. complex Csin(complex z); // sinus
  46. complex Ctan(complex z); // tangent
  47. // Inverse complex trigonometric functions
  48. complex Carc_cos(complex z); // arc cosinus
  49. complex Carc_sin(complex z); // arc sinus
  50. complex Carc_tan(complex z); // arc tangent
  51. // Hyperbolic complex functions
  52. complex Cch(complex z); // hyperbolic cosinus
  53. complex Csh(complex z); // hyperbolic sinus
  54. complex Cth(complex z); // hyperbolic tangent
  55. // Inverse hyperbolic complex functions
  56. complex Carc_ch(complex z); // hyperbolic arc cosinus
  57. complex Carc_sh(complex z); // hyperbolic arc sinus
  58. complex Carc_th(complex z); // hyperbolic arc tangente