This repository has been archived by the owner on Nov 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddf_ari.hpp
196 lines (165 loc) · 8.06 KB
/
ddf_ari.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*
** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
**
** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
** Universitaet Karlsruhe, Germany
** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
** Universitaet Wuppertal, Germany
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Library General Public
** License as published by the Free Software Foundation; either
** version 2 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Library General Public License for more details.
**
** You should have received a copy of the GNU Library General Public
** License along with this library; if not, write to the Free
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* CVS $Id: ddf_ari.hpp,v 1.16 2014/01/30 17:49:26 cxsc Exp $ */
//============================================================================
//
// Program/Module
// from
// C++ TOOLBOX FOR VERIFIED COMPUTING I
// Basic Numerical Problems
//
// Copyright (c) 1995 Rolf Hammer, Matthias Hocks, Dietmar Ratz
//
// For details on theory, algorithms, and programs, see the book
//
// R. Hammer, M. Hocks, U. Kulisch, D. Ratz: C++ Toolbox for
// Verified Computing I - Basic Numerical Problems. Springer-Verlag,
// Heidelberg, New York, 1995.
//
//============================================================================
//----------------------------------------------------------------------------
// File: ddf_ari (header)
// Purpose: Definition of an interval differentiation arithmetic which allows
// function evaluation with automatic differentiation up to second order.
// Type:
// ddf_FctPtr : pointer for a function of type 'DerivType'
// Class DerivType:
// DerivType() : constructors
// operators +, -, *, / : operators of diff. arithmetic
// operator = : assignment operator
// DerivConst()
// DerivVar() : to define derivative constants/variables
// fValue()
// dfValue()
// ddfValue() : to get function and derivative values
// sqr(), sqrt(), power(),
// exp(), sin(), cos(), ...: elementary functions of diff. arithmetic
// fEval() : to compute function value only
// dfEval() : to compute function and first derivative
// value
// ddfEval() : to compute function, first, and second
// derivative value
//----------------------------------------------------------------------------
#ifndef __DDF_ARI_HPP
#define __DDF_ARI_HPP
#include <interval.hpp> // Interval arithmetic
class DerivType;
typedef DerivType (*ddf_FctPtr)(const DerivType&);
class DerivType {
typedef cxsc::interval interval;
typedef cxsc::real real;
private:
interval f, df, ddf;
public:
DerivType ( );
DerivType ( const interval&, const interval&, const interval& );
DerivType ( const DerivType& );
DerivType& operator= ( const DerivType& );
friend DerivType DerivConst ( const real& );
friend DerivType DerivConst ( const interval& );
friend DerivType DerivVar ( const real& );
friend DerivType DerivVar ( const interval& );
friend inline const interval fValue ( const DerivType& );
friend inline const interval dfValue ( const DerivType& );
friend inline const interval ddfValue ( const DerivType& );
friend DerivType operator+ ( const DerivType& );
friend DerivType operator- ( const DerivType& );
friend DerivType operator+ ( const DerivType&, const DerivType& );
friend DerivType operator- ( const DerivType&, const DerivType& );
friend DerivType operator* ( const DerivType&, const DerivType& );
friend DerivType operator/ ( const DerivType&, const DerivType& );
friend DerivType operator+ ( const DerivType&, const interval& );
friend DerivType operator- ( const DerivType&, const interval& );
friend DerivType operator/ ( const DerivType&, const interval& );
friend DerivType operator* ( const DerivType&, const interval& );
friend DerivType operator+ ( const interval&, const DerivType& );
friend DerivType operator- ( const interval&, const DerivType& );
friend DerivType operator* ( const interval&, const DerivType& );
friend DerivType operator/ ( const interval&, const DerivType& );
friend DerivType operator+ ( const DerivType&, const real& );
friend DerivType operator- ( const DerivType&, const real& );
friend DerivType operator* ( const DerivType&, const real& );
friend DerivType operator/ ( const DerivType&, const real& );
friend DerivType operator+ ( const real&, const DerivType& );
friend DerivType operator- ( const real&, const DerivType& );
friend DerivType operator* ( const real&, const DerivType& );
friend DerivType operator/ ( const real&, const DerivType& );
friend DerivType sqr ( const DerivType& );
friend DerivType power ( const DerivType&, int );
friend DerivType power ( const DerivType&, const interval& );
friend DerivType sqrt ( const DerivType& );
friend DerivType exp ( const DerivType& );
friend DerivType ln ( const DerivType& );
friend DerivType sin ( const DerivType& );
friend DerivType cos ( const DerivType& );
friend DerivType tan ( const DerivType& );
friend DerivType cot ( const DerivType& );
friend DerivType asin ( const DerivType& );
friend DerivType acos ( const DerivType& );
friend DerivType atan ( const DerivType& );
friend DerivType acot ( const DerivType& );
friend DerivType sinh ( const DerivType& );
friend DerivType cosh ( const DerivType& );
friend DerivType tanh ( const DerivType& );
friend DerivType coth ( const DerivType& );
friend DerivType asinh ( const DerivType& );
friend DerivType acosh ( const DerivType& );
friend DerivType atanh ( const DerivType& );
friend DerivType acoth ( const DerivType& );
friend void fEval ( ddf_FctPtr f, interval, interval&);
friend void dfEval ( ddf_FctPtr f, interval, interval&, interval& );
friend void ddfEval( ddf_FctPtr f, interval, interval&, interval&,
interval& );
};
DerivType sqr ( const DerivType& );
DerivType power ( const DerivType&, int );
DerivType sqrt ( const DerivType& );
DerivType exp ( const DerivType& );
DerivType ln ( const DerivType& );
DerivType sin ( const DerivType& );
DerivType cos ( const DerivType& );
DerivType tan ( const DerivType& );
DerivType cot ( const DerivType& );
DerivType asin ( const DerivType& );
DerivType acos ( const DerivType& );
DerivType atan ( const DerivType& );
DerivType acot ( const DerivType& );
DerivType sinh ( const DerivType& );
DerivType cosh ( const DerivType& );
DerivType tanh ( const DerivType& );
DerivType coth ( const DerivType& );
DerivType asinh ( const DerivType& );
DerivType acosh ( const DerivType& );
DerivType atanh ( const DerivType& );
DerivType acoth ( const DerivType& );
void fEval ( ddf_FctPtr f, cxsc::interval, cxsc::interval&);
void dfEval ( ddf_FctPtr f, cxsc::interval, cxsc::interval&, cxsc::interval& );
void ddfEval( ddf_FctPtr f, cxsc::interval, cxsc::interval&, cxsc::interval&, cxsc::interval& );
DerivType DerivConst ( const cxsc::real& );
DerivType DerivConst ( const cxsc::interval& );
DerivType DerivVar ( const cxsc::real& );
DerivType DerivVar ( const cxsc::interval& );
inline const cxsc::interval fValue ( const DerivType& u ) { return u.f; }
inline const cxsc::interval dfValue ( const DerivType& u ) { return u.df; }
inline const cxsc::interval ddfValue ( const DerivType& u ) { return u.ddf; }
#endif