ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
depvars.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 // file fvar.cpp
12 // constructors, destructors and misc functions involving class prevariable
13 #include "fvar.hpp"
14 
15 #ifndef _MSC_VER
16  #include <unistd.h>
17 #endif
18 
24  {
26  v1=v2;
28  return (prevariable&)v1;
29  }
30 
36  {
39 
40  int mmin=v1.indexmin();
41  int mmax=v1.indexmax();
42  if (mmin != v2.indexmin() || mmax != v2.indexmax())
43  {
44  cerr << " Incompatible bounds in dvar_vector& operator"
45  " << (const dvar_vector& v1, const dvar_vector& v2)" << endl;
46  ad_exit(21);
47  }
48 
49  for (int i=mmin;i<=mmax;i++)
50  {
51  v1(i) << v2(i);
52  }
54  return (dvar_vector&) v1;
55  }
56 
62  {
65 
66  int mmin=v1.rowmin();
67  int mmax=v1.rowmax();
68  if (mmin != v2.rowmin() || mmax != v2.rowmax())
69  {
70  cerr << " Incompatible bounds in dvar_matrix& operator"
71  " << (const dvar_matrix& v1, const dvar_matrix& v2)" << endl;
72  ad_exit(21);
73  }
74  for (int i=mmin;i<=mmax;i++)
75  {
76  v1(i) << v2(i);
77  }
79  return (dvar_matrix&)v1;
80  }
81 
87  grad_buffer_position(1,ndv),
88  cmpdif_buffer_position(1,ndv),
89  grad_file_position(1,ndv),
90  cmpdif_file_position(1,ndv),
91  grad_file_count(1,ndv),
92  cmpdif_file_count(1,ndv)
93  {
95  depvar_count=0;
102  }
103 
109  {
110  int depvar_count=++DEPVARS_INFO->depvar_count;
111  //max_num_dependent_variables=ndv;
112  if (depvar_count>DEPVARS_INFO->max_num_dependent_variables)
113  {
114  cout << "maximum number of depdendent variables of "
115  << DEPVARS_INFO->max_num_dependent_variables << " exceeded "
116  << endl
117  << "use gradient_structure::set_NUM_DEPENDENT_VARIABLES(int i);"
118  << endl << "to increase the number of dependent variables"
119  << endl;
120  ad_exit(1);
121  }
124  DEPVARS_INFO->grad_file_count(depvar_count)=
126  DEPVARS_INFO->cmpdif_file_count(depvar_count)=fp->file_ptr;
127  DEPVARS_INFO->grad_file_position(depvar_count)
128  =LSEEK(GRAD_STACK1->_GRADFILE_PTR,0,SEEK_CUR);
129  DEPVARS_INFO->cmpdif_file_position(depvar_count)
130  =LSEEK(fp->file_ptr,0,SEEK_CUR);
131  }
Base class for dvariable.
Definition: fvar.hpp:1315
void initialize()
Initialize elements in pointer array to null.
Definition: ptr_vec.cpp:154
int rowmax(void) const
Definition: fvar.hpp:2564
dependent_variables_information * DEPVARS_INFO
#define ADUNCONST(type, obj)
Creates a shallow copy of obj that is not CONST.
Definition: fvar.hpp:140
void initialize(void)
Intialize vector values to zero.
Definition: lvector.cpp:216
exitptr ad_exit
Definition: gradstrc.cpp:53
void save_dependent_variable_position(const prevariable &)
Description not yet available.
Definition: depvars.cpp:108
ADMB variable vector.
Definition: fvar.hpp:2172
#define LSEEK
Definition: fvar.hpp:75
prnstream & endl(prnstream &)
dependent_variables_information(int ndv)
Description not yet available.
Definition: depvars.cpp:86
void RETURN_ARRAYS_INCREMENT()
Definition: gradstrc.cpp:478
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
static _THREAD gradient_structure * _instance
int rowmin(void) const
Definition: fvar.hpp:2560
int indexmin() const
Definition: fvar.hpp:2287
void initialize(void)
Description not yet available.
Definition: ivec2.cpp:17
static _THREAD DF_FILE * fp
grad_stack_entry * ptr
Definition: fvar.hpp:934
ostream & operator<<(const ostream &_s, preshowpoint p)
Description not yet available.
Definition: admanip.cpp:48
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
int _GRADFILE_PTR
Definition: fvar.hpp:942
void RETURN_ARRAYS_DECREMENT()
Definition: gradstrc.cpp:511
static _THREAD grad_stack * GRAD_STACK1
class for things related to the gradient structures, including dimension of arrays, size of buffers, etc.
int indexmax() const
Definition: fvar.hpp:2292