ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shared1.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 <admodel.h>
8 
9 # if defined(USE_SHARE_FLAGS)
10 /*
11  static int integer(const index_type& it)
12  {
13  return it.integer();
14  }
15 */
16 
18  {
20  {
22  }
23  i3_array & bmap = share_flags->get_bmap();
24  int mmin=bmap.indexmin();
25  int mmax=bmap.indexmax();
26  int nv=0;
27  for (int i=mmin;i<=mmax;i++)
28  {
29  nv+=::size_count((*this)(bmap(i,1,1),bmap(i,1,2)));
30  }
31  return nv;
32  }
33 
35  (const dvector& _x,const int& _ii)
36  {
37  ADUNCONST(int,ii)
39  index_type& it=*(share_flags->get_invflags());
40  //int mmin=share_flags->invflags->indexmin();
41  //int mmax=share_flags->invflags->indexmax();
42  int mmin=it.indexmin();
43  int mmax=it.indexmax();
44  int i;
45  for (i=mmin;i<=mmax;i++)
46  {
47  int k1=it(i)(1).integer();
48  int k2=it(i)(2).integer();
49  const dvar_vector & v=(*this)(k1,k2);
50  int kmin=v.indexmin();
51  int kmax=v.indexmax();
52  for (int k=kmin;k<=kmax;k++)
53  {
54  x(ii++)=::value(v(k));
55  }
56  }
57  }
58 
60  const int& _ii,const dvariable& pen)
61  {
62  ADUNCONST(int,ii)
64  i3_array & bmap = share_flags->get_bmap();
65  int mmin=bmap.indexmin();
66  int mmax=bmap.indexmax();
67  for (int i=mmin;i<=mmax;i++)
68  {
69  int jmin=bmap(i).indexmin();
70  int jmax=bmap(i).indexmax();
71 
72  int ii1 = 0;
73  for (int j=jmin;j<=jmax;j++)
74  {
75  dvar_vector& v=(*this)(bmap(i,j,1),bmap(i,j,2));
76 
77  int kmin=v.indexmin();
78  int kmax=v.indexmax();
79 
80  ii1=ii;
81  for (int k=kmin;k<=kmax;k++)
82  {
83  v(k)=x(ii1++);
84  }
85  }
86  ii=ii1;
87  }
88  }
89 
91  (const index_type& sf,const index_type& af)
92  {
93  share_flags = new shareinfo(sf,af);
94  int idim1= share_flags->get_shareflags()->dimension();
95  share_flags->get_dimension()=idim1;
96  int idim2= share_flags->get_activeflags()->dimension();
97  switch (idim1)
98  {
99  case 1:
100  share_flags->get_inv_vector_shared(current_phase);
101  break;
102  case 2:
103  {
104  cout << idim1 << " " << idim2 << endl;
105  // check rationality
106  int mmin1= share_flags->get_shareflags()->indexmin();
107  int mmax1= share_flags->get_shareflags()->indexmax();
108  int mmin2= share_flags->get_activeflags()->indexmin();
109  int mmax2= share_flags->get_activeflags()->indexmax();
110  int mmin=indexmin();
111  int mmax=indexmax();
112  if (mmin1 != mmin || mmax1 != mmax ||
113  mmin2 != mmin || mmax2 != mmax)
114  {
115  cerr << "sanity error" << endl;
116  ad_exit(1);
117  }
118  share_flags->get_inv_matrix_shared(current_phase);
119  }
120  break;
121  default:
122  cerr << "Error" << endl;
123  ad_exit(1);
124  }
125  }
126 # endif
Uses polymorphism to get index information from various data types to be used in constructing and all...
Definition: fvar.hpp:7731
#define x
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Definition: fvar.hpp:140
Vector of double precision numbers.
Definition: dvector.h:50
exitptr ad_exit
Definition: gradstrc.cpp:53
ADMB variable vector.
Definition: fvar.hpp:2172
int indexmin() const
Definition: fvar.hpp:4021
virtual void shared_set_value(const dvar_vector &, const int &, const dvariable &pen)
Definition: shared1.cpp:59
void get_inv_matrix_shared(int _cf)
Definition: shared.cpp:269
virtual unsigned int size_count() const
Return number of active parameters.
Definition: model21.cpp:41
shareinfo * share_flags
Definition: admodel.h:818
prnstream & endl(prnstream &)
int & get_current_phase(void)
Definition: shared.cpp:196
static int current_phase
Definition: admodel.h:842
Description not yet available.
Definition: admodel.h:777
Description not yet available.
i3_array & get_bmap(void)
Definition: shared.cpp:208
int indexmax() const
Definition: fvar.hpp:7764
int indexmin() const
Definition: fvar.hpp:2287
virtual void setshare(const index_type &sf, const index_type &af)
Definition: shared1.cpp:91
virtual void shared_set_value_inv(const dvector &, const int &)
Definition: shared1.cpp:35
virtual int shared_size_count(void)
Definition: shared1.cpp:17
long int integer
Definition: cbivnorm.cpp:31
int indexmax() const
Definition: fvar.hpp:4025
dvector value(const df1_one_vector &v)
Definition: df11fun.cpp:69
Description not yet available.
Definition: fvar.hpp:3944
int indexmax() const
Definition: fvar.hpp:2292
Fundamental data type for reverse mode automatic differentiation.
Definition: fvar.hpp:1518
int indexmin() const
Definition: fvar.hpp:7760