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