casacore
QMath.h
Go to the documentation of this file.
1 //# QMath.h: Mathematical operations for the Quantum class.
2 //# Copyright (C) 1994,1995,1996,1998,1999,2000,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 //# $Id$
27 
28 #ifndef CASA_QMATH_H
29 #define CASA_QMATH_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/casa/Arrays/ArrayFwd.h>
35 #include <casacore/casa/BasicSL/Complex.h>
36 #include <casacore/casa/Quanta/Quantum.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Typedefs
41 
42 // <summary>
43 // Mathematical operations for the Quantum class.
44 // </summary>
45 
46 // <use visibility=export>
47 
48 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tQuantum">
49 //
50 // <prerequisite>
51 // <li> <linkto class=Unit>Unit</linkto>
52 // <li> <linkto class=Quantum>Quantum</linkto>
53 // </prerequisite>
54 //
55 // <etymology>
56 // QMath derived from Quantum Mathematical functions
57 // </etymology>
58 //
59 // <synopsis>
60 // Quantities are values with a unit. Their basic specification can be one of
61 // two forms:
62 // <srcblock>
63 // Quantity( Double value, String unit); // or: Unit unit
64 // Quantum<Type> ( Type value, String unit) // or: Unit unit
65 // </srcblock>
66 //
67 // A unit is a string of known unit fields separated
68 // by 'space' or '.' (to indicate multiply) or '/' (to indicate divide).
69 // See the <linkto class=Unit>Unit</linkto> class for details.
70 // Example: km/s/(Mpc.s)2 is identical to km.s-1.Mpc-2.s-2
71 //
72 // This file defines the mathematical operations that can be done on
73 // <linkto class=Quantum><src>Quantum<T></src></linkto>.
74 //
75 // They can be subdivided into various groupings:
76 // <ul>
77 // <li> <linkto file="QMath.h#prefix">Unary operations</linkto>
78 // <li> <linkto file="QMath.h#in-place">In place arithmetic functions: left hand side changed in place</linkto>
79 // <li> <linkto file="QMath.h#math">Arithmetic functions: return <src>Quantum<T></src></linkto>
80 // <li> <linkto file="QMath.h#arithmetic">Some useful arithmetic (linear) functions</linkto>
81 // <li> <linkto file="QMath.h#trigonometric">Trigonometric functions</linkto>
82 // <li> <linkto file="QMath.h#foreign">Functions to implement integer ceil/floor</linkto>
83 // </ul>
84 //
85 // The operations/functions defined are:
86 // <ul>
87 // <li> unary <src>+(Quantum<T>)</src>
88 // <li> unary <src>-(Quantum<T>)</src>
89 // <li> <src>+=Quantum<T>; +=T; -=Quantum<T>; -=T;</src>
90 // <li> <src>*=Quantum<T>, *=T; /=Quantum<T>; /=T;</src>
91 // <li> <src>+/-/*//</src> for <src>Quantum<T>,Quantum<T>; T,Quantum<T>; Quantum<T>,T;</src>
92 // <li> <src>abs, ceil, floor(Quantum<T>)</src>
93 // <li> <src>pow(Quantum<T>, Int);</src>
94 // <li> <src>sin, cos, tan(Quantum<T>)</src> with proper unit handling
95 // <li> <src>asin, acos, atan, atan2(Quantum<T>)</src> with proper unit handling
96 // <li> <src>log, log10, exp, root, sqrt</src> with proper unit handling
97 // </ul>
98 // <note role=warning>
99 // Some operators are implemented as member functions, and can be found in the
100 // <linkto class=Quantum>Quantum</linkto> class.
101 // </note>
102 // </synopsis>
103 //
104 // <motivation>
105 // To separate the mathematical operations from Quantum.
106 // </motivation>
107 //
108 // <todo asof="941201">
109 // <li> Some inlining (did not work first go)
110 // </todo>
111 
112 // <linkfrom anchor="Quantum mathematical operations" classes="Quantum">
113 // <here>Quantum mathematical operations</here> -- Mathematical operations
114 // for the Quantum class.
115 // </linkfrom>
116 
117 // <group name="Quantum mathematical operations">
118 
119 
120 // Unary operations
121 // <group name="prefix">
122 // See <linkto class=Quantum>Quantum</linkto> class
123 // </group>
124 
125 
126 // In place arithmetic functions: left hand side changed in place
127 // <thrown>
128 // <li> AipsError if non-conforming units (+ and -)
129 // <li> AipsError if illegal result unit (* and /; programming error)
130 // </thrown>
131 // <group name="in-place">
132 // See <linkto class=Quantum>Quantum</linkto> class
133 // </group>
134 
135 
136 // Arithmetic operators: return Quantum<T>
137 // <thrown>
138 // <li> AipsError if non-conforming units (+ and -)
139 // </thrown>
140 // <group name="math">
141 // See <linkto class=Quantum>Quantum</linkto> class for equal argument types
142 template <class Qtype>
143 Quantum<Qtype> operator+(const Quantum<Qtype> &left, const Qtype &other);
144 template <class Qtype>
145 Quantum<Qtype> operator+(const Qtype &left, const Quantum<Qtype> &other);
146 template <class Qtype>
147 Quantum<Qtype> operator-(const Quantum<Qtype> &left, const Qtype &other);
148 template <class Qtype>
149 Quantum<Qtype> operator-(const Qtype &left, const Quantum<Qtype> &other);
150 template <class Qtype>
151 Quantum<Qtype> operator*(const Quantum<Qtype> &left, const Qtype &other);
152 template <class Qtype>
153 Quantum<Qtype> operator*(const Qtype &left, const Quantum<Qtype> &other);
154 template <class Qtype>
155 Quantum<Qtype> operator/(const Quantum<Qtype> &left, const Qtype &other);
156 template <class Qtype>
157 Quantum<Qtype> operator/(const Qtype &left, const Quantum<Qtype> &other);
158 // </group>
159 
160 
161 // Some useful arithmetic (linear) functions
162 // <group name="arithmetic">
163 // Return the Quantum raised to specified power; take the (integer) root;
164 // and integerization
165 // <thrown>
166 // <li> AipsError if power exponent too large (abs > 100)
167 // <li> AipsError if root exponent zero
168 // </thrown>
169 template <class Qtype>
171 template <class Qtype>
173 template <class Qtype>
175 template <class Qtype>
177 template <class Qtype>
179 template <class Qtype>
181 // </group>
182 
183 
184 // Trigonometric and exponential functions
185 // For direct functions input should be in angles, output will be empty units.
186 // For inverse functions input should be empty, output in radians
187 // <thrown>
188 // <li> AipsError if incorrect units. I.e. non-angle for direct functions,
189 // non-empty for inverse functions; non-empty for exp and log
190 // </thrown>
191 // <group name="trigonometric">
192 template <class Qtype>
193 Quantum<Qtype> sin(const Quantum<Qtype> &left);
194 template <class Qtype>
195 Quantum<Qtype> cos(const Quantum<Qtype> &left);
196 template <class Qtype>
197 Quantum<Qtype> tan(const Quantum<Qtype> &left);
198 template <class Qtype>
199 Quantum<Qtype> asin(const Quantum<Qtype> &left);
200 template <class Qtype>
201 Quantum<Qtype> acos(const Quantum<Qtype> &left);
202 template <class Qtype>
203 Quantum<Qtype> atan(const Quantum<Qtype> &left);
204 template <class Qtype>
205 Quantum<Qtype> atan2(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
206 template <class Qtype>
207 Quantum<Qtype> atan2(const Quantum<Qtype> &left, const Qtype &other);
208 template <class Qtype>
209 Quantum<Qtype> atan2(const Qtype &left, const Quantum<Qtype> &other);
210 template <class Qtype>
211 Quantum<Qtype> log(const Quantum<Qtype> &left);
212 template <class Qtype>
213 Quantum<Qtype> log10(const Quantum<Qtype> &left);
214 template <class Qtype>
215 Quantum<Qtype> exp(const Quantum<Qtype> &left);
216 // </group>
217 
218 
219 // min and max
220 template <class Qtype>
221 Quantum<Qtype> min(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
222 template <class Qtype>
223 Quantum<Qtype> max(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
224 
225 
226 // Functions to implement integer ceil/floor and others
227 // <group name="foreign">
228 Int ceil(const Int &val);
229 Int floor(const Int &val);
238 // </group>
239 //# Inline Implementations
240 
241 // </group>
242 
243 
244 } //# NAMESPACE CASACORE - END
245 
246 #ifndef CASACORE_NO_AUTO_TEMPLATES
247 #include <casacore/casa/Quanta/QMath.tcc>
248 #endif //# CASACORE_NO_AUTO_TEMPLATES
249 #endif
this file contains all the compiler specific defines
Definition: mainpage.dox:28
LatticeExprNode exp(const LatticeExprNode &expr)
LatticeExprNode asin(const LatticeExprNode &expr)
LatticeExprNode acos(const LatticeExprNode &expr)
LatticeExprNode atan(const LatticeExprNode &expr)
LatticeExprNode log10(const LatticeExprNode &expr)
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
LatticeExprNode operator-(const LatticeExprNode &expr)
LatticeExprNode tan(const LatticeExprNode &expr)
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
LatticeExprNode log(const LatticeExprNode &expr)
int Int
Definition: aipstype.h:50
LatticeExprNode cos(const LatticeExprNode &expr)
LatticeExprNode floor(const LatticeExprNode &expr)
double Double
Definition: aipstype.h:55
LatticeExprNode ceil(const LatticeExprNode &expr)
Quantum< Qtype > pow(const Quantum< Qtype > &left, Int p)
Some useful arithmetic (linear) functions
Quantum< Qtype > floor(const Quantum< Qtype > &left)
Quantum< Qtype > ceil(const Quantum< Qtype > &left)
Quantum< Qtype > sqrt(const Quantum< Qtype > &left)
Quantum< Qtype > max(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
Quantum< Qtype > abs(const Quantum< Qtype > &left)
Quantum< Qtype > min(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
min and max
Quantum< Qtype > root(const Quantum< Qtype > &left, Int p)