ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
f4arr1.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 {
19  dvar4_array tmp;
20  tmp.allocate(m);
21  int min = m.slicemin();
22  int max = m.slicemax();
23  dvar3_array* ptmpi = &tmp(min);
24  const dvar3_array* pmi = &m(min);
25  for (int i = min; i <= max; ++i)
26  {
27  *ptmpi = sqrt(*pmi);
28  ++ptmpi;
29  ++pmi;
30  }
31  return tmp;
32 }
33 
39 {
40  dvar4_array tmp;
41  tmp.allocate(m);
42  int min = m.slicemin();
43  int max = m.slicemax();
44  dvar3_array* ptmpi = &tmp(min);
45  const dvar3_array* pmi = &m(min);
46  for (int i = min; i <= max; ++i)
47  {
48  *ptmpi = exp(*pmi);
49  ++ptmpi;
50  ++pmi;
51  }
52  return tmp;
53 }
54 
60 {
61  dvar4_array tmp;
62  tmp.allocate(m);
63  int min = m.slicemin();
64  int max = m.slicemax();
65  dvar3_array* ptmpi = &tmp(min);
66  const dvar3_array* pmi = &m(min);
67  for (int i = min; i <= max; ++i)
68  {
69  *ptmpi = mfexp(*pmi);
70  ++ptmpi;
71  ++pmi;
72  }
73  return tmp;
74 }
75 
81 {
82  dvar4_array tmp;
83  tmp.allocate(m);
84  int min = m.indexmin();
85  int max = m.indexmax();
86  dvar3_array* ptmpi = &tmp(min);
87  const dvar3_array* pmi = &m(min);
88  for (int i = min; i <= max; ++i)
89  {
90  *ptmpi = log(*pmi);
91  ++ptmpi;
92  ++pmi;
93  }
94  return tmp;
95 }
96 
102 {
105 
106  int min = m.indexmin();
107  int max = m.indexmax();
108  dvariable tmp = 0.0;
109  const dvar3_array* pmi = &m(min);
110  for (int i = min; i <= max; ++i)
111  {
112  tmp += sum(*pmi);
113  ++pmi;
114  }
116  return tmp;
117 }
int slicemax(void)
Definition: fvar.hpp:5575
int indexmax() const
Definition: fvar.hpp:5622
Description not yet available.
Definition: fvar.hpp:5433
int slicemin(void)
Definition: fvar.hpp:5571
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 mfexp(const d3_array &m)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr7.cpp:10
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
#define min(a, b)
Definition: cbivnorm.cpp:188
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
void allocate(int hsl, int hsu, int sl, int sh, int nrl, int nrh, int ncl, int nch)
Allocate variable array with dimensions [hsl to hsu] x [sl to sh] x [nrl to nrh] x [ncl to nch]...
Definition: f4arr.cpp:309
Description not yet available.
Definition: fvar.hpp:4197
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
#define max(a, b)
Definition: cbivnorm.cpp:189
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
int indexmin() const
Definition: fvar.hpp:5621
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