inline
void
podarray<eT>::init_warm(const uword new_n_elem)
  {
  arma_extra_debug_sigprint();
  
  if(n_elem == new_n_elem)
    {
    return;
    }
    
  if(n_elem > podarray_prealloc_n_elem::val )
    {
    memory::release( mem );
    }
  
  if(new_n_elem <= podarray_prealloc_n_elem::val )
    {
    mem = mem_local;
    }
  else
    {
    mem = memory::acquire<eT>(new_n_elem);
    
    arma_check_bad_alloc( (mem == 0), "arma::podarray: out of memory" );
    }
  
  access::rw(n_elem) = new_n_elem;
  }
Пример #2
0
inline
void
field<oT>::init(const uword n_rows_in, const uword n_cols_in)
  {
  arma_extra_debug_sigprint( arma_boost::format("n_rows_in = %d, n_cols_in = %d") % n_rows_in % n_cols_in );
  
  const uword n_elem_new = n_rows_in * n_cols_in;

  if(n_elem == n_elem_new)
    {
    // delete_objects();
    // create_objects();
    access::rw(n_rows) = n_rows_in;
    access::rw(n_cols) = n_cols_in;
    }
  else
    {
    delete_objects();
    
    if(n_elem > sizeof(mem_local)/sizeof(oT*) )
      {
      delete [] mem;
      }
    
    if(n_elem_new <= sizeof(mem_local)/sizeof(oT*) )
      {
      mem = mem_local;
      }
    else
      {
      mem = new(std::nothrow) oT* [n_elem_new];
      arma_check_bad_alloc( (mem == 0), "field::init(): out of memory" );
      }
    
    access::rw(n_elem) = n_elem_new;
    
    if(n_elem_new == 0)
      {
      access::rw(n_rows) = 0;
      access::rw(n_cols) = 0;
      }
    else
      {
      access::rw(n_rows) = n_rows_in;
      access::rw(n_cols) = n_cols_in;
      }
    
    create_objects();
    
    }
  
  }
arma_hot
inline
void
podarray<eT>::init_cold(const uword new_n_elem)
  {
  arma_extra_debug_sigprint();
  
  if(new_n_elem <= podarray_prealloc_n_elem::val )
    {
    mem = mem_local;
    }
  else
    {
    mem = memory::acquire<eT>(new_n_elem);
    
    arma_check_bad_alloc( (mem == 0), "arma::podarray: out of memory" );
    }
  }