CHROMA
Public Member Functions | Private Member Functions | Private Attributes | List of all members

Remez algorithm. More...

#include <remez_gmp.h>

Public Member Functions

 RemezGMP ()
 Default constructor. More...
 
 RemezGMP (const Real &lower, const Real &upper, long prec)
 Constructor. More...
 
 ~RemezGMP ()
 Destructor. More...
 
void setBounds (const Real &lower, const Real &upper)
 Reset the bounds of the approximation. More...
 
Real generateApprox (int num_degree, int den_degree, unsigned long power_num, unsigned long power_den)
 Generate the rational approximation x^(pnum/pden) More...
 
Real generateApprox (int degree, unsigned long power_num, unsigned long power_den)
 
RemezCoeff_t getPFE ()
 Return the partial fraction expansion of the approximation x^(pnum/pden) More...
 
RemezCoeff_t getIPFE ()
 Return the partial fraction expansion of the approximation x^(-pnum/pden) More...
 
Real evalPFE (const Real &x, const RemezCoeff_t &coeff)
 Given a partial fraction expansion, evaluate it at x. More...
 

Private Member Functions

void initialGuess ()
 Initial values of maximal and minmal errors. More...
 
void equations ()
 Solve the equations. More...
 
void search (multi1d< bigfloat > &step)
 Search for error maxima and minima. More...
 
void stpini (multi1d< bigfloat > &step)
 Initialise step sizes. More...
 
int root ()
 Calculate the roots of the approximation. More...
 
bigfloat polyEval (const bigfloat &x, const multi1d< bigfloat > &poly, long size)
 Evaluate the polynomial. More...
 
bigfloat polyDiff (const bigfloat &x, const multi1d< bigfloat > &poly, long size)
 Evaluate the differential of the polynomial. More...
 
bigfloat rtnewt (const multi1d< bigfloat > &poly, long i, const bigfloat &x1, const bigfloat &x2, const bigfloat &xacc)
 Newton's method to calculate roots. More...
 
void pfe (multi1d< bigfloat > &res, multi1d< bigfloat > &poles, const bigfloat &norm)
 
bigfloat approx (const bigfloat &x)
 
bigfloat func (const bigfloat &x)
 Calculate function required for the approximation. More...
 
bigfloat getErr (const bigfloat &x, int &sign)
 Compute size and sign of the approximation error at x. More...
 
int simq (multi1d< bigfloat > &A, multi1d< bigfloat > &B, multi1d< bigfloat > &X, int n)
 Solve the system AX=B. More...
 
void allocate (int num_degree, int den_degree)
 Free memory and reallocate as necessary. More...
 

Private Attributes

multi1d< bigfloatparam
 
multi1d< bigfloatroots
 
multi1d< bigfloatpoles
 
bigfloat norm
 
int n
 The numerator and denominator degree (n=d) More...
 
int d
 
bigfloat apstrt
 The bounds of the approximation. More...
 
bigfloat apwidt
 
bigfloat apend
 
unsigned long power_num
 the numerator and denominator of the power we are approximating More...
 
unsigned long power_den
 
bool alloc
 Flag to determine whether the arrays have been allocated. More...
 
int nd1
 Variables used to calculate the approximation. More...
 
int iter
 
multi1d< bigfloatxx
 
multi1d< bigfloatmm
 
multi1d< bigfloatstep
 
bigfloat delta
 
bigfloat spread
 
bigfloat tolerance
 
int neq
 The number of equations we must solve at each iteration (n+d+1) More...
 
long prec
 The precision of the GNU MP library. More...
 

Detailed Description

Remez algorithm.

The Remez algorithm is used for generating the nth root rational approximation.

Note this class can only be used if the gnu multiprecision (GNU MP) library is present.

Definition at line 26 of file remez_gmp.h.

Constructor & Destructor Documentation

◆ RemezGMP() [1/2]

Chroma::RemezGMP::RemezGMP ( )

Default constructor.

Definition at line 13 of file remez_gmp.cc.

References alloc, Chroma::END_CODE(), and Chroma::START_CODE().

◆ RemezGMP() [2/2]

Chroma::RemezGMP::RemezGMP ( const Real &  lower,
const Real &  upper,
long  prec 
)

