casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TabVecLogic.h
Go to the documentation of this file.
00001 //# TabVecLogic.h: Global functions for table vector logical operations
00002 //# Copyright (C) 1994,1995,1999
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: TabVecLogic.h 21298 2012-12-07 14:53:03Z gervandiepen $
00027 
00028 #ifndef TABLES_TABVECLOGIC_H
00029 #define TABLES_TABVECLOGIC_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <tables/Tables/TableVector.h>
00034 #include <tables/Tables/TVecLogic.h>
00035 
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 // <summary>
00040 // Comparison between two table vectors
00041 // </summary>
00042 
00043 // <use visibility=local>
00044 
00045 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00046 // </reviewed>
00047 
00048 // <synopsis>
00049 // Element by element comparisons between the left and right table vectors.
00050 // The result is true only if the comparison is true for every element
00051 // of the table vectors.
00052 // At some point operators will be available that return masks where the
00053 // comparison is true.
00054 // The left and right operands must be conformant (i.e. have equal length).
00055 // </synopsis>
00056 
00057 // <group name=vectorComparison>
00058 template<class T> inline
00059     Bool allLE (const TableVector<T>& left, const TableVector<T>& right);
00060 template<class T> inline
00061     Bool allLT (const TableVector<T>& left, const TableVector<T>& right);
00062 template<class T> inline
00063     Bool allGE (const TableVector<T>& left, const TableVector<T>& right);
00064 template<class T> inline
00065     Bool allGT (const TableVector<T>& left, const TableVector<T>& right);
00066 template<class T> inline
00067     Bool allEQ (const TableVector<T>& left, const TableVector<T>& right);
00068 template<class T> inline
00069     Bool allNE (const TableVector<T>& left, const TableVector<T>& right);
00070 // </group>
00071 
00072 
00073 
00074 // <summary>
00075 // Comparison between a table vector and a scalar
00076 // </summary>
00077 
00078 // <use visibility=local>
00079 
00080 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
00081 // </reviewed>
00082 
00083 // <synopsis>
00084 // Element by element comparisons between a table vector and a scalar,
00085 // which behaves as if it were a conformant table vector filled with the
00086 // scalar value.
00087 // At some point operators will be available that return masks where the
00088 // comparison is true.
00089 // </synopsis>
00090 
00091 // <group name=scalarComparison>
00092 template<class T> inline
00093     Bool allLE (const TableVector<T>& left, const T& right);
00094 template<class T> inline
00095     Bool allLE (const T& left, const TableVector<T>& right);
00096 template<class T> inline
00097     Bool allLT (const TableVector<T>& left, const T& right);
00098 template<class T> inline
00099     Bool allLT (const T& left, const TableVector<T>& right);
00100 template<class T> inline
00101     Bool allGE (const TableVector<T>& left, const T& right);
00102 template<class T> inline
00103     Bool allGE (const T& left, const TableVector<T>& right);
00104 template<class T> inline
00105     Bool allGT (const TableVector<T>& left, const T& right);
00106 template<class T> inline
00107     Bool allGT (const T& left, const TableVector<T>& right);
00108 template<class T> inline
00109     Bool allEQ (const TableVector<T>& left, const T& right);
00110 template<class T> inline
00111     Bool allEQ (const T& left, const TableVector<T>& right);
00112 template<class T> inline
00113     Bool allNE (const TableVector<T>& left, const T& right);
00114 template<class T> inline
00115     Bool allNE (const T& left, const TableVector<T>& right);
00116 // </group>
00117 
00118 
00119 //# Implement all functions inline.
00120 //# The actual work is done in TVecLogic.cc.
00121 //#
00122 #define TABVECLOGICOPER(NAME) \
00123 template<class T> inline \
00124 Bool aips_name2(all,NAME) (const TableVector<T>& l, \
00125                            const TableVector<T>& r) \
00126     { return aips_name2(tabVecReptv,NAME) (l.tabVec(), r.tabVec()); } \
00127 template<class T> inline \
00128 Bool aips_name2(all,NAME) (const T& val, const TableVector<T>& tv) \
00129     { return aips_name2(tabVecRepvall,NAME) (val, tv.tabVec()); } \
00130 template<class T> inline \
00131 Bool aips_name2(all,NAME) (const TableVector<T>& tv, const T& val) \
00132     { return aips_name2(tabVecRepvalr,NAME) (tv.tabVec(), val); }
00133 
00134 TABVECLOGICOPER(LE)
00135 TABVECLOGICOPER(LT)
00136 TABVECLOGICOPER(GE)
00137 TABVECLOGICOPER(GT)
00138 TABVECLOGICOPER(EQ)
00139 TABVECLOGICOPER(NE)
00140 
00141 
00142 // 
00143 // Element by element comparisons between the "l" and "r" table vectors. The
00144 // result is true if the comparison is true for some element of the vectors.
00145 // At some point operators will be available that return masks where the
00146 // comparison is true. The vectors must conform or an exception is thrown.
00147 template<class T> inline
00148 Bool anyLE (const TableVector<T>& l, const TableVector<T>& r)
00149 {
00150     return (allGT (l, r)  ?  False : True);
00151 }
00152 template<class T> inline
00153 Bool anyLT (const TableVector<T>& l, const TableVector<T>& r)
00154 {
00155     return (allGE (l, r)  ?  False : True);
00156 }
00157 template<class T> inline
00158 Bool anyGE (const TableVector<T>& l, const TableVector<T>& r)
00159 {
00160     return (allLT (l, r)  ?  False : True);
00161 }
00162 template<class T> inline
00163 Bool anyGT (const TableVector<T>& l, const TableVector<T>& r)
00164 {
00165     return (allLE (l, r)  ?  False : True);
00166 }
00167 template<class T> inline
00168 Bool anyEQ (const TableVector<T>& l, const TableVector<T>& r)
00169 {
00170     return (allNE (l, r)  ?  False : True);
00171 }
00172 template<class T> inline
00173 Bool anyNE (const TableVector<T>& l, const TableVector<T>& r)
00174 {
00175     return (allEQ (l, r)  ?  False : True);
00176 }
00177 
00178 
00179 // 
00180 // Element by element comparisons between a table vector and a scalar, which
00181 // behaves as if it were a conformant vector filled with the value "val."
00182 // The result is true if the comparison is true for some element of the vector.
00183 // At some point operators will be available that return masks where the
00184 // comparison is true.
00185 template<class T> inline
00186 Bool anyLE (const TableVector<T>& tv, const T &val)
00187 {
00188     return (allGT (tv, val)  ?  False : True);
00189 }
00190 template<class T> inline
00191 Bool anyLE (const T &val, const TableVector<T>& tv)
00192 {
00193     return (allGT (val, tv)  ?  False : True);
00194 }
00195 template<class T> inline
00196 Bool anyLT (const TableVector<T>& tv, const T &val)
00197 {
00198     return (allGE (tv, val)  ?  False : True);
00199 }
00200 template<class T> inline
00201 Bool anyLT (const T &val, const TableVector<T>& tv)
00202 {
00203     return (allGE (val, tv)  ?  False : True);
00204 }
00205 template<class T> inline
00206 Bool anyGE (const TableVector<T>& tv, const T &val)
00207 {
00208     return (allLT (tv, val)  ?  False : True);
00209 }
00210 template<class T> inline
00211 Bool anyGE (const T &val, const TableVector<T>& tv)
00212 {
00213     return (allLT (val, tv)  ?  False : True);
00214 }
00215 template<class T> inline
00216 Bool anyGT (const TableVector<T>& tv, const T &val)
00217 {
00218     return (allLE (tv, val)  ?  False : True);
00219 }
00220 template<class T> inline
00221 Bool anyGT (const T &val, const TableVector<T>& tv)
00222 {
00223     return (allLE (val, tv)  ?  False : True);
00224 }
00225 template<class T> inline
00226 Bool anyEQ (const TableVector<T>& tv, const T &val)
00227 {
00228     return (allNE (tv, val)  ?  False : True);
00229 }
00230 template<class T> inline
00231 Bool anyEQ (const T &val, const TableVector<T>& tv)
00232 {
00233     return (allNE (val, tv)  ?  False : True);
00234 }
00235 template<class T> inline
00236 Bool anyNE (const TableVector<T>& tv, const T &val)
00237 {
00238     return (allEQ (tv, val)  ?  False : True);
00239 }
00240 template<class T> inline
00241 Bool anyNE (const T &val, const TableVector<T>& tv)
00242 {
00243     return (allEQ (val, tv)  ?  False : True);
00244 }
00245 
00246 
00247 
00248 } //# NAMESPACE CASA - END
00249 
00250 #ifndef CASACORE_NO_AUTO_TEMPLATES
00251 #include <tables/Tables/TabVecLogic.tcc>
00252 #endif //# CASACORE_NO_AUTO_TEMPLATES
00253 #endif