ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
f3arr1.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 #include "admb_messages.h"
13 
14 #ifndef OPT_LIB
15 
20 prevariable dvar3_array::operator () (int k, int i, int j)
21 {
22  if (!allocated(*this))
23  {
24  cerr << "trying to access an unallocated object" << endl;
25  ad_exit(21);
26  }
27  if (k < slicemin())
28  {
29  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- slice index too low",
30  "prevariable dvar3_array::operator () (int k, int i, int j)",
31  slicemin(), slicemax(), k);
32  }
33  if (k > slicemax())
34  {
35  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- slice index too high",
36  "prevariable dvar3_array::operator () (int k, int i, int j)",
37  slicemin(), slicemax(), k);
38  }
39  return (t + k)->operator()(i,j);
40 }
41 
47 {
48  if (k < slicemin())
49  {
50  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- slice index too low",
51  "dvar_vector& dvar3_array::operator () (int k, int i)",
52  slicemin(), slicemax(), k);
53  }
54  if (k > slicemax())
55  {
56  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- slice index too high",
57  "dvar_vector& dvar3_array::operator () (int k, int i)",
58  slicemin(), slicemax(), k);
59  }
60  return (t + k)->operator()(i);
61 }
62 
68  {
69  if (i < slicemin())
70  {
71  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- slice index too low",
72  "dvar_matrix& dvar3_array::operator [] (int i)",
73  slicemin(), slicemax(), i);
74  }
75  if (i > slicemax())
76  {
77  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- slice index too high",
78  "dvar_matrix& dvar3_array::operator [] (int i)",
79  slicemin(), slicemax(), i);
80  }
81  return t[i];
82  }
83 
89  {
90  if (!allocated(*this))
91  {
92  cerr << "trying to access an unallocated object" << endl;
93  ad_exit(21);
94  }
95  if (i < slicemin())
96  {
97  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- slice index too low",
98  "dvar_matrix& dvar3_array::operator () (int i)",
99  slicemin(), slicemax(), i);
100  }
101  if (i > slicemax())
102  {
103  ADMB_ARRAY_BOUNDS_ERROR("array bound exceeded -- slice index too high",
104  "dvar_matrix& dvar3_array::operator () (int i)",
105  slicemin(), slicemax(), i);
106  }
107  return t[i];
108  }
109 #endif
110 
116 {
119 
120  int min = m.indexmin();
121  int max = m.indexmax();
122  dvariable tmp=0.;
123  const dvar_matrix* pmi = &m(min);
124  for (int i = min; i <= max; ++i)
125  {
126  tmp += sum(*pmi);
127  ++pmi;
128  }
130  return tmp;
131 }
Base class for dvariable.
Definition: fvar.hpp:1315
int slicemin() const
Definition: fvar.hpp:4274
int allocated(const ivector &v)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: fvar_a59.cpp:13
double sum(const d3_array &darray)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: d3arr.cpp:21
int slicemax() const
Definition: fvar.hpp:4275
exitptr ad_exit
Definition: gradstrc.cpp:53
ADMB variable vector.
Definition: fvar.hpp:2172
int indexmax() const
Definition: fvar.hpp:4273
dvar_matrix * t
Definition: fvar.hpp:4199
const dvar_matrix & operator[](int i) const
Definition: fvar.hpp:4358
prnstream & endl(prnstream &)
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.
static _THREAD gradient_structure * _instance
Description not yet available.
Definition: fvar.hpp:4197
#define ADMB_ARRAY_BOUNDS_ERROR(message, function, lower_bounds, upper_bounds, index)
Definition: admb_messages.h:47
const prevariable operator()(int k, int i, int j) const
Definition: fvar.hpp:4343
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
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:4272
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518