◆ ~RemezGMP()

Chroma::RemezGMP::~RemezGMP ( )
inline

Destructor.

Definition at line 36 of file remez_gmp.h.

Member Function Documentation

◆ allocate()

void Chroma::RemezGMP::allocate ( int  num_degree,
int  den_degree 
)
private

Free memory and reallocate as necessary.

Definition at line 54 of file remez_gmp.cc.

References alloc, Chroma::END_CODE(), mm, param, poles, roots, Chroma::START_CODE(), and xx.

Referenced by generateApprox().

◆ approx()

bigfloat Chroma::RemezGMP::approx ( const bigfloat x)
private

Definition at line 410 of file remez_gmp.cc.

References d, Chroma::END_CODE(), Chroma::i, n, param, Chroma::START_CODE(), and x.

Referenced by getErr().

◆ equations()

void Chroma::RemezGMP::equations ( void  )
private

Solve the equations.

Definition at line 367 of file remez_gmp.cc.

References d, Chroma::END_CODE(), func(), Chroma::i, j, n, neq, param, simq(), Chroma::START_CODE(), x, xx, y, and z.

Referenced by generateApprox().

◆ evalPFE()

Real Chroma::RemezGMP::evalPFE ( const Real &  x,
const RemezCoeff_t coeff 
)

Given a partial fraction expansion, evaluate it at x.

Definition at line 762 of file remez_gmp.cc.

References Chroma::i, Chroma::RemezCoeff_t::norm, Chroma::RemezCoeff_t::pole, Chroma::RemezCoeff_t::res, and x.

◆ func()

bigfloat Chroma::RemezGMP::func ( const bigfloat x)
private

Calculate function required for the approximation.

Definition at line 447 of file remez_gmp.cc.

References Chroma::END_CODE(), power_den, power_num, prec, Chroma::START_CODE(), x, and y.

Referenced by equations(), and getErr().

◆ generateApprox() [1/2]

Real Chroma::RemezGMP::generateApprox ( int  degree,
unsigned long  power_num,
unsigned long  power_den 
)

Definition at line 83 of file remez_gmp.cc.

References generateApprox().

◆ generateApprox() [2/2]

Real Chroma::RemezGMP::generateApprox ( int  num_degree,
int  den_degree,
unsigned long  power_num,
unsigned long  power_den 
)

Generate the rational approximation x^(pnum/pden)

Definition at line 89 of file remez_gmp.cc.

References allocate(), d, delta, Chroma::END_CODE(), equations(), getErr(), initialGuess(), iter, mm, n, neq, power_den, power_num, root(), search(), spread, Chroma::START_CODE(), step, stpini(), and tolerance.

Referenced by generateApprox().

◆ getErr()

bigfloat Chroma::RemezGMP::getErr ( const bigfloat x,
int &  sign 
)
private

Compute size and sign of the approximation error at x.

Definition at line 429 of file remez_gmp.cc.

References approx(), func(), and x.

Referenced by generateApprox(), and search().

◆ getIPFE()

RemezCoeff_t Chroma::RemezGMP::getIPFE ( )

Return the partial fraction expansion of the approximation x^(-pnum/pden)

Definition at line 189 of file remez_gmp.cc.

References alloc, d, Chroma::END_CODE(), Chroma::i, n, Chroma::RemezCoeff_t::norm, norm, Chroma::p, pfe(), Chroma::RemezCoeff_t::pole, poles, Chroma::r, Chroma::RemezCoeff_t::res, roots, and Chroma::START_CODE().

◆ getPFE()

RemezCoeff_t Chroma::RemezGMP::getPFE ( )

Return the partial fraction expansion of the approximation x^(pnum/pden)

Definition at line 149 of file remez_gmp.cc.

References alloc, d, Chroma::END_CODE(), Chroma::i, n, Chroma::RemezCoeff_t::norm, norm, Chroma::p, pfe(), Chroma::RemezCoeff_t::pole, poles, Chroma::r, Chroma::RemezCoeff_t::res, roots, and Chroma::START_CODE().

◆ initialGuess()

void Chroma::RemezGMP::initialGuess ( )
private

