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