casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef SCIMATH_AUTODIFFMATH_H
27#define SCIMATH_AUTODIFFMATH_H
28
29//# Includes
30
31#include <casacore/casa/aips.h>
32#include <casacore/casa/BasicMath/Math.h>
33#include <casacore/scimath/Mathematics/AutoDiff.h>
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37// <summary>
38// Implements all mathematical operators and functions for AutoDiff.
39// </summary>
40//
41// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tAutoDiff" demos="">
42// </reviewed>
43//
44// <prerequisite>
45// <li> <linkto class=AutoDiff>AutoDiff</linkto> class
46// </prerequisite>
47//
48// <etymology>
49// Implements all mathematical operators and functions for AutoDiff.
50// </etymology>
51//
52// <todo asof="20001/08/12">
53// <li> nothing I know of
54// </todo>
55
56// <group name="AutoDiff mathematical operations">
58// Unary arithmetic operators.
59// <group>
60template<class T>
62template<class T>
64// </group>
65
66// Arithmetic on two AutoDiff objects, returning an AutoDiff object
67// <group>
68template<class T>
69AutoDiff<T> operator+(const AutoDiff<T> &left, const AutoDiff<T> &right);
70template<class T>
71AutoDiff<T> operator-(const AutoDiff<T> &left, const AutoDiff<T> &right);
72template<class T>
73AutoDiff<T> operator*(const AutoDiff<T> &left, const AutoDiff<T> &right);
74template<class T>
75AutoDiff<T> operator/(const AutoDiff<T> &left, const AutoDiff<T> &right);
76// </group>
77
78// Arithmetic on an AutoDiff and a scalar, returning an AutoDiff
79// <group>
80template<class T>
81AutoDiff<T> operator+(const AutoDiff<T> &left, const T &right);
82template<class T>
83AutoDiff<T> operator-(const AutoDiff<T> &left, const T &right);
84template<class T>
85AutoDiff<T> operator*(const AutoDiff<T> &left, const T &right);
86template<class T>
87AutoDiff<T> operator/(const AutoDiff<T> &left, const T &right);
88// </group>
89
90// Arithmetic between a scalar and an AutoDiff returning an AutoDiff
91// <group>
92template<class T>
93AutoDiff<T> operator+(const T &left, const AutoDiff<T> &right);
94template<class T>
95AutoDiff<T> operator-(const T &left, const AutoDiff<T> &right);
96template<class T>
97AutoDiff<T> operator*(const T &left, const AutoDiff<T> &right);
98template<class T>
99AutoDiff<T> operator/(const T &left, const AutoDiff<T> &right);
100// </group>
101
102// Transcendental functions
103// <group>
104template<class T> AutoDiff<T> acos(const AutoDiff<T> &ad);
105template<class T> AutoDiff<T> asin(const AutoDiff<T> &ad);
106template<class T> AutoDiff<T> atan(const AutoDiff<T> &ad);
107template<class T> AutoDiff<T> atan2(const AutoDiff<T> &y,
108 const AutoDiff<T> &x);
109template<class T> AutoDiff<T> cos(const AutoDiff<T> &ad);
110template<class T> AutoDiff<T> cosh(const AutoDiff<T> &ad);
111template<class T> AutoDiff<T> exp(const AutoDiff<T> &ad);
112template<class T> AutoDiff<T> log(const AutoDiff<T> &ad);
113template<class T> AutoDiff<T> log10(const AutoDiff<T> &ad);
114template<class T> AutoDiff<T> erf(const AutoDiff<T> &ad);
115template<class T> AutoDiff<T> erfc(const AutoDiff<T> &ad);
116template<class T> AutoDiff<T> pow(const AutoDiff<T> &a,
117 const AutoDiff<T> &b);
118template<class T> AutoDiff<T> pow(const AutoDiff<T> &a, const T &b);
119template<class T> AutoDiff<T> square(const AutoDiff<T> &ad);
120template<class T> AutoDiff<T> cube(const AutoDiff<T> &ad);
121template<class T> AutoDiff<T> sin(const AutoDiff<T> &ad);
122template<class T> AutoDiff<T> sinh(const AutoDiff<T> &ad);
123template<class T> AutoDiff<T> sqrt(const AutoDiff<T> &ad);
124template<class T> AutoDiff<T> tan(const AutoDiff<T> &ad);
125template<class T> AutoDiff<T> tanh(const AutoDiff<T> &ad);
126template<class T> AutoDiff<T> abs(const AutoDiff<T> &ad);
127// </group>
128// Floating-point remainder of x/c, with the same sign as x, where c is
129// a constant.
130// <group>
131template<class T> AutoDiff<T> fmod(const AutoDiff<T> &x, const T &c);
132template<class T> AutoDiff<T> fmod(const AutoDiff<T> &x,
133 const AutoDiff<T> &c);
134// </group>
135// Floor and ceil of values
136// <group>
137template<class T> AutoDiff<T> floor(const AutoDiff<T> &ad);
138template<class T> AutoDiff<T> ceil(const AutoDiff<T> &ad);
139// </group>
140
141// Comparison operators. Only the values are compared: in the actual
142// functions, comparisons are used to decide on algorithms. To check
143// if two AutoDiff values are equal, use comparison for both
144// value and derivatives.
145// <note role=tip> To check if two AutoDiff values are equal, use the
146// member method <src>equals()</src> (e.g. for debugging and testing).
147// </note>
148// <group>
149// Compare two AutoDiff's
150template<class T> Bool operator>(const AutoDiff<T> &left,
151 const AutoDiff<T> &right);
152template<class T> Bool operator<(const AutoDiff<T> &left,
153 const AutoDiff<T> &right);
154template<class T> Bool operator>=(const AutoDiff<T> &left,
155 const AutoDiff<T> &right);
156template<class T> Bool operator<=(const AutoDiff<T> &left,
157 const AutoDiff<T> &right);
158template<class T> Bool operator==(const AutoDiff<T> &left,
159 const AutoDiff<T> &right);
160template<class T> Bool operator!=(const AutoDiff<T> &left,
161 const AutoDiff<T> &right);
162template<class T> Bool near(const AutoDiff<T> &left,
163 const AutoDiff<T> &right);
164template<class T> Bool near(const AutoDiff<T> &left,
165 const AutoDiff<T> &right, const Double tol);
166template<class T> Bool allnear(const AutoDiff<T> &left,
167 const AutoDiff<T> &right, const Double tol);
168template<class T> Bool nearAbs(const AutoDiff<T> &left,
169 const AutoDiff<T> &right, const Double tol);
170template<class T> Bool allnearAbs(const AutoDiff<T> &left,
171 const AutoDiff<T> &right, const Double tol);
172// </group>
173// Compare an AutoDiff and a constant
174// <group>
175template<class T> Bool operator>(const AutoDiff<T> &left, const T &right);
176template<class T> Bool operator<(const AutoDiff<T> &left, const T &right);
177template<class T> Bool operator>=(const AutoDiff<T> &left, const T &right);
178template<class T> Bool operator<=(const AutoDiff<T> &left, const T &right);
179template<class T> Bool operator==(const AutoDiff<T> &left, const T &right);
180template<class T> Bool operator!=(const AutoDiff<T> &left, const T &right);
181template<class T> Bool near(const AutoDiff<T> &left, const T &right);
182template<class T> Bool near(const AutoDiff<T> &left, const T &right,
183 const Double tol);
184template<class T> Bool allnear(const AutoDiff<T> &left, const T &right,
185 const Double tol);
186template<class T> Bool nearAbs(const AutoDiff<T> &left, const T &right,
187 const Double tol);
188template<class T> Bool allnearAbs(const AutoDiff<T> &left, const T &right,
189 const Double tol);
190// </group>
191// Compare a constant and an AutoDiff
192// <group>
193template<class T> Bool operator>(const T &left, const AutoDiff<T> &right);
194template<class T> Bool operator<(const T &left, const AutoDiff<T> &right);
195template<class T> Bool operator>=(const T &left, const AutoDiff<T> &right);
196template<class T> Bool operator<=(const T &left, const AutoDiff<T> &right);
197template<class T> Bool operator==(const T &left, const AutoDiff<T> &right);
198template<class T> Bool operator!=(const T &left, const AutoDiff<T> &right);
199template<class T> Bool near(const T &left, const AutoDiff<T> &right,
200 const Double tol);
201template<class T> Bool allnear(const T &left, const AutoDiff<T> &right,
202 const Double tol);
203template<class T> Bool nearAbs(const T &left, const AutoDiff<T> &right,
204 const Double tol);
205template<class T> Bool allnearAbs(const T &left, const AutoDiff<T> &right,
206 const Double tol);
207// </group>
208// Test special values
209// <group>
210template<class T> Bool isNaN(const AutoDiff<T> &val);
211template<class T> Bool isInf(AutoDiff<T> &val);
212// </group>
213// Minimum/maximum
214// <group>
215template<class T> AutoDiff<T> min(const AutoDiff<T> &left,
216 const AutoDiff<T> &right);
217template<class T> AutoDiff<T> max(const AutoDiff<T> &left,
218 const AutoDiff<T> &right);
219// </group>
220
221// </group>
222
223
224} //# NAMESPACE CASACORE - END
225
226#ifndef CASACORE_NO_AUTO_TEMPLATES
227#include <casacore/scimath/Mathematics/AutoDiffMath.tcc>
228#endif //# CASACORE_NO_AUTO_TEMPLATES
229#endif
this file contains all the compiler specific defines
Definition mainpage.dox:28
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53
AutoDiff< T > acos(const AutoDiff< T > &ad)
Transcendental functions.
Bool nearAbs(const T &left, const AutoDiff< T > &right, const Double tol)
Bool operator<=(const T &left, const AutoDiff< T > &right)
Bool near(const AutoDiff< T > &left, const AutoDiff< T > &right, const Double tol)
Bool operator<(const T &left, const AutoDiff< T > &right)
AutoDiff< T > min(const AutoDiff< T > &left, const AutoDiff< T > &right)
Minimum/maximum.
AutoDiff< T > floor(const AutoDiff< T > &ad)
Floor and ceil of values.
AutoDiff< T > operator-(const AutoDiff< T > &left, const AutoDiff< T > &right)
AutoDiff< T > fmod(const AutoDiff< T > &x, const AutoDiff< T > &c)
AutoDiff< T > operator/(const AutoDiff< T > &left, const T &right)
Bool operator>(const AutoDiff< T > &left, const AutoDiff< T > &right)
Comparison operators.
Bool operator<(const AutoDiff< T > &left, const T &right)
AutoDiff< T > max(const AutoDiff< T > &left, const AutoDiff< T > &right)
Bool operator<(const AutoDiff< T > &left, const AutoDiff< T > &right)
Bool operator>(const AutoDiff< T > &left, const T &right)
Compare an AutoDiff and a constant.
AutoDiff< T > operator*(const AutoDiff< T > &left, const AutoDiff< T > &right)
Bool near(const AutoDiff< T > &left, const T &right)
AutoDiff< T > operator/(const AutoDiff< T > &left, const AutoDiff< T > &right)
AutoDiff< T > operator-(const T &left, const AutoDiff< T > &right)
Bool nearAbs(const AutoDiff< T > &left, const AutoDiff< T > &right, const Double tol)
Bool operator>=(const T &left, const AutoDiff< T > &right)
Bool near(const T &left, const AutoDiff< T > &right, const Double tol)
AutoDiff< T > operator+(const AutoDiff< T > &left, const T &right)
Arithmetic on an AutoDiff and a scalar, returning an AutoDiff.
AutoDiff< T > pow(const AutoDiff< T > &a, const T &b)
Bool allnear(const AutoDiff< T > &left, const AutoDiff< T > &right, const Double tol)
Bool allnearAbs(const T &left, const AutoDiff< T > &right, const Double tol)
AutoDiff< T > operator+(const AutoDiff< T > &left, const AutoDiff< T > &right)
Arithmetic on two AutoDiff objects, returning an AutoDiff object.
Bool operator==(const AutoDiff< T > &left, const AutoDiff< T > &right)
Bool operator!=(const AutoDiff< T > &left, const AutoDiff< T > &right)
Bool operator>(const T &left, const AutoDiff< T > &right)
Compare a constant and an AutoDiff.
AutoDiff< T > fmod(const AutoDiff< T > &x, const T &c)
Floating-point remainder of x/c, with the same sign as x, where c is a constant.
Bool allnear(const AutoDiff< T > &left, const T &right, const Double tol)
AutoDiff< T > operator-(const AutoDiff< T > &left, const T &right)
AutoDiff< T > operator*(const T &left, const AutoDiff< T > &right)
Bool operator>=(const AutoDiff< T > &left, const T &right)
Bool operator!=(const AutoDiff< T > &left, const T &right)
Bool operator!=(const T &left, const AutoDiff< T > &right)
Bool allnearAbs(const AutoDiff< T > &left, const T &right, const Double tol)
Bool operator>=(const AutoDiff< T > &left, const AutoDiff< T > &right)
Bool operator<=(const AutoDiff< T > &left, const AutoDiff< T > &right)
Bool allnearAbs(const AutoDiff< T > &left, const AutoDiff< T > &right, const Double tol)
AutoDiff< T > atan2(const AutoDiff< T > &y, const AutoDiff< T > &x)
AutoDiff< T > operator*(const AutoDiff< T > &left, const T &right)
Bool near(const AutoDiff< T > &left, const T &right, const Double tol)
Bool operator==(const T &left, const AutoDiff< T > &right)
Bool nearAbs(const AutoDiff< T > &left, const T &right, const Double tol)
Bool operator==(const AutoDiff< T > &left, const T &right)
Bool isNaN(const AutoDiff< T > &val)
Test special values.
AutoDiff< T > operator/(const T &left, const AutoDiff< T > &right)
Bool operator<=(const AutoDiff< T > &left, const T &right)
Bool allnear(const T &left, const AutoDiff< T > &right, const Double tol)
Bool near(const AutoDiff< T > &left, const AutoDiff< T > &right)
AutoDiff< T > operator+(const T &left, const AutoDiff< T > &right)
Arithmetic between a scalar and an AutoDiff returning an AutoDiff.
AutoDiff< T > operator+(const AutoDiff< T > &other)
Unary arithmetic operators.
AutoDiff< T > pow(const AutoDiff< T > &a, const AutoDiff< T > &b)