Initial values of maximal and minmal errors.

Definition at line 228 of file remez_gmp.cc.

References Chroma::a, apend, apstrt, apwidt, Chroma::END_CODE(), Chroma::i, M_PI, mm, neq, Chroma::r, Chroma::START_CODE(), and xx.

Referenced by generateApprox().

◆ pfe()

void Chroma::RemezGMP::pfe ( multi1d< bigfloat > &  res,
multi1d< bigfloat > &  poles,
const bigfloat norm 
)
private

Definition at line 683 of file remez_gmp.cc.

References d, Chroma::END_CODE(), Chroma::i, j, l, n, norm, poles, Chroma::QDP_error_exit(), and Chroma::START_CODE().

Referenced by getIPFE(), and getPFE().

◆ polyDiff()

bigfloat Chroma::RemezGMP::polyDiff ( const bigfloat x,
const multi1d< bigfloat > &  poly,
long  size 
)
private

Evaluate the differential of the polynomial.

Definition at line 646 of file remez_gmp.cc.

References Chroma::i, and x.

Referenced by rtnewt().

◆ polyEval()

bigfloat Chroma::RemezGMP::polyEval ( const bigfloat x,
const multi1d< bigfloat > &  poly,
long  size 
)
private

Evaluate the polynomial.

Definition at line 638 of file remez_gmp.cc.

References Chroma::i, and x.

Referenced by rtnewt().

◆ root()

int Chroma::RemezGMP::root ( )
private

Calculate the roots of the approximation.

Definition at line 588 of file remez_gmp.cc.

References d, Chroma::END_CODE(), Chroma::i, j, n, neq, norm, param, poles, roots, rtnewt(), Chroma::START_CODE(), and x.

Referenced by generateApprox().

◆ rtnewt()

bigfloat Chroma::RemezGMP::rtnewt ( const multi1d< bigfloat > &  poly,
long  i,
const bigfloat x1,
const bigfloat x2,
const bigfloat xacc 
)
private

Newton's method to calculate roots.

Definition at line 655 of file remez_gmp.cc.

References Chroma::END_CODE(), Chroma::i, j, JMAX, polyDiff(), polyEval(), and Chroma::START_CODE().

Referenced by root().

◆ search()

void Chroma::RemezGMP::search ( multi1d< bigfloat > &  step)
private

Search for error maxima and minima.

Definition at line 277 of file remez_gmp.cc.

References Chroma::a, apend, apstrt, delta, Chroma::END_CODE(), getErr(), Chroma::i, j, l, mm, neq, q, Chroma::QDP_error_exit(), spread, Chroma::START_CODE(), step, and xx.

Referenced by generateApprox().

◆ setBounds()

void Chroma::RemezGMP::setBounds ( const Real &  lower,
const Real &  upper 
)

Reset the bounds of the approximation.

Definition at line 71 of file remez_gmp.cc.

References apend, apstrt, apwidt, Chroma::END_CODE(), and Chroma::START_CODE().

◆ simq()

int Chroma::RemezGMP::simq ( multi1d< bigfloat > &  A,
multi1d< bigfloat > &  B,
multi1d< bigfloat > &  X,
int  n 
)
private

Solve the system AX=B.

Definition at line 468 of file remez_gmp.cc.

References Chroma::A(), Chroma::END_CODE(), Chroma::i, j, Chroma::k, l, n, neq, q, Chroma::QDP_error_exit(), Chroma::START_CODE(), and sum.

Referenced by equations().

◆ stpini()

void Chroma::RemezGMP::stpini ( multi1d< bigfloat > &  step)
private

Initialise step sizes.

Definition at line 260 of file remez_gmp.cc.

References apend, apstrt, delta, Chroma::END_CODE(), Chroma::i, neq, Chroma::QDP_error_exit(), Chroma::START_CODE(), step, and xx.

Referenced by generateApprox().

Member Data Documentation

◆ alloc

bool Chroma::RemezGMP::alloc
private

Flag to determine whether the arrays have been allocated.

Definition at line 72 of file remez_gmp.h.

Referenced by allocate(), getIPFE(), getPFE(), and RemezGMP().

◆ apend

bigfloat Chroma::RemezGMP::apend
private

