示例#1
0
文件: f6arr.cpp 项目: jimianelli/admb
/**
 * Description not yet available.
 * \param
 */
 void dvar6_array::allocate(const ad_integer& hsl,const ad_integer& hsu,
  const index_type& sl,const index_type& sh,const index_type& nrl,
   const index_type& nrh,const index_type& ncl,const index_type& nch,
   const index_type& l5,const index_type& u5,
   const index_type& l6,const index_type& u6)
 {
   if ( (shape=new vector_shape (hsl,hsu)) == 0)
   {
     cerr << " Error allocating memory in dvar5_array contructor\n";
   }

   int ss=size();
   if ( (t = new dvar5_array[ss]) == 0)
   {
     cerr << " Error allocating memory in dvar5_array contructor\n";
     ad_exit(21);
   }
   t -= indexmin();
   int il=hsl;
   int iu=hsu;
   for (int i=il; i<=iu; i++)
   {
     t[i].allocate(ad_integer(sl(i)),ad_integer(sh(i)),nrl(i),nrh(i),
        ncl(i),nch(i),l5(i),u5(i),l6(i),u6(i));
   }
 }
示例#2
0
文件: i4arr.cpp 项目: jimianelli/admb
/**
 * Description not yet available.
 * \param
 */
 void i4_array::allocate(const ad_integer& hsl,const ad_integer& hsu,
   const index_type& sl,const index_type& sh,const index_type& nrl,
   const index_type& nrh,const index_type& ncl,const index_type& nch)
 {
   int ss=hsu-hsl+1;
   if (ss>0)
   {
     if ( (t = new i3_array[ss]) == 0)
     {
       cerr << " Error allocating memory in i4_array contructor\n";
       ad_exit(21);
     }
     if ( (shape=new vector_shapex(hsl,hsu,t)) == 0)
     {
       cerr << " Error allocating memory in i4_array contructor\n";
       ad_exit(21);
     }
     t -= indexmin();
     for (int i=hsl; i<=hsu; i++)
     {
       (*this)(i).allocate(ad_integer(sl(i)),ad_integer(sh(i)),nrl(i),nrh(i),
         ncl(i),nch(i));
     }
   }
   else
   {
     t=0;
     shape=0;
   }
 }
