コード例 #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
ファイル: f3arr3.cpp プロジェクト: colemonnahan/admb
/**
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));
  }
}