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
>
5
NAMESPACE_BEGIN
(
Grid
);
6
NAMESPACE_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
58
typedef
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 */
72
}
ZOLOTAREV_DATA
;
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
80
ZOLOTAREV_DATA
*
higham
(
ZOLO_PRECISION
epsilon,
int
n) ;
81
ZOLOTAREV_DATA
*
zolotarev
(
ZOLO_PRECISION
epsilon,
int
n,
int
type
);
82
void
zolotarev_free
(zolotarev_data *zdata);
83
#endif
84
85
#ifdef __cplusplus
86
NAMESPACE_END
(Approx);
87
NAMESPACE_END
(
Grid
);
88
#endif
89
Namespace.h
NAMESPACE_BEGIN
#define NAMESPACE_BEGIN(A)
Definition
Namespace.h:35
NAMESPACE_END
#define NAMESPACE_END(A)
Definition
Namespace.h:36
ZOLOTAREV_DATA
#define ZOLOTAREV_DATA
Definition
Zolotarev.cc:32
ZPRECISION
#define ZPRECISION
Definition
Zolotarev.h:15
ZOLO_PRECISION
#define ZOLO_PRECISION
Definition
Zolotarev.h:13
zolotarev_free
void zolotarev_free(zolotarev_data *zdata)
Definition
Zolotarev.cc:418
higham
ZOLOTAREV_DATA * higham(ZOLO_PRECISION epsilon, int n)
Definition
Zolotarev.cc:429
zolotarev
ZOLOTAREV_DATA * zolotarev(ZOLO_PRECISION epsilon, int n, int type)
Definition
Zolotarev.cc:296
Grid
Definition
Deflation.h:31
type
ZOLOTAREV_DATA::a
ZPRECISION * a
Definition
Zolotarev.h:59
ZOLOTAREV_DATA::Delta
ZPRECISION Delta
Definition
Zolotarev.h:65
ZOLOTAREV_DATA::deg_denom
int deg_denom
Definition
Zolotarev.h:71
ZOLOTAREV_DATA::da
int da
Definition
Zolotarev.h:69
ZOLOTAREV_DATA::db
int db
Definition
Zolotarev.h:69
ZOLOTAREV_DATA::gamma
ZPRECISION * gamma
Definition
Zolotarev.h:64
ZOLOTAREV_DATA::type
int type
Definition
Zolotarev.h:68
ZOLOTAREV_DATA::A
ZPRECISION A
Definition
Zolotarev.h:61
ZOLOTAREV_DATA::epsilon
ZPRECISION epsilon
Definition
Zolotarev.h:66
ZOLOTAREV_DATA::alpha
ZPRECISION * alpha
Definition
Zolotarev.h:62
ZOLOTAREV_DATA::ap
ZPRECISION * ap
Definition
Zolotarev.h:60
ZOLOTAREV_DATA::deg_num
int deg_num
Definition
Zolotarev.h:70
ZOLOTAREV_DATA::dd
int dd
Definition
Zolotarev.h:69
ZOLOTAREV_DATA::n
int n
Definition
Zolotarev.h:67
ZOLOTAREV_DATA::beta
ZPRECISION * beta
Definition
Zolotarev.h:63
ZOLOTAREV_DATA::dn
int dn
Definition
Zolotarev.h:69
Grid
algorithms
approx
Zolotarev.h
Generated by
1.16.1