Field

Classes

class  field< oT >
 A lightweight 2D container for abitrary objects (the objects must have a copy constructor). More...
class  field_aux

Functions

 field::~field ()
 field::field ()
 field::field (const field &x)
 construct a field from a given field
const fieldfield::operator= (const field &x)
 construct a field from a given field
 field::field (const subview_field< oT > &x)
 construct a field from subview_field (e.g. construct a field from a delayed subfield operation)
const fieldfield::operator= (const subview_field< oT > &x)
 construct a field from subview_field (e.g. construct a field from a delayed subfield operation)
 field::field (const u32 n_elem_in)
 construct the field with the specified number of elements, assuming a column-major layout
 field::field (const u32 n_rows_in, const u32 n_cols_in)
 construct the field with the specified dimensions
void field::set_size (const u32 n_obj_in)
 change the field to have the specified number of elements, assuming a column-major layout (data is not preserved)
void field::set_size (const u32 n_rows_in, const u32 n_cols_in)
 change the field to have the specified dimensions (data is not preserved)
void field::copy_size (const field &x)
 change the field to have the specified dimensions (data is not preserved)
arma_inline oT & field::operator[] (const u32 i)
 linear element accessor (treats the field as a vector); no bounds check
arma_inline const oT & field::operator[] (const u32 i) const
 linear element accessor (treats the field as a vector); no bounds check
arma_inline oT & field::operator() (const u32 i)
 linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG is defined
arma_inline const oT & field::operator() (const u32 i) const
 linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG is defined
arma_inline oT & field::operator() (const u32 row, const u32 col)
 element accessor; bounds checking not done when ARMA_NO_DEBUG is defined
arma_inline const oT & field::operator() (const u32 row, const u32 col) const
 element accessor; bounds checking not done when ARMA_NO_DEBUG is defined
arma_inline oT & field::at (const u32 row, const u32 col)
 element accessor; no bounds check
arma_inline const oT & field::at (const u32 row, const u32 col) const
 element accessor; no bounds check
subview_field< oT > field::row (const u32 row_num)
 creation of subview_field (row of a field)
const subview_field< oT > field::row (const u32 row_num) const
 creation of subview_field (row of a field)
subview_field< oT > field::col (const u32 col_num)
 creation of subview_field (column of a field)
const subview_field< oT > field::col (const u32 col_num) const
 creation of subview_field (column of a field)
subview_field< oT > field::rows (const u32 in_row1, const u32 in_row2)
 creation of subview_field (subfield comprised of specified rows)
const subview_field< oT > field::rows (const u32 in_row1, const u32 in_row2) const
 creation of subview_field (subfield comprised of specified rows)
subview_field< oT > field::cols (const u32 in_col1, const u32 in_col2)
 creation of subview_field (subfield comprised of specified columns)
const subview_field< oT > field::cols (const u32 in_col1, const u32 in_col2) const
 creation of subview_field (subfield comprised of specified columns)
subview_field< oT > field::subfield (const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2)
 creation of subview_field (subfield with arbitrary dimensions)
const subview_field< oT > field::subfield (const u32 in_row1, const u32 in_col1, const u32 in_row2, const u32 in_col2) const
 creation of subview_field (generic submatrix)
void field::print (const std::string extra_text="") const
 print contents of the field (to the cout stream), optionally preceding with a user specified line of text. the field class preserves the stream's flags but the associated operator<< function for type oT may still modify the stream's parameters. NOTE: this function assumes that type oT can be printed, i.e. the function "std::ostream& operator<< (std::ostream&, const oT&)" has been defined.
void field::print (std::ostream &user_stream, const std::string extra_text="") const
 print contents of the field to a user specified stream, optionally preceding with a user specified line of text. the field class preserves the stream's flags but the associated operator<< function for type oT may still modify the stream's parameters. NOTE: this function assumes that type oT can be printed, i.e. the function "std::ostream& operator<< (std::ostream&, const oT&)" has been defined.
void field::fill (const oT &x)
 fill the field with an object
void field::reset ()
void field::reset_objects ()
void field::save (const std::string name, const file_type type=arma_binary) const
void field::load (const std::string name, const file_type type=auto_detect)
void field::init (const field< oT > &x)
 construct a field from a given field
void field::init (const u32 n_rows_in, const u32 n_cols_in)
 internal field construction; if the requested size is small enough, memory from the stack is used. otherwise memory is allocated via 'new'
