ADMB Documentation  11.1.2490
 All Classes Files Functions Variables Typedefs Friends Defines
df13fun.h
Go to the documentation of this file.
00001 /*
00002  * $Id: df13fun.h 1730 2014-03-04 01:30:47Z 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(__DF12FUN__)
00046 #  define __DF12FUN__
00047 #ifndef FVAR_HPP
00048 #  include <fvar.hpp>
00049 #endif
00050 //class df1b2variable;
00051 
00056   class df1_three_variable
00057   {
00058     double v[4];
00059   public:
00060     static prevariable * ind_var[];
00061     static int num_ind_var;
00062     double * get_u(void) const {return (double*) (&(v[0]));}
00063     double * get_u_x(void)const {return (double*) (&(v[1]));}
00064     double * get_u_y(void)const {return (double*) (&(v[2]));}
00065     double * get_u_z(void)const {return (double*) (&(v[3]));}
00066     df1_three_variable& operator = (const df1_three_variable& v);
00067     df1_three_variable& operator = (double v);
00068     df1_three_variable& operator += (const df1_three_variable& v);
00069     df1_three_variable& operator *= (const df1_three_variable& v);
00070     df1_three_variable& operator *= (double v);
00071     df1_three_variable& operator += (double v);
00072     df1_three_variable& operator -= (const df1_three_variable& v);
00073     df1_three_variable& operator -= (double v);
00074     df1_three_variable& operator /= (const df1_three_variable& v);
00075     df1_three_variable& my_diveq (const df1_three_variable& v);
00076     df1_three_variable& operator /= (double v);
00077     df1_three_variable(void);
00078     df1_three_variable(const df1_three_variable& );
00079     void initialize(void);
00080   };
00081 
00082   inline double value(const df1_three_variable& x)
00083     { return double(*x.get_u()); }
00084 
00089   class init_df1_three_variable : public df1_three_variable
00090   {
00091   public:
00092     ~init_df1_three_variable();
00093     void deallocate(void);
00094     init_df1_three_variable(const prevariable& );
00095     init_df1_three_variable(double );
00096   };
00097 
00102   class df1_three_vector
00103   {
00104     int index_min;
00105     int index_max;
00106     vector_shapex * shape;
00107     df1_three_variable * v;
00108   public:
00109     int indexmin(void) const { return int(index_min); }
00110     int indexmax(void) const { return int(index_max); }
00111     df1_three_vector(int min,int max);
00112     df1_three_vector(void);
00113     void allocate(void);
00114     void allocate(int min,int max);
00115     df1_three_variable& operator () (int i) const
00116     {
00117       return (df1_three_variable&) (*(v+i));
00118     }
00119     df1_three_variable& operator [] (int i) const
00120     {
00121       return (df1_three_variable&) (*(v+i));
00122     }
00123     void initialize(void);
00124     void deallocate(void);
00125     ~df1_three_vector();
00126     df1_three_vector(const df1_three_vector& m2);
00127   };
00128 
00129 
00130 
00131  dvector value(const df1_three_vector& v);
00132  dvector first_derivatives(const df1_three_vector& v);
00133 
00138   class df1_three_matrix
00139   {
00140     int index_min;
00141     int index_max;
00142     mat_shapex * shape;
00143     df1_three_vector * v;
00144   public:
00145     int indexmin(void) const { return int(index_min); }
00146     int indexmax(void) const { return int(index_max); }
00147     df1_three_matrix(int rmin,int rmax,int cmin,int cmax);
00148     df1_three_vector& operator () (int i) const
00149     {
00150       return (df1_three_vector&) *(v+i);
00151     }
00152     df1_three_vector& operator [] (int i) const
00153     {
00154       return (df1_three_vector&) *(v+i);
00155     }
00156     df1_three_variable& operator () (int i,int j) const
00157     {
00158       return (df1_three_variable&) (*(v+i))(j);
00159     }
00160     void initialize(void);
00161 //df1_three_variable& operator()(int i,int j) const { return *((v+i)->(v+j)); }
00162     void deallocate(void);
00163     ~df1_three_matrix();
00164     df1_three_matrix(const df1_three_matrix& m2);
00165   };
00166 
00167  dmatrix value(const df1_three_matrix& v);
00168 
00169  dmatrix first_derivatives(const df1_three_matrix& v);
00170  dmatrix second_derivatives(const df1_three_matrix& v);
00171  dmatrix third_derivatives(const df1_three_matrix& v);
00172 
00173 /*
00174   df1_three_variable operator F(const df1_three_variable& x)
00175   {
00176     df1_three_variable z;
00177 
00178     *z.get_u() = ::F(*x.get_u());
00179 
00180     *z.get_udot() = ::D1F(*x.get_u())* *x.get_udot();
00181 
00182     *z.get_udot2() = ::D2F(*x.get_u())* square(*x.get_udot())
00183                    + ::D1F(*x.get_u())* *x.get_udot2();
00184 
00185     *z.get_udot3() = ::D3F(*x.get_u()) * cube(*x.get_udot())
00186                    + 3.0 * ::D2F(*x.get_u()) * *x.get_udot() * *x.get_udot2()
00187                    + ::D1F(*x.get_u()) * *x.get_udot3();
00188     return z;
00189   }
00190 
00191 */
00192 
00193   df1_three_variable sin(const df1_three_variable& x);
00194   df1_three_variable fabs(const df1_three_variable& x);
00195   df1_three_variable sqrt(const df1_three_variable& x);
00196   df1_three_variable atan(const df1_three_variable& x);
00197   df1_three_variable cos(const df1_three_variable& x);
00198   df1_three_variable tan(const df1_three_variable& x);
00199   df1_three_variable log(const df1_three_variable& x);
00200   df1_three_variable square(const df1_three_variable& x);
00201   df1_three_variable cube(const df1_three_variable& x);
00202   df1_three_variable pow(const df1_three_variable& x,
00203     const df1_three_variable& y);
00204 
00205   df1_three_variable sqrt(const df1_three_variable& x);
00206   df1_three_variable exp(const df1_three_variable& x);
00207   df1_three_variable inv(const df1_three_variable& x);
00208   df1_three_variable operator * (const df1_three_variable& x,
00209     const df1_three_variable& y);
00210   df1_three_variable operator * (double x,
00211     const df1_three_variable& y);
00212   df1_three_variable operator * (const df1_three_variable& x,
00213     double y);
00214   df1_three_variable operator / (const df1_three_variable& x,
00215     const df1_three_variable& y);
00216 
00217   df1_three_variable operator / (const double x,const df1_three_variable& y);
00218 
00219   df1_three_variable operator / (const df1_three_variable& x,
00220     const double y);
00221 
00222   df1_three_variable operator + (const double x,
00223     const df1_three_variable& y);
00224 
00225   df1_three_variable operator + (const df1_three_variable& x,
00226     const double y);
00227 
00228   df1_three_variable operator + (const df1_three_variable& x,
00229     const df1_three_variable& y);
00230   df1_three_variable operator - (double x,const df1_three_variable& y);
00231   df1_three_variable operator - (const df1_three_variable& x,double y);
00232 
00233   df1_three_variable operator - (const df1_three_variable& x,
00234     const df1_three_variable& y);
00235   df1_three_variable operator - (const df1_three_variable& x,
00236     const df1_three_variable& y);
00237   df1_three_variable operator / (const df1_three_variable& x,
00238     const df1_three_variable& y);
00239   df1_three_variable operator * (const df1_three_variable& x,
00240     const df1_three_variable& y);
00241 
00242 
00243   df1_three_variable operator - (const df1_three_variable& v);
00244   df1_three_matrix choleski_decomp(const df1_three_matrix& MM);
00245 
00246   df1_three_variable cumd_gamma(const df1_three_variable& x,
00247     const df1_three_variable& a);
00248 
00249 
00250   df1_three_variable gammln(const df1_three_variable& xx);
00251 #endif  // __DF12FUN__
00252