Example #1
0
/**
Allocate variable vector of matrices with dimensions
[sl to sh] x ([nrl to nrh] x [ncl to nch])
where nch is a vector of indexes.
\param sl lower index of vector
\param sh upper index of vector
\param nrl lower row index for matrix
\param nrh upper row index for matrix
\param ncl lower column index for matrix
\param nch upper column index for matrix
*/
void dvar3_array::allocate(int sl,int sh,int nrl,int nrh,int ncl,int nch)
{
  if (sh < sl)
  {
    allocate();
    return;
  }
#ifdef DIAG
  myheapcheck("Entering dvar3_array matrix(sl,sh,nrl,nrh,ncl,nch)" );
#endif
  if ((shape = new three_array_shape(sl, sh)) == 0)
  {
    cerr << " Error allocating memory in dvar3_array contructor" << endl;
  }
  if ((t = new dvar_matrix[slicesize()]) == 0)
  {
    cerr << " Error allocating memory in dvar3_array contructor" << endl;
    ad_exit(21);
  }
  t -= slicemin();
  for (int i = sl; i <= sh; ++i)
  {
    t[i].allocate(nrl, nrh, ncl, nch);
  }
}
Example #2
0
/**
Allocate variable vector of matrices with dimensions
[sl to sh] x ([nrl to nrh] x [ncl to nch])
where nrl is a vector of indexes.
\param sl lower index of vector
\param sh upper index of vector
\param nrl vector of lower row indexes for matrix
\param nrh upper row index for matrix
\param ncl upper column index for matrix
\param nch upper column index for matrix
*/
void dvar3_array::allocate(int sl, int sh, const ivector& nrl, int nrh,
  int ncl, int nch)
{
  if (sh < sl)
  {
    allocate();
    return;
  }
  if (sl !=nrl.indexmin() || sh !=nrl.indexmax())
  {
    cerr << "Incompatible array bounds in "
     "dmatrix(int nrl,int nrh, const ivector& ncl, const ivector& nch)" << endl;
    ad_exit(1);
  }
  if ( (shape=new three_array_shape(sl,sh)) == 0)
  {
    cerr << " Error allocating memory in dvar3_array contructor" << endl;
  }
  if ( (t = new dvar_matrix[slicesize()]) == 0)
  {
    cerr << " Error allocating memory in dvar3_array contructor" << endl;
    ad_exit(21);
  }
  t -= slicemin();
  for (int i = sl; i <= sh; ++i)
  {
    t[i].allocate(nrl(i), nrh, ncl, nch);
  }
}
Example #3
0
/**
Allocate dvar3_array with same dimensions as m1.
*/
void dvar3_array::allocate(const dvar3_array& m1)
{
#ifdef DIAG
  myheapcheck("Entering dvar3_array matrix(const d3_array& m1)" );
#endif
  if ((shape = new three_array_shape(m1.slicemin(), m1.slicemax())) == 0)
  {
    cerr << " Error allocating memory in dvar3_array contructor" << endl;
  }
  if ((t = new dvar_matrix[slicesize()]) == 0)
  {
    cerr << " Error allocating memory in dvar3_array contructor" << endl;
    ad_exit(21);
  }
  t -= slicemin();
  for (int i = slicemin(); i <= slicemax(); ++i)
  {
    t[i].allocate(m1[i]);
  }
}
Example #4
0
/**
Allocate d3_array with same dimensions as d3v.
\param d3v a dvar3_array
*/
void d3_array::allocate(const dvar3_array& d3v)
{
  int sl = d3v.slicemin();
  int sh = d3v.slicemax();
  if ((shape = new three_array_shape(sl, sh)) == 0)
  {
     cerr << " Error: d3_array unable to allocate memory in "
          << __FILE__ << ':' << __LINE__ << '\n';
     ad_exit(1);
  }
  if ((t = new dmatrix[slicesize()]) == 0)
  {
    cerr << " Error: d3_array unable to allocate memory in "
         << __FILE__ << ':' << __LINE__ << '\n';
    ad_exit(1);
  }
  t -= slicemin();
  for (int i = sl; i <= sh; ++i)
  {
    t[i].allocate(d3v(i));
  }
}
Example #5
0
/**
Allocate array of matrices with dimensions
[sl to sh] x [nrl to nrh] x [ncl to nch].
\param sl lower vector index
\param sh upper vector index
\param nrl lower matrix row index
\param nrl upper matrix row index
\param ncl lower matrix column index
\param ncl upper matrix column index
*/
void i3_array::allocate(
  int sl, int sh,
  const index_type& nrl, const index_type& nrh,
  const index_type& ncl, const index_type& nch)
{
  if (sl > sh)
  {
    allocate();
  }
  else
  {  
    if ((nrl.isinteger() && (sl !=nrl.indexmin() || sh !=nrl.indexmax()))
       || (nch.isinteger() && (sl !=nch.indexmin() || sh !=nch.indexmax()))
       || (ncl.isinteger() && (sl !=ncl.indexmin() || sh !=ncl.indexmax()))
       || (nrh.isinteger() && (sl !=nrh.indexmin() || sh !=nrh.indexmax())))
    {
      cerr << "Incompatible i3_array bounds in " << __FILE__ << ':' << __LINE__ << ".\n";
      ad_exit(1);
    }
    if ((shape = new three_array_shape(sl,sh)) == 0)
    {
      cerr << " Error: d3_array unable to allocate memory in "
           << __FILE__ << ':' << __LINE__ << '\n';
      ad_exit(1);
    }
    if ((t = new imatrix[slicesize()]) == 0)
    {
      cerr << " Error: d3_array unable to allocate memory in "
           << __FILE__ << ':' << __LINE__ << '\n';
      ad_exit(1);
    }
    t -= slicemin();
    for (int i = sl; i <= sh; ++i)
    {
      t[i].allocate(nrl(i), nrh(i), ncl(i), nch(i));
    }
  }
}