ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
size.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  */
7 #include "fvar.hpp"
8 
14 unsigned int size_count(const dvar_vector& x)
15 {
16  return !(x) ? 0 : x.size();
17 }
18 
23 int size_count_partial(const dvar_vector& x,int n)
24 {
25  if (!(x))
26  return 0;
27  else
28  return max(0, n);
29 }
30 
36 unsigned int size_count(const dvar_matrix& x)
37 {
38  unsigned int size = 0;
39  if (!(x) == false)
40  {
41  int min = x.rowmin();
42  int max = x.rowmax();
43  const dvar_vector* pxi = &x(min);
44  for (int i = min; i <= max; ++i)
45  {
46  size += size_count(*pxi);
47 
48  ++pxi;
49  }
50  }
51  return size;
52 }
53 
58 int size_count_partial(const dvar_matrix& x, int n)
59 {
60  if (!(x))
61  return 0;
62  else
63  {
64  int tmp=0;
65  int min=x.rowmin();
66  int max=x.rowmax();
67  const dvar_vector* pxi = &x(min);
68  for (int i=min;i<=max;++i)
69  {
70  tmp+=size_count_partial(*pxi, n);
71 
72  ++pxi;
73  }
74  return tmp;
75  }
76 }
82 unsigned int size_count(const dvar3_array& x)
83 {
84  unsigned int size = 0;
85  if (!(x) == false)
86  {
87  int min = x.slicemin();
88  int max = x.slicemax();
89  const dvar_matrix* pxi = &x(min);
90  for (int i = min; i <= max; ++i)
91  {
92  size += size_count(*pxi);
93 
94  ++pxi;
95  }
96  }
97  return size;
98 }
104 unsigned int size_count(const dvar4_array& x)
105 {
106  unsigned int size = 0;
107  if (!(x) == false)
108  {
109  int min = x.indexmin();
110  int max = x.indexmax();
111  const dvar3_array* pxi = &x(min);
112  for (int i = min; i <= max; ++i)
113  {
114  size += size_count(*pxi);
115 
116  ++pxi;
117  }
118  }
119  return size;
120 }
126 unsigned int size_count(const d4_array& x)
127 {
128  unsigned int size = 0;
129  if (!(x) == false)
130  {
131  int min = x.indexmin();
132  int max = x.indexmax();
133  const d3_array* pxi = &x(min);
134  for (int i = min; i <= max; ++i)
135  {
136  size += size_count(*pxi);
137 
138  ++pxi;
139  }
140  }
141  return size;
142 }
143 
148 int size_count_partial(const dvar3_array& x, int n)
149 {
150  if (!(x))
151  return 0;
152  else
153  {
154  int tmp=0;
155  int min=x.slicemin();
156  int max=x.slicemax();
157  const dvar_matrix* pxi = &x(min);
158  for (int i=min;i<=max;i++)
159  {
160  tmp += size_count_partial(*pxi, n);
161 
162  ++pxi;
163  }
164  return tmp;
165  }
166 }
int indexmax() const
Definition: fvar.hpp:5622
int rowmax(void) const
Definition: fvar.hpp:2564
int slicemin() const
Definition: fvar.hpp:4274
int size_count_partial(const dvector &x, int n)
Description not yet available.
Definition: dsize.cpp:26
Description not yet available.
Definition: fvar.hpp:5433
#define x
int slicemax() const
Definition: fvar.hpp:4275
ADMB variable vector.
Definition: fvar.hpp:2172
unsigned int size() const
Definition: fvar.hpp:2297
Description not yet available.
Definition: fvar.hpp:5161
#define min(a, b)
Definition: cbivnorm.cpp:188
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int rowmin(void) const
Definition: fvar.hpp:2560
Description not yet available.
Definition: fvar.hpp:4197
int indexmin() const
Definition: fvar.hpp:5305
int indexmax() const
Definition: fvar.hpp:5309
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
unsigned int size_count(const dvector &x)
Returns total size of elements in vector x.
Definition: dsize.cpp:17
#define max(a, b)
Definition: cbivnorm.cpp:189
Description not yet available.
Definition: fvar.hpp:3727
int indexmin() const
Definition: fvar.hpp:5621