예제 #1
0
파일: f3arr.cpp 프로젝트: johnrsibert/admb
/**
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]);
  }
}
예제 #2
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));
  }
}