ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
df32fun.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  */
47 #if !defined(__DF32FUN__)
48 # define __DF32FUN__
49 class df1b2variable;
50 
56 {
57  double v[10];
58 
59 public:
61  static int num_ind_var;
62 
65 
66  double *get_u(void) const
67  {
68  return (double*)(&(v[0]));
69  }
70  double *get_u_x(void) const
71  {
72  return (double*)(&(v[1]));
73  }
74  double *get_u_y(void) const
75  {
76  return (double*)(&(v[2]));
77  }
78  double *get_u_xx(void) const
79  {
80  return (double*)(&(v[3]));
81  }
82  double *get_u_xy(void) const
83  {
84  return (double*)(&(v[4]));
85  }
86  double *get_u_yy(void) const
87  {
88  return (double*)(&(v[5]));
89  }
90  double *get_u_xxx(void) const
91  {
92  return (double*)(&(v[6]));
93  }
94  double *get_u_xxy(void) const
95  {
96  return (double*)(&(v[7]));
97  }
98  double *get_u_xyy(void) const
99  {
100  return (double*)(&(v[8]));
101  }
102  double *get_u_yyy(void) const
103  {
104  return (double*)(&(v[9]));
105  }
107  df3_two_variable& operator=(double v);
110  df3_two_variable& operator*=(double v);
111  df3_two_variable& operator+=(double v);
112  df3_two_variable& operator-=(double v);
115 };
116 
121 inline double value(const df3_two_variable & x)
122 {
123  return double (*x.get_u());
124 }
125 
131 {
132  public:
134  init_df3_two_variable(double);
135 };
136 
142 {
147  public:
148  int indexmin(void) const
149  {
150  return int (index_min);
151  }
152  int indexmax(void) const
153  {
154  return int (index_max);
155  }
156  df3_two_vector(int min, int max);
157  df3_two_vector(void);
158  void allocate(void);
159  void allocate(int min, int max);
161  {
162  return (df3_two_variable &) (*(v + i));
163  }
165  {
166  return (df3_two_variable &) (*(v + i));
167  }
168  void initialize(void);
169  void deallocate(void);
170  ~df3_two_vector();
171  df3_two_vector(const df3_two_vector & m2);
172 };
173 
174 
175 
176 dvector value(const df3_two_vector & v);
177 
179 
181 
183 
189 {
194  public:
195  int indexmin(void) const
196  {
197  return int (index_min);
198  }
199  int indexmax(void) const
200  {
201  return int (index_max);
202  }
203  df3_two_matrix(int rmin, int rmax, int cmin, int cmax);
205  {
206  return (df3_two_vector &) * (v + i);
207  }
209  {
210  return (df3_two_vector &) * (v + i);
211  }
212  df3_two_variable & operator () (int i, int j) const
213  {
214  return (df3_two_variable &) (*(v + i)) (j);
215  }
216  void initialize(void);
217  //df3_two_variable& operator () (int i,int j) const
218  // { return *((v+i)->(v+j)); }
219  void deallocate(void);
220  ~df3_two_matrix();
221  df3_two_matrix(const df3_two_matrix & m2);
222 };
223 
224 dmatrix value(const df3_two_matrix & v);
225 
229 
230 /*
231  df3_two_variable operator F(const df3_two_variable& x)
232  {
233  df3_two_variable z;
234 
235  *z.get_u() = ::F(*x.get_u());
236 
237  *z.get_udot() = ::D1F(*x.get_u())* *x.get_udot();
238 
239  *z.get_udot2() = ::D2F(*x.get_u())* square(*x.get_udot())
240  + ::D1F(*x.get_u())* *x.get_udot2();
241 
242  *z.get_udot3() = ::D3F(*x.get_u()) * cube(*x.get_udot())
243  + 3.0 * ::D2F(*x.get_u()) * *x.get_udot() * *x.get_udot2()
244  + ::D1F(*x.get_u()) * *x.get_udot3();
245  return z;
246  }
247 
248 */
249 
260  const df3_two_variable & y);
265  const df3_two_variable & y);
266 df3_two_variable operator *(double x, const df3_two_variable & y);
267 df3_two_variable operator *(const df3_two_variable & x, double y);
269  const df3_two_variable & y);
270 df3_two_variable operator /(const double x, const df3_two_variable & y);
271 
272 df3_two_variable operator /(const df3_two_variable & x, const double y);
273 
274 df3_two_variable operator +(const double x, const df3_two_variable & y);
275 
276 df3_two_variable operator +(const df3_two_variable & x, const double y);
277 
279  const df3_two_variable & y);
280 df3_two_variable operator -(double x, const df3_two_variable & y);
281 df3_two_variable operator -(const df3_two_variable & x, double y);
283  const df3_two_variable & y);
284 int operator <(const df3_two_variable & x, double n);
285 int operator >(const df3_two_variable & x, double n);
286 int operator >=(const df3_two_variable & x, double n);
287 int operator ==(const df3_two_variable & x, const df3_two_variable & n);
288 int operator ==(const df3_two_variable & x, double n);
289 int operator ==(double x, const df3_two_variable & n);
290 int operator <(const df3_two_variable & x, const df3_two_variable & n);
291 int operator >(const df3_two_variable & x, const df3_two_variable & n);
292 
295 
297  const df3_two_variable & a);
298 
300 #endif
d3_array tan(const d3_array &arr3)
Returns d3_array results with computed tan from elements in arr3.
Definition: d3arr2a.cpp:73
~df3_two_vector()
Destructor.
Definition: df32fun.cpp:49
Description not yet available.
Definition: fvar.hpp:2030
double * get_u_xy(void) const
Definition: df32fun.h:82
double gammln(double xx)
Log gamma function.
Definition: combc.cpp:52
Description not yet available.
Definition: df32fun.h:55
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
df3_two_vector & operator()(int i) const
Definition: df32fun.h:204
Description not yet available.
Definition: df32fun.h:130
void initialize(void)
Initialize df3_two_vector to zero.
Definition: df32fun.cpp:91
double cumd_gamma(double x, double a)
Definition: cgamdev.cpp:38
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
double v[10]
Definition: df32fun.h:57
df1_two_variable fabs(const df1_two_variable &x)
Definition: df12fun.cpp:891
double * get_u(void) const
Definition: df32fun.h:66
d3_array cube(const d3_array &m)
Description not yet available.
Definition: d3arr5.cpp:17
int indexmax(void) const
Definition: df32fun.h:199
int operator<(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:53
df3_two_vector(void)
Default constructor.
Definition: df32fun.cpp:103
df3_two_variable & operator*=(const df3_two_variable &v)
Multiply df3_two_variable and v which calls set_derivatives.
Definition: df32fun.cpp:340
Description not yet available.
Definition: df1b2fun.h:266
df1_one_matrix choleski_decomp(const df1_one_matrix &MM)
Definition: df11fun.cpp:606
dmatrix operator*(const d3_array &t, const dvector &v)
Description not yet available.
Definition: d3arr12.cpp:17
double * get_u_y(void) const
Definition: df32fun.h:74
int operator==(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:17
double * get_u_xx(void) const
Definition: df32fun.h:78
double * get_u_x(void) const
Definition: df32fun.h:70
void allocate(void)
Does NOT allocate, but initializes empty df3_two_vector.
Definition: df32fun.cpp:145
vector_shapex * shape
Definition: df32fun.h:145
double * get_u_xyy(void) const
Definition: df32fun.h:98
int indexmin(void) const
Definition: df32fun.h:148
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2c.cpp:11
df3_two_variable & operator=(const df3_two_variable &v)
Description not yet available.
Definition: df32fun.cpp:784
#define min(a, b)
Definition: cbivnorm.cpp:188
static df1b2variable * ind_var[]
Definition: df32fun.h:60
dmatrix second_derivatives(const df1_one_matrix &v)
df3_two_variable & operator+=(const df3_two_variable &v)
Add values from _v to df3_two_variable.
Definition: df32fun.cpp:305
double * get_u_xxy(void) const
Definition: df32fun.h:94
int indexmax(void) const
Definition: df32fun.h:152
Description not yet available.
Definition: df32fun.h:188
double * get_u_yyy(void) const
Definition: df32fun.h:102
~df3_two_matrix()
Destructor.
Definition: df32fun.cpp:191
d3_array exp(const d3_array &arr3)
Returns d3_array results with computed exp from elements in arr3.
Definition: d3arr2a.cpp:28
df3_two_variable & operator()(int i) const
Definition: df32fun.h:160
dvector first_derivatives(const df1_one_vector &v)
Description not yet available.
Definition: df11fun.cpp:399
df3_two_variable & operator[](int i) const
Definition: df32fun.h:164
df3_two_variable & operator-=(double v)
Subtract value _v from only df3_two_variable u with the rest of the values unchanged.
Definition: df32fun.cpp:332
void initialize(void)
Description not yet available.
Definition: df32fun.cpp:221
Description not yet available.
Definition: fvar.hpp:2819
df3_two_matrix(int rmin, int rmax, int cmin, int cmax)
Construct matrix of df3_two_variable with dimension [rmin to rmax] x [cmin to cmax].
Definition: df32fun.cpp:240
double * get_u_yy(void) const
Definition: df32fun.h:86
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
df3_two_vector & operator[](int i) const
Definition: df32fun.h:208
int operator>(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:44
df3_two_vector * v
Definition: df32fun.h:193
int indexmin(void) const
Definition: df32fun.h:195
Description not yet available.
Definition: df32fun.h:141
df3_two_variable * v
Definition: df32fun.h:146
mat_shapex * shape
Definition: df32fun.h:192
d3_array operator/(const d3_array &m, const double d)
Author: David Fournier.
Definition: d3arr2b.cpp:14
init_df3_two_variable(const df1b2variable &)
Description not yet available.
Definition: df32fun.cpp:1049
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
static int num_ind_var
Definition: df32fun.h:61
void deallocate(void)
Deallocate df3_two_vector, then set to empty.
Definition: df32fun.cpp:196
void deallocate(void)
Deallocate df3_two_vector, then set to empty.
Definition: df32fun.cpp:54
df3_two_variable & operator/=(const df3_two_variable &v)
Description not yet available.
Definition: df32fun.cpp:369
int operator>=(double v0, const prevariable &v1)
Description not yet available.
Definition: compare.cpp:35
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
double * get_u_xxx(void) const
Definition: df32fun.h:90
d3_array pow(const d3_array &m, int e)
Description not yet available.
Definition: d3arr6.cpp:17