ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
d3arr2a.cpp
Go to the documentation of this file.
1 
6 #include "fvar.hpp"
7 
13 d3_array log(const d3_array& arr3)
14 {
15  d3_array results;
16  results.allocate(arr3);
17  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
18  {
19  results(i) = log(arr3(i));
20  }
21  return results;
22 }
28 d3_array exp(const d3_array& arr3)
29 {
30  d3_array results;
31  results.allocate(arr3);
32  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
33  {
34  results(i) = exp(arr3(i));
35  }
36  return results;
37 }
43 d3_array sin(const d3_array& arr3)
44 {
45  d3_array results;
46  results.allocate(arr3);
47  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
48  {
49  results(i) = sin(arr3(i));
50  }
51  return results;
52 }
58 d3_array cos(const d3_array& arr3)
59 {
60  d3_array results;
61  results.allocate(arr3);
62  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
63  {
64  results(i) = cos(arr3(i));
65  }
66  return results;
67 }
73 d3_array tan(const d3_array& arr3)
74 {
75  d3_array results;
76  results.allocate(arr3);
77  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
78  {
79  results(i) = tan(arr3(i));
80  }
81  return results;
82 }
92 d3_array elem_prod(const d3_array& a, const d3_array& b)
93 {
94  d3_array results;
95  results.allocate(a);
96  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
97  {
98  results(i) = elem_prod(a(i), b(i));
99  }
100  return results;
101 }
112 d3_array elem_div(const d3_array& a, const d3_array& b)
113 {
114  d3_array results;
115  results.allocate(a);
116  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
117  {
118  results(i) = elem_div(a(i), b(i));
119  }
120  return results;
121 }
132 d3_array operator+(const d3_array& a, const d3_array& b)
133 {
134  d3_array results;
135  results.allocate(a);
136  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
137  {
138  results(i) = a(i) + b(i);
139  }
140  return results;
141 }
152 d3_array operator-(const d3_array& a, const d3_array& b)
153 {
154  d3_array results;
155  results.allocate(a);
156  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
157  {
158  results(i) = a(i) - b(i);
159  }
160  return results;
161 }
167 double norm2(const d3_array& a)
168 {
169  double sum = 0.0;
170  for (int i = a.slicemin(); i <= a.slicemax(); ++i)
171  {
172  sum += norm2(a(i));
173  }
174  return sum;
175 }
176 /*
177 Return sum of squared elements in a.
178 
179 \param a d3_array
180 */
181 double sumsq(const d3_array& a)
182 {
183  return norm2(a);
184 }
190 double norm(const d3_array& a)
191 {
192  return sqrt(norm2(a));
193 }
200 d3_array operator+(double value, const d3_array& a)
201 {
202  d3_array results;
203  results.allocate(a);
204  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
205  {
206  results(i) = value + a(i);
207  }
208  return results;
209 }
216 d3_array operator-(double value, const d3_array& a)
217 {
218  d3_array results;
219  results.allocate(a);
220  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
221  {
222  results(i) = value - a(i);
223  }
224  return results;
225 }
232 d3_array operator+(const d3_array& a, double value)
233 {
234  d3_array results;
235  results.allocate(a);
236  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
237  {
238  results(i) = a(i) + value;
239  }
240  return results;
241 }
248 d3_array operator-(const d3_array& a, double value)
249 {
250  d3_array results;
251  results.allocate(a);
252  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
253  {
254  results(i) = a(i) - value;
255  }
256  return results;
257 }
264 d3_array operator*(const d3_array& a, double value)
265 {
266  d3_array results;
267  results.allocate(a);
268  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
269  {
270  results(i) = a(i) * value;
271  }
272  return results;
273 }
280 d3_array operator*(double value, const d3_array& a)
281 {
282  d3_array results;
283  results.allocate(a);
284  for (int i = results.slicemin(); i <= results.slicemax(); ++i)
285  {
286  results(i) = value * a(i);
287  }
288  return results;
289 }
d3_array tan(const d3_array &arr3)
Returns d3_array results with computed tan from elements in arr3.
Definition: d3arr2a.cpp:73
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
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
void allocate(const ad_integer &sl, const ad_integer &sh, const index_type &nrl, const index_type &nrh, const index_type &ncl, const index_type &nch)
Allocate array of matrices with dimensions [sl to sh] x [nrl to nrh] x [ncl to nch].
Definition: indextyp.cpp:327
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
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
int slicemax() const
Definition: fvar.hpp:3830
dmatrix operator*(const d3_array &t, const dvector &v)
Description not yet available.
Definition: d3arr12.cpp:17
d3_array sqrt(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2c.cpp:11
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
int slicemin() const
Definition: fvar.hpp:3826
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
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
Description not yet available.
Definition: fvar.hpp:3727
d3_array log(const d3_array &arr3)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr2a.cpp:13