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