ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
multiindex.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 
17  multi_index::multi_index(int min,int max,int dim) :
18  mind(min),maxd(max),depth(min), index(1, dim)
19  {
20  index=min;
21  }
23  {
24  int imin=index.indexmin();
25  int imax=index.indexmax();
26  index(imin)++;
27  int tmpdepth=1;
28  for (int i=imin;i<=imax;i++)
29  {
30  if (index(i)>maxd)
31  {
32  if (i<imax)
33  {
34  index(i+1)++;
35  }
36  index(i)=mind;
37  tmpdepth=i+1;
38  }
39  else
40  {
41  break;
42  }
43  }
44  if (tmpdepth>depth)
45  depth =tmpdepth;
46  }
48  {
49  int imin=index.indexmin();
50  int imax=index.indexmax();
51  int offset=index(imin)-mind;
52  int mx=min(depth,imax);
53  int sz=maxd-mind+1;
54  for (int i=imin+1;i<=mx;i++)
55  {
56  offset+=int(pow(double(sz),i-imin))*(index(i)-mind);
57  }
58  return offset;
59  }
60 
66  {
67  index=mind;
68  depth=mind;
69  }
int mind
Definition: fvar.hpp:9224
int depth
Definition: fvar.hpp:9226
int get_offset(void)
Definition: multiindex.cpp:47
#define min(a, b)
Definition: cbivnorm.cpp:188
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void operator++(void)
Definition: multiindex.cpp:22
int indexmin() const
Definition: ivector.h:99
int indexmax() const
Definition: ivector.h:104
void initialize()
Description not yet available.
Definition: multiindex.cpp:65
int maxd
Definition: fvar.hpp:9225
ivector index
Definition: fvar.hpp:9227
#define max(a, b)
Definition: cbivnorm.cpp:189
multi_index(int min, int max, int dim)
Description not yet available.
Definition: multiindex.cpp:17
d3_array pow(const d3_array &m, int e)
Description not yet available.
Definition: d3arr6.cpp:17