ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
df32fun.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  */
00047 #if !defined(__DF32FUN__)
00048 #  define __DF32FUN__
00049 class df1b2variable;
00050 
00055 class df3_two_variable
00056 {
00057   double v[10];
00058 
00059 public:
00060   static df1b2variable* ind_var[];
00061   static int num_ind_var;
00062 
00063   df3_two_variable();
00064   df3_two_variable(const df3_two_variable &);
00065 
00066   double *get_u(void) const
00067   {
00068     return (double*)(&(v[0]));
00069   }
00070   double *get_u_x(void) const
00071   {
00072     return (double*)(&(v[1]));
00073   }
00074   double *get_u_y(void) const
00075   {
00076     return (double*)(&(v[2]));
00077   }
00078   double *get_u_xx(void) const
00079   {
00080     return (double*)(&(v[3]));
00081   }
00082   double *get_u_xy(void) const
00083   {
00084     return (double*)(&(v[4]));
00085   }
00086   double *get_u_yy(void) const
00087   {
00088     return (double*)(&(v[5]));
00089   }
00090   double *get_u_xxx(void) const
00091   {
00092     return (double*)(&(v[6]));
00093   }
00094   double *get_u_xxy(void) const
00095   {
00096     return (double*)(&(v[7]));
00097   }
00098   double *get_u_xyy(void) const
00099   {
00100     return (double*)(&(v[8]));
00101   }
00102   double *get_u_yyy(void) const
00103   {
00104     return (double*)(&(v[9]));
00105   }
00106   df3_two_variable& operator=(const df3_two_variable & v);
00107   df3_two_variable& operator=(double v);
00108   df3_two_variable& operator+=(const df3_two_variable & v);
00109   df3_two_variable& operator*=(const df3_two_variable & v);
00110   df3_two_variable& operator*=(double v);
00111   df3_two_variable& operator+=(double v);
00112   df3_two_variable& operator-=(double v);
00113   df3_two_variable& operator-=(const df3_two_variable & v);
00114   df3_two_variable& operator/=(const df3_two_variable & v);
00115 };
00116 
00121 inline double value(const df3_two_variable & x)
00122 {
00123    return double (*x.get_u());
00124 }
00125 
00130 class init_df3_two_variable:public df3_two_variable
00131 {
00132  public:
00133    init_df3_two_variable(const df1b2variable &);
00134     init_df3_two_variable(double);
00135 };
00136 
00141 class df3_two_vector
00142 {
00143    int index_min;
00144    int index_max;
00145    vector_shapex *shape;
00146    df3_two_variable *v;
00147  public:
00148    int indexmin(void) const
00149    {
00150       return int (index_min);
00151    }
00152    int indexmax(void) const
00153    {
00154       return int (index_max);
00155    }
00156    df3_two_vector(int min, int max);
00157     df3_two_vector(void);
00158    void allocate(void);
00159    void allocate(int min, int max);
00160     df3_two_variable & operator () (int i) const
00161    {
00162       return (df3_two_variable &) (*(v + i));
00163    }
00164    df3_two_variable & operator [] (int i) const
00165    {
00166       return (df3_two_variable &) (*(v + i));
00167    }
00168    void initialize(void);
00169    void deallocate(void);
00170    ~df3_two_vector();
00171     df3_two_vector(const df3_two_vector & m2);
00172 };
00173 
00174 
00175 
00176 dvector value(const df3_two_vector & v);
00177 
00178 dvector first_derivatives(const df3_two_vector & v);
00179 
00180 dvector second_derivatives(const df3_two_vector & v);
00181 
00182 dvector third_derivatives(const df3_two_vector & v);
00183 
00188 class df3_two_matrix
00189 {
00190    int index_min;
00191    int index_max;
00192    mat_shapex *shape;
00193    df3_two_vector *v;
00194  public:
00195    int indexmin(void) const
00196    {
00197       return int (index_min);
00198    }
00199    int indexmax(void) const
00200    {
00201       return int (index_max);
00202    }
00203    df3_two_matrix(int rmin, int rmax, int cmin, int cmax);
00204     df3_two_vector & operator () (int i) const
00205    {
00206       return (df3_two_vector &) * (v + i);
00207    }
00208    df3_two_vector & operator [] (int i) const
00209    {
00210       return (df3_two_vector &) * (v + i);
00211    }
00212    df3_two_variable & operator () (int i, int j) const
00213    {
00214       return (df3_two_variable &) (*(v + i)) (j);
00215    }
00216    void initialize(void);
00217    //df3_two_variable& operator () (int i,int j) const
00218    //  { return *((v+i)->(v+j)); }
00219    void deallocate(void);
00220    ~df3_two_matrix();
00221     df3_two_matrix(const df3_two_matrix & m2);
00222 };
00223 
00224 dmatrix value(const df3_two_matrix & v);
00225 
00226 dmatrix first_derivatives(const df3_two_matrix & v);
00227 dmatrix second_derivatives(const df3_two_matrix & v);
00228 dmatrix third_derivatives(const df3_two_matrix & v);
00229 
00230 /*
00231   df3_two_variable operator F(const df3_two_variable& x)
00232   {
00233     df3_two_variable z;
00234 
00235     *z.get_u() = ::F(*x.get_u());
00236 
00237     *z.get_udot() = ::D1F(*x.get_u())* *x.get_udot();
00238 
00239     *z.get_udot2() = ::D2F(*x.get_u())* square(*x.get_udot())
00240                    + ::D1F(*x.get_u())* *x.get_udot2();
00241 
00242     *z.get_udot3() = ::D3F(*x.get_u()) * cube(*x.get_udot())
00243                    + 3.0 * ::D2F(*x.get_u()) * *x.get_udot() * *x.get_udot2()
00244                    + ::D1F(*x.get_u()) * *x.get_udot3();
00245     return z;
00246   }
00247 
00248 */
00249 
00250 df3_two_variable sin(const df3_two_variable & x);
00251 df3_two_variable fabs(const df3_two_variable & x);
00252 df3_two_variable sqrt(const df3_two_variable & x);
00253 df3_two_variable atan(const df3_two_variable & x);
00254 df3_two_variable cos(const df3_two_variable & x);
00255 df3_two_variable tan(const df3_two_variable & x);
00256 df3_two_variable log(const df3_two_variable & x);
00257 df3_two_variable square(const df3_two_variable & x);
00258 df3_two_variable cube(const df3_two_variable & x);
00259 df3_two_variable pow(const df3_two_variable & x,
00260                      const df3_two_variable & y);
00261 df3_two_variable sqrt(const df3_two_variable & x);
00262 df3_two_variable exp(const df3_two_variable & x);
00263 df3_two_variable inv(const df3_two_variable & x);
00264 df3_two_variable operator *(const df3_two_variable & x,
00265                             const df3_two_variable & y);
00266 df3_two_variable operator *(double x, const df3_two_variable & y);
00267 df3_two_variable operator *(const df3_two_variable & x, double y);
00268 df3_two_variable operator /(const df3_two_variable & x,
00269                             const df3_two_variable & y);
00270 df3_two_variable operator /(const double x, const df3_two_variable & y);
00271 
00272 df3_two_variable operator /(const df3_two_variable & x, const double y);
00273 
00274 df3_two_variable operator +(const double x, const df3_two_variable & y);
00275 
00276 df3_two_variable operator +(const df3_two_variable & x, const double y);
00277 
00278 df3_two_variable operator +(const df3_two_variable & x,
00279                             const df3_two_variable & y);
00280 df3_two_variable operator -(double x, const df3_two_variable & y);
00281 df3_two_variable operator -(const df3_two_variable & x, double y);
00282 df3_two_variable operator -(const df3_two_variable & x,
00283                             const df3_two_variable & y);
00284 int operator <(const df3_two_variable & x, double n);
00285 int operator >(const df3_two_variable & x, double n);
00286 int operator >=(const df3_two_variable & x, double n);
00287 int operator ==(const df3_two_variable & x, const df3_two_variable & n);
00288 int operator ==(const df3_two_variable & x, double n);
00289 int operator ==(double x, const df3_two_variable & n);
00290 int operator <(const df3_two_variable & x, const df3_two_variable & n);
00291 int operator >(const df3_two_variable & x, const df3_two_variable & n);
00292 
00293 df3_two_variable operator -(const df3_two_variable & v);
00294 df3_two_matrix choleski_decomp(const df3_two_matrix & MM);
00295 
00296 df3_two_variable cumd_gamma(const df3_two_variable & x,
00297                             const df3_two_variable & a);
00298 
00299 df3_two_variable gammln(const df3_two_variable & xx);
00300 #endif