//# QLogical.h: class to manipulate physical, dimensioned quantities //# Copyright (C) 1994,1995,1996,1998,1999,2000 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id$ #ifndef CASA_QLOGICAL_H #define CASA_QLOGICAL_H //# Includes #include #include #include namespace casacore { //# NAMESPACE CASACORE - BEGIN //# Forward Declarations //# Typedefs // // Logical operations for the Quantum class. // // // // // //
  • Unit //
  • Quantum // // // // QLogical derived from Quantum logical functions // // // // Quantities are values with a unit. Their basic specification can be one of // two forms: // // Quantity( Double value, String unit); // or: Unit unit // Quantum ( Type value, String unit) // or: Unit unit // // // A unit is a string of known unit fields separated // by 'space' or '.' (to indicate multiply) or '/' (to indicate divide). // See the Unit class for details. // Example: km/s/(Mpc.s)2 is identical to km.s-1.Mpc-2.s-2 // // This file defines the logical operations that can be done on // Quantum. // // They can be subdivided into various groupings: //
      //
    • Straight comparisons: // unequal if non-conforming units or different values //
    • Comparisons //
    • Special make Bool routines // to cater for array comparisons //
    // // The operations defined are: //
      //
    • Quantum == Quantum or ==T //
    • Quantum != Quantum or !=T //
    • > < >= <= of Quantum or T and Quantum //
    • near, nearAbs(Quantum or T, Quantum or T [, tolerance]) //
    //
    // // // To separate the logical operations from Quantum // // // //
  • Some inlining (did not work first go) //
  • Recode with allEQ etc if part of library for all data types, // and get rid of the special QMakeBool(), and the // include LogiArrayFwd.h // // // // Quantum logical operations -- Logical operations // for the Quantum class. // // // // Straight comparisons: unequal if non-conforming units or different values // if units made equal. I.e. 1in != 1m , // 1in != 1s , 36in == 1yd ./ // template Bool operator==(const Quantum &left, const Quantum &other); template Bool operator==(const Quantum &left, const Qtype &other); template Bool operator==(const Qtype &left, const Quantum &other); template Bool operator!=(const Quantum &left, const Quantum &other); template Bool operator!=(const Quantum &left, const Qtype &other); template Bool operator!=(const Qtype &left, const Quantum &other); // // Near-ness tests: unequal if non-conforming units. In other cases the // tolerance is in the units of the first argument, with the second argument // converted, if necessary, to the same units as the first. // Note (SUN?) compiler does not accept default arguments in template functions // template Bool near(const Quantum &left, const Quantum &other); template Bool near(const Quantum &left, const Quantum &other, Double tol); template Bool near(const Quantum &left, const Qtype &other); template Bool near(const Quantum &left, const Qtype &other, Double tol); template Bool near(const Qtype &left, const Quantum &other); template Bool near(const Qtype &left, const Quantum &other, Double tol); template Bool nearAbs(const Quantum &left, const Quantum &other); template Bool nearAbs(const Quantum &left, const Quantum &other, Double tol); template Bool nearAbs(const Quantum &left, const Quantum &other, const Quantum& tol); template Bool nearAbs(const Quantum &left, const Qtype &other); template Bool nearAbs(const Quantum &left, const Qtype &other, Double tol); template Bool nearAbs(const Qtype &left, const Quantum &other); template Bool nearAbs(const Qtype &left, const Quantum &other, Double tol); // // // Comparisons. The comparisons are done on values at equal units with // transparent conversion if necessary. // //
  • AipsError if non-conforming units // // template Bool operator<(const Quantum &left, const Quantum &other); template Bool operator<(const Quantum &left, const Qtype &other); template Bool operator<(const Qtype &left, const Quantum &other); template Bool operator>(const Quantum &left, const Quantum &other); template Bool operator>(const Quantum &left, const Qtype &other); template Bool operator>(const Qtype &left, const Quantum &other); template Bool operator<=(const Quantum &left, const Quantum &other); template Bool operator<=(const Quantum &left, const Qtype &other); template Bool operator<=(const Qtype &left, const Quantum &other); template Bool operator>=(const Quantum &left, const Quantum &other); template Bool operator>=(const Quantum &left, const Qtype &other); template Bool operator>=(const Qtype &left, const Quantum &other); // // // Special make Bool routines to cater for array comparisons // Bool QMakeBool(Int val); Bool QMakeBool(const LogicalArray &val); // //# Inline Implementations // } //# NAMESPACE CASACORE - END #ifndef CASACORE_NO_AUTO_TEMPLATES #include #endif //# CASACORE_NO_AUTO_TEMPLATES #endif