coeffs.hpp 1.3 KB

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