ADMB Documentation  11.1.1913
 All Classes Files Functions Variables Typedefs Friends Defines
df33fun.h
Go to the documentation of this file.
00001 /*
00002  * $Id: df33fun.h 1726 2014-03-04 00:47:15Z johnoel $
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     double * get_u(void) const {return (double*) (&(v[0]));}
00061     double * get_u_x(void)const {return (double*) (&(v[1]));}
00062     double * get_u_y(void)const {return (double*) (&(v[2]));}
00063 
00064     double * get_u_z(void)const {return (double*) (&(v[3]));}
00065 
00066     double * get_u_xx(void)const {return (double*) (&(v[4]));}
00067 
00068     double * get_u_xy(void)const {return (double*) (&(v[5]));}
00069     double * get_u_xz(void)const {return (double*) (&(v[6]));}
00070 
00071     double * get_u_yy(void)const {return (double*) (&(v[7]));}
00072 
00073     double * get_u_yz(void)const {return (double*) (&(v[8]));}
00074     double * get_u_zz(void)const {return (double*) (&(v[9]));}
00075 
00076     double * get_u_xxx(void)const {return (double*) (&(v[10]));}
00077 
00078     double * get_u_xxy(void)const {return (double*) (&(v[11]));}
00079 
00080     double * get_u_xxz(void)const {return (double*) (&(v[12]));}
00081 
00082     double * get_u_xyy(void)const {return (double*) (&(v[13]));}
00083 
00084     double * get_u_xyz(void)const {return (double*) (&(v[14]));}
00085     double * get_u_xzz(void)const {return (double*) (&(v[15]));}
00086 
00087     double * get_u_yyy(void)const {return (double*) (&(v[16]));}
00088     double * get_u_yyz(void)const {return (double*) (&(v[17]));}
00089     double * get_u_yzz(void)const {return (double*) (&(v[18]));}
00090 
00091     double * get_u_zzz(void)const {return (double*) (&(v[19]));}
00092 
00093     df3_three_variable& operator = (const df3_three_variable& v);
00094     df3_three_variable& operator = (double v);
00095     df3_three_variable& operator += (const df3_three_variable& v);
00096     df3_three_variable& operator *= (const df3_three_variable& v);
00097     df3_three_variable& operator *= (double v);
00098     df3_three_variable& operator += (double v);
00099     df3_three_variable& operator -= (const df3_three_variable& v);
00100     df3_three_variable& operator -= (double v);
00101     df3_three_variable& operator /= (const df3_three_variable& v);
00102     df3_three_variable(void);
00103     df3_three_variable(const df3_three_variable& );
00104     void initialize(void);
00105   };
00106 
00111   inline  double value(const df3_three_variable& x)
00112     { return double(*x.get_u()); }
00113 
00118   class init_df3_three_variable : public df3_three_variable
00119   {
00120   public:
00121     init_df3_three_variable(const df1b2variable& );
00122     init_df3_three_variable(double );
00123     ~init_df3_three_variable();
00124   };
00125 
00130   class df3_three_vector
00131   {
00132     int index_min;
00133     int index_max;
00134     vector_shapex * shape;
00135     df3_three_variable * v;
00136   public:
00137     int indexmin(void) const { return int(index_min); }
00138     int indexmax(void) const { return int(index_max); }
00139     df3_three_vector(int min,int max);
00140     df3_three_vector(void);
00141     void allocate(void);
00142     void allocate(int min,int max);
00143     df3_three_variable& operator () (int i) const
00144     {
00145       return (df3_three_variable&) (*(v+i));
00146     }
00147     df3_three_variable& operator [] (int i) const
00148     {
00149       return (df3_three_variable&) (*(v+i));
00150     }
00151     void initialize(void);
00152     void deallocate(void);
00153     ~df3_three_vector();
00154     df3_three_vector(const df3_three_vector& m2);
00155   };
00156 
00157 
00158 
00159  dvector value(const df3_three_vector& v);
00160 
00161  dvector first_derivatives(const df3_three_vector& v);
00162 
00163  dvector second_derivatives(const df3_three_vector& v);
00164 
00165  dvector third_derivatives(const df3_three_vector& v);
00166 
00171   class df3_three_matrix
00172   {
00173     int index_min;
00174     int index_max;
00175     mat_shapex * shape;
00176     df3_three_vector * v;
00177   public:
00178     int indexmin(void) const { return int(index_min); }
00179     int indexmax(void) const { return int(index_max); }
00180     df3_three_matrix(int rmin,int rmax,int cmin,int cmax);
00181     df3_three_vector& operator () (int i) const
00182     {
00183       return (df3_three_vector&) *(v+i);
00184     }
00185     df3_three_vector& operator [] (int i) const
00186     {
00187       return (df3_three_vector&) *(v+i);
00188     }
00189     df3_three_variable& operator () (int i,int j) const
00190     {
00191       return (df3_three_variable&) (*(v+i))(j);
00192     }
00193     void initialize(void);
00194     //df3_three_variable& operator () (int i,int j) const
00195     // { return *((v+i)->(v+j)); }
00196     void deallocate(void);
00197     ~df3_three_matrix();
00198     df3_three_matrix(const df3_three_matrix& m2);
00199   };
00200 
00201  dmatrix value(const df3_three_matrix& v);
00202 
00203  dmatrix first_derivatives(const df3_three_matrix& v);
00204  dmatrix second_derivatives(const df3_three_matrix& v);
00205  dmatrix third_derivatives(const df3_three_matrix& v);
00206 
00207 /*
00208   df3_three_variable operator F(const df3_three_variable& x)
00209   {
00210     df3_three_variable z;
00211 
00212     *z.get_u() = ::F(*x.get_u());
00213 
00214     *z.get_udot() = ::D1F(*x.get_u())* *x.get_udot();
00215 
00216     *z.get_udot2() = ::D2F(*x.get_u())* square(*x.get_udot())
00217                    + ::D1F(*x.get_u())* *x.get_udot2();
00218 
00219     *z.get_udot3() = ::D3F(*x.get_u()) * cube(*x.get_udot())
00220                    + 3.0 * ::D2F(*x.get_u()) * *x.get_udot() * *x.get_udot2()
00221                    + ::D1F(*x.get_u()) * *x.get_udot3();
00222     return z;
00223   }
00224 
00225 */
00226 
00227   df3_three_variable fabs(const df3_three_variable& x);
00228   df3_three_variable sin(const df3_three_variable& x);
00229   df3_three_variable sqrt(const df3_three_variable& x);
00230   df3_three_variable atan(const df3_three_variable& x);
00231   df3_three_variable cos(const df3_three_variable& x);
00232   df3_three_variable tan(const df3_three_variable& x);
00233   df3_three_variable log(const df3_three_variable& x);
00234   df3_three_variable square(const df3_three_variable& x);
00235   df3_three_variable cube(const df3_three_variable& x);
00236   df3_three_variable pow(const df3_three_variable& x,
00237     const df3_three_variable& y);
00238 
00239   df3_three_variable sqrt(const df3_three_variable& x);
00240   df3_three_variable exp(const df3_three_variable& x);
00241   df3_three_variable inv(const df3_three_variable& x);
00242   df3_three_variable operator * (const df3_three_variable& x,
00243     const df3_three_variable& y);
00244   df3_three_variable operator * (double x,
00245     const df3_three_variable& y);
00246   df3_three_variable operator * (const df3_three_variable& x,
00247     double y);
00248   df3_three_variable operator / (const df3_three_variable& x,
00249     const df3_three_variable& y);
00250 
00251   df3_three_variable operator / (const double x,const df3_three_variable& y);
00252 
00253   df3_three_variable operator / (const df3_three_variable& x,
00254     const double y);
00255 
00256   df3_three_variable operator + (const double x,
00257     const df3_three_variable& y);
00258 
00259   df3_three_variable operator + (const df3_three_variable& x,
00260     const double y);
00261 
00262   df3_three_variable operator + (const df3_three_variable& x,
00263     const df3_three_variable& y);
00264   df3_three_variable operator - (double x,const df3_three_variable& y);
00265   df3_three_variable operator - (const df3_three_variable& x,double y);
00266 
00267   df3_three_variable operator - (const df3_three_variable& x,
00268     const df3_three_variable& y);
00269 
00270   df3_three_variable operator - (const df3_three_variable& v);
00271   df3_three_matrix choleski_decomp(const df3_three_matrix& MM);
00272 
00273   df3_three_variable cumd_gamma(const df3_three_variable& x,
00274     const df3_three_variable& a);
00275 
00276   df3_three_variable gammln(const df3_three_variable& xx);
00277 #endif  // __DF32FUN__