casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AutoDiffMath.h
Go to the documentation of this file.
1 //# AutoDiffMath.h: Implements all mathematical functions for AutoDiff.
2 //# Copyright (C) 1995,1999,2001,2002,2004
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef SCIMATH_AUTODIFFMATH_H
30 #define SCIMATH_AUTODIFFMATH_H
31 
32 //# Includes
33 
34 #include <casacore/casa/aips.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 // <summary>
41 // Implements all mathematical operators and functions for AutoDiff.
42 // </summary>
43 //
44 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tAutoDiff" demos="">
45 // </reviewed>
46 //
47 // <prerequisite>
48 // <li> <linkto class=AutoDiff>AutoDiff</linkto> class
49 // </prerequisite>
50 //
51 // <etymology>
52 // Implements all mathematical operators and functions for AutoDiff.
53 // </etymology>
54 //
55 // <todo asof="20001/08/12">
56 // <li> nothing I know of
57 // </todo>
58 
59 // <group name="AutoDiff mathematical operations">
60 
61 // Unary arithmetic operators.
62 // <group>
63 template<class T>
64 AutoDiff<T> operator+(const AutoDiff<T> &other);
65 template<class T>
66 AutoDiff<T> operator-(const AutoDiff<T> &other);
67 // </group>
68 
69 // Arithmetic on two AutoDiff objects, returning an AutoDiff object
70 // <group>
71 template<class T>
72 AutoDiff<T> operator+(const AutoDiff<T> &left, const AutoDiff<T> &right);
73 template<class T>
74 AutoDiff<T> operator-(const AutoDiff<T> &left, const AutoDiff<T> &right);
75 template<class T>
76 AutoDiff<T> operator*(const AutoDiff<T> &left, const AutoDiff<T> &right);
77 template<class T>
78 AutoDiff<T> operator/(const AutoDiff<T> &left, const AutoDiff<T> &right);
79 // </group>
80 
81 // Arithmetic on an AutoDiff and a scalar, returning an AutoDiff
82 // <group>
83 template<class T>
84 AutoDiff<T> operator+(const AutoDiff<T> &left, const T &right);
85 template<class T>
86 AutoDiff<T> operator-(const AutoDiff<T> &left, const T &right);
87 template<class T>
88 AutoDiff<T> operator*(const AutoDiff<T> &left, const T &right);
89 template<class T>
90 AutoDiff<T> operator/(const AutoDiff<T> &left, const T &right);
91 // </group>
92 
93 // Arithmetic between a scalar and an AutoDiff returning an AutoDiff
94 // <group>
95 template<class T>
96 AutoDiff<T> operator+(const T &left, const AutoDiff<T> &right);
97 template<class T>
98 AutoDiff<T> operator-(const T &left, const AutoDiff<T> &right);
99 template<class T>
100 AutoDiff<T> operator*(const T &left, const AutoDiff<T> &right);
101 template<class T>
102 AutoDiff<T> operator/(const T &left, const AutoDiff<T> &right);
103 // </group>
104 
105 // Transcendental functions
106 // <group>
107 template<class T> AutoDiff<T> acos(const AutoDiff<T> &ad);
108 template<class T> AutoDiff<T> asin(const AutoDiff<T> &ad);
109 template<class T> AutoDiff<T> atan(const AutoDiff<T> &ad);
110 template<class T> AutoDiff<T> atan2(const AutoDiff<T> &y,
111  const AutoDiff<T> &x);
112 template<class T> AutoDiff<T> cos(const AutoDiff<T> &ad);
113 template<class T> AutoDiff<T> cosh(const AutoDiff<T> &ad);
114 template<class T> AutoDiff<T> exp(const AutoDiff<T> &ad);
115 template<class T> AutoDiff<T> log(const AutoDiff<T> &ad);
116 template<class T> AutoDiff<T> log10(const AutoDiff<T> &ad);
117 template<class T> AutoDiff<T> erf(const AutoDiff<T> &ad);
118 template<class T> AutoDiff<T> erfc(const AutoDiff<T> &ad);
119 template<class T> AutoDiff<T> pow(const AutoDiff<T> &a,
120  const AutoDiff<T> &b);
121 template<class T> AutoDiff<T> pow(const AutoDiff<T> &a, const T &b);
122 template<class T> AutoDiff<T> square(const AutoDiff<T> &ad);
123 template<class T> AutoDiff<T> cube(const AutoDiff<T> &ad);
124 template<class T> AutoDiff<T> sin(const AutoDiff<T> &ad);
125 template<class T> AutoDiff<T> sinh(const AutoDiff<T> &ad);
126 template<class T> AutoDiff<T> sqrt(const AutoDiff<T> &ad);
127 template<class T> AutoDiff<T> tan(const AutoDiff<T> &ad);
128 template<class T> AutoDiff<T> tanh(const AutoDiff<T> &ad);
129 template<class T> AutoDiff<T> abs(const AutoDiff<T> &ad);
130 // </group>
131 // Floating-point remainder of x/c, with the same sign as x, where c is
132 // a constant.
133 // <group>
134 template<class T> AutoDiff<T> fmod(const AutoDiff<T> &x, const T &c);
135 template<class T> AutoDiff<T> fmod(const AutoDiff<T> &x,
136  const AutoDiff<T> &c);
137 // </group>
138 // Floor and ceil of values
139 // <group>
140 template<class T> AutoDiff<T> floor(const AutoDiff<T> &ad);
141 template<class T> AutoDiff<T> ceil(const AutoDiff<T> &ad);
142 // </group>
143 
144 // Comparison operators. Only the values are compared: in the actual
145 // functions, comparisons are used to decide on algorithms. To check
146 // if two AutoDiff values are equal, use comparison for both
147 // value and derivatives.
148 // <note role=tip> To check if two AutoDiff values are equal, use the
149 // member method <src>equals()</src> (e.g. for debugging and testing).
150 // </note>
151 // <group>
152 // Compare two AutoDiff's
153 template<class T> Bool operator>(const AutoDiff<T> &left,
154  const AutoDiff<T> &right);
155 template<class T> Bool operator<(const AutoDiff<T> &left,
156  const AutoDiff<T> &right);
157 template<class T> Bool operator>=(const AutoDiff<T> &left,
158  const AutoDiff<T> &right);
159 template<class T> Bool operator<=(const AutoDiff<T> &left,
160  const AutoDiff<T> &right);
161 template<class T> Bool operator==(const AutoDiff<T> &left,
162  const AutoDiff<T> &right);
163 template<class T> Bool operator!=(const AutoDiff<T> &left,
164  const AutoDiff<T> &right);
165 template<class T> Bool near(const AutoDiff<T> &left,
166  const AutoDiff<T> &right);
167 template<class T> Bool near(const AutoDiff<T> &left,
168  const AutoDiff<T> &right, const Double tol);
169 template<class T> Bool allnear(const AutoDiff<T> &left,
170  const AutoDiff<T> &right, const Double tol);
171 template<class T> Bool nearAbs(const AutoDiff<T> &left,
172  const AutoDiff<T> &right, const Double tol);
173 template<class T> Bool allnearAbs(const AutoDiff<T> &left,
174  const AutoDiff<T> &right, const Double tol);
175 // </group>
176 // Compare an AutoDiff and a constant
177 // <group>
178 template<class T> Bool operator>(const AutoDiff<T> &left, const T &right);
179 template<class T> Bool operator<(const AutoDiff<T> &left, const T &right);
180 template<class T> Bool operator>=(const AutoDiff<T> &left, const T &right);
181 template<class T> Bool operator<=(const AutoDiff<T> &left, const T &right);
182 template<class T> Bool operator==(const AutoDiff<T> &left, const T &right);
183 template<class T> Bool operator!=(const AutoDiff<T> &left, const T &right);
184 template<class T> Bool near(const AutoDiff<T> &left, const T &right);
185 template<class T> Bool near(const AutoDiff<T> &left, const T &right,
186  const Double tol);
187 template<class T> Bool allnear(const AutoDiff<T> &left, const T &right,
188  const Double tol);
189 template<class T> Bool nearAbs(const AutoDiff<T> &left, const T &right,
190  const Double tol);
191 template<class T> Bool allnearAbs(const AutoDiff<T> &left, const T &right,
192  const Double tol);
193 // </group>
194 // Compare a constant and an AutoDiff
195 // <group>
196 template<class T> Bool operator>(const T &left, const AutoDiff<T> &right);
197 template<class T> Bool operator<(const T &left, const AutoDiff<T> &right);
198 template<class T> Bool operator>=(const T &left, const AutoDiff<T> &right);
199 template<class T> Bool operator<=(const T &left, const AutoDiff<T> &right);
200 template<class T> Bool operator==(const T &left, const AutoDiff<T> &right);
201 template<class T> Bool operator!=(const T &left, const AutoDiff<T> &right);
202 template<class T> Bool near(const T &left, const AutoDiff<T> &right,
203  const Double tol);
204 template<class T> Bool allnear(const T &left, const AutoDiff<T> &right,
205  const Double tol);
206 template<class T> Bool nearAbs(const T &left, const AutoDiff<T> &right,
207  const Double tol);
208 template<class T> Bool allnearAbs(const T &left, const AutoDiff<T> &right,
209  const Double tol);
210 // </group>
211 // Test special values
212 // <group>
213 template<class T> Bool isNaN(const AutoDiff<T> &val);
214 template<class T> Bool isInf(AutoDiff<T> &val);
215 // </group>
216 // Minimum/maximum
217 // <group>
218 template<class T> AutoDiff<T> min(const AutoDiff<T> &left,
219  const AutoDiff<T> &right);
220 template<class T> AutoDiff<T> max(const AutoDiff<T> &left,
221  const AutoDiff<T> &right);
222 // </group>
223 
224 // </group>
225 
226 
227 } //# NAMESPACE CASACORE - END
228 
229 #ifndef CASACORE_NO_AUTO_TEMPLATES
230 #include <casacore/scimath/Mathematics/AutoDiffMath.tcc>
231 #endif //# CASACORE_NO_AUTO_TEMPLATES
232 #endif
LatticeExprNode log10(const LatticeExprNode &expr)
LatticeExprNode log(const LatticeExprNode &expr)
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
Bool near(const GaussianBeam &left, const GaussianBeam &other, const Double relWidthTol, const Quantity &absPaTol)
LatticeExprNode exp(const LatticeExprNode &expr)
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
Definition: Allocator.h:129
LatticeExprNode floor(const LatticeExprNode &expr)
LatticeExprNode cos(const LatticeExprNode &expr)
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode tanh(const LatticeExprNode &expr)
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
TableExprNode isInf(const TableExprNode &node)
Definition: ExprNode.h:1626
double Double
Definition: aipstype.h:55
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type...
LatticeExprNode sqrt(const LatticeExprNode &expr)
LatticeExprNode tan(const LatticeExprNode &expr)
LatticeExprNode atan(const LatticeExprNode &expr)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Class that computes partial derivatives by automatic differentiation.
Definition: AutoDiff.h:257
TableExprNode cube(const TableExprNode &node)
Definition: ExprNode.h:1351
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
LatticeExprNode fmod(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode asin(const LatticeExprNode &expr)
LatticeExprNode sinh(const LatticeExprNode &expr)
const Double c
Fundamental physical constants (SI units):
LatticeExprNode acos(const LatticeExprNode &expr)
TableExprNode square(const TableExprNode &node)
Definition: ExprNode.h:1346
LatticeExprNode operator-(const LatticeExprNode &expr)
TableExprNode nearAbs(const TableExprNode &left, const TableExprNode &right)
Definition: ExprNode.h:1250
LatticeExprNode isNaN(const LatticeExprNode &expr)
Test if a value is a NaN.
LatticeExprNode ceil(const LatticeExprNode &expr)
LatticeExprNode pow(const LatticeExprNode &left, const LatticeExprNode &right)
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
Definition: Allocator.h:135
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
LatticeExprNode cosh(const LatticeExprNode &expr)
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.