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