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