coeffs.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "coeffs.hpp"
  2. //*****************************
  3. //* Defintion of externs data *
  4. //****************************
  5. Reel coeffs[num_coeffs];
  6. //******************
  7. //* compute_coeffs *
  8. //******************
  9. void compute_coeffs(){
  10. CoeffAnalytic ca[num_coeffs];
  11. ca[pos(0,0)]={0,0}; //C_(0,0)=0
  12. ca[pos(0,1)]={-1,0}; //C_(1,0)=-1
  13. //Compute C_(i,i)
  14. Rationnal r=0;
  15. for(size_t i=1;i<=max_ind_coeffs;++i){
  16. Rationnal t(1,2*i-1);
  17. r=r+t;
  18. ca[pos(i,i)]={0,-4*r};
  19. }
  20. for(size_t j=2;j<=max_ind_coeffs;++j){
  21. //C(0,j)=4*C(0,j-1)-C(0,j-2)-2*C(1,j-1)
  22. ca[pos(0,j)].a=4*ca[pos(0,j-1)].a-ca[pos(0,j-2)].a-2*ca[pos(1,j-1)].a;
  23. ca[pos(0,j)].b=4*ca[pos(0,j-1)].b-ca[pos(0,j-2)].b-2*ca[pos(1,j-1)].b;
  24. for(size_t i=1;i<=j-2;++i){
  25. //C(i,j)=4*C(i,j-1)-C(i,j-2)-C(i-1,j-1)-C(i+1,j-1)
  26. ca[pos(i,j)].a=4*ca[pos(i,j-1)].a-ca[pos(i,j-2)].a-ca[pos(i-1,j-1)].a-ca[pos(i+1,j-1)].a;
  27. ca[pos(i,j)].b=4*ca[pos(i,j-1)].b-ca[pos(i,j-2)].b-ca[pos(i-1,j-1)].b-ca[pos(i+1,j-1)].b;
  28. }
  29. //C(j-1,j)=2*C(j-1,j-1)-C(j-2,j-1)
  30. ca[pos(j-1,j)].a=2*ca[pos(j-1,j-1)].a-ca[pos(j-2,j-1)].a;
  31. ca[pos(j-1,j)].b=2*ca[pos(j-1,j-1)].b-ca[pos(j-2,j-1)].b;
  32. }
  33. Rationnal fpii(1725033,5419351);
  34. Reel epii=2.275957200481571e-15; //epii=1/pi-1/fpii
  35. for(size_t j=0;j<=max_ind_coeffs;++j){
  36. for(size_t i=0;i<=j;++i){
  37. size_t ind=pos(i,j);
  38. Rationnal f=ca[ind].a+fpii*ca[ind].b;
  39. coeffs[pos(i,j)]=(Reel)f+(Reel)ca[ind].b*epii;
  40. }
  41. }
  42. }