casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SparseDiffMath.h
Go to the documentation of this file.
00001 //# SparseDiffMath.h: Implements all mathematical functions for SparseDiff.
00002 //# Copyright (C) 2007
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 //#
00027 //# $Id: SparseDiffMath.h,v 1.1 2007/11/16 04:34:46 wbrouw Exp $
00028 
00029 #ifndef SCIMATH_SPARSEDIFFMATH_H
00030 #define SCIMATH_SPARSEDIFFMATH_H
00031 
00032 //# Includes
00033 
00034 #include <casa/aips.h>
00035 #include <casa/BasicMath/Math.h>
00036 #include <scimath/Mathematics/SparseDiff.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040   // <summary>
00041   // Implements all mathematical operators and functions for SparseDiff.
00042   // </summary>
00043   //
00044   // <reviewed reviewer="UNKNOWN" date="" tests="tSparseDiff" demos="">
00045   // </reviewed>
00046   //
00047   // <prerequisite>
00048   // <li> <linkto class=SparseDiff>SparseDiff</linkto> class
00049   // </prerequisite>
00050   //
00051   // <etymology>
00052   // Implements all mathematical operators and functions for SparseDiff.
00053   // </etymology>
00054   //
00055   // <todo asof="20001/08/12">
00056   //  <li> nothing I know of
00057   // </todo>
00058  
00059   // <group name="SparseDiff mathematical operations">
00060 
00061   // Unary arithmetic operators.
00062   // <group>
00063   template<class T>
00064   SparseDiff<T> operator+(const SparseDiff<T> &other);
00065   template<class T>
00066   SparseDiff<T> operator-(const SparseDiff<T> &other);
00067   // </group>
00068 
00069   // Arithmetic on two SparseDiff objects, returning a SparseDiff object
00070   // <group>
00071   template<class T> 
00072   SparseDiff<T> operator+(const SparseDiff<T> &left, const SparseDiff<T> &right);
00073   template<class T> 
00074   SparseDiff<T> operator-(const SparseDiff<T> &left, const SparseDiff<T> &right);
00075   template<class T> 
00076   SparseDiff<T> operator*(const SparseDiff<T> &left, const SparseDiff<T> &right);
00077   template<class T> 
00078   SparseDiff<T> operator/(const SparseDiff<T> &left, const SparseDiff<T> &right);
00079   // </group>
00080 
00081   // Arithmetic on a SparseDiff and a scalar, returning a SparseDiff
00082   // <group>
00083   template<class T> 
00084   SparseDiff<T> operator+(const SparseDiff<T> &left, const T &right);
00085   template<class T> 
00086   SparseDiff<T> operator-(const SparseDiff<T> &left, const T &right);
00087   template<class T> 
00088   SparseDiff<T> operator*(const SparseDiff<T> &left, const T &right);
00089   template<class T> 
00090   SparseDiff<T> operator/(const SparseDiff<T> &left, const T &right);
00091   // </group>
00092 
00093   // Arithmetic between a scalar and a SparseDiff returning a SparseDiff
00094   // <group>
00095   template<class T> 
00096   SparseDiff<T> operator+(const T &left, const SparseDiff<T> &right);
00097   template<class T> 
00098   SparseDiff<T> operator-(const T &left, const SparseDiff<T> &right);
00099   template<class T> 
00100   SparseDiff<T> operator*(const T &left, const SparseDiff<T> &right);
00101   template<class T> 
00102   SparseDiff<T> operator/(const T &left, const SparseDiff<T> &right);
00103   // </group>
00104 
00105   // Transcendental functions
00106   // <group>
00107   template<class T> SparseDiff<T> acos(const SparseDiff<T> &ad);
00108   template<class T> SparseDiff<T> asin(const SparseDiff<T> &ad);
00109   template<class T> SparseDiff<T> atan(const SparseDiff<T> &ad);
00110   template<class T> SparseDiff<T> atan2(const SparseDiff<T> &y, 
00111                                         const SparseDiff<T> &x);
00112   template<class T> SparseDiff<T> cos(const SparseDiff<T> &ad);
00113   template<class T> SparseDiff<T> cosh(const SparseDiff<T> &ad);
00114   template<class T> SparseDiff<T> exp(const SparseDiff<T> &ad);
00115   template<class T> SparseDiff<T> log(const SparseDiff<T> &ad);
00116   template<class T> SparseDiff<T> log10(const SparseDiff<T> &ad);
00117   template<class T> SparseDiff<T> erf(const SparseDiff<T> &ad);
00118   template<class T> SparseDiff<T> erfc(const SparseDiff<T> &ad);
00119   template<class T> SparseDiff<T> pow(const SparseDiff<T> &a, 
00120                                       const SparseDiff<T> &b);
00121   template<class T> SparseDiff<T> pow(const SparseDiff<T> &a, const T &b);
00122   template<class T> SparseDiff<T> square(const SparseDiff<T> &ad);
00123   template<class T> SparseDiff<T> cube(const SparseDiff<T> &ad);
00124   template<class T> SparseDiff<T> sin(const SparseDiff<T> &ad);
00125   template<class T> SparseDiff<T> sinh(const SparseDiff<T> &ad);
00126   template<class T> SparseDiff<T> sqrt(const SparseDiff<T> &ad);
00127   template<class T> SparseDiff<T> tan(const SparseDiff<T> &ad);
00128   template<class T> SparseDiff<T> tanh(const SparseDiff<T> &ad);
00129   template<class T> SparseDiff<T> abs(const SparseDiff<T> &ad);
00130   // </group>
00131   // Floating-point remainder of x/c, with the same sign as x, where c is
00132   // a constant.
00133   // <group>
00134   template<class T> SparseDiff<T> fmod(const SparseDiff<T> &x, const T &c);
00135   template<class T> SparseDiff<T> fmod(const SparseDiff<T> &x,
00136                                        const SparseDiff<T> &c);
00137   // </group>
00138   // Floor and ceil of values
00139   // <group>
00140   template<class T> SparseDiff<T> floor(const SparseDiff<T> &ad);
00141   template<class T> SparseDiff<T> ceil(const SparseDiff<T> &ad);
00142   // </group>
00143  
00144   // Comparison operators.  Only the values are compared: in the actual
00145   // functions, comparisons are used to decide on algorithms. To check
00146   // if two SparseDiff values are equal, use comparison for both 
00147   // value and derivatives.
00148   // <note role=tip> To check if two SparseDiff values are equal, use the
00149   // member method <src>equals()</src> (e.g. for debugging and testing).
00150   // </note>
00151   // <group>
00152   // Compare two SparseDiff's
00153   template<class T> Bool operator>(const SparseDiff<T> &left,
00154                                    const SparseDiff<T> &right);
00155   template<class T> Bool operator<(const SparseDiff<T> &left,
00156                                    const SparseDiff<T> &right);
00157   template<class T> Bool operator>=(const SparseDiff<T> &left,
00158                                     const SparseDiff<T> &right);
00159   template<class T> Bool operator<=(const SparseDiff<T> &left,
00160                                     const SparseDiff<T> &right);
00161   template<class T> Bool operator==(const SparseDiff<T> &left,
00162                                     const SparseDiff<T> &right);
00163   template<class T> Bool operator!=(const SparseDiff<T> &left,
00164                                     const SparseDiff<T> &right);
00165   template<class T> Bool near(const SparseDiff<T> &left,
00166                               const SparseDiff<T> &right);
00167   template<class T> Bool near(const SparseDiff<T> &left,
00168                               const SparseDiff<T> &right, const Double tol);
00169   template<class T> Bool allnear(const SparseDiff<T> &left,
00170                                  const SparseDiff<T> &right, const Double tol);
00171   template<class T> Bool nearAbs(const SparseDiff<T> &left,
00172                                  const SparseDiff<T> &right, const Double tol);
00173   template<class T> Bool allnearAbs(const SparseDiff<T> &left,
00174                                     const SparseDiff<T> &right, const Double tol);
00175   // </group>
00176   // Compare a SparseDiff and a constant
00177   // <group>
00178   template<class T> Bool operator>(const SparseDiff<T> &left, const T &right);
00179   template<class T> Bool operator<(const SparseDiff<T> &left, const T &right);
00180   template<class T> Bool operator>=(const SparseDiff<T> &left, const T &right);
00181   template<class T> Bool operator<=(const SparseDiff<T> &left, const T &right);
00182   template<class T> Bool operator==(const SparseDiff<T> &left, const T &right);
00183   template<class T> Bool operator!=(const SparseDiff<T> &left, const T &right);
00184   template<class T> Bool near(const SparseDiff<T> &left, const T &right);
00185   template<class T> Bool near(const SparseDiff<T> &left, const T &right,
00186                               const Double tol);
00187   template<class T> Bool allnear(const SparseDiff<T> &left, const T &right,
00188                                  const Double tol);
00189   template<class T> Bool nearAbs(const SparseDiff<T> &left, const T &right,
00190                                  const Double tol);
00191   template<class T> Bool allnearAbs(const SparseDiff<T> &left, const T &right,
00192                                     const Double tol);
00193   // </group>
00194   // Compare a constant and a SparseDiff
00195   // <group>
00196   template<class T> Bool operator>(const T &left, const SparseDiff<T> &right);
00197   template<class T> Bool operator<(const T &left, const SparseDiff<T> &right);
00198   template<class T> Bool operator>=(const T &left, const SparseDiff<T> &right);
00199   template<class T> Bool operator<=(const T &left, const SparseDiff<T> &right);
00200   template<class T> Bool operator==(const T &left, const SparseDiff<T> &right);
00201   template<class T> Bool operator!=(const T &left, const SparseDiff<T> &right);
00202   template<class T> Bool near(const T &left, const SparseDiff<T> &right,
00203                               const Double tol);
00204   template<class T> Bool allnear(const T &left, const SparseDiff<T> &right,
00205                                  const Double tol);
00206   template<class T> Bool nearAbs(const T &left, const SparseDiff<T> &right,
00207                                  const Double tol);
00208   template<class T> Bool allnearAbs(const T &left, const SparseDiff<T> &right,
00209                                     const Double tol);
00210   // </group>
00211   // Test special values
00212   // <group>
00213   template<class T> Bool isNaN(const SparseDiff<T> &val);
00214   template<class T> Bool isInf(SparseDiff<T> &val);
00215   // </group>
00216   // Minimum/maximum
00217   // <group>
00218   template<class T> SparseDiff<T> min(const SparseDiff<T> &left,
00219                                       const SparseDiff<T> &right);
00220   template<class T> SparseDiff<T> max(const SparseDiff<T> &left,
00221                                       const SparseDiff<T> &right);
00222   // </group>
00223 
00224   // </group>
00225 
00226 
00227 } //# NAMESPACE CASA - END
00228 
00229 #ifndef CASACORE_NO_AUTO_TEMPLATES
00230 #include <scimath/Mathematics/SparseDiffMath.tcc>
00231 #endif //# CASACORE_NO_AUTO_TEMPLATES
00232 #endif