coefficients.hpp 690 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef COEFFICIENTS_HPP
  2. #define COEFFICIENTS_HPP
  3. #include <mpfr.h>
  4. #include "config.hpp"
  5. class Coefficients{
  6. private:
  7. static constexpr size_t imax=1000;
  8. static constexpr size_t ncoeffs=((imax+2)*(imax+1))/2;
  9. mpfr_t* coeffs;
  10. size_t pos(size_t i,size_t j);
  11. public:
  12. Coefficients();
  13. void set(mpfr_t c,size_t i,size_t j);
  14. mpfr_ptr get(size_t i,size_t j);
  15. };
  16. inline size_t
  17. Coefficients::pos(size_t i,size_t j){
  18. return i+j*(j+1)/2;
  19. }
  20. inline void
  21. Coefficients::set(mpfr_t c,size_t i,size_t j){
  22. mpfr_set(c,(i<j)?coeffs[pos(i,j)]:coeffs[pos(j,i)],MPFR_RNDN);
  23. }
  24. inline mpfr_ptr
  25. Coefficients::get(size_t i,size_t j){
  26. return(i<j)?coeffs[pos(i,j)]:coeffs[pos(j,i)];
  27. }
  28. #endif