ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fill.cpp
Go to the documentation of this file.
1 #include "statsLib.h"
2 
40 void fill(const dmatrix& _d,const dvector& _v)
41 {
42  ADUNCONST(dmatrix,d)
44  int mmin =d.indexmin();
45  int mmax =d.indexmax();
46  int sz=0;
47  int i;
48  ivector sz1(mmin,mmax);
49  for (i=mmin;i<=mmax;i++)
50  {
51  sz1(i)=d(i).indexmax()-d(i).indexmin()+1;
52  sz+=sz1(i);
53  }
54 
55  if (sz != v.indexmax()-v.indexmin()+1)
56  {
57  cerr << "Error in sizes in function"
58  " void fill(const dmatrix& _d,const dvector& v)" << endl;
59  ad_exit(1);
60  }
61  int offset=v.indexmin();
62  for (i=mmin;i<=mmax;i++)
63  {
64  d(i)=v(offset,offset+sz1(i)-1).shift(d(i).indexmin());
65  }
66 }
67 
75 void fill(const dvar_matrix& _d,const dvar_vector& _v)
76 {
79  int mmin =d.indexmin();
80  int mmax =d.indexmax();
81  int sz=0;
82  int i;
83  ivector sz1(mmin,mmax);
84  for (i=mmin;i<=mmax;i++)
85  {
86  sz1(i)=d(i).indexmax()-d(i).indexmin()+1;
87  sz+=sz1(i);
88  }
89 
90  if (sz != v.indexmax()-v.indexmin()+1)
91  {
92  cerr << "Error in sizes in function"
93  " void fill(const dmatrix& _d,const dvector& v)" << endl;
94  ad_exit(1);
95  }
96  int offset=v.indexmin();
97  for (i=mmin;i<=mmax;i++)
98  {
99  d(i)=v(offset,offset+sz1(i)-1).shift(d(i).indexmin());
100  }
101 }
#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
prnstream & endl(prnstream &)
Array of integers(int) with indexes from index_min to indexmax.
Definition: ivector.h:50
int indexmax() const
Definition: ivector.h:104
Description not yet available.
Definition: fvar.hpp:2819
Library of statistic functions.
Class definition of matrix with derivitive information .
Definition: fvar.hpp:2480
void fill(const dmatrix &_d, const dvector &_v)
Definition: fill.cpp:40