CHROMA
|
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< bigfloat > | param |
multi1d< bigfloat > | roots |
multi1d< bigfloat > | poles |
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< bigfloat > | xx |
multi1d< bigfloat > | mm |
multi1d< bigfloat > | step |
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... | |
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.
Chroma::RemezGMP::RemezGMP | ( | ) |
Default constructor.
Definition at line 13 of file remez_gmp.cc.
References alloc, Chroma::END_CODE(), and Chroma::START_CODE().
Chroma::RemezGMP::RemezGMP | ( | const Real & | lower, |
const Real & | upper, | ||
long | prec | ||
) |
Constructor.
Definition at line 24 of file remez_gmp.cc.
References alloc, apend, apstrt, apwidt, d, Chroma::END_CODE(), n, prec, Chroma::bigfloat::setDefaultPrecision(), Chroma::START_CODE(), and tolerance.
|
inline |
Destructor.
Definition at line 36 of file remez_gmp.h.
|
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().
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().
|
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().
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.
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().
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().
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().
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().
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().
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().
|
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().
|
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().
|
private |
Evaluate the differential of the polynomial.
Definition at line 646 of file remez_gmp.cc.
Referenced by rtnewt().
|
private |
|
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().
|
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().
|
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().
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().
|
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().
|
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().
|
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().
|
private |
Definition at line 65 of file remez_gmp.h.
Referenced by initialGuess(), RemezGMP(), search(), setBounds(), and stpini().
|
private |
The bounds of the approximation.
Definition at line 65 of file remez_gmp.h.
Referenced by initialGuess(), RemezGMP(), search(), setBounds(), and stpini().
|
private |
Definition at line 65 of file remez_gmp.h.
Referenced by initialGuess(), RemezGMP(), and setBounds().
|
private |
Definition at line 62 of file remez_gmp.h.
Referenced by approx(), equations(), generateApprox(), getIPFE(), getPFE(), pfe(), RemezGMP(), and root().
|
private |
Definition at line 77 of file remez_gmp.h.
Referenced by generateApprox(), search(), and stpini().
|
private |
Definition at line 75 of file remez_gmp.h.
Referenced by generateApprox().
|
private |
Definition at line 76 of file remez_gmp.h.
Referenced by allocate(), generateApprox(), initialGuess(), and search().
|
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().
|
private |
Variables used to calculate the approximation.
Definition at line 75 of file remez_gmp.h.
|
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().
|
private |
|
private |
Definition at line 58 of file remez_gmp.h.
Referenced by allocate(), approx(), equations(), and root().
|
private |
Definition at line 58 of file remez_gmp.h.
Referenced by allocate(), getIPFE(), getPFE(), pfe(), and root().
|
private |
Definition at line 69 of file remez_gmp.h.
Referenced by func(), and generateApprox().
|
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().
|
private |
The precision of the GNU MP library.
Definition at line 83 of file remez_gmp.h.
Referenced by func(), and RemezGMP().
|
private |
Definition at line 58 of file remez_gmp.h.
Referenced by allocate(), getIPFE(), getPFE(), and root().
|
private |
Definition at line 77 of file remez_gmp.h.
Referenced by generateApprox(), and search().
|
private |
Definition at line 76 of file remez_gmp.h.
Referenced by generateApprox(), search(), and stpini().
|
private |
Definition at line 77 of file remez_gmp.h.
Referenced by generateApprox(), and RemezGMP().
|
private |
Definition at line 76 of file remez_gmp.h.
Referenced by allocate(), equations(), initialGuess(), search(), and stpini().