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