casacore
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>
35#include <casacore/casa/BasicMath/Math.h>
36#include <casacore/scimath/Mathematics/AutoDiff.h>
37
38namespace 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">
61// Unary arithmetic operators.
62// <group>
63template<class T>
65template<class T>
67// </group>
68
69// Arithmetic on two AutoDiff objects, returning an AutoDiff object
70// <group>
71template<class T>
72AutoDiff<T> operator+(const AutoDiff<T> &left, const AutoDiff<T> &right);
73template<class T>
74AutoDiff<T> operator-(const AutoDiff<T> &left, const AutoDiff<T> &right);
75template<class T>
76AutoDiff<T> operator*(const AutoDiff<T> &left, const AutoDiff<T> &right);
77template<class T>
78AutoDiff<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>
83template<class T>
84AutoDiff<T> operator+(const AutoDiff<T> &left, const T &right);
85template<class T>
86AutoDiff<T> operator-(const AutoDiff<T> &left, const T &right);
87template<class T>
88AutoDiff<T> operator*(const AutoDiff<T> &left, const T &right);
89template<class T>
90AutoDiff<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>
95template<class T>
96AutoDiff<T> operator+(const T &left, const AutoDiff<T> &right);
97template<class T>
98AutoDiff<T> operator-(const T &left, const AutoDiff<T> &right);
99template<class T>
100AutoDiff<T> operator*(const T &left, const AutoDiff<T> &right);
101template<class T>
102AutoDiff<T> operator/(const T &left, const AutoDiff<T> &right);
103// </group>
104
105// Transcendental functions
106// <group>
107template<class T> AutoDiff<T> acos(const AutoDiff<T> &ad);
108template<class T> AutoDiff<T> asin(const AutoDiff<T> &ad);
109template<class T> AutoDiff<T> atan(const AutoDiff<T> &ad);
110template<class T> AutoDiff<T> atan2(const AutoDiff<T> &y,
111 const AutoDiff<T> &x);
112template<class T> AutoDiff<T> cos(const AutoDiff<T> &ad);
113template<class T> AutoDiff<T> cosh(const AutoDiff<T> &ad);
114template<class T> AutoDiff<T> exp(const AutoDiff<T> &ad);
115template<class T> AutoDiff<T> log(const AutoDiff<T> &ad);
116template<class T> AutoDiff<T> log10(const AutoDiff<T> &ad);
117template<class T> AutoDiff<T> erf(const AutoDiff<T> &ad);
118template<class T> AutoDiff<T> erfc(const AutoDiff<T> &ad);
119template<class T> AutoDiff<T> pow(const AutoDiff<T> &a,
120 const AutoDiff<T> &b);
121template<class T> AutoDiff<T> pow(const AutoDiff<T> &a, const T &b);
122template<class T> AutoDiff<T> square(const AutoDiff<T> &ad);
123template<class T> AutoDiff<T> cube(const AutoDiff<T> &ad);
124template<class T> AutoDiff<T> sin(const AutoDiff<T> &ad);
125template<class T> AutoDiff<T> sinh(const AutoDiff<T> &ad);
126template<class T> AutoDiff<T> sqrt(const AutoDiff<T> &ad);
127template<class T> AutoDiff<T> tan(const AutoDiff<T> &ad);
128template<class T> AutoDiff<T> tanh(const AutoDiff<T> &ad);
129template<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>
134template<class T> AutoDiff<T> fmod(const AutoDiff<T> &x, const T &c);
135template<class T> AutoDiff<T> fmod(const AutoDiff<T> &x,
136 const AutoDiff<T> &c);
137// </group>
138// Floor and ceil of values
139// <group>
140template<class T> AutoDiff<T> floor(const AutoDiff<T> &ad);
141template<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
153template<class T> Bool operator>(const AutoDiff<T> &left,
154 const AutoDiff<T> &right);
155template<class T> Bool operator<(const AutoDiff<T> &left,
156 const AutoDiff<T> &right);
157template<class T> Bool operator>=(const AutoDiff<T> &left,
158 const AutoDiff<T> &right);
159template<class T> Bool operator<=(const AutoDiff<T> &left,
160 const AutoDiff<T> &right);
161template<class T> Bool operator==(const AutoDiff<T> &left,
162 const AutoDiff<T> &right);
163template<class T> Bool operator!=(const AutoDiff<T> &left,
164 const AutoDiff<T> &right);
165template<class T> Bool near(const AutoDiff<T> &left,
166 const AutoDiff<T> &right);
167template<class T> Bool near(const AutoDiff<T> &left,
168 const AutoDiff<T> &right, const Double tol);
169template<class T> Bool allnear(const AutoDiff<T> &left,
170 const AutoDiff<T> &right, const Double tol);
171template<class T> Bool nearAbs(const AutoDiff<T> &left,
172 const AutoDiff<T> &right, const Double tol);
173template<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>
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 operator<=(const AutoDiff<T> &left, const T &right);
182template<class T> Bool operator==(const AutoDiff<T> &left, const T &right);
183template<class T> Bool operator!=(const AutoDiff<T> &left, const T &right);
184template<class T> Bool near(const AutoDiff<T> &left, const T &right);
185template<class T> Bool near(const AutoDiff<T> &left, const T &right,
186 const Double tol);
187template<class T> Bool allnear(const AutoDiff<T> &left, const T &right,
188 const Double tol);
189template<class T> Bool nearAbs(const AutoDiff<T> &left, const T &right,
190 const Double tol);
191template<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>
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 operator<=(const T &left, const AutoDiff<T> &right);
200template<class T> Bool operator==(const T &left, const AutoDiff<T> &right);
201template<class T> Bool operator!=(const T &left, const AutoDiff<T> &right);
202template<class T> Bool near(const T &left, const AutoDiff<T> &right,
203 const Double tol);
204template<class T> Bool allnear(const T &left, const AutoDiff<T> &right,
205 const Double tol);
206template<class T> Bool nearAbs(const T &left, const AutoDiff<T> &right,
207 const Double tol);
208template<class T> Bool allnearAbs(const T &left, const AutoDiff<T> &right,
209 const Double tol);
210// </group>
211// Test special values
212// <group>
213template<class T> Bool isNaN(const AutoDiff<T> &val);
214template<class T> Bool isInf(AutoDiff<T> &val);
215// </group>
216// Minimum/maximum
217// <group>
218template<class T> AutoDiff<T> min(const AutoDiff<T> &left,
219 const AutoDiff<T> &right);
220template<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
const Double c
Fundamental physical constants (SI units):
this file contains all the compiler specific defines
Definition: mainpage.dox:28
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
double Double
Definition: aipstype.h:55
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)