!===============================================================================
!
! module_truncrat.F90
!
!-------------------------------------------------------------------------------
!
! Module for truncated rational approximations (ratapp)
!
! Author: Taylor Haar
! Last modified: 17/03/2017
!
!-------------------------------------------------------------------------------
# include "defs.h"

!-------------------------------------------------------------------------------
! The truncated ratapp is defined via the base rational approximation R_rid = R,
! and the truncation points n_low and n_high. If we write
!   R(K) = \prod(i=1,n) (K + a_i)/(K + b_i),
! then our truncated ratapp is given by
!   R_{low,high}(K) = \prod(i=low,high) (K + a_i)/(K + b_i).
! The current implementation assumes that a_i and b_i are ordered such that
!   a_i >= a_{i+1} and b_i >= b_{i+1},
! and that R_{1,m} is also an approximation to K^-1/2.
!
! However, the ratapp generation routines produce shifts that are *increasing*,
! so we have to reverse the indices when using truncated ratapps.
!-------------------------------------------------------------------------------

module module_truncrat

  type :: type_truncrat
     integer :: rid ! Rational approximation id (act. ratapp_zolo) 
     integer :: n_low, n_high ! First and last index of ratapp
  end type type_truncrat
  
  type(type_truncrat), save :: truncrat(30)
  integer, save :: n_trunc_id = 0

end module module_truncrat

!===============================================================================
