ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
f1b2vc3.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 <df1b2fun.h>
12 
18 {
19  df1b2vector& M = (df1b2vector&)_MM;
20  df1b2vector& N = (df1b2vector&)_NN;
21  int rmin=M.indexmin();
22  int rmax=M.indexmax();
23  int cmin=N.indexmin();
24  int cmax=N.indexmax();
25  df1b2matrix tmp(rmin,rmax);
26  for (int i=rmin;i<=rmax;i++)
27  {
28  tmp(i).noallocate(cmin,cmax);
29  for (int j=cmin;j<=cmax;j++)
30  {
31  tmp(i,j)=M(i)*N(j);
32  }
33  }
34  return tmp;
35 }
36 
42 {
44  df1b2vector tmp;
45  int mmin=x.indexmin();
46  int mmax=x.indexmax();
47  tmp.noallocate(mmin,mmax);
48  for (int i=mmin;i<=mmax;i++)
49  {
50  tmp(i)=mfexp(x(i));
51  }
52  return tmp;
53 }
54 
60 {
63  df1b2vector tmp;
64  int mmin=x.indexmin();
65  int mmax=x.indexmax();
66  tmp.noallocate(mmin,mmax);
67  for (int i=mmin;i<=mmax;i++)
68  {
69  tmp(i)=v*x(i);
70  }
71  return tmp;
72 }
73 
79 {
82  df1b2vector tmp;
83  int mmin=x.indexmin();
84  int mmax=x.indexmax();
85  tmp.noallocate(mmin,mmax);
86  for (int i=mmin;i<=mmax;i++)
87  {
88  tmp(i)=v*x(i);
89  }
90  return tmp;
91 }
92 
98 {
101  df1b2vector tmp;
102  int mmin=x.indexmin();
103  int mmax=x.indexmax();
104  tmp.noallocate(mmin,mmax);
105  for (int i=mmin;i<=mmax;i++)
106  {
107  tmp(i)=v*x(i);
108  }
109  return tmp;
110 }
111 
117 {
120  df1b2vector tmp;
121  int mmin=x.indexmin();
122  int mmax=x.indexmax();
123  tmp.noallocate(mmin,mmax);
124  for (int i=mmin;i<=mmax;i++)
125  {
126  tmp(i)=v+x(i);
127  }
128  return tmp;
129 }
130 
136 {
139  df1b2vector tmp;
140  int mmin=x.indexmin();
141  int mmax=x.indexmax();
142  tmp.noallocate(mmin,mmax);
143  for (int i=mmin;i<=mmax;i++)
144  {
145  tmp(i)=v+x(i);
146  }
147  return tmp;
148 }
149 
155 {
157  df1b2vector tmp;
158  int mmin=x.indexmin();
159  int mmax=x.indexmax();
160  tmp.noallocate(mmin,mmax);
161  for (int i=mmin;i<=mmax;i++)
162  {
163  tmp(i)=v+x(i);
164  }
165  return tmp;
166 }
167 
172 df1b2vector operator + (const df1b2vector& _x,const double v)
173 {
175  df1b2vector tmp;
176  int mmin=x.indexmin();
177  int mmax=x.indexmax();
178  tmp.noallocate(mmin,mmax);
179  for (int i=mmin;i<=mmax;i++)
180  {
181  tmp(i)=v+x(i);
182  }
183  return tmp;
184 }
185 
190 df1b2vector operator - (const df1b2vector& _x,const double& v)
191 {
193  df1b2vector tmp;
194  int mmin=x.indexmin();
195  int mmax=x.indexmax();
196  tmp.noallocate(mmin,mmax);
197  for (int i=mmin;i<=mmax;i++)
198  {
199  tmp(i)=v-x(i);
200  }
201  return tmp;
202 }
203 
204 /*
205 df1b2variable operator * (const df1b2vector& _v,const df1b2vector& _x)
206 {
207  ADUNCONST(df1b2vector,v)
208  ADUNCONST(df1b2vector,x)
209  df1b2variable tmp=0.0;
210  int mmin=x.indexmin();
211  int mmax=x.indexmax();
212  for (int i=mmin;i<=mmax;i++)
213  {
214  tmp+=v(i)*x(i);
215  }
216  return tmp;
217 }
218 */
219 
225 {
226  ADUNCONST(dvector,v)
228  df1b2variable tmp=0.0;
229  int mmin=x.indexmin();
230  int mmax=x.indexmax();
231  for (int i=mmin;i<=mmax;i++)
232  {
233  tmp+=v(i)*x(i);
234  }
235  return tmp;
236 }
237 
243 {
246  df1b2variable tmp=0.0;
247  int mmin=x.indexmin();
248  int mmax=x.indexmax();
249  for (int i=mmin;i<=mmax;i++)
250  {
251  tmp+=v(i)*x(i);
252  }
253  return tmp;
254 }
255 
260 int size_count(const df1b2vector& _x)
261 {
263  return x.indexmax()-x.indexmin()+1;
264 }
265 
270 int size_count(const df1b2matrix& _x)
271 {
273  int tmp=0;
274  int mmin=x.indexmin();
275  int mmax=x.indexmax();
276  for (int i=mmin;i<=mmax;i++)
277  {
278  tmp+=size_count(x(i));
279  }
280  return tmp;
281 }
282 
288 {
289  int mmin=indexmin();
290  int mmax=indexmax();
291  for (int i=mmin;i<=mmax;i++)
292  {
293  //x(i).initialize();
294  (*this)(i)=0.0;
295  }
296 }
297 
303 {
305  df1b2vector tmp;
306  int mmin=x.indexmin();
307  int mmax=x.indexmax();
308  tmp.noallocate(mmin,mmax);
309  for (int i=mmin;i<=mmax;i++)
310  {
311  tmp(i)=v*x(i);
312  }
313  return tmp;
314 }
315 
321 {
323  df1b2vector tmp;
324  int mmin=v.indexmin();
325  int mmax=v.indexmax();
326  tmp.noallocate(mmin,mmax);
327  for (int i=mmin;i<=mmax;i++)
328  {
329  tmp(i)=v(i)*x;
330  }
331  return tmp;
332 }
#define N
Definition: rngen.cpp:56
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
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Definition: fvar.hpp:140
Vector of double precision numbers.
Definition: dvector.h:50
Description not yet available.
Definition: df1b2fun.h:953
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 indexmin(void) const
Definition: df1b2fun.h:969
Description not yet available.
Definition: df1b2fun.h:266
dmatrix operator*(const d3_array &t, const dvector &v)
Description not yet available.
Definition: d3arr12.cpp:17
d3_array mfexp(const d3_array &m)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr7.cpp:10
void noallocate(int lib, int ub)
Description not yet available.
Definition: f1b2vc1.cpp:733
#define M
Definition: rngen.cpp:57
dmatrix outer_prod(const dvector &v1, const dvector &v2)
Description not yet available.
Definition: dmat23.cpp:17
Description not yet available.
Definition: df1b2fun.h:1042
int indexmax(void) const
Definition: df1b2fun.h:970
unsigned int size_count(const dvector &x)
Returns total size of elements in vector x.
Definition: dsize.cpp:17
Description not yet available.
void initialize(void)
Description not yet available.
Definition: f1b2vc3.cpp:287