ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
f3arr9.cpp
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  */
11 #include "fvar.hpp"
12 
21 {
24 
25  dvar3_array result;
26  result.allocate(m1);
27  for (int i = result.slicemin(); i <= result.slicemax(); ++i)
28  {
29  result(i) = elem_prod(m1(i), m2(i));
30  }
32 
33  return result;
34 }
43 {
46  dvar3_array result;
47  result.allocate(m1);
48  for (int i = result.slicemin(); i <= result.slicemax(); ++i)
49  {
50  result(i) = elem_div(m1(i), m2(i));
51  }
53 
54  return result;
55 }
63 {
66  dvar3_array result;
67  result.allocate(m1);
68  for (int i = result.slicemin(); i <= result.slicemax(); ++i)
69  {
70  result(i) = m1(i) + m2(i);
71  }
73 
74  return result;
75 }
83 {
86  dvar3_array result;
87  result.allocate(m1);
88  for (int i = result.slicemin(); i <= result.slicemax(); ++i)
89  {
90  result(i) = m1(i) - m2(i);
91  }
93 
94  return result;
95 }
103 {
106  dvar3_array result;
107  result.allocate(m2);
108  for (int i = result.slicemin(); i <= result.slicemax(); ++i)
109  {
110  result(i) = d + m2(i);
111  }
113 
114  return result;
115 }
123 {
126 
127  dvar3_array result;
128  result.allocate(m2);
129  for (int i = result.slicemin(); i <= result.slicemax(); ++i)
130  {
131  result(i) = d - m2(i);
132  }
134 
135  return result;
136 }
137 
143  {
146 
147  dvar3_array tmp;
148  tmp.allocate(m2);
149  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
150  {
151  tmp(i)=d*m2(i);
152  }
154  return tmp;
155  }
156 
162  {
165  dvar3_array tmp;
166  tmp.allocate(m2);
167  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
168  {
169  tmp(i)=d*m2(i);
170  }
172  return tmp;
173  }
174 
179 dvar3_array operator*(double d, const dvar3_array& m2)
180  {
183  dvar3_array tmp;
184  tmp.allocate(m2);
185  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
186  {
187  tmp(i)=d*m2(i);
188  }
190  return tmp;
191  }
192 
198  {
201  dvar3_array tmp;
202  tmp.allocate(m1);
203  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
204  {
205  tmp(i)=m1(i)-d;
206  }
208  return tmp;
209  }
210 
216  {
219  dvar3_array tmp;
220  tmp.allocate(m1);
221  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
222  {
223  tmp(i)=m1(i)+d;
224  }
226  return tmp;
227  }
228 
233 dvar3_array operator+(double d, const dvar3_array& m1)
234  {
237  dvar3_array tmp;
238  tmp.allocate(m1);
239  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
240  {
241  tmp(i)=d+m1(i);
242  }
244  return tmp;
245  }
246 
252  {
255  dvar3_array tmp;
256  tmp.allocate(m1);
257  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
258  {
259  tmp(i)=m1(i)*d;
260  }
262  return tmp;
263  }
264 
270  {
273  dvar3_array tmp;
274  tmp.allocate(m1);
275 
276  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
277  {
278  tmp(i)=m1(i)+d1;
279  }
280 
282  return tmp;
283  }
d3_array elem_prod(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements product of a(i, j, k) * b(i, j, k).
Definition: d3arr2a.cpp:92
int slicemin() const
Definition: fvar.hpp:4274
void allocate(int sl, int sh, int nrl, int nrh, int ncl, int nch)
Allocate variable vector of matrices with dimensions [sl to sh] x ([nrl to nrh] x [ncl to nch]) where...
Definition: f3arr.cpp:91
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
int slicemax() const
Definition: fvar.hpp:4275
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
d3_array elem_div(const d3_array &a, const d3_array &b)
Returns d3_array results with computed elements division of a(i, j, k) / b(i, j, k).
Definition: d3arr2a.cpp:112
dmatrix operator*(const d3_array &t, const dvector &v)
Description not yet available.
Definition: d3arr12.cpp:17
void RETURN_ARRAYS_INCREMENT()
Definition: gradstrc.cpp:478
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static _THREAD gradient_structure * _instance
Description not yet available.
Definition: fvar.hpp:4197
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
Description not yet available.
Definition: fvar.hpp:3727
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518