示例#3
0
/**
Allocate variable array with dimensions
[hsl to hsu] x [sl to sh] x [nrl to nrh] x [ncl to nch] x [l5 to u5].

\param hsl lower dvar5_array index
\param hsu upper dvar5_array index
\param sl lower dvar4_array index
\param su upper dvar4_array index
\param nrl lower dvar3_array row index
\param nrh upper dvar3_array row index
\param ncl lower matrix row index
\param nch upper matrix row index
\param l5 lower matrix column index
\param u5 upper matrix column index
*/
void dvar5_array::allocate(
  const ad_integer& hsl, const ad_integer& hsu,
  const index_type& sl, const index_type& sh,
  const index_type& nrl, const index_type& nrh,
  const index_type& ncl, const index_type& nch,
  const index_type& l5, const index_type& u5)
{
  if ((shape = new vector_shape(hsl, hsu)) == 0)
  {
    cerr << " Error: dvar5_array unable to allocate memory in "
         << __FILE__ << ':' << __LINE__ << '\n';
    ad_exit(1);
  }
  if ((t = new dvar4_array[size()]) == 0)
  {
    cerr << " Error: dvar5_array unable to allocate memory in "
         << __FILE__ << ':' << __LINE__ << '\n';
    ad_exit(1);
  }

  t -= indexmin();

  int il=hsl;
  int iu=hsu;
  for (int i = il; i <= iu; ++i)
  {
    t[i].allocate(
      ad_integer(sl(i)), ad_integer(sh(i)),
      nrl(i), nrh(i),
      ncl(i), nch(i),
      l5(i),u5(i));
  }
}
示例#4
0
void param_init_bounded_number_vector::allocate(int min1,int max1,
  const double_index_type & bmin,const double_index_type & bmax,
  const index_type& phase_start,const char * s)
{
  int size = max1 - min1 + 1;
  if (size > 0)
  {
    v = new param_init_bounded_number[size];
    if (!v)
    {
        cerr << " error trying to allocate memory in "
          "param_init_bounded_number_vector " << endl;
        exit(1);
    }
    index_min=min1;
    index_max=max1;
    v-=indexmin();
    for (int i=indexmin();i<=indexmax();i++)
    {
       if (it) v[i].set_initial_value(ad_double((*it)[i]));
       adstring ss=s + adstring("[") + str(i) + adstring("]");
       v[i].allocate(ad_double(bmin[i]),ad_double(bmax[i]),
         ad_integer(phase_start[i]),(char*)(ss) );
    }
  }
}
示例#5
0
/**
Allocate vector of integers with dimension [_ncl to _nch].

\param _ncl lower vector index 
\param _nch upper vector index 
*/
void ivector::allocate(const ad_integer& _ncl, const index_type& _nch)
{
  index_min = _ncl;
  index_max = ad_integer(_nch);
  unsigned int ss = static_cast<unsigned int>(
    index_max < index_min ? 0 : index_max - index_min + 1);
  if (ss > 0)
  {
   if ((v = new int[ss]) == 0)
   {
     cerr << " Error: ivector unable to allocate memory in "
          << __FILE__ << ':' << __LINE__ << '\n';
     ad_exit(1);
   }
   if ((shape = new vector_shapex(index_min, index_max, v)) == NULL)
   {
     cerr << " Error: ivector unable to allocate memory in "
          << __FILE__ << ':' << __LINE__ << '\n';
     ad_exit(1);
   }
   v -= indexmin();
#ifdef SAFE_INITIALIZE
   for (int i = indexmin(); i <= indexmax(); ++i)
   {
     v[i] = 0;
   }
#endif
  }
  else
  {
    allocate();
  }
}
示例#6
0
/**
Allocate array with dimensions
[hsl to hsu] x [sl to sh] x [nrl to nrh] x [ncl to nch].

\param hsl lower i4_array index
\param hsu upper i4_array index
\param sl lower i3_array index
\param su upper i3_array index
\param nrl lower matrix row index
\param nrh upper matrix row index
\param ncl lower matrix column index
\param nch upper matrix column index
*/
void i4_array::allocate(
  const ad_integer& hsl, const ad_integer& hsu,
  const index_type& sl, const index_type& sh,
  const index_type& nrl, const index_type& nrh,
  const index_type& ncl, const index_type& nch)
{
  unsigned int ss =
    static_cast<unsigned int>(hsu < hsl ? 0 : hsu - hsl + 1);
  if (ss > 0)
  {
    if ((t = new i3_array[ss]) == 0)
    {
      cerr << " Error: i4_array unable to allocate memory in "
           << __FILE__ << ':' << __LINE__ << '\n';
      ad_exit(1);
    }
    if ((shape = new vector_shapex(hsl, hsu, t)) == 0)
    {
       cerr << " Error: i4_array unable to allocate memory in "
            << __FILE__ << ':' << __LINE__ << '\n';
       ad_exit(1);
    }
    t -= indexmin();
    for (int i = hsl; i <= hsu; ++i)
    {
      (*this)(i).allocate(
         ad_integer(sl(i)), ad_integer(sh(i)),
         nrl(i), nrh(i),
         ncl(i), nch(i));
    }
  }
  else
  {
    t = 0;
    shape = 0;
  }
}
示例#7
0
/**
Allocate vector of reals with dimension [_ncl to _nch].

\param _ncl lower vector index 
\param _nch upper vector index 
*/
void dvector::allocate(const ad_integer& _ncl,const index_type& _nch)
{
  int ncl = _ncl;
  int nch = ad_integer(_nch);
  unsigned int ss =
    static_cast<unsigned int>(nch < ncl ? 0 : nch - ncl + 1);
  if (ss > 0)
  {
    if ((v = new double[ss]) == 0)
    {
      cerr << " Error: dvector unable to allocate memory in "
           << __FILE__ << ':' << __LINE__ << '\n';
      ad_exit(1);
    }
#if defined(THREAD_SAFE)
    if ((shape = new ts_vector_shapex(ncl, nch, v)) == NULL)
#else
    if ((shape = new vector_shapex(ncl, nch, v)) == NULL)
#endif
    {
      cerr << " Error: dvector unable to allocate memory in "
           << __FILE__ << ':' << __LINE__ << '\n';
      ad_exit(1);
    }
    index_min = ncl;
    index_max = nch;
    v -= indexmin();
#ifdef SAFE_INITIALIZE
    for (int i = indexmin(); i <= indexmax(); ++i)
    {
      v[i] = 0.0;
    }
#endif
  }
  else
  {
    allocate();
  }
}