Definition at line 65 of file remez_gmp.h.

Referenced by initialGuess(), RemezGMP(), search(), setBounds(), and stpini().

◆ apstrt

bigfloat Chroma::RemezGMP::apstrt
private

The bounds of the approximation.

Definition at line 65 of file remez_gmp.h.

Referenced by initialGuess(), RemezGMP(), search(), setBounds(), and stpini().

◆ apwidt

bigfloat Chroma::RemezGMP::apwidt
private

Definition at line 65 of file remez_gmp.h.

Referenced by initialGuess(), RemezGMP(), and setBounds().

◆ d

int Chroma::RemezGMP::d
private

Definition at line 62 of file remez_gmp.h.

Referenced by approx(), equations(), generateApprox(), getIPFE(), getPFE(), pfe(), RemezGMP(), and root().

◆ delta

bigfloat Chroma::RemezGMP::delta
private

Definition at line 77 of file remez_gmp.h.

Referenced by generateApprox(), search(), and stpini().

◆ iter

int Chroma::RemezGMP::iter
private

Definition at line 75 of file remez_gmp.h.

Referenced by generateApprox().

◆ mm

multi1d<bigfloat> Chroma::RemezGMP::mm
private

Definition at line 76 of file remez_gmp.h.

Referenced by allocate(), generateApprox(), initialGuess(), and search().

◆ n

int Chroma::RemezGMP::n
private

The numerator and denominator degree (n=d)

Definition at line 62 of file remez_gmp.h.

Referenced by approx(), equations(), generateApprox(), getIPFE(), getPFE(), pfe(), RemezGMP(), root(), and simq().

◆ nd1

int Chroma::RemezGMP::nd1
private

Variables used to calculate the approximation.

Definition at line 75 of file remez_gmp.h.

◆ neq

int Chroma::RemezGMP::neq
private

The number of equations we must solve at each iteration (n+d+1)

Definition at line 80 of file remez_gmp.h.

Referenced by equations(), generateApprox(), initialGuess(), root(), search(), simq(), and stpini().

◆ norm

bigfloat Chroma::RemezGMP::norm
private

Definition at line 59 of file remez_gmp.h.

Referenced by getIPFE(), getPFE(), pfe(), and root().

◆ param

multi1d<bigfloat> Chroma::RemezGMP::param
private

Definition at line 58 of file remez_gmp.h.

Referenced by allocate(), approx(), equations(), and root().

◆ poles

multi1d<bigfloat> Chroma::RemezGMP::poles
private

Definition at line 58 of file remez_gmp.h.

Referenced by allocate(), getIPFE(), getPFE(), pfe(), and root().

◆ power_den

unsigned long Chroma::RemezGMP::power_den
private

Definition at line 69 of file remez_gmp.h.

Referenced by func(), and generateApprox().

◆ power_num

unsigned long Chroma::RemezGMP::power_num
private

the numerator and denominator of the power we are approximating

Definition at line 68 of file remez_gmp.h.

Referenced by func(), and generateApprox().

◆ prec

long Chroma::RemezGMP::prec
private

The precision of the GNU MP library.

Definition at line 83 of file remez_gmp.h.

Referenced by func(), and RemezGMP().

◆ roots

multi1d<bigfloat> Chroma::RemezGMP::roots
private

Definition at line 58 of file remez_gmp.h.

Referenced by allocate(), getIPFE(), getPFE(), and root().

◆ spread

bigfloat Chroma::RemezGMP::spread
private

Definition at line 77 of file remez_gmp.h.

Referenced by generateApprox(), and search().

◆ step

multi1d<bigfloat> Chroma::RemezGMP::step
private

Definition at line 76 of file remez_gmp.h.

Referenced by generateApprox(), search(), and stpini().

◆ tolerance

bigfloat Chroma::RemezGMP::tolerance
private

Definition at line 77 of file remez_gmp.h.

Referenced by generateApprox(), and RemezGMP().

◆ xx

multi1d<bigfloat> Chroma::RemezGMP::xx
private

Definition at line 76 of file remez_gmp.h.

Referenced by allocate(), equations(), initialGuess(), search(), and stpini().


The documentation for this class was generated from the following files: