ADMB Documentation  11.5.3249
 All Classes Files Functions Variables Typedefs Friends Defines
df33fun.h
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  *
00007  * ADModelbuilder and associated libraries and documentations are
00008  * provided under the general terms of the "BSD" license.
00009  *
00010  * License:
00011  *
00012  * Redistribution and use in source and binary forms, with or without
00013  * modification, are permitted provided that the following conditions are
00014  * met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright
00017  * notice, this list of conditions and the following disclaimer.
00018  *
00019  * 2.  Redistributions in binary form must reproduce the above copyright
00020  * notice, this list of conditions and the following disclaimer in the
00021  * documentation and/or other materials provided with the distribution.
00022  *
00023  * 3.  Neither the name of the  University of California, Otter Research,
00024  * nor the ADMB Foundation nor the names of its contributors may be used
00025  * to endorse or promote products derived from this software without
00026  * specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00029  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00030  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00031  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00032  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00033  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00034  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00035  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00036  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00038  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  *
00040  */
00045 #if !defined(__DF33FUN__)
00046 #  define __DF33FUN__
00047 class df1b2variable;
00048 
00053 class df3_three_variable
00054 {
00055   double v[20];
00056 public:
00057   static df1b2variable* ind_var[];
00058   static int num_ind_var;
00059   static int num_local_ind_var;
00060 
00061   df3_three_variable();
00062   df3_three_variable(const df3_three_variable&);
00063 
00064   double* get_u() const { return (double*)(&(v[0])); }
00065   double* get_u_x() const { return (double*)(&(v[1])); }
00066   double* get_u_y() const { return (double*)(&(v[2])); }
00067   double* get_u_z() const { return (double*)(&(v[3])); }
00068   double* get_u_xx() const { return (double*)(&(v[4])); }
00069   double* get_u_xy() const { return (double*)(&(v[5])); }
00070   double* get_u_xz() const { return (double*)(&(v[6])); }
00071   double* get_u_yy() const { return (double*)(&(v[7])); }
00072   double* get_u_yz() const { return (double*)(&(v[8])); }
00073   double* get_u_zz() const { return (double*)(&(v[9])); }
00074   double* get_u_xxx() const { return (double*)(&(v[10])); }
00075   double* get_u_xxy() const { return (double*)(&(v[11])); }
00076   double* get_u_xxz() const { return (double*)(&(v[12])); }
00077   double* get_u_xyy() const { return (double*)(&(v[13])); }
00078   double* get_u_xyz() const { return (double*)(&(v[14])); }
00079   double* get_u_xzz() const { return (double*)(&(v[15])); }
00080   double* get_u_yyy() const { return (double*)(&(v[16])); }
00081   double* get_u_yyz() const { return (double*)(&(v[17])); }
00082   double* get_u_yzz() const { return (double*)(&(v[18])); }
00083   double* get_u_zzz() const { return (double*)(&(v[19])); }
00084 
00085   df3_three_variable& operator=(const df3_three_variable& v);
00086   df3_three_variable& operator=(double v);
00087   df3_three_variable& operator+=(const df3_three_variable& v);
00088   df3_three_variable& operator*=(const df3_three_variable& v);
00089   df3_three_variable& operator*=(double v);
00090   df3_three_variable& operator+=(double v);
00091   df3_three_variable& operator-=(const df3_three_variable& v);
00092   df3_three_variable& operator-=(double v);
00093   df3_three_variable& operator/=(const df3_three_variable& v);
00094 
00095   void initialize();
00096 };
00097 
00102   inline  double value(const df3_three_variable& x)
00103     { return double(*x.get_u()); }
00104 
00109   class init_df3_three_variable : public df3_three_variable
00110   {
00111   public:
00112     init_df3_three_variable(const df1b2variable& );
00113     init_df3_three_variable(double );
00114     ~init_df3_three_variable();
00115   };
00116 
00121   class df3_three_vector
00122   {
00123     int index_min;
00124     int index_max;
00125     vector_shapex * shape;
00126     df3_three_variable * v;
00127   public:
00128     int indexmin(void) const { return int(index_min); }
00129     int indexmax(void) const { return int(index_max); }
00130     df3_three_vector(int min,int max);
00131     df3_three_vector(void);
00132     void allocate(void);
00133     void allocate(int min,int max);
00134     df3_three_variable& operator () (int i) const
00135     {
00136       return (df3_three_variable&) (*(v+i));
00137     }
00138     df3_three_variable& operator [] (int i) const
00139     {
00140       return (df3_three_variable&) (*(v+i));
00141     }
00142     void initialize(void);
00143     void deallocate(void);
00144     ~df3_three_vector();
00145     df3_three_vector(const df3_three_vector& m2);
00146   };
00147 
00148 
00149 
00150  dvector value(const df3_three_vector& v);
00151 
00152  dvector first_derivatives(const df3_three_vector& v);
00153 
00154  dvector second_derivatives(const df3_three_vector& v);
00155 
00156  dvector third_derivatives(const df3_three_vector& v);
00157 
00162   class df3_three_matrix
00163   {
00164     int index_min;
00165     int index_max;
00166     mat_shapex * shape;
00167     df3_three_vector * v;
00168   public:
00169     int indexmin(void) const { return int(index_min); }
00170     int indexmax(void) const { return int(index_max); }
00171     df3_three_matrix(int rmin,int rmax,int cmin,int cmax);
00172     df3_three_vector& operator () (int i) const
00173     {
00174       return (df3_three_vector&) *(v+i);
00175     }
00176     df3_three_vector& operator [] (int i) const
00177     {
00178       return (df3_three_vector&) *(v+i);
00179     }
00180     df3_three_variable& operator () (int i,int j) const
00181     {
00182       return (df3_three_variable&) (*(v+i))(j);
00183     }
00184     void initialize(void);
00185     //df3_three_variable& operator () (int i,int j) const
00186     // { return *((v+i)->(v+j)); }
00187     void deallocate(void);
00188     ~df3_three_matrix();
00189     df3_three_matrix(const df3_three_matrix& m2);
00190   };
00191 
00192  dmatrix value(const df3_three_matrix& v);
00193 
00194  dmatrix first_derivatives(const df3_three_matrix& v);
00195  dmatrix second_derivatives(const df3_three_matrix& v);
00196  dmatrix third_derivatives(const df3_three_matrix& v);
00197 
00198 /*
00199   df3_three_variable operator F(const df3_three_variable& x)
00200   {
00201     df3_three_variable z;
00202 
00203     *z.get_u() = ::F(*x.get_u());
00204 
00205     *z.get_udot() = ::D1F(*x.get_u())* *x.get_udot();
00206 
00207     *z.get_udot2() = ::D2F(*x.get_u())* square(*x.get_udot())
00208                    + ::D1F(*x.get_u())* *x.get_udot2();
00209 
00210     *z.get_udot3() = ::D3F(*x.get_u()) * cube(*x.get_udot())
00211                    + 3.0 * ::D2F(*x.get_u()) * *x.get_udot() * *x.get_udot2()
00212                    + ::D1F(*x.get_u()) * *x.get_udot3();
00213     return z;
00214   }
00215 
00216 */
00217 
00218   df3_three_variable fabs(const df3_three_variable& x);
00219   df3_three_variable sin(const df3_three_variable& x);
00220   df3_three_variable sqrt(const df3_three_variable& x);
00221   df3_three_variable atan(const df3_three_variable& x);
00222   df3_three_variable cos(const df3_three_variable& x);
00223   df3_three_variable tan(const df3_three_variable& x);
00224   df3_three_variable log(const df3_three_variable& x);
00225   df3_three_variable square(const df3_three_variable& x);
00226   df3_three_variable cube(const df3_three_variable& x);
00227   df3_three_variable pow(const df3_three_variable& x,
00228     const df3_three_variable& y);
00229 
00230   df3_three_variable sqrt(const df3_three_variable& x);
00231   df3_three_variable exp(const df3_three_variable& x);
00232   df3_three_variable inv(const df3_three_variable& x);
00233   df3_three_variable operator * (const df3_three_variable& x,
00234     const df3_three_variable& y);
00235   df3_three_variable operator * (double x,
00236     const df3_three_variable& y);
00237   df3_three_variable operator * (const df3_three_variable& x,
00238     double y);
00239   df3_three_variable operator / (const df3_three_variable& x,
00240     const df3_three_variable& y);
00241 
00242   df3_three_variable operator / (const double x,const df3_three_variable& y);
00243 
00244   df3_three_variable operator / (const df3_three_variable& x,
00245     const double y);
00246 
00247   df3_three_variable operator + (const double x,
00248     const df3_three_variable& y);
00249 
00250   df3_three_variable operator + (const df3_three_variable& x,
00251     const double y);
00252 
00253   df3_three_variable operator + (const df3_three_variable& x,
00254     const df3_three_variable& y);
00255   df3_three_variable operator - (double x,const df3_three_variable& y);
00256   df3_three_variable operator - (const df3_three_variable& x,double y);
00257 
00258   df3_three_variable operator - (const df3_three_variable& x,
00259     const df3_three_variable& y);
00260 
00261   df3_three_variable operator - (const df3_three_variable& v);
00262   df3_three_matrix choleski_decomp(const df3_three_matrix& MM);
00263 
00264   df3_three_variable cumd_gamma(const df3_three_variable& x,
00265     const df3_three_variable& a);
00266 
00267   df3_three_variable gammln(const df3_three_variable& xx);
00268 #endif  // __DF32FUN__