casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QLogical.h
Go to the documentation of this file.
00001 //# QLogical.h: class to manipulate physical, dimensioned quantities
00002 //# Copyright (C) 1994,1995,1996,1998,1999,2000
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: QLogical.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_QLOGICAL_H
00029 #define CASA_QLOGICAL_H
00030 
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/Quanta/Quantum.h>
00035 #include <casa/Arrays/LogiArrayFwd.h>
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 //# Forward Declarations
00040 
00041 //# Typedefs
00042 
00043 // <summary>
00044 //   Logical operations for the Quantum class.
00045 // </summary>
00046 
00047 // <use visibility=export>
00048 
00049 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tQuantum">
00050 //
00051 // <prerequisite>
00052 //   <li> <linkto class=Unit>Unit</linkto>
00053 //   <li> <linkto class=Quantum>Quantum</linkto>
00054 // </prerequisite>
00055 //
00056 // <etymology>
00057 // QLogical derived from Quantum logical functions
00058 // </etymology>
00059 //
00060 // <synopsis> 
00061 // Quantities are values with a unit. Their basic specification can be one of
00062 // two forms:
00063 // <srcblock>
00064 // Quantity( Double value, String unit);        // or: Unit unit
00065 // Quantum<Type> ( Type value, String unit)     // or: Unit unit
00066 // </srcblock>
00067 //
00068 // A unit is a string of known unit fields separated
00069 // by 'space' or '.' (to indicate multiply) or '/' (to indicate divide).
00070 // See the <linkto class=Unit>Unit</linkto> class for details.
00071 // Example: km/s/(Mpc.s)2  is identical to km.s-1.Mpc-2.s-2
00072 //
00073 // This file defines the logical operations that can be done on
00074 // <linkto class=Quantum><src>Quantum<T></src></linkto>.
00075 //
00076 // They can be subdivided into various groupings:
00077 // <ul>
00078 //   <li> <linkto file="QLogical.h#equality">Straight comparisons: 
00079 //          unequal if non-conforming units or different values</linkto>
00080 //   <li> <linkto file="QLogical.h#compare">Comparisons</linkto>
00081 //   <li> <linkto file="QLogical.h#foreign">Special make Bool routines
00082 //                to cater for array comparisons</linkto>
00083 // </ul>
00084 //
00085 // The operations defined are:
00086 // <ul>
00087 //   <li> Quantum<T> == Quantum<T> or ==T 
00088 //   <li> Quantum<T> != Quantum<T> or !=T 
00089 //   <li> > < >= <= of Quantum<T> or T and Quantum<T>
00090 //   <li> near, nearAbs(Quantum<T> or T, Quantum<T> or T [, tolerance]) 
00091 // </ul>
00092 // </synopsis> 
00093 //
00094 // <motivation>
00095 // To separate the logical operations from Quantum
00096 // </motivation>
00097 //
00098 // <todo asof="941201">
00099 //   <li> Some inlining (did not work first go)
00100 //   <li> Recode with allEQ etc if part of library for all data types,
00101 //              and get rid of the special QMakeBool(), and the
00102 //              include LogiArrayFwd.h
00103 // </todo>
00104 //
00105 // <linkfrom anchor="Quantum logical operations" classes="Quantum">
00106 //   <here>Quantum logical operations</here> -- Logical operations
00107 //   for the Quantum class.
00108 // </linkfrom>
00109 
00110 // <group name="Quantum logical operations">
00111 
00112 //
00113 // Straight comparisons: unequal if non-conforming units or different values
00114 // if units made equal. I.e. <src> 1in != 1m </src>,
00115 // <src> 1in != 1s </src>, <src> 36in == 1yd </src>./
00116 // <group name="equality">
00117 template <class Qtype>
00118 Bool operator==(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
00119 template <class Qtype>
00120 Bool operator==(const Quantum<Qtype> &left, const Qtype &other);
00121 template <class Qtype>
00122 Bool operator==(const Qtype &left, const Quantum<Qtype> &other);
00123 template <class Qtype>
00124 Bool operator!=(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
00125 template <class Qtype>
00126 Bool operator!=(const Quantum<Qtype> &left, const Qtype &other);
00127 template <class Qtype>
00128 Bool operator!=(const Qtype &left, const Quantum<Qtype> &other);
00129 // </group>
00130 
00131 // Near-ness tests: unequal if non-conforming units. In other cases the
00132 // tolerance is in the units of the first argument, with the second argument
00133 // converted, if necessary, to the same units as the first.
00134 // Note (SUN?) compiler does not accept default arguments in template functions
00135 // <group name="near">
00136 template <class Qtype>
00137 Bool near(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
00138 template <class Qtype>
00139 Bool near(const Quantum<Qtype> &left, const Quantum<Qtype> &other,
00140           Double tol);
00141 template <class Qtype>
00142 Bool near(const Quantum<Qtype> &left, const Qtype &other);
00143 template <class Qtype>
00144 Bool near(const Quantum<Qtype> &left, const Qtype &other,
00145           Double tol);
00146 template <class Qtype>
00147 Bool near(const Qtype &left, const Quantum<Qtype> &other);
00148 template <class Qtype>
00149 Bool near(const Qtype &left, const Quantum<Qtype> &other,
00150           Double tol);
00151 template <class Qtype>
00152 Bool nearAbs(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
00153 template <class Qtype>
00154 Bool nearAbs(const Quantum<Qtype> &left, const Quantum<Qtype> &other,
00155           Double tol);
00156 template <class Qtype>
00157 Bool nearAbs(const Quantum<Qtype> &left, const Quantum<Qtype> &other,
00158           const Quantum<Qtype>& tol);
00159 template <class Qtype>
00160 Bool nearAbs(const Quantum<Qtype> &left, const Qtype &other);
00161 template <class Qtype>
00162 Bool nearAbs(const Quantum<Qtype> &left, const Qtype &other,
00163           Double tol);
00164 template <class Qtype>
00165 Bool nearAbs(const Qtype &left, const Quantum<Qtype> &other);
00166 template <class Qtype>
00167 Bool nearAbs(const Qtype &left, const Quantum<Qtype> &other,
00168           Double tol);
00169 // </group>
00170 //
00171 // Comparisons. The comparisons are done on values at equal units with
00172 // transparent conversion if necessary.
00173 // <thrown>
00174 //   <li> AipsError if non-conforming units
00175 // </thrown>
00176 // <group name="compare">
00177 template <class Qtype>
00178 Bool operator<(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
00179 template <class Qtype>
00180 Bool operator<(const Quantum<Qtype> &left, const Qtype &other);
00181 template <class Qtype>
00182 Bool operator<(const Qtype &left, const Quantum<Qtype> &other);
00183 template <class Qtype>
00184 Bool operator>(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
00185 template <class Qtype>
00186 Bool operator>(const Quantum<Qtype> &left, const Qtype &other);
00187 template <class Qtype>
00188 Bool operator>(const Qtype &left, const Quantum<Qtype> &other);
00189 template <class Qtype>
00190 Bool operator<=(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
00191 template <class Qtype>
00192 Bool operator<=(const Quantum<Qtype> &left, const Qtype &other);
00193 template <class Qtype>
00194 Bool operator<=(const Qtype &left, const Quantum<Qtype> &other);
00195 template <class Qtype>
00196 Bool operator>=(const Quantum<Qtype> &left, const Quantum<Qtype> &other);
00197 template <class Qtype>
00198 Bool operator>=(const Quantum<Qtype> &left, const Qtype &other);
00199 template <class Qtype>
00200 Bool operator>=(const Qtype &left, const Quantum<Qtype> &other);
00201 // </group>
00202 //
00203 // Special make Bool routines to cater for array comparisons
00204 // <group name="foreign">
00205 Bool QMakeBool(Int val);
00206 Bool QMakeBool(const LogicalArray &val);
00207 // </group>
00208 
00209 //# Inline Implementations
00210 
00211 // </group>
00212 
00213 
00214 } //# NAMESPACE CASA - END
00215 
00216 #ifndef CASACORE_NO_AUTO_TEMPLATES
00217 #include <casa/Quanta/QLogical.tcc>
00218 #endif //# CASACORE_NO_AUTO_TEMPLATES
00219 #endif