void field::delete_objects ()
void field::create_objects ()
template<typename oT >
static void field_aux::reset_objects (field< oT > &x)
template<typename eT >
static void field_aux::reset_objects (field< Mat< eT > > &x)
template<typename eT >
static void field_aux::reset_objects (field< Col< eT > > &x)
template<typename eT >
static void field_aux::reset_objects (field< Row< eT > > &x)
template<typename eT >
static void field_aux::reset_objects (field< Cube< eT > > &x)
static void field_aux::reset_objects (field< std::string > &x)
template<typename oT >
static void field_aux::save (const field< oT > &x, const std::string &name, const file_type type)
template<typename oT >
static void field_aux::load (field< oT > &x, const std::string &name, const file_type type)
template<typename eT >
static void field_aux::save (const field< Mat< eT > > &x, const std::string &name, const file_type type)
template<typename eT >
static void field_aux::load (field< Mat< eT > > &x, const std::string &name, const file_type type)
template<typename eT >
static void field_aux::save (const field< Col< eT > > &x, const std::string &name, const file_type type)
template<typename eT >
static void field_aux::load (field< Col< eT > > &x, const std::string &name, const file_type type)
template<typename eT >
static void field_aux::save (const field< Row< eT > > &x, const std::string &name, const file_type type)
template<typename eT >
static void field_aux::load (field< Row< eT > > &x, const std::string &name, const file_type type)
template<typename eT >
static void field_aux::save (const field< Cube< eT > > &x, const std::string &name, const file_type type)
template<typename eT >
static void field_aux::load (field< Cube< eT > > &x, const std::string &name, const file_type type)
static void field_aux::save (const field< std::string > &x, const std::string &name, const file_type type)
static void field_aux::load (field< std::string > &x, const std::string &name, const file_type type)

Function Documentation

template<typename oT >
field< oT >::~field (  )  [inline, inherited]

Definition at line 22 of file field_meat.hpp.

References arma_config::debug, field< oT >::delete_objects(), field< oT >::mem, field< oT >::mem_local, field< oT >::n_cols, field< oT >::n_elem, field< oT >::n_rows, and access::rw().

00023   {
00024   arma_extra_debug_sigprint_this(this);
00025   
00026   delete_objects();
00027   
00028   if(n_elem > sizeof(mem_local)/sizeof(oT*) )
00029     {
00030     delete [] mem;
00031     }
00032   
00033   if(arma_config::debug == true)
00034     {
00035     // try to expose buggy user code that accesses deleted objects
00036     access::rw(n_rows) = 0;
00037     access::rw(n_cols) = 0;
00038     access::rw(n_elem) = 0;
00039     mem = 0;
00040     }
00041   }

template<typename oT >
field< oT >::field (  )  [inline, inherited]

Definition at line 47 of file field_meat.hpp.

00048   : n_rows(0)
00049   , n_cols(0)
00050   , n_elem(0)
00051   , mem(0)
00052   {
00053   arma_extra_debug_sigprint_this(this);
00054   }

template<typename oT >
field< oT >::field ( const field< oT > &  x  )  [inline, inherited]

construct a field from a given field

Definition at line 61 of file field_meat.hpp.

References field< oT >::init().

00062   : n_rows(0)
00063   , n_cols(0)
00064   , n_elem(0)
00065   , mem(0)
00066   {
00067   arma_extra_debug_sigprint(arma_boost::format("this = %x   x = %x") % this % &x);
00068   
00069   init(x);
00070   }

template<typename oT >
const field< oT > & field< oT >::operator= ( const field< oT > &  x  )  [inline, inherited]

construct a field from a given field

Definition at line 78 of file field_meat.hpp.

References field< oT >::init().

Referenced by field< oT >::field().

00079   {
00080   arma_extra_debug_sigprint();
00081   
00082   init(x);
00083   return *this;
00084   }

template<typename oT >
field< oT >::field ( const subview_field< oT > &  x  )  [inline, inherited]

construct a field from subview_field (e.g. construct a field from a delayed subfield operation)

Definition at line 91 of file field_meat.hpp.

References field< oT >::operator=().

00092   : n_rows(0)
00093   , n_cols(0)
00094   , n_elem(0)
00095   , mem(0)
00096   {
00097   arma_extra_debug_sigprint_this(this);
00098   
00099   this->operator=(X);
00100   }

template<typename oT >
const field< oT > & field< oT >::operator= ( const subview_field< oT > &  x  )  [inline, inherited]

construct a field from subview_field (e.g. construct a field from a delayed subfield operation)

Definition at line 108 of file field_meat.hpp.

00109   {
00110   arma_extra_debug_sigprint();
00111   
00112   subview_field<oT>::extract(*this, X);
00113   return *this;
00114   }

template<typename oT >
field< oT >::field ( const u32  n_elem_in  )  [inline, explicit, inherited]

construct the field with the specified number of elements, assuming a column-major layout

