/source/intComplexBarycParab1D.c

https://github.com/EyNuel/cTraceo · C · 75 lines · 17 code · 8 blank · 50 comment · 0 complexity · 81069da07ef413ae32eb2d048f929c6f MD5 · raw file

  1. /****************************************************************************************
  2. * intComplexBarycParab1D.c *
  3. * (formerly "cbpa1d.for") *
  4. * Perform Barycentric Parabolic interpolation at 1D on complex numbers. *
  5. * NOTE: this file is practically identical to intBarycParab1D.c, the only *
  6. * difference is that this one operates on complex values. *
  7. * *
  8. * ------------------------------------------------------------------------------------ *
  9. * Website: *
  10. * https://github.com/EyNuel/cTraceo/wiki *
  11. * *
  12. * License: This file is part of the cTraceo Raytracing Model and is released under the *
  13. * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License *
  14. * http://creativecommons.org/licenses/by-nc-sa/3.0/ *
  15. * *
  16. * NOTE: cTraceo is research code under active development. *
  17. * The code may contain bugs and updates are possible in the future. *
  18. * *
  19. * Written for project SENSOCEAN by: *
  20. * Emanuel Ey *
  21. * emanuel.ey@gmail.com *
  22. * Copyright (C) 2011 - 2013 *
  23. * Signal Processing Laboratory *
  24. * Universidade do Algarve *
  25. * *
  26. * cTraceo is the C port of the FORTRAN 77 TRACEO code written by: *
  27. * Orlando Camargo Rodriguez: *
  28. * Copyright (C) 2010 *
  29. * Orlando Camargo Rodriguez *
  30. * orodrig@ualg.pt *
  31. * Universidade do Algarve *
  32. * Physics Department *
  33. * Signal Processing Laboratory *
  34. * *
  35. * ------------------------------------------------------------------------------------ *
  36. * Inputs: *
  37. * x: vector containing x0, x1, x2 (note that this value is real) *
  38. * f: vector containing f0, f1, f2 *
  39. * xi: scalar (the interpolation point) *
  40. * *
  41. * Outputs: *
  42. * fi: interpolated value of f at xi *
  43. * fxi: 1st derivative of f at xi *
  44. * fxxi: 2nd derivative of f at xi *
  45. * *
  46. * Return Value: *
  47. * None *
  48. * *
  49. ****************************************************************************************/
  50. #pragma once
  51. #include <complex.h>
  52. void intComplexBarycParab1D(double*, complex double*, complex double, complex double*, complex double*, complex double*);
  53. void intComplexBarycParab1D(double* x, complex double* f, complex double xi, complex double* fi, complex double* fxi, complex double* fxxi){
  54. complex double a1,a2,px1,px2,sx1,sx2;
  55. //TODO remove calculation of second derivative -it is never used.
  56. px1 = (x[1] -x[0]) * (x[1] -x[2]);
  57. px2 = (x[2] -x[0]) * (x[2] -x[1]);
  58. a1 = ( f[1] - f[0] )/px1;
  59. a2 = ( f[2] - f[0] )/px2;
  60. px1 = (xi - x[0]) * (xi - x[2]);
  61. px2 = (xi - x[0]) * (xi - x[1]);
  62. sx1 = 2*(xi) - x[0] - x[2];
  63. sx2 = 2*(xi) - x[0] - x[1];
  64. *fi = f[0] + a1*px1 +a2*px2;
  65. *fxi = a1*sx1 +a2*sx2;
  66. *fxxi = a1*2 +a2*2;
  67. }