ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dmat_a.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  struct dvec_ptr_ptr
18  {
19  void ** m;
20  };
21 
27  {
28  int nrl=pos.row_min;
29  int nrh=pos.row_max;
30  const ivector& ncl=pos.lb;
31  const ivector& nch=pos.ub;
32 #ifdef DIAG
33  myheapcheck("Entering dmatrix(nrl,nrh,ncl,nch)" );
34 #endif
35 
36 #ifndef OPT_LIB
37  if (nrl != ncl.indexmin() || nrh != ncl.indexmax()
38  || nrl != nch.indexmin() || nrh != nch.indexmax())
39  {
40  cerr << "Incompatible array bounds in "
41  "dmatrix(int nrl,int nrh, const ivector& ncl, const ivector& nch)\n";
42  ad_exit(1);
43  }
44 #endif
45  index_min=nrl;
46  index_max=nrh;
47 
48  if ( (m = new dvector[rowsize()]) == 0)
49  {
50  cerr << " Error allocating memory in dmatrix contructor\n";
51  ad_exit(21);
52  }
53  if ( (shape = new mat_shapex(m)) == 0)
54  {
55  cerr << " Error allocating memory in dmatrix contructor\n";
56  ad_exit(21);
57  }
58 
59 #ifdef DIAG
60  cerr << "Created a dmatrix with adress "<< farptr_tolong(m)<<"\n";
61 #endif
62 
63  m -= rowmin();
64 
65  dvector* pm = m + nrl;
66  int* pncl = ncl.get_v() + nrl;
67  int* pnch = nch.get_v() + nrl;
68  for (int i = nrl; i <= nrh; ++i)
69  {
70  pm->allocate(*pncl, *pnch);
71  ++pm;
72  ++pncl;
73  ++pnch;
74 #ifdef DIAG
75  cerr << "Created a dvector with address "<< farptr_tolong((void*)(m+i))<<"\n";
76 #endif
77  }
78 
79 #ifdef DIAG
80  myheapcheck("Leaving dmatrix(nrl,nrh,ncl,nch)" );
81 #endif
82  }
83 
89  {
90  int nrl=pos.row_min;
91  int nrh=pos.row_max;
92  const ivector& ncl=pos.lb;
93  const ivector& nch=pos.ub;
94 
95 #ifdef DIAG
96  myheapcheck("Entering dmatrix(nrl,nrh,ncl,nch)" );
97 #endif
98 
99 #ifndef OPT_LIB
100  if (nrl != ncl.indexmin() || nrh != ncl.indexmax()
101  || nrl != nch.indexmin() || nrh != nch.indexmax())
102  {
103  cerr << "Incompatible array bounds in "
104  "dmatrix(int nrl,int nrh, const ivector& ncl, const ivector& nch)\n";
105  ad_exit(1);
106  }
107 #endif
108  index_min=nrl;
109  index_max=nrh;
110 
111  if ( (m = new dvector[rowsize()]) == 0)
112  {
113  cerr << " Error allocating memory in dmatrix contructor\n";
114  ad_exit(21);
115  }
116 
117  if ( (shape = new mat_shapex(m))== 0)
118  {
119  cerr << " Error allocating memory in dmatrix contructor\n";
120  ad_exit(21);
121  }
122 
123 #ifdef DIAG
124  cerr << "Created a dmatrix with adress "<< farptr_tolong(m)<<"\n";
125 #endif
126 
127  m -= rowmin();
128 
129  dvector* pm = m + nrl;
130  int* pncl = ncl.get_v() + nrl;
131  int* pnch = nch.get_v() + nrl;
132  for (int i = nrl; i <= nrh; ++i)
133  {
134  pm->allocate(*pncl, *pnch);
135  ++pncl;
136  ++pnch;
137  ++pm;
138  }
139 #ifdef DIAG
140  myheapcheck("Leaving dmatrix(nrl,nrh,ncl,nch)" );
141 #endif
142  }
Description not yet available.
Definition: fvar.hpp:4883
int index_min
Definition: fvar.hpp:2822
void myheapcheck(char *msg)
Does nothing.
Definition: dvector.cpp:669
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
Definition: dmat.cpp:11
Description not yet available.
Definition: fvar.hpp:2030
void ** m
Definition: dmat.cpp:13
dmatrix(void)
Default constructor.
Definition: dmat0.cpp:16
Vector of double precision numbers.
Definition: dvector.h:50
void allocate(int ncl, int ncu)
Allocate memory for a dvector.
Definition: dvector.cpp:409
exitptr ad_exit
Definition: gradstrc.cpp:53
int index_max
Definition: fvar.hpp:2823
mat_shapex * shape
Definition: fvar.hpp:2825
int * get_v() const
Definition: ivector.h:114
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
int indexmin() const
Definition: ivector.h:99
dvector * m
Definition: fvar.hpp:2824
int indexmax() const
Definition: ivector.h:104
ivector lb
Definition: fvar.hpp:4888
ivector ub
Definition: fvar.hpp:4889
size_t pos(const adstring &substr, const adstring &s)
Definition: string3.cpp:56
unsigned int rowsize() const
Definition: fvar.hpp:2934
int rowmin() const
Definition: fvar.hpp:2925
Description not yet available.
Definition: fvar.hpp:4843