Definition at line 122 of file field_meat.hpp.

References field< oT >::init().

00123   : n_rows(0)
00124   , n_cols(0)
00125   , n_elem(0)
00126   , mem(0)
00127   {
00128   arma_extra_debug_sigprint_this(this);
00129   
00130   init(n_elem_in, 1);
00131   }

template<typename oT >
field< oT >::field ( const u32  n_rows_in,
const u32  n_cols_in 
) [inline, inherited]

construct the field with the specified dimensions

Definition at line 138 of file field_meat.hpp.

References field< oT >::init().

00139   : n_rows(0)
00140   , n_cols(0)
00141   , n_elem(0)
00142   , mem(0)
00143   {
00144   arma_extra_debug_sigprint_this(this);
00145   
00146   init(n_rows_in, n_cols_in);
00147   }

template<typename oT >
void field< oT >::set_size ( const u32  n_obj_in  )  [inline, inherited]

change the field to have the specified number of elements, assuming a column-major layout (data is not preserved)

Definition at line 156 of file field_meat.hpp.

References field< oT >::init().

Referenced by subview_field< oT >::extract(), diskio::load_arma_binary(), diskio::load_ppm_binary(), and diskio::load_std_string().

00157   {
00158   arma_extra_debug_sigprint(arma_boost::format("n_elem_in = %d") % n_elem_in);
00159   
00160   init(n_elem_in, 1);
00161   }

template<typename oT >
void field< oT >::set_size ( const u32  n_rows_in,
const u32  n_cols_in 
) [inline, inherited]

change the field to have the specified dimensions (data is not preserved)

Definition at line 169 of file field_meat.hpp.

References field< oT >::init().

00170   {
00171   arma_extra_debug_sigprint(arma_boost::format("n_rows_in = %d, n_cols_in = %d") % n_rows_in % n_cols_in);
00172   
00173   init(n_rows_in, n_cols_in);
00174   }

template<typename oT >
void field< oT >::copy_size ( const field< oT > &  x  )  [inline, inherited]

change the field to have the specified dimensions (data is not preserved)

Definition at line 182 of file field_meat.hpp.

References field< oT >::init(), field< oT >::n_cols, and field< oT >::n_rows.

00183   {
00184   arma_extra_debug_sigprint();
00185   
00186   if(this != &x)
00187     {
00188     init(x.n_rows, x.n_cols);
00189     }
00190   }

template<typename oT >
arma_inline oT & field< oT >::operator[] ( const u32  i  )  [inline, inherited]

linear element accessor (treats the field as a vector); no bounds check

Definition at line 198 of file field_meat.hpp.

References field< oT >::mem.

00199   {
00200   return (*mem[i]);
00201   }

template<typename oT >
arma_inline const oT & field< oT >::operator[] ( const u32  i  )  const [inline, inherited]

linear element accessor (treats the field as a vector); no bounds check

Definition at line 209 of file field_meat.hpp.

References field< oT >::mem.

00210   {
00211   return (*mem[i]);
00212   }

template<typename oT >
arma_inline oT & field< oT >::operator() ( const u32  i  )  [inline, inherited]

linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG is defined

Definition at line 219 of file field_meat.hpp.

References field< oT >::mem, and field< oT >::n_elem.

00220   {
00221   arma_debug_check( (i >= n_elem), "field::operator(): index out of bounds");
00222   return (*mem[i]);
00223   }

template<typename oT >
arma_inline const oT & field< oT >::operator() ( const u32  i  )  const [inline, inherited]

linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG is defined

Definition at line 231 of file field_meat.hpp.

References field< oT >::mem, and field< oT >::n_elem.

00232   {
00233   arma_debug_check( (i >= n_elem), "field::operator(): index out of bounds");
00234   return (*mem[i]);
00235   }

template<typename oT >
arma_inline oT & field< oT >::operator() ( const u32  row,
const u32  col 
) [inline, inherited]

element accessor; bounds checking not done when ARMA_NO_DEBUG is defined

Definition at line 243 of file field_meat.hpp.

References field< oT >::mem, field< oT >::n_cols, and field< oT >::n_rows.

00244   {
00245   arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "field::operator(): index out of bounds");
00246   return (*mem[in_row + in_col*n_rows]);
00247   }

template<typename oT >
arma_inline const oT & field< oT >::operator() ( const u32  row,
const u32  col 
) const [inline, inherited]

element accessor; bounds checking not done when ARMA_NO_DEBUG is defined

Definition at line 255 of file field_meat.hpp.

References field< oT >::mem, field< oT >::n_cols, and field< oT >::n_rows.

