ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
f3arr2.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 
18  {
21  dvariable tmp=0.0;
22  for (int k=m.slicemin();k<=m.slicemax();k++)
23  {
24  tmp+=norm2(m(k));
25  }
26  tmp=sqrt(tmp);
28  return tmp;
29  }
30 
36  {
39  dvariable tmp=0.0;
40  for (int k=m.slicemin();k<=m.slicemax();k++)
41  {
42  tmp+=norm2(m(k));
43  }
45  return tmp;
46  }
47 dvariable sumsq(const dvar3_array& m) {return(norm2(m));}
48 
55 {
58  dvar3_array tmp;
59  tmp.allocate(m);
60  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
61  {
62  tmp(i)=exp(m(i));
63  }
65  return tmp;
66 }
73 {
76  dvar3_array tmp;
77  tmp.allocate(m);
78  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
79  {
80  tmp(i)=log(m(i));
81  }
83  return tmp;
84 }
91 {
94  dvar3_array tmp;
95  tmp.allocate(m);
96  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
97  {
98  tmp(i)=sin(m(i));
99  }
101  return tmp;
102 }
109 {
112  dvar3_array tmp;
113  tmp.allocate(m);
114  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
115  {
116  tmp(i)=cos(m(i));
117  }
119  return tmp;
120 }
127 {
130  dvar3_array tmp;
131  tmp.allocate(m);
132  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
133  {
134  tmp(i)=sqrt(m(i));
135  }
137  return tmp;
138 }
145 {
148  dvar3_array tmp;
149  tmp.allocate(m);
150  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
151  {
152  tmp(i)=sqr(m(i));
153  }
155  return tmp;
156 }
157 
163  {
166  dvar3_array tmp;
167  tmp.allocate(m);
168  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
169  {
170  tmp(i)=tan(m(i));
171  }
173  return tmp;
174  }
175 
181  {
184  dvar3_array tmp;
185  tmp.allocate(m1);
186  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
187  {
188  tmp(i)=elem_prod(m1(i),m2(i));
189  }
191  return tmp;
192  }
193 
199  {
202  dvar3_array tmp;
203  tmp.allocate(m1);
204  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
205  {
206  tmp(i)=elem_div(m1(i),m2(i));
207  }
209  return tmp;
210  }
211 
217  {
220  dvar3_array tmp;
221  tmp.allocate(m1);
222  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
223  {
224  tmp(i)=m1(i)+m2(i);
225  }
227  return tmp;
228  }
229 
235  {
238  dvar3_array tmp;
239  tmp.allocate(m1);
240  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
241  {
242  tmp(i)=m1(i)-m2(i);
243  }
245  return tmp;
246  }
247 
253  {
256  dvar3_array tmp;
257  tmp.allocate(m1);
258  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
259  {
260  tmp(i)=elem_prod(m1(i),m2(i));
261  }
263  return tmp;
264  }
265 
271  {
274  dvar3_array tmp;
275  tmp.allocate(m1);
276  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
277  {
278  tmp(i)=elem_div(m1(i),m2(i));
279  }
281  return tmp;
282  }
283 
289  {
292  dvar3_array tmp;
293  tmp.allocate(m1);
294  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
295  {
296  tmp(i)=m1(i)+m2(i);
297  }
299  return tmp;
300  }
301 
307  {
310  dvar3_array tmp;
311  tmp.allocate(m1);
312  for (int i=tmp.slicemin();i<=tmp.slicemax();i++)
313  {
314  tmp(i)=m1(i)-m2(i);
315  }
317  return tmp;
318  }
d3_array tan(const d3_array &arr3)
Returns d3_array results with computed tan from elements in arr3.
Definition: d3arr2a.cpp:73
d3_array sqr(const d3_array &arr3)
Returns d3_array with square values from arr3.
Definition: d3arr2c.cpp:25
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
double sumsq(const d3_array &a)
Definition: d3arr2a.cpp:181
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
d3_array sin(const d3_array &arr3)
Returns d3_array results with computed sin from elements in arr3.
Definition: d3arr2a.cpp:43
double norm(const d3_array &a)
Return computed norm value of a.
Definition: d3arr2a.cpp:190
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2c.cpp:11
void RETURN_ARRAYS_INCREMENT()
Definition: gradstrc.cpp:478
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
static _THREAD gradient_structure * _instance
Description not yet available.
Definition: fvar.hpp:4197
double norm2(const d3_array &a)
Return sum of squared elements in a.
Definition: d3arr2a.cpp:167
d3_array cos(const d3_array &arr3)
Returns d3_array results with computed cos from elements in arr3.
Definition: d3arr2a.cpp:58
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
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13