//# QMath.h: Mathematical operations for the Quantum class. //# Copyright (C) 1994,1995,1996,1998,1999,2000,2004 //# 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_QMATH_H #define CASA_QMATH_H //# Includes #include #include #include #include namespace casacore { //# NAMESPACE CASACORE - BEGIN //# Typedefs // // Mathematical operations for the Quantum class. // // // // // // //
  • Unit //
  • Quantum // // // // QMath derived from Quantum Mathematical 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 a space or a . (to indicate multiply) or a / (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 mathematical operations that can be done on // Quantum. // // They can be subdivided into various groupings: //
      //
    • Unary operations //
    • In place arithmetic functions: left hand side changed in place //
    • Arithmetic functions: return Quantum //
    • Some useful arithmetic (linear) functions //
    • Trigonometric functions //
    • Functions to implement integer ceil/floor //
    // // The operations/functions defined are: //
      //
    • unary +(Quantum) //
    • unary -(Quantum) //
    • +=Quantum; +=T; -=Quantum; -=T; //
    • *=Quantum, *=T; /=Quantum; /=T; //
    • +,-,*,/ for Quantum,Quantum; T,Quantum; Quantum,T; //
    • abs, ceil, floor(Quantum) //
    • pow(Quantum, Int); //
    • sin, cos, tan(Quantum) with proper unit handling //
    • asin, acos, atan, atan2(Quantum) with proper unit handling //
    • log, log10, exp, root, sqrt with proper unit handling //
    // // Some operators are implemented as member functions, and can be found in the // Quantum class. // //
    // // // To separate the mathematical operations from Quantum. // // // //
  • Some inlining (did not work first go) // // // Quantum mathematical operations -- Mathematical operations // for the Quantum class. // // // Unary operations // // See Quantum class // // In place arithmetic functions: left hand side changed in place // //
  • AipsError if non-conforming units (+ and -) //
  • AipsError if illegal result unit (* and /; programming error) // // // See Quantum class // // Arithmetic operators: return Quantum // //
  • AipsError if non-conforming units (+ and -) // // // See Quantum class for equal argument types template Quantum operator+(const Quantum &left, const Qtype &other); template Quantum operator+(const Qtype &left, const Quantum &other); template Quantum operator-(const Quantum &left, const Qtype &other); template Quantum operator-(const Qtype &left, const Quantum &other); template Quantum operator*(const Quantum &left, const Qtype &other); template Quantum operator*(const Qtype &left, const Quantum &other); template Quantum operator/(const Quantum &left, const Qtype &other); template Quantum operator/(const Qtype &left, const Quantum &other); // // Some useful arithmetic (linear) functions // // Return the Quantum raised to specified power; take the (integer) root; // and integerization // //
  • AipsError if power exponent too large (abs > 100) //
  • AipsError if root exponent zero // template Quantum pow(const Quantum &left, Int p); template Quantum root(const Quantum &left, Int p); template Quantum sqrt(const Quantum &left); template Quantum abs(const Quantum &left); template Quantum ceil(const Quantum &left); template Quantum floor(const Quantum &left); // // Trigonometric and exponential functions // For direct functions input should be in angles, output will be empty units. // For inverse functions input should be empty, output in radians // //
  • AipsError if incorrect units. I.e. non-angle for direct functions, // non-empty for inverse functions; non-empty for exp and log // // template Quantum sin(const Quantum &left); template Quantum cos(const Quantum &left); template Quantum tan(const Quantum &left); template Quantum asin(const Quantum &left); template Quantum acos(const Quantum &left); template Quantum atan(const Quantum &left); template Quantum atan2(const Quantum &left, const Quantum &other); template Quantum atan2(const Quantum &left, const Qtype &other); template Quantum atan2(const Qtype &left, const Quantum &other); template Quantum log(const Quantum &left); template Quantum log10(const Quantum &left); template Quantum exp(const Quantum &left); // // min and max template Quantum min(const Quantum &left, const Quantum &other); template Quantum max(const Quantum &left, const Quantum &other); // Functions to implement integer ceil/floor and others // Int ceil(const Int &val); Int floor(const Int &val); Array operator *(const Array &in, Double f); Array operator /(const Array &in, Double f); Array operator *(const Array &in, Double f); Array operator /(const Array &in, Double f); Array operator *(const Array &in, Double f); Array operator /(const Array &in, Double f); Array operator *(const Array &in, Double f); Array operator /(const Array &in, Double f); // //# Inline Implementations // } //# NAMESPACE CASACORE - END #ifndef CASACORE_NO_AUTO_TEMPLATES #include #endif //# CASACORE_NO_AUTO_TEMPLATES #endif