casacore
Loading...
Searching...
No Matches
QLogical.h
Go to the documentation of this file.
1// # QLogical.h: class to manipulate physical, dimensioned quantities
2// # Copyright (C) 1994,1995,1996,1998,1999,2000
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_QLOGICAL_H
27#define CASA_QLOGICAL_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Quanta/Quantum.h>
32#include <casacore/casa/Arrays/ArrayFwd.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward Declarations
37
38// # Typedefs
39
40// <summary>
41// Logical operations for the Quantum class.
42// </summary>
43
44// <use visibility=export>
45
46// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tQuantum">
47//
48// <prerequisite>
49// <li> <linkto class=Unit>Unit</linkto>
50// <li> <linkto class=Quantum>Quantum</linkto>
51// </prerequisite>
52//
53// <etymology>
54// QLogical derived from Quantum logical 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 'space' or '.' (to indicate multiply) or '/' (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 logical 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="QLogical.h#equality">Straight comparisons:
76// unequal if non-conforming units or different values</linkto>
77// <li> <linkto file="QLogical.h#compare">Comparisons</linkto>
78// <li> <linkto file="QLogical.h#foreign">Special make Bool routines
79// to cater for array comparisons</linkto>
80// </ul>
81//
82// The operations defined are:
83// <ul>
84// <li> Quantum<T> == Quantum<T> or ==T
85// <li> Quantum<T> != Quantum<T> or !=T
86// <li> > < >= <= of Quantum<T> or T and Quantum<T>
87// <li> near, nearAbs(Quantum<T> or T, Quantum<T> or T [, tolerance])
88// </ul>
89// </synopsis>
90//
91// <motivation>
92// To separate the logical operations from Quantum
93// </motivation>
94//
95// <todo asof="941201">
96// <li> Some inlining (did not work first go)
97// <li> Recode with allEQ etc if part of library for all data types,
98// and get rid of the special QMakeBool(), and the
99// include LogiArrayFwd.h
100// </todo>
101//
102// <linkfrom anchor="Quantum logical operations" classes="Quantum">
103// <here>Quantum logical operations</here> -- Logical operations
104// for the Quantum class.
105// </linkfrom>
106
107// <group name="Quantum logical operations">
109//
110// Straight comparisons: unequal if non-conforming units or different values
111// if units made equal. I.e. <src> 1in != 1m </src>,
112// <src> 1in != 1s </src>, <src> 36in == 1yd </src>./
113// <group name="equality">
114template <class Qtype>
115Bool operator==(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
116template <class Qtype>
117Bool operator==(const Quantum<Qtype> &left, const Qtype &other);
118template <class Qtype>
119Bool operator==(const Qtype &left, const Quantum<Qtype> &other);
120template <class Qtype>
121Bool operator!=(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
122template <class Qtype>
123Bool operator!=(const Quantum<Qtype> &left, const Qtype &other);
124template <class Qtype>
125Bool operator!=(const Qtype &left, const Quantum<Qtype> &other);
126// </group>
127
128// Near-ness tests: unequal if non-conforming units. In other cases the
129// tolerance is in the units of the first argument, with the second argument
130// converted, if necessary, to the same units as the first.
131// Note (SUN?) compiler does not accept default arguments in template functions
132// <group name="near">
133template <class Qtype>
134Bool near(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
135template <class Qtype>
136Bool near(const Quantum<Qtype> &left, const Quantum<Qtype> &other, Double tol);
137template <class Qtype>
138Bool near(const Quantum<Qtype> &left, const Qtype &other);
139template <class Qtype>
140Bool near(const Quantum<Qtype> &left, const Qtype &other, Double tol);
141template <class Qtype>
142Bool near(const Qtype &left, const Quantum<Qtype> &other);
143template <class Qtype>
144Bool near(const Qtype &left, const Quantum<Qtype> &other, Double tol);
145template <class Qtype>
146Bool nearAbs(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
147template <class Qtype>
148Bool nearAbs(const Quantum<Qtype> &left, const Quantum<Qtype> &other, Double tol);
149template <class Qtype>
150Bool nearAbs(const Quantum<Qtype> &left, const Quantum<Qtype> &other, const Quantum<Qtype> &tol);
151template <class Qtype>
152Bool nearAbs(const Quantum<Qtype> &left, const Qtype &other);
153template <class Qtype>
154Bool nearAbs(const Quantum<Qtype> &left, const Qtype &other, Double tol);
155template <class Qtype>
156Bool nearAbs(const Qtype &left, const Quantum<Qtype> &other);
157template <class Qtype>
158Bool nearAbs(const Qtype &left, const Quantum<Qtype> &other, Double tol);
159// </group>
160//
161// Comparisons. The comparisons are done on values at equal units with
162// transparent conversion if necessary.
163// <thrown>
164// <li> AipsError if non-conforming units
165// </thrown>
166// <group name="compare">
167template <class Qtype>
168Bool operator<(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
169template <class Qtype>
170Bool operator<(const Quantum<Qtype> &left, const Qtype &other);
171template <class Qtype>
172Bool operator<(const Qtype &left, const Quantum<Qtype> &other);
173template <class Qtype>
174Bool operator>(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
175template <class Qtype>
176Bool operator>(const Quantum<Qtype> &left, const Qtype &other);
177template <class Qtype>
178Bool operator>(const Qtype &left, const Quantum<Qtype> &other);
179template <class Qtype>
180Bool operator<=(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
181template <class Qtype>
182Bool operator<=(const Quantum<Qtype> &left, const Qtype &other);
183template <class Qtype>
184Bool operator<=(const Qtype &left, const Quantum<Qtype> &other);
185template <class Qtype>
186Bool operator>=(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
187template <class Qtype>
188Bool operator>=(const Quantum<Qtype> &left, const Qtype &other);
189template <class Qtype>
190Bool operator>=(const Qtype &left, const Quantum<Qtype> &other);
191// </group>
192//
193// Special make Bool routines to cater for array comparisons
194// <group name="foreign">
195Bool QMakeBool(Int val);
197// </group>
198
199// # Inline Implementations
200
201// </group>
202
203} // namespace casacore
204
205#ifndef CASACORE_NO_AUTO_TEMPLATES
206#include <casacore/casa/Quanta/QLogical.tcc>
207#endif // # CASACORE_NO_AUTO_TEMPLATES
208#endif
bool operator==(const String &x, const String &y)
Global comparison operators.
Definition String.h:849
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
bool operator<(const String &x, const String &y)
Definition String.h:853
bool operator>=(const String &x, const String &y)
Definition String.h:852
TableExprNode nearAbs(const TableExprNode &left, const TableExprNode &right)
Definition ExprNode.h:1148
Array< LogicalArrayElem > LogicalArray
Definition ArrayFwd.h:17
bool operator<=(const String &x, const String &y)
Definition String.h:854
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
bool operator>(const String &x, const String &y)
Definition String.h:851
bool operator!=(const String &x, const String &y)
Definition String.h:850
double Double
Definition aipstype.h:53
Bool near(const GaussianBeam &left, const GaussianBeam &other, const Double relWidthTol, const Quantity &absPaTol)
Bool operator==(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
Straight comparisons: unequal if non-conforming units or different values if units made equal.
Bool nearAbs(const Quantum< Qtype > &left, const Qtype &other)
Bool operator<(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
Comparisons.
Bool operator==(const Quantum< Qtype > &left, const Qtype &other)
Bool operator<=(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
Bool operator>=(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
Bool nearAbs(const Qtype &left, const Quantum< Qtype > &other, Double tol)
Bool nearAbs(const Quantum< Qtype > &left, const Quantum< Qtype > &other, const Quantum< Qtype > &tol)
Bool operator!=(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
Bool operator>=(const Qtype &left, const Quantum< Qtype > &other)
Bool operator>(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
Bool nearAbs(const Qtype &left, const Quantum< Qtype > &other)
Bool nearAbs(const Quantum< Qtype > &left, const Quantum< Qtype > &other, Double tol)
Bool near(const Quantum< Qtype > &left, const Qtype &other)
Bool operator>=(const Quantum< Qtype > &left, const Qtype &other)
Bool operator>(const Qtype &left, const Quantum< Qtype > &other)
Bool nearAbs(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
Bool nearAbs(const Quantum< Qtype > &left, const Qtype &other, Double tol)
Bool operator>(const Quantum< Qtype > &left, const Qtype &other)
Bool operator!=(const Quantum< Qtype > &left, const Qtype &other)
Bool near(const Qtype &left, const Quantum< Qtype > &other)
Bool operator<=(const Qtype &left, const Quantum< Qtype > &other)
Bool QMakeBool(Int val)
Special make Bool routines to cater for array comparisons .
Bool operator==(const Qtype &left, const Quantum< Qtype > &other)
Bool near(const Quantum< Qtype > &left, const Qtype &other, Double tol)
Bool operator<(const Qtype &left, const Quantum< Qtype > &other)
Bool operator<(const Quantum< Qtype > &left, const Qtype &other)
Bool near(const Quantum< Qtype > &left, const Quantum< Qtype > &other)
Near-ness tests: unequal if non-conforming units.
Bool near(const Quantum< Qtype > &left, const Quantum< Qtype > &other, Double tol)
Bool operator!=(const Qtype &left, const Quantum< Qtype > &other)
Bool near(const Qtype &left, const Quantum< Qtype > &other, Double tol)
Bool operator<=(const Quantum< Qtype > &left, const Qtype &other)