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