ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
df12fun.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  *
7  * ADModelbuilder and associated libraries and documentations are
8  * provided under the general terms of the "BSD" license.
9  *
10  * License:
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are
14  * met:
15  *
16  * 1. Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  *
19  * 2. Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution.
22  *
23  * 3. Neither the name of the University of California, Otter Research,
24  * nor the ADMB Foundation nor the names of its contributors may be used
25  * to endorse or promote products derived from this software without
26  * specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  */
45 #if !defined(__DF12FUN__)
46 # define __DF12FUN__
47 #include <fvar.hpp>
48 //class df1b2variable;
49 
55  {
56  double v[3];
57  public:
58  static prevariable * ind_var[];
59  static int num_ind_var;
60  double* get_u() const {return (double*) (&(v[0]));}
61  double* get_u_x() const {return (double*) (&(v[1]));}
62  double* get_u_y() const {return (double*) (&(v[2]));}
74  };
75 
76  inline double value(const df1_two_variable& x) { return double(*x.get_u()); }
77 
83  {
84  public:
86  void deallocate(void);
88  init_df1_two_variable(double );
89  };
90 
96  {
97  int index_min;
98  int index_max;
101  public:
102  int indexmin(void) const { return index_min; }
103  int indexmax(void) const { return index_max; }
104  df1_two_vector(int min,int max);
105  df1_two_vector(void);
106  void allocate(void);
107  void allocate(int min,int max);
109  {
110  return (df1_two_variable&) (*(v+i));
111  }
113  {
114  return (df1_two_variable&) (*(v+i));
115  }
116  void initialize(void);
117  void deallocate(void);
118  ~df1_two_vector();
119  df1_two_vector(const df1_two_vector& m2);
120  };
121 
122 
123 
124  dvector value(const df1_two_vector& v);
126 
132  {
137  public:
138  int indexmin(void) const { return index_min; }
139  int indexmax(void) const { return index_max; }
140  df1_two_matrix(int rmin,int rmax,int cmin,int cmax);
142  {
143  return (df1_two_vector&) *(v+i);
144  }
146  {
147  return (df1_two_vector&) *(v+i);
148  }
149  df1_two_variable& operator () (int i,int j) const
150  {
151  return (df1_two_variable&) (*(v+i))(j);
152  }
153  void initialize(void);
154 //df1_two_variable& operator()(int i,int j) const { return *((v+i)->(v+j)); }
155  void deallocate(void);
156  ~df1_two_matrix();
157  df1_two_matrix(const df1_two_matrix& m2);
158  };
159 
160  dmatrix value(const df1_two_matrix& v);
161 
165 
166 /*
167  df1_two_variable operator F(const df1_two_variable& x)
168  {
169  df1_two_variable z;
170 
171  *z.get_u() = ::F(*x.get_u());
172 
173  *z.get_udot() = ::D1F(*x.get_u())* *x.get_udot();
174 
175  *z.get_udot2() = ::D2F(*x.get_u())* square(*x.get_udot())
176  + ::D1F(*x.get_u())* *x.get_udot2();
177 
178  *z.get_udot3() = ::D3F(*x.get_u()) * cube(*x.get_udot())
179  + 3.0 * ::D2F(*x.get_u()) * *x.get_udot() * *x.get_udot2()
180  + ::D1F(*x.get_u()) * *x.get_udot3();
181  return z;
182  }
183 
184 */
185 
196  const df1_two_variable& y);
197  df1_two_variable pow(double x,const df1_two_variable& y);
198 
203  const df1_two_variable& y);
205  const df1_two_variable& y);
207  double y);
209  const df1_two_variable& y);
210 
211  df1_two_variable operator / (const double x,const df1_two_variable& y);
212 
214  const double y);
215 
216  df1_two_variable operator + (const double x,
217  const df1_two_variable& y);
218 
220  const double y);
221 
223  const df1_two_variable& y);
226 
228  const df1_two_variable& y);
230  const df1_two_variable& y);
232  const df1_two_variable& y);
234  const df1_two_variable& y);
235 
238 
240  const df1_two_variable& a);
241 
243 #endif // __DF12FUN__
Base class for dvariable.
Definition: fvar.hpp:1315
d3_array tan(const d3_array &arr3)
Returns d3_array results with computed tan from elements in arr3.
Definition: d3arr2a.cpp:73
double * get_u() const
Definition: df12fun.h:60
df1_two_variable & operator=(const df1_two_variable &v)
Description not yet available.
Definition: df12fun.cpp:569
df1_two_variable * v
Definition: df12fun.h:100
Description not yet available.
Definition: fvar.hpp:2030
df1_two_variable & operator*=(double v)
Mulitiply value v with values in df1_two_variable.
Definition: df12fun.cpp:343
double gammln(double xx)
Log gamma function.
Definition: combc.cpp:52
void allocate(void)
Does NOT allocate, but initializes empty df1_two_vector.
Definition: df12fun.cpp:157
d3_array operator-(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements addition of a(i, j, k) + b(i, j, k).
Definition: d3arr2a.cpp:152
#define x
Vector of double precision numbers.
Definition: dvector.h:50
double cumd_gamma(double x, double a)
Definition: cgamdev.cpp:38
static int num_ind_var
Definition: df12fun.h:59
df1_two_variable & operator[](int i) const
Definition: df12fun.h:112
d3_array operator+(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements addition of a(i, j, k) + b(i, j, k).
Definition: d3arr2a.cpp:132
df1_one_variable atan(const df1_one_variable &x)
Definition: df11fun.cpp:312
d3_array sin(const d3_array &arr3)
Returns d3_array results with computed sin from elements in arr3.
Definition: d3arr2a.cpp:43
df1_two_variable fabs(const df1_two_variable &x)
Definition: df12fun.cpp:891
void initialize(void)
Description not yet available.
Definition: df12fun.cpp:103
d3_array cube(const d3_array &m)
Description not yet available.
Definition: d3arr5.cpp:17
df1_two_variable & operator+=(const df1_two_variable &v)
Description not yet available.
Definition: df12fun.cpp:332
void deallocate(void)
Description not yet available.
Definition: df12fun.cpp:761
df1_one_matrix choleski_decomp(const df1_one_matrix &MM)
Definition: df11fun.cpp:606
df1_two_variable & operator/=(const df1_two_variable &v)
Description not yet available.
Definition: df12fun.cpp:298
init_df1_two_variable(const prevariable &)
Description not yet available.
Definition: df12fun.cpp:770
dmatrix operator*(const d3_array &t, const dvector &v)
Description not yet available.
Definition: d3arr12.cpp:17
void deallocate(void)
Description not yet available.
Definition: df12fun.cpp:216
~df1_two_matrix()
Description not yet available.
Definition: df12fun.cpp:207
df1_two_vector(void)
Default constructor.
Definition: df12fun.cpp:116
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2c.cpp:11
df1_two_variable()
Default constructor.
Definition: df12fun.cpp:22
#define min(a, b)
Definition: cbivnorm.cpp:188
dmatrix second_derivatives(const df1_one_matrix &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
Definition: d3arr2a.cpp:28
dvector first_derivatives(const df1_one_vector &v)
Description not yet available.
Definition: df11fun.cpp:399
vector_shapex * shape
Definition: df12fun.h:99
df1_two_variable & operator()(int i) const
Definition: df12fun.h:108
Description not yet available.
Definition: fvar.hpp:2819
int indexmax(void) const
Definition: df12fun.h:103
void initialize(void)
Description not yet available.
Definition: df12fun.cpp:241
Description not yet available.
Definition: df12fun.h:131
int indexmin(void) const
Definition: df12fun.h:138
df1_two_variable & operator-=(const df1_two_variable &v)
Description not yet available.
Definition: df12fun.cpp:285
Description not yet available.
Definition: df12fun.h:95
Holds &quot;shape&quot; information for vector objects.
Definition: vector_shapex.h:46
d3_array cos(const d3_array &arr3)
Returns d3_array results with computed cos from elements in arr3.
Definition: d3arr2a.cpp:58
static prevariable * ind_var[]
Definition: df12fun.h:58
mat_shapex * shape
Definition: df12fun.h:135
int index_max
Definition: df12fun.h:98
int indexmax(void) const
Definition: df12fun.h:139
double v[3]
Definition: df12fun.h:56
double * get_u_y() const
Definition: df12fun.h:62
Description not yet available.
Definition: df12fun.h:54
df1_two_vector * v
Definition: df12fun.h:136
int indexmin(void) const
Definition: df12fun.h:102
df1_two_matrix(int rmin, int rmax, int cmin, int cmax)
Construct matrix of df1_two_variable with dimension [rmin to rmax] x [cmin to cmax].
Definition: df12fun.cpp:259
d3_array operator/(const d3_array &m, const double d)
Author: David Fournier.
Definition: d3arr2b.cpp:14
Description not yet available.
Definition: df12fun.h:82
dmatrix third_derivatives(const df1_one_matrix &v)
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
#define max(a, b)
Definition: cbivnorm.cpp:189
~df1_two_vector()
Destructor.
Definition: df12fun.cpp:55
df1_two_vector & operator[](int i) const
Definition: df12fun.h:145
void deallocate(void)
Description not yet available.
Definition: df12fun.cpp:64
df1_two_vector & operator()(int i) const
Definition: df12fun.h:141
double square(const double value)
Return square of value; constant object.
Definition: d3arr4.cpp:16
df1_one_variable inv(const df1_one_variable &x)
Definition: df11fun.cpp:384
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13
int index_min
Definition: df12fun.h:97
~init_df1_two_variable()
Description not yet available.
Definition: df12fun.cpp:752
double * get_u_x() const
Definition: df12fun.h:61
d3_array pow(const d3_array &m, int e)
Description not yet available.
Definition: d3arr6.cpp:17