coeffs.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef COEFFS_HPP
  2. #define COEFFS_HPP
  3. #include <cassert>
  4. #include "config.hpp"
  5. #include "rationnal.hpp"
  6. #include "flint/fmpz.h"
  7. #include "flint/fmpz_poly.h"
  8. //**********************
  9. //* Coefficients C_m,n *
  10. //**********************
  11. //! Maximal coefficinet index
  12. static const size_t max_ind_coeffs=max_len/2+2;
  13. //! Number of coefficients
  14. static const size_t num_coeffs=((max_ind_coeffs+1)*(max_ind_coeffs+2))/2;
  15. //! Array of coefficients
  16. extern Reel coeffs[num_coeffs];
  17. extern fmpz_poly_t coeffs_poly[num_coeffs];
  18. extern Int coeffs_den;
  19. //! Return the indice of coefficient C_{i,j}
  20. size_t pos(size_t i,size_t j);
  21. //! Return an approximation of coefficient C_{i,j}
  22. Reel get_coeff(size_t i,size_t j);
  23. //! Return polynom of coefficient C_{i,j}
  24. void set_poly_coeff(size_t i,size_t j,fmpz_poly_t p);
  25. //! Compute all the coefficients
  26. void compute_coeffs();
  27. //! Represent an analytic coefficient
  28. struct CoeffAnalytic{
  29. //! The coefficient is a-4b/pi
  30. Rationnal a,b;
  31. };
  32. //********************
  33. //* Inline functions *
  34. //********************
  35. inline size_t
  36. pos(size_t i,size_t j){
  37. return (j*(j+1))/2+i;
  38. }
  39. inline Reel
  40. get_coeff(size_t i,size_t j){
  41. return i<j?coeffs[pos(i,j)]:coeffs[pos(j,i)];
  42. }
  43. inline void
  44. set_poly_coeff(size_t i,size_t j,fmpz_poly_t p){
  45. size_t ind=i<j?pos(i,j):pos(j,i);
  46. fmpz_poly_set(p,coeffs_poly[ind]);
  47. }
  48. #endif