00256   {
00257   arma_debug_check( ((in_row >= n_rows) || (in_col >= n_cols)), "field::operator(): index out of bounds");
00258   return (*mem[in_row + in_col*n_rows]);
00259   }

template<typename oT >
arma_inline oT & field< oT >::at ( const u32  row,
const u32  col 
) [inline, inherited]

element accessor; no bounds check

Definition at line 267 of file field_meat.hpp.

References field< oT >::mem, and field< oT >::n_rows.

Referenced by subview_field< oT >::extract(), field< oT >::init(), diskio::load_std_string(), subview_field< oT >::operator=(), arma_ostream::print(), and diskio::save_std_string().

00268   {
00269   return (*mem[in_row + in_col*n_rows]);
00270   }

template<typename oT >
arma_inline const oT & field< oT >::at ( const u32  row,
const u32  col 
) const [inline, inherited]

element accessor; no bounds check

Definition at line 278 of file field_meat.hpp.

References field< oT >::mem, and field< oT >::n_rows.

00279   {
00280   return (*mem[in_row + in_col*n_rows]);
00281   }

template<typename oT >
subview_field< oT > field< oT >::row ( const u32  row_num  )  [inline, inherited]
template<typename oT >
const subview_field< oT > field< oT >::row ( const u32  row_num  )  const [inline, inherited]

creation of subview_field (row of a field)

Definition at line 303 of file field_meat.hpp.

References field< oT >::n_cols, and field< oT >::n_rows.

00304   {
00305   arma_extra_debug_sigprint();
00306   
00307   arma_debug_check( (row_num >= n_rows), "field::row(): row out of bounds" );
00308   return subview_field<oT>(*this, row_num, 0, row_num, n_cols-1);
00309   }

template<typename oT >
subview_field< oT > field< oT >::col ( const u32  col_num  )  [inline, inherited]
template<typename oT >
const subview_field< oT > field< oT >::col ( const u32  col_num  )  const [inline, inherited]

creation of subview_field (column of a field)

Definition at line 331 of file field_meat.hpp.

References field< oT >::n_cols, and field< oT >::n_rows.

00332   {
00333   arma_extra_debug_sigprint();
00334   
00335   arma_debug_check( (col_num >= n_cols), "field::col(): out of bounds");
00336   return subview_field<oT>(*this, 0, col_num, n_rows-1, col_num);
00337   }

template<typename oT >
subview_field< oT > field< oT >::rows ( const u32  in_row1,
const u32  in_row2 
) [inline, inherited]

creation of subview_field (subfield comprised of specified rows)

Definition at line 345 of file field_meat.hpp.

References field< oT >::n_cols, and field< oT >::n_rows.

00346   {
00347   arma_extra_debug_sigprint();
00348   
00349   arma_debug_check
00350     (
00351     ( (in_row1 > in_row2) || (in_row2 >= n_rows) ),
00352     "field::rows(): indicies out of bounds or incorrectly used"
00353     );
00354   
00355   return subview_field<oT>(*this, in_row1, 0, in_row2, n_cols-1);
00356   }

template<typename oT >
const subview_field< oT > field< oT >::rows ( const u32  in_row1,
const u32  in_row2 
) const [inline, inherited]

creation of subview_field (subfield comprised of specified rows)

Definition at line 364 of file field_meat.hpp.

References field< oT >::n_cols, and field< oT >::n_rows.

00365   {
00366   arma_extra_debug_sigprint();
00367   
00368   arma_debug_check
00369     (
00370     ( (in_row1 > in_row2) || (in_row2 >= n_rows) ),
00371     "field::rows(): indicies out of bounds or incorrectly used"
00372     );
00373   
00374   return subview_field<oT>(*this, in_row1, 0, in_row2, n_cols-1);
00375   }

template<typename oT >
subview_field< oT > field< oT >::cols ( const u32  in_col1,
const u32  in_col2 
) [inline, inherited]

creation of subview_field (subfield comprised of specified columns)

Definition at line 383 of file field_meat.hpp.

References field< oT >::n_cols, and field< oT >::n_rows.

00384   {
00385   arma_extra_debug_sigprint();
00386   
00387   arma_debug_check
00388     (
00389     ( (in_col1 > in_col2) || (in_col2 >= n_cols) ),
00390     "field::cols(): indicies out of bounds or incorrectly used"
00391     );
00392   
00393   return subview_field<oT>(*this, 0, in_col1, n_rows-1, in_col2);
00394   }

template<typename oT >
const subview_field< oT > field< oT >::cols ( const u32  in_col1,
const u32  in_col2 
) const [inline, inherited]

creation of subview_field (subfield comprised of specified columns)

Definition at line 402 of file field_meat.hpp.

References field< oT >::n_cols, and field< oT >::n_rows.

00403   {
00404   arma_extra_debug_sigprint();
00405   
00406   arma_debug_check
00407     (
00408     ( (in_col1 > in_col2) || (in_col2 >= n_cols) ),
00409     "field::cols(): indicies out of bounds or incorrectly used"
00410     );
00411   
00412   return subview_field<oT>(*this, 0, in_col1, n_rows-1, in_col2);
00413   }

template<typename oT >
subview_field< oT > field< oT >::subfield ( const u32  in_row1,
const u32  in_col1,
const u32  in_row2,
const u32  in_col2 
) [inline, inherited]

creation of subview_field (subfield with arbitrary dimensions)

Definition at line 421 of file field_meat.hpp.

References field< oT >::n_cols, and field< oT >::n_rows.

00422   {
00423   arma_extra_debug_sigprint();
00424   
00425   arma_debug_check
00426     (
00427     (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (in_col2 >= n_cols),
00428     "field::subfield(): indices out of bounds or incorrectly used"
00429     );
00430   
00431   return subview_field<oT>(*this, in_row1, in_col1, in_row2, in_col2);
00432   }

template<typename oT >
const subview_field< oT > field< oT >::subfield ( const u32  in_row1,
const u32  in_col1,
const u32  in_row2,
const u32  in_col2 
) const [inline, inherited]

creation of subview_field (generic submatrix)

Definition at line 440 of file field_meat.hpp.

References field< oT >::n_cols, and field< oT >::n_rows.

00441   {
00442   arma_extra_debug_sigprint();
00443   
00444   arma_debug_check
00445     (
00446     (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >= n_rows) || (in_col2 >= n_cols),
00447     "field::subfield(): indices out of bounds or incorrectly used"
00448     );
00449   
00450   return subview_field<oT>(*this, in_row1, in_col1, in_row2, in_col2);
00451   }

template<typename oT >
void field< oT >::print ( const std::string  extra_text = ""  )  const [inline, inherited]

print contents of the field (to the cout stream), optionally preceding with a user specified line of text. the field class preserves the stream's flags but the associated operator<< function for type oT may still modify the stream's parameters. NOTE: this function assumes that type oT can be printed, i.e. the function "std::ostream& operator<< (std::ostream&, const oT&)" has been defined.

Definition at line 467 of file field_meat.hpp.

Referenced by field< oT >::print().

00468   {
00469   arma_extra_debug_sigprint();
00470   
00471   if(extra_text.length() != 0)
00472     {
00473     const std::streamsize orig_width = cout.width();
00474     
00475     cout << extra_text << '\n';
00476   
00477     cout.width(orig_width);
00478     }
00479   
00480   arma_ostream::print(cout, *this);
00481   }

template<typename oT >
void field< oT >::print ( std::ostream &  user_stream,
const std::string  extra_text = "" 
) const [inline, inherited]

print contents of the field to a user specified stream, optionally preceding with a user specified line of text. the field class preserves the stream's flags but the associated operator<< function for type oT may still modify the stream's parameters. NOTE: this function assumes that type oT can be printed, i.e. the function "std::ostream& operator<< (std::ostream&, const oT&)" has been defined.

Definition at line 497 of file field_meat.hpp.

References field< oT >::print().

00498   {
00499   arma_extra_debug_sigprint();
00500   
00501   if(extra_text.length() != 0)
00502     {
00503     const std::streamsize orig_width = user_stream.width();
00504     
00505     user_stream << extra_text << '\n';
00506   
00507     user_stream.width(orig_width);
00508     }
00509   
00510   arma_ostream::print(user_stream, *this);
00511   }

template<typename oT >
void field< oT >::fill ( const oT &  x  )  [inline, inherited]

fill the field with an object

Definition at line 519 of file field_meat.hpp.

References field< oT >::n_elem.

00520   {
00521   arma_extra_debug_sigprint();
00522   
00523   field<oT>& t = *this;
00524   
00525   for(u32 i=0; i<n_elem; ++i)
00526     {
00527     t[i] = x;
00528     }
00529   }

template<typename oT >
void field< oT >::reset (  )  [inline, inherited]

Definition at line 536 of file field_meat.hpp.

References field< oT >::init().

Referenced by field_aux::load(), diskio::load_arma_binary(), diskio::load_auto_detect(), diskio::load_ppm_binary(), and diskio::load_std_string().

00537   {
00538   arma_extra_debug_sigprint();
00539   
00540   init(0,0);
00541   }

template<typename oT >
void field< oT >::reset_objects (  )  [inline, inherited]

Definition at line 548 of file field_meat.hpp.

00549   {
00550   arma_extra_debug_sigprint();
00551   
00552   field_aux::reset_objects(*this);
00553   }

template<typename oT >
void field< oT >::save ( const std::string  name,
const file_type  type = arma_binary 
) const [inline, inherited]

Definition at line 560 of file field_meat.hpp.

00561   {
00562   arma_extra_debug_sigprint();
00563   
00564   field_aux::save(*this, name, type);
00565   }

template<typename oT >
void field< oT >::load ( const std::string  name,
const file_type  type = auto_detect 
) [inline, inherited]

Definition at line 572 of file field_meat.hpp.

00573   {
00574   arma_extra_debug_sigprint();
00575   
00576   field_aux::load(*this, name, type);
00577   }

template<typename oT >
void field< oT >::init ( const field< oT > &  x  )  [inline, private, inherited]

construct a field from a given field

Definition at line 585 of file field_meat.hpp.

References field< oT >::at(), field< oT >::col(), field< oT >::n_cols, field< oT >::n_rows, and field< oT >::row().

Referenced by field< oT >::copy_size(), field< oT >::field(), field< oT >::operator=(), field< oT >::reset(), and field< oT >::set_size().

00586   {
00587   arma_extra_debug_sigprint();
00588   
00589   if(this != &x)
00590     {
00591     init(x.n_rows, x.n_cols);
00592     
00593     field& t = *this;
00594     
00595     for(u32 col=0; col<x.n_cols; ++col)
00596     for(u32 row=0; row<x.n_rows; ++row)
00597       {
00598       t.at(row,col) = x.at(row,col);
00599       }
00600     }
00601   
00602   }

template<typename oT >
void field< oT >::init ( const u32  n_rows_in,
const u32  n_cols_in 
) [inline, private, inherited]

internal field construction; if the requested size is small enough, memory from the stack is used. otherwise memory is allocated via 'new'

Definition at line 610 of file field_meat.hpp.

References arma_check(), field< oT >::create_objects(), field< oT >::delete_objects(), field< oT >::mem, field< oT >::mem_local, field< oT >::n_cols, field< oT >::n_elem, field< oT >::n_rows, and access::rw().

00611   {
00612   arma_extra_debug_sigprint( arma_boost::format("n_rows_in = %d, n_cols_in = %d") % n_rows_in % n_cols_in );
00613   
00614   const u32 n_elem_new = n_rows_in * n_cols_in;
00615 
00616   if(n_elem == n_elem_new)
00617     {
00618     // delete_objects();
00619     // create_objects();
00620     access::rw(n_rows) = n_rows_in;
00621     access::rw(n_cols) = n_cols_in;
00622     }
00623   else
00624     {
00625     delete_objects();
00626     
00627     if(n_elem > sizeof(mem_local)/sizeof(oT*) )
00628       {
00629       delete [] mem;
00630       }
00631     
00632     if(n_elem_new <= sizeof(mem_local)/sizeof(oT*) )
00633       {
00634       mem = mem_local;
00635       }
00636     else
00637       {
00638       mem = new(std::nothrow) oT* [n_elem_new];
00639       arma_check( (mem == 0), "field::init(): out of memory" );
00640       }
00641     
00642     access::rw(n_elem) = n_elem_new;
00643     
00644     if(n_elem_new == 0)
00645       {
00646       access::rw(n_rows) = 0;
00647       access::rw(n_cols) = 0;
00648       }
00649     else
00650       {
00651       access::rw(n_rows) = n_rows_in;
00652       access::rw(n_cols) = n_cols_in;
00653       }
00654     
00655     create_objects();
00656     
00657     }
00658   
00659   }

template<typename oT >
void field< oT >::delete_objects (  )  [inline, private, inherited]

Definition at line 666 of file field_meat.hpp.

References field< oT >::mem, and field< oT >::n_elem.

Referenced by field< oT >::init(), field_aux::reset_objects(), and field< oT >::~field().

00667   {
00668   arma_extra_debug_sigprint( arma_boost::format("n_elem = %d") % n_elem );
00669   
00670   for(u32 i=0; i<n_elem; ++i)
00671     {
00672     if(mem[i] != 0)
00673       {
00674       delete mem[i];
00675       mem[i] = 0;
00676       }
00677     }
00678   
00679   }

template<typename oT >
void field< oT >::create_objects (  )  [inline, private, inherited]

Definition at line 686 of file field_meat.hpp.

References field< oT >::mem, and field< oT >::n_elem.

Referenced by field< oT >::init(), and field_aux::reset_objects().

00687   {
00688   arma_extra_debug_sigprint( arma_boost::format("n_elem = %d") % n_elem );
00689   
00690   for(u32 i=0; i<n_elem; ++i)
00691     {
00692     mem[i] = new oT;
00693     }
00694   
00695   }

template<typename oT >
void field_aux::reset_objects ( field< oT > &  x  )  [inline, static, inherited]

Definition at line 708 of file field_meat.hpp.

References field< oT >::create_objects(), and field< oT >::delete_objects().

00709   {
00710   arma_extra_debug_sigprint();
00711   
00712   x.delete_objects();
00713   x.create_objects();
00714   }

template<typename eT >
void field_aux::reset_objects ( field< Mat< eT > > &  x  )  [inline, static, inherited]

Definition at line 721 of file field_meat.hpp.

00722   {
00723   arma_extra_debug_sigprint();
00724   
00725   for(u32 i=0; i<x.n_elem; ++i)
00726     {
00727     (*(x.mem[i])).reset();
00728     }
00729   }

template<typename eT >
void field_aux::reset_objects ( field< Col< eT > > &  x  )  [inline, static, inherited]

Definition at line 736 of file field_meat.hpp.

00737   {
00738   arma_extra_debug_sigprint();
00739   
00740   for(u32 i=0; i<x.n_elem; ++i)
00741     {
00742     (*(x.mem[i])).reset();
00743     }
00744   }

template<typename eT >
void field_aux::reset_objects ( field< Row< eT > > &  x  )  [inline, static, inherited]

Definition at line 751 of file field_meat.hpp.

00752   {
00753   arma_extra_debug_sigprint();
00754   
00755   for(u32 i=0; i<x.n_elem; ++i)
00756     {
00757     (*(x.mem[i])).reset();
00758     }
00759   }

template<typename eT >
void field_aux::reset_objects ( field< Cube< eT > > &  x  )  [inline, static, inherited]

Definition at line 766 of file field_meat.hpp.

00767   {
00768   arma_extra_debug_sigprint();
00769   
00770   for(u32 i=0; i<x.n_elem; ++i)
00771     {
00772     (*(x.mem[i])).reset();
00773     }
00774   }

void field_aux::reset_objects ( field< std::string > &  x  )  [inline, static, inherited]

Definition at line 780 of file field_meat.hpp.

References field< oT >::mem, and field< oT >::n_elem.

00781   {
00782   arma_extra_debug_sigprint();
00783   
00784   for(u32 i=0; i<x.n_elem; ++i)
00785     {
00786     (*(x.mem[i])).clear();
00787     }
00788   }

template<typename oT >
void field_aux::save ( const field< oT > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 801 of file field_meat.hpp.

References arma_print().

00802   {
00803   arma_extra_debug_sigprint();
00804   
00805   arma_print("field_aux::save(): sorry, saving this type of field is currently not supported");
00806   }

template<typename oT >
void field_aux::load ( field< oT > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 813 of file field_meat.hpp.

References arma_print(), and field< oT >::reset().

00814   {
00815   arma_extra_debug_sigprint();
00816   
00817   arma_print("field_aux::load(): sorry, loading this type of field is currently not supported");
00818   x.reset();
00819   }

template<typename eT >
void field_aux::save ( const field< Mat< eT > > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 826 of file field_meat.hpp.

References arma_binary, arma_stop(), ppm_binary, diskio::save_arma_binary(), and diskio::save_ppm_binary().

00827   {
00828   arma_extra_debug_sigprint();
00829   
00830   switch(type)
00831     {
00832     case arma_binary:
00833       diskio::save_arma_binary(x, name);
00834       break;
00835       
00836     case ppm_binary:
00837       diskio::save_ppm_binary(x, name);
00838       break;
00839     
00840     default:
00841       arma_stop("field_aux::save(): unsupported type");
00842     }
00843   }

template<typename eT >
void field_aux::load ( field< Mat< eT > > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 850 of file field_meat.hpp.

References arma_binary, arma_stop(), auto_detect, diskio::load_arma_binary(), diskio::load_auto_detect(), diskio::load_ppm_binary(), and ppm_binary.

00851   {
00852   arma_extra_debug_sigprint();
00853   
00854   switch(type)
00855     {
00856     case auto_detect:
00857       diskio::load_auto_detect(x, name);
00858       break;
00859     
00860     case arma_binary:
00861       diskio::load_arma_binary(x, name);
00862       break;
00863       
00864     case ppm_binary:
00865       diskio::load_ppm_binary(x, name);
00866       break;
00867     
00868     default:
00869       arma_stop("field_aux::load(): unsupported type");
00870     }
00871   }

template<typename eT >
void field_aux::save ( const field< Col< eT > > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 878 of file field_meat.hpp.

References arma_binary, arma_stop(), ppm_binary, diskio::save_arma_binary(), and diskio::save_ppm_binary().

00879   {
00880   arma_extra_debug_sigprint();
00881   
00882   switch(type)
00883     {
00884     case arma_binary:
00885       diskio::save_arma_binary(x, name);
00886       break;
00887       
00888     case ppm_binary:
00889       diskio::save_ppm_binary(x, name);
00890       break;
00891     
00892     default:
00893       arma_stop("field_aux::save(): unsupported type");
00894     }
00895   }

template<typename eT >
void field_aux::load ( field< Col< eT > > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 902 of file field_meat.hpp.

References arma_binary, arma_stop(), auto_detect, diskio::load_arma_binary(), diskio::load_auto_detect(), diskio::load_ppm_binary(), and ppm_binary.

00903   {
00904   arma_extra_debug_sigprint();
00905   
00906   switch(type)
00907     {
00908     case auto_detect:
00909       diskio::load_auto_detect(x, name);
00910       break;
00911     
00912     case arma_binary:
00913       diskio::load_arma_binary(x, name);
00914       break;
00915       
00916     case ppm_binary:
00917       diskio::load_ppm_binary(x, name);
00918       break;
00919     
00920     default:
00921       arma_stop("field_aux::load(): unsupported type");
00922     }
00923   }

template<typename eT >
void field_aux::save ( const field< Row< eT > > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 930 of file field_meat.hpp.

References arma_binary, arma_stop(), ppm_binary, diskio::save_arma_binary(), and diskio::save_ppm_binary().

00931   {
00932   arma_extra_debug_sigprint();
00933   
00934   switch(type)
00935     {
00936     case arma_binary:
00937       diskio::save_arma_binary(x, name);
00938       break;
00939       
00940     case ppm_binary:
00941       diskio::save_ppm_binary(x, name);
00942       break;
00943     
00944     default:
00945       arma_stop("field_aux::save(): unsupported type");
00946     }
00947   }

template<typename eT >
void field_aux::load ( field< Row< eT > > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 954 of file field_meat.hpp.

References arma_binary, arma_stop(), auto_detect, diskio::load_arma_binary(), diskio::load_auto_detect(), diskio::load_ppm_binary(), and ppm_binary.

00955   {
00956   arma_extra_debug_sigprint();
00957   
00958   switch(type)
00959     {
00960     case auto_detect:
00961       diskio::load_auto_detect(x, name);
00962       break;
00963     
00964     case arma_binary:
00965       diskio::load_arma_binary(x, name);
00966       break;
00967       
00968     case ppm_binary:
00969       diskio::load_ppm_binary(x, name);
00970       break;
00971     
00972     default:
00973       arma_stop("field_aux::load(): unsupported type");
00974     }
00975   }

template<typename eT >
void field_aux::save ( const field< Cube< eT > > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 982 of file field_meat.hpp.

References arma_binary, arma_stop(), ppm_binary, diskio::save_arma_binary(), and diskio::save_ppm_binary().

00983   {
00984   arma_extra_debug_sigprint();
00985   
00986   switch(type)
00987     {
00988     case arma_binary:
00989       diskio::save_arma_binary(x, name);
00990       break;
00991       
00992     case ppm_binary:
00993       diskio::save_ppm_binary(x, name);
00994       break;
00995     
00996     default:
00997       arma_stop("field_aux::save(): unsupported type");
00998     }
00999   }

template<typename eT >
void field_aux::load ( field< Cube< eT > > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 1006 of file field_meat.hpp.

References arma_binary, arma_stop(), auto_detect, diskio::load_arma_binary(), diskio::load_auto_detect(), diskio::load_ppm_binary(), and ppm_binary.

01007   {
01008   arma_extra_debug_sigprint();
01009   
01010   switch(type)
01011     {
01012     case auto_detect:
01013       diskio::load_auto_detect(x, name);
01014       break;
01015     
01016     case arma_binary:
01017       diskio::load_arma_binary(x, name);
01018       break;
01019       
01020     case ppm_binary:
01021       diskio::load_ppm_binary(x, name);
01022       break;
01023     
01024     default:
01025       arma_stop("field_aux::load(): unsupported type");
01026     }
01027   }

void field_aux::save ( const field< std::string > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 1033 of file field_meat.hpp.

References diskio::save_std_string().

01034   {
01035   arma_extra_debug_sigprint();
01036   
01037   diskio::save_std_string(x, name);
01038   }

void field_aux::load ( field< std::string > &  x,
const std::string &  name,
const file_type  type 
) [inline, static, inherited]

Definition at line 1044 of file field_meat.hpp.

References diskio::load_std_string().

01045   {
01046   arma_extra_debug_sigprint();
01047   
01048   diskio::load_std_string(x, name);
01049   }