ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
df3fun.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  */
41 
42 
43 #if !defined(__DF3FUN__)
44 # define __DF3FUN__
45 
47 {
48  double v[4];
49 public:
51 
54 
55  double* get_u(void) const {return (double*)(&(v[0])); }
56  double* get_udot(void) const {return (double*)(&(v[1])); }
57  double* get_udot2(void) const {return (double*)(&(v[2])); }
58  double* get_udot3(void) const {return (double*)(&(v[3])); }
59 
61  df3_one_variable& operator=(double v);
67 };
68 
69  inline double value(const df3_one_variable& x) { return double(*x.get_u()); }
70 
72  {
73  public:
75  init_df3_one_variable(double );
76  };
77 
78 
79 
81  {
82  int index_min;
83  int index_max;
86  public:
87  int indexmin(void) const { return int(index_min); }
88  int indexmax(void) const { return int(index_max); }
89  df3_one_vector(int min,int max);
90  df3_one_vector(void);
91  void allocate(void);
92  void allocate(int min,int max);
94  {
95  return (df3_one_variable&) (*(v+i));
96  }
98  {
99  return (df3_one_variable&) (*(v+i));
100  }
101  void initialize(void);
102  void deallocate(void);
103  ~df3_one_vector();
104  df3_one_vector(const df3_one_vector& m2);
105  };
106 
107  dvector value(const df3_one_vector& v);
108 
110 
112 
114 
116  {
121  public:
122  int indexmin(void) const { return int(index_min); }
123  int indexmax(void) const { return int(index_max); }
124  df3_one_matrix(int rmin,int rmax,int cmin,int cmax);
126  {
127  return (df3_one_vector&) *(v+i);
128  }
130  {
131  return (df3_one_vector&) *(v+i);
132  }
133  df3_one_variable& operator () (int i,int j) const
134  {
135  return (df3_one_variable&) (*(v+i))(j);
136  }
137  void initialize(void);
138 //df3_one_variable& operator () (int i,int j) const { return *((v+i)->(v+j)); }
139  void deallocate(void);
140  ~df3_one_matrix();
141  df3_one_matrix(const df3_one_matrix& m2);
142  };
143 
144  dmatrix value(const df3_one_matrix& v);
145 
149 
150 /*
151  df3_one_variable operator F(const df3_one_variable& x)
152  {
153  df3_one_variable z;
154 
155  *z.get_u() = ::F(*x.get_u());
156 
157  *z.get_udot() = ::D1F(*x.get_u())* *x.get_udot();
158 
159  *z.get_udot2() = ::D2F(*x.get_u())* square(*x.get_udot())
160  + ::D1F(*x.get_u())* *x.get_udot2();
161 
162  *z.get_udot3() = ::D3F(*x.get_u()) * cube(*x.get_udot())
163  + 3.0 * ::D2F(*x.get_u()) * *x.get_udot() * *x.get_udot2()
164  + ::D1F(*x.get_u()) * *x.get_udot3();
165  return z;
166  }
167 
168 */
169 
175  const df3_one_variable& y);
177  const df3_one_variable& y);
179  double y);
181  const df3_one_variable& y);
182 
183  df3_one_variable operator / (const double x,const df3_one_variable& y);
184 
186  const double y);
187 
188  df3_one_variable operator + (const double x,
189  const df3_one_variable& y);
190 
192  const double y);
193 
195  const df3_one_variable& y);
196 
198  double);
200  const df3_one_variable& y);
201 
204 #endif // __DF3FUN__
init_df3_one_variable(const df1b2variable &)
Construct init_df3_one_variable from _var.
Definition: df3fun.cpp:638
int indexmax(void) const
Definition: df3fun.h:123
vector_shapex * shape
Definition: df3fun.h:84
Description not yet available.
Definition: fvar.hpp:2030
double * get_udot3(void) const
Definition: df3fun.h:58
df3_one_vector(void)
Default constructor.
Definition: df3fun.cpp:134
double * get_udot(void) const
Definition: df3fun.h:56
void allocate(void)
Does NOT allocate, but initializes empty df3_one_vector.
Definition: df3fun.cpp:172
int index_max
Definition: df3fun.h:83
mat_shapex * shape
Definition: df3fun.h:119
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_one_variable * v
Definition: df3fun.h:85
df3_one_variable & operator()(int i) const
Definition: df3fun.h:93
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
int index_max
Definition: df3fun.h:118
double * get_udot2(void) const
Definition: df3fun.h:57
int indexmin(void) const
Definition: df3fun.h:87
df3_one_matrix(int rmin, int rmax, int cmin, int cmax)
Definition: df3fun.cpp:303
~df3_one_matrix()
Destructor.
Definition: df3fun.cpp:257
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
df3_one_vector & operator[](int i) const
Definition: df3fun.h:129
double * get_u(void) const
Definition: df3fun.h:55
df3_one_variable & operator+=(const df3_one_variable &v)
Subtract v values from df3_one_variable u, udot, udot2 and udot3.
Definition: df3fun.cpp:379
~df3_one_vector()
Destructor.
Definition: df3fun.cpp:47
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_one_variable & operator/=(const df3_one_variable &v)
#define min(a, b)
Definition: cbivnorm.cpp:188
void initialize(void)
Definition: df3fun.cpp:283
dmatrix second_derivatives(const df1_one_matrix &v)
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
Description not yet available.
Definition: fvar.hpp:2819
df3_one_vector & operator()(int i) const
Definition: df3fun.h:125
df3_one_vector * v
Definition: df3fun.h:120
Holds "shape" information for vector objects.
Definition: vector_shapex.h:46
int index_min
Definition: df3fun.h:117
df3_one_variable & operator[](int i) const
Definition: df3fun.h:97
int indexmax(void) const
Definition: df3fun.h:88
double v[4]
Definition: df3fun.h:48
df3_one_variable()
Default constructor.
Definition: df3fun.cpp:15
int index_min
Definition: df3fun.h:82
df3_one_variable & operator=(const df3_one_variable &v)
Definition: df3fun.cpp:472
d3_array operator/(const d3_array &m, const double d)
Author: David Fournier.
Definition: d3arr2b.cpp:14
int indexmin(void) const
Definition: df3fun.h:122
dmatrix third_derivatives(const df1_one_matrix &v)
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
void deallocate(void)
Deallocate df3_one_vector, then set to empty.
Definition: df3fun.cpp:52
#define max(a, b)
Definition: cbivnorm.cpp:189
df3_one_variable & operator-=(const df3_one_variable &v)
Subtract _v values from df3_one_variable u, udot, udot2 and udot3.
Definition: df3fun.cpp:357
static df1b2variable * ind_var
Definition: df3fun.h:50
void deallocate(void)
Deallocate df3_one_matrix, then set to empty.
Definition: df3fun.cpp:262
void initialize(void)
Definition: df3fun.cpp:121
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
df3_one_variable & operator*=(const df3_one_variable &v)