coeffs.hpp 973 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef COEFFS_HPP
  2. #define COEFFS_HPP
  3. #include "config.hpp"
  4. #include "rationnal.hpp"
  5. //**********************
  6. //* Coefficients C_m,n *
  7. //**********************
  8. //! Maximal coefficinet index
  9. static const size_t max_ind_coeffs=max_len/2+2;
  10. //! Number of coefficients
  11. static const size_t num_coeffs=((max_ind_coeffs+1)*(max_ind_coeffs+2))/2;
  12. //! Array of coefficients
  13. extern Reel coeffs[num_coeffs];
  14. //! Return the indice of coefficient C_{i,j}
  15. size_t pos(size_t i,size_t j);
  16. //! Return an approximation of coefficient C_{i,j}
  17. Reel get_coeff(size_t i,size_t j);
  18. //! Compute all the coefficients
  19. void compute_coeffs();
  20. //! Represent an analytic coefficient
  21. struct CoeffAnalytic{
  22. //! The coefficient is a-4b/pi
  23. Rationnal a,b;
  24. };
  25. //********************
  26. //* Inline functions *
  27. //********************
  28. inline size_t
  29. pos(size_t i,size_t j){
  30. return (j*(j+1))/2+i;
  31. }
  32. inline Reel
  33. get_coeff(size_t i,size_t j){
  34. return i<j?coeffs[pos(i,j)]:coeffs[pos(j,i)];
  35. }
  36. #endif