ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
f3arr15.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  const index_type& nrl, const index_type& nrh,
19  const index_type& ncl, const index_type& nch)
20  {
21  allocate(sl,sh,nrl,nrh,ncl,nch);
22 #ifndef OPT_LIB
23  initialize();
24 #endif
25  }
26 
39  ad_integer sl, ad_integer sh,
40  const index_type& nrl, const index_type& nrh,
41  const index_type& ncl, const index_type& nch)
42 {
43  if (sh < sl)
44  {
45  allocate();
46  }
47  else
48  {
49 #ifdef DIAG
50  myheapcheck("Entering d3_array matrix(sl,sh,nrl,nrh,ncl,nch)" );
51 #endif
52  if ( (nrl.isinteger() && (sl !=nrl.indexmin() || sh !=nrl.indexmax())) ||
53  (nrh.isinteger() && (sl !=nrh.indexmin() || sh !=nrh.indexmax())) )
54  {
55  cerr << nrl.isinteger() << " " << nrh.isinteger() << endl;
56  cerr << sl << " " << nrl.indexmin() << endl;
57  cerr << sh << " " << nrl.indexmax() << endl;
58  cerr << sl << " " << nrh.indexmin() << endl;
59  cerr << sh << " " << nrh.indexmax() << endl;
60  cerr << "Incompatible array bounds in dvar3_array(int nrl,int nrh,"
61  "const index_type& nrl,const index_type& nrh,"
62  "const index_type& ncl,const index_type& nch)" << endl;
63  ad_exit(1);
64  }
65  if ((shape = new three_array_shape(sl, sh)) == 0)
66  {
67  cerr << " Error: dvar3_array unable to allocate memory in "
68  << __FILE__ << ':' << __LINE__ << '\n';
69  ad_exit(1);
70  }
71  if ((t = new dvar_matrix[slicesize()]) == 0)
72  {
73  cerr << " Error: dvar3_array unable to allocate memory in "
74  << __FILE__ << ':' << __LINE__ << '\n';
75  ad_exit(1);
76  }
77  t -= slicemin();
78  for (int i = sl; i <= sh; ++i)
79  {
80  t[i].allocate(nrl[i], nrh[i], ncl[i], nch[i]);
81  }
82  }
83 }
84 
90  ad_integer sl, ad_integer sh,
91  const index_type& nrl, const index_type& nrh)
92 {
93  if (sh<sl)
94  {
95  allocate();
96  }
97  else
98  {
99 #ifdef DIAG
100  myheapcheck("Entering d3_array matrix(sl,sh,nrl,nrh,ncl,nch)" );
101 #endif
102  if ((nrl.isinteger() && (sl !=nrl.indexmin() || sh !=nrl.indexmax()))
103  || (nrh.isinteger() && (sl !=nrh.indexmin() || sh !=nrh.indexmax())))
104  {
105  cerr << nrl.isinteger() << " " << nrh.isinteger() << endl;
106  cerr << sl << " " << nrl.indexmin() << endl;
107  cerr << sh << " " << nrl.indexmax() << endl;
108  cerr << sl << " " << nrh.indexmin() << endl;
109  cerr << "Incompatible array bounds in dvar3_array(int nrl,int nrh,"
110  "const index_type& nrl,const index_type& nrh,"
111  "const index_type& ncl,const index_type& nch)" << endl;
112  ad_exit(1);
113  }
114  if ((shape = new three_array_shape(sl, sh)) == 0)
115  {
116  cerr << " Error: dvar3_array unable to allocate memory in "
117  << __FILE__ << ':' << __LINE__ << '\n';
118  ad_exit(1);
119  }
120  if ((t = new dvar_matrix[slicesize()]) == 0)
121  {
122  cerr << " Error: dvar3_array unable to allocate memory in "
123  << __FILE__ << ':' << __LINE__ << '\n';
124  ad_exit(1);
125  }
126  t -= slicemin();
127  for (int i = sl; i <= sh; ++i)
128  {
129  t[i].allocate(nrl[i], nrh[i]);
130  }
131  }
132 }
139 {
140  if (sh < sl)
141  {
142  allocate();
143  }
144  else
145  {
146 #ifdef DIAG
147  myheapcheck("Entering d3_array matrix(sl,sh,nrl,nrh,ncl,nch)" );
148 #endif
149  if ((shape = new three_array_shape(sl, sh)) == 0)
150  {
151  cerr << " Error: dvar3_array unable to allocate memory in "
152  << __FILE__ << ':' << __LINE__ << '\n';
153  ad_exit(1);
154  }
155  if ((t = new dvar_matrix[slicesize()]) == 0)
156  {
157  cerr << " Error: dvar3_array unable to allocate memory in "
158  << __FILE__ << ':' << __LINE__ << '\n';
159  ad_exit(1);
160  }
161  t -= slicemin();
162  for (int i = sl; i <= sh; ++i)
163  {
164  t[i].allocate();
165  }
166  }
167 }
void myheapcheck(char *msg)
Does nothing.
Definition: dvector.cpp:669
Uses polymorphism to get index information from various data types to be used in constructing and all...
Definition: fvar.hpp:7731
int slicemin() const
Definition: fvar.hpp:4274
int isinteger() const
Definition: fvar.hpp:7752
void initialize(void)
Description not yet available.
Definition: f3arr.cpp:17
Description not yet available.
Definition: fvar.hpp:3698
exitptr ad_exit
Definition: gradstrc.cpp:53
dvar_matrix * t
Definition: fvar.hpp:4199
dvar3_array(void)
Default constructor.
Definition: f3arr17.cpp:11
prnstream & endl(prnstream &)
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int indexmax() const
Definition: fvar.hpp:7764
void allocate(void)
Does not allocte, but initialize class members.
Definition: f3arr17.cpp:18
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
unsigned int slicesize() const
Definition: fvar.hpp:4277
three_array_shape * shape
Definition: fvar.hpp:4200
void allocate(int nrl, int nrh, int ncl, int nch)
Allocates AD variable matrix with dimensions nrl to nrh by ncl to nch.
Definition: fvar_mat.cpp:216
Stores integer.
Definition: fvar.hpp:7654
int indexmin() const
Definition: fvar.hpp:7760