ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
f6arr1.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 
22  dvar6_array tmp;
23  tmp.allocate(m);
24  int min = tmp.indexmin();
25  int max = tmp.indexmax();
26  dvar5_array* ptmpi = &tmp(min);
27  const d5_array* pmi = &m(min);
28  for (int i=min;i<=max;++i)
29  {
30  *ptmpi = *pmi / d;
31  ++ptmpi;
32  ++pmi;
33  }
35  return tmp;
36  }
37 
42 dvar6_array operator/(const dvar6_array& m, const double d)
43  {
46  dvar6_array tmp;
47  tmp.allocate(m);
48  int min = tmp.indexmin();
49  int max = tmp.indexmax();
50  dvar5_array* ptmpi = &tmp(min);
51  const dvar5_array* pmi = &m(min);
52  for (int i=min;i<=max;++i)
53  {
54  *ptmpi = *pmi / d;
55  ++ptmpi;
56  ++pmi;
57  }
59  return tmp;
60  }
61 
67  {
70  dvar6_array tmp;
71  tmp.allocate(m);
72  int min = tmp.indexmin();
73  int max = tmp.indexmax();
74  dvar5_array* ptmpi = &tmp(min);
75  const dvar5_array* pmi = &m(min);
76  for (int i=min;i<=max;++i)
77  {
78  *ptmpi = *pmi / d;
79  ++ptmpi;
80  ++pmi;
81  }
83  return tmp;
84  }
85 
91  {
94  int min = indexmin();
95  int max = indexmax();
96  dvar5_array* pti = t + min;
97  for (int i=min;i<=max;++i)
98  {
99  *pti /= d;
100  ++pti;
101  }
103  }
104 
109 void dvar6_array::operator/=(const double& d)
110  {
113  int min = indexmin();
114  int max = indexmax();
115  dvar5_array* pti = t + min;
116  for (int i=min;i<=max;++i)
117  {
118  *pti /= d;
119  ++pti;
120  }
122  }
123 
129 {
132  dvariable tmp=0.;
133  int min = m.indexmin();
134  int max = m.indexmax();
135  const dvar5_array* pmi = &m(min);
136  for (int i = min; i <= max; ++i)
137  {
138  tmp+=sum(*pmi);
139 
140  ++pmi;
141  }
143  return tmp;
144 }
void allocate(int hhsl, int hhsu)
Allocate vector of dvar5_array with dimension [hsl to hsu].
Definition: f6arr.cpp:507
Base class for dvariable.
Definition: fvar.hpp:1315
Description not yet available.
Definition: fvar.hpp:6861
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
dvar5_array * t
Definition: fvar.hpp:6864
Description not yet available.
Definition: fvar.hpp:6673
void RETURN_ARRAYS_INCREMENT()
Definition: gradstrc.cpp:478
#define min(a, b)
Definition: cbivnorm.cpp:188
Description not yet available.
Definition: fvar.hpp:6498
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static _THREAD gradient_structure * _instance
int indexmin() const
Definition: fvar.hpp:7028
void operator/=(const prevariable &d)
Description not yet available.
Definition: f6arr1.cpp:90
Description not yet available.
Definition: fvar.hpp:6331
int indexmax() const
Definition: fvar.hpp:7032
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
d3_array operator/(const d3_array &m, const double d)
Author: David Fournier.
Definition: d3arr2b.cpp:14
#define max(a, b)
Definition: cbivnorm.cpp:189
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518