CHROMA
zolotarev.h
Go to the documentation of this file.
1 /* -*- Mode: C; comment-column: 22; fill-column: 79; -*- */
2 #define HVERSION Header Time-stamp: <14-OCT-2004 09:26:51.00 adk@MISSCONTRARY>
3 
4 #ifndef ZOLOTAREV_INTERNAL
5 #ifndef PRECISION
6 #define PRECISION double
7 #endif
8 #define ZPRECISION PRECISION
9 #define ZOLOTAREV_DATA zolotarev_data
10 #endif
11 
12 /* This struct contains the coefficients which parameterise an optimal rational
13  * approximation to the signum function.
14  *
15  * The parameterisations used are:
16  *
17  * Factored form for type 0 (R0(0) = 0)
18  *
19  * R0(x) = A * x * prod(x^2 - a[j], j = 0 .. dn-1) / prod(x^2 - ap[j], j = 0
20  * .. dd-1),
21  *
22  * where deg_num = 2*dn + 1 and deg_denom = 2*dd.
23  *
24  * Factored form for type 1 (R1(0) = infinity)
25  *
26  * R1(x) = (A / x) * prod(x^2 - a[j], j = 0 .. dn-1) / prod(x^2 - ap[j], j = 0
27  * .. dd-1),
28  *
29  * where deg_num = 2*dn and deg_denom = 2*dd + 1.
30  *
31  * Partial fraction form
32  *
33  * R(x) = alpha[da] * x + sum(alpha[j] * x / (x^2 - ap[j]), j = 0 .. da-1)
34  *
35  * where da = dd for type 0 and da = dd + 1 with ap[dd] = 0 for type 1.
36  *
37  * Continued fraction form
38  *
39  * R(x) = beta[db-1] * x + 1 / (beta[db-2] * x + 1 / (beta[db-3] * x + ...))
40  *
41  * with the final coefficient being beta[0], with d' = 2 * dd + 1 for type 0
42  * and db = 2 * dd + 2 for type 1.
43  *
44  * Cayley form (Chiu's domain wall formulation)
45  *
46  * R(x) = (1 - T(x)) / (1 + T(x))
47  *
48  * where T(x) = prod((x - gamma[j]) / (x + gamma[j]), j = 0 .. n-1)
49  */
50 
51 typedef struct {
52  ZPRECISION *a, /* zeros of numerator, a[0 .. dn-1] */
53  *ap, /* poles (zeros of denominator), ap[0 .. dd-1] */
54  A, /* overall factor */
55  *alpha, /* coefficients of partial fraction, alpha[0 .. da-1] */
56  *beta, /* coefficients of continued fraction, beta[0 .. db-1] */
57  *gamma, /* zeros of numerator of T in Cayley form */
58  Delta, /* maximum error, |R(x) - sgn(x)| <= Delta */
59  epsilon; /* minimum x value, epsilon < |x| < 1 */
60  int n, /* approximation degree */
61  type, /* 0: R(0) = 0, 1: R(0) = infinity */
62  dn, dd, da, db, /* number of elements of a, ap, alpha, and beta */
63  deg_num, /* degree of numerator = deg_denom +/- 1 */
64  deg_denom; /* degree of denominator */
66 
67 #ifndef ZOLOTAREV_INTERNAL
68 
69 /* zolotarev(epsilon, n, type) returns a pointer to an initialised
70  * zolotarev_data structure. The arguments must satisfy the constraints that
71  * epsilon > 0, n > 0, and type = 0 or 1. */
72 
73 ZOLOTAREV_DATA* zolotarev(PRECISION epsilon, int n, int type);
76 #endif
unsigned n
Definition: ldumul_w.cc:36
int epsilon(int i, int j, int k)
ZPRECISION * a
Definition: zolotarev.h:52
ZPRECISION Delta
Definition: zolotarev.h:58
ZPRECISION * gamma
Definition: zolotarev.h:57
ZPRECISION A
Definition: zolotarev.h:54
ZPRECISION epsilon
Definition: zolotarev.h:59
ZPRECISION * alpha
Definition: zolotarev.h:55
ZPRECISION * ap
Definition: zolotarev.h:53
ZPRECISION * beta
Definition: zolotarev.h:56
#define ZOLOTAREV_DATA
Definition: zolotarev.h:9
#define ZPRECISION
Definition: zolotarev.h:8
void zolotarev_free(ZOLOTAREV_DATA *f)
#define PRECISION
Definition: zolotarev.h:6
ZOLOTAREV_DATA * higham(PRECISION epsilon, int n)
ZOLOTAREV_DATA * zolotarev(PRECISION epsilon, int n, int type)