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// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/ArrayFwd.h>
32#include <casacore/casa/BasicSL/Complex.h>
33#include <casacore/casa/Quanta/Quantum.h>
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// # Typedefs
38
39// <summary>
40// Mathematical operations for the Quantum class.
41// </summary>
42
43// <use visibility=export>
44
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tQuantum">
46// </reviewed>
47//
48// <prerequisite>
49// <li> <linkto class=Unit>Unit</linkto>
50// <li> <linkto class=Quantum>Quantum</linkto>
51// </prerequisite>
52//
53// <etymology>
54// QMath derived from Quantum Mathematical functions
55// </etymology>
56//
57// <synopsis>
58// Quantities are values with a unit. Their basic specification can be one of
59// two forms:
60// <srcblock>
61// Quantity( Double value, String unit); // or: Unit unit
62// Quantum<Type> ( Type value, String unit) // or: Unit unit
63// </srcblock>
64//
65// A unit is a string of known unit fields separated
66// by a space or a . (to indicate multiply) or a / (to indicate divide).
67// See the <linkto class=Unit>Unit</linkto> class for details.
68// Example: km/s/(Mpc.s)2 is identical to km.s-1.Mpc-2.s-2
69//
70// This file defines the mathematical operations that can be done on
71// <linkto class=Quantum><src>Quantum<T></src></linkto>.
72//
73// They can be subdivided into various groupings:
74// <ul>
75// <li> <linkto file="QMath.h#prefix">Unary operations</linkto>
76// <li> <linkto file="QMath.h#in-place">In place arithmetic functions: left hand side changed in
77// place</linkto> <li> <linkto file="QMath.h#math">Arithmetic functions: return
78// <src>Quantum<T></src></linkto> <li> <linkto file="QMath.h#arithmetic">Some useful arithmetic
79// (linear) functions</linkto> <li> <linkto file="QMath.h#trigonometric">Trigonometric
80// functions</linkto> <li> <linkto file="QMath.h#foreign">Functions to implement integer
81// 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// Unary operations
119// <group name="prefix">
120// See <linkto class=Quantum>Quantum</linkto> class
121// </group>
122
123// In place arithmetic functions: left hand side changed in place
124// <thrown>
125// <li> AipsError if non-conforming units (+ and -)
126// <li> AipsError if illegal result unit (* and /; programming error)
127// </thrown>
128// <group name="in-place">
129// See <linkto class=Quantum>Quantum</linkto> class
130// </group>
131
132// Arithmetic operators: return Quantum<T>
133// <thrown>
134// <li> AipsError if non-conforming units (+ and -)
135// </thrown>
136// <group name="math">
137// See <linkto class=Quantum>Quantum</linkto> class for equal argument types
138template <class Qtype>
139Quantum<Qtype> operator+(const Quantum<Qtype> &left, const Qtype &other);
140template <class Qtype>
141Quantum<Qtype> operator+(const Qtype &left, const Quantum<Qtype> &other);
142template <class Qtype>
143Quantum<Qtype> operator-(const Quantum<Qtype> &left, const Qtype &other);
144template <class Qtype>
145Quantum<Qtype> operator-(const Qtype &left, const Quantum<Qtype> &other);
146template <class Qtype>
147Quantum<Qtype> operator*(const Quantum<Qtype> &left, const Qtype &other);
148template <class Qtype>
149Quantum<Qtype> operator*(const Qtype &left, const Quantum<Qtype> &other);
150template <class Qtype>
151Quantum<Qtype> operator/(const Quantum<Qtype> &left, const Qtype &other);
152template <class Qtype>
153Quantum<Qtype> operator/(const Qtype &left, const Quantum<Qtype> &other);
154// </group>
155
156// Some useful arithmetic (linear) functions
157// <group name="arithmetic">
158// Return the Quantum raised to specified power; take the (integer) root;
159// and integerization
160// <thrown>
161// <li> AipsError if power exponent too large (abs > 100)
162// <li> AipsError if root exponent zero
163// </thrown>
164template <class Qtype>
166template <class Qtype>
168template <class Qtype>
170template <class Qtype>
172template <class Qtype>
174template <class Qtype>
176// </group>
177
178// Trigonometric and exponential functions
179// For direct functions input should be in angles, output will be empty units.
180// For inverse functions input should be empty, output in radians
181// <thrown>
182// <li> AipsError if incorrect units. I.e. non-angle for direct functions,
183// non-empty for inverse functions; non-empty for exp and log
184// </thrown>
185// <group name="trigonometric">
186template <class Qtype>
188template <class Qtype>
190template <class Qtype>
192template <class Qtype>
194template <class Qtype>
196template <class Qtype>
198template <class Qtype>
199Quantum<Qtype> atan2(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
200template <class Qtype>
201Quantum<Qtype> atan2(const Quantum<Qtype> &left, const Qtype &other);
202template <class Qtype>
203Quantum<Qtype> atan2(const Qtype &left, const Quantum<Qtype> &other);
204template <class Qtype>
206template <class Qtype>
208template <class Qtype>
210// </group>
211
212// min and max
213template <class Qtype>
215template <class Qtype>
217
218// Functions to implement integer ceil/floor and others
219// <group name="foreign">
220Int ceil(const Int &val);
221Int floor(const Int &val);
230// </group>
231// # Inline Implementations
232
233// </group>
234
235} // namespace casacore
236
237#ifndef CASACORE_NO_AUTO_TEMPLATES
238#include <casacore/casa/Quanta/QMath.tcc>
239#endif // # CASACORE_NO_AUTO_TEMPLATES
240#endif
String operator+(const String &lhs, const String &rhs)
Global concatenation operators.
Definition String.h:816
For temporary backward namespace compatibility, use casa as alias for casacore.
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)
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)
T & operator*()
Provide access to the field's value.
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)
Array< Complex > operator/(const Array< Complex > &in, Double f)
Quantum< Qtype > atan2(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
Quantum< Qtype > log(const Quantum< Qtype > &left)
Array< Complex > operator*(const Array< Complex > &in, Double f)
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)
Array< DComplex > operator/(const Array< DComplex > &in, Double f)
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)
Array< DComplex > operator*(const Array< DComplex > &in, Double f)
Array< Float > operator/(const Array< Float > &in, Double f)
Quantum< Qtype > operator*(const Qtype &left, const Quantum< Qtype > &other)
Array< Int > operator*(const Array< Int > &in, Double f)
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)
Array< Int > operator/(const Array< Int > &in, Double f)
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)
Array< Float > operator*(const Array< Float > &in, Double f)