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 
37 namespace 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">
111 
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">
117 template <class Qtype>
118 Bool operator==(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
119 template <class Qtype>
120 Bool operator==(const Quantum<Qtype> &left, const Qtype &other);
121 template <class Qtype>
122 Bool operator==(const Qtype &left, const Quantum<Qtype> &other);
123 template <class Qtype>
124 Bool operator!=(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
125 template <class Qtype>
126 Bool operator!=(const Quantum<Qtype> &left, const Qtype &other);
127 template <class Qtype>
128 Bool 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">
136 template <class Qtype>
137 Bool near(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
138 template <class Qtype>
139 Bool near(const Quantum<Qtype> &left, const Quantum<Qtype> &other,
140  Double tol);
141 template <class Qtype>
142 Bool near(const Quantum<Qtype> &left, const Qtype &other);
143 template <class Qtype>
144 Bool near(const Quantum<Qtype> &left, const Qtype &other,
145  Double tol);
146 template <class Qtype>
147 Bool near(const Qtype &left, const Quantum<Qtype> &other);
148 template <class Qtype>
149 Bool near(const Qtype &left, const Quantum<Qtype> &other,
150  Double tol);
151 template <class Qtype>
152 Bool nearAbs(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
153 template <class Qtype>
154 Bool nearAbs(const Quantum<Qtype> &left, const Quantum<Qtype> &other,
155  Double tol);
156 template <class Qtype>
157 Bool nearAbs(const Quantum<Qtype> &left, const Quantum<Qtype> &other,
158  const Quantum<Qtype>& tol);
159 template <class Qtype>
160 Bool nearAbs(const Quantum<Qtype> &left, const Qtype &other);
161 template <class Qtype>
162 Bool nearAbs(const Quantum<Qtype> &left, const Qtype &other,
163  Double tol);
164 template <class Qtype>
165 Bool nearAbs(const Qtype &left, const Quantum<Qtype> &other);
166 template <class Qtype>
167 Bool 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">
177 template <class Qtype>
178 Bool operator<(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
179 template <class Qtype>
180 Bool operator<(const Quantum<Qtype> &left, const Qtype &other);
181 template <class Qtype>
182 Bool operator<(const Qtype &left, const Quantum<Qtype> &other);
183 template <class Qtype>
184 Bool operator>(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
185 template <class Qtype>
186 Bool operator>(const Quantum<Qtype> &left, const Qtype &other);
187 template <class Qtype>
188 Bool operator>(const Qtype &left, const Quantum<Qtype> &other);
189 template <class Qtype>
190 Bool operator<=(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
191 template <class Qtype>
192 Bool operator<=(const Quantum<Qtype> &left, const Qtype &other);
193 template <class Qtype>
194 Bool operator<=(const Qtype &left, const Quantum<Qtype> &other);
195 template <class Qtype>
196 Bool operator>=(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
197 template <class Qtype>
198 Bool operator>=(const Quantum<Qtype> &left, const Qtype &other);
199 template <class Qtype>
200 Bool 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">
205 Bool 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 QMakeBool(Int val)
Special make Bool routines to cater for array comparisons