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)
template<typename oT2 >
void field::copy_size (const field< oT2 > &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::save (std::ostream &os, const file_type type=arma_binary) const
void field::load (const std::string name, const file_type type=auto_detect)
void field::load (std::istream &is, 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::save (const field< oT > &x, std::ostream &os, 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 oT >
static void field_aux::load (field< oT > &x, std::istream &is, 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::save (const field< Mat< eT > > &x, std::ostream &os, 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::load (field< Mat< eT > > &x, std::istream &is, 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::save (const field< Col< eT > > &x, std::ostream &os, 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::load (field< Col< eT > > &x, std::istream &is, 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::save (const field< Row< eT > > &x, std::ostream &os, 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::load (field< Row< eT > > &x, std::istream &is, 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::save (const field< Cube< eT > > &x, std::ostream &os, const file_type type)
template<typename eT >
static void field_aux::load (field< Cube< eT > > &x, const std::string &name, const file_type type)
template<typename eT >
static void field_aux::load (field< Cube< eT > > &x, std::istream &is, 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::save (const field< std::string > &x, std::ostream &os, const file_type type)
static void field_aux::load (field< std::string > &x, const std::string &name, const file_type type)
static void field_aux::load (field< std::string > &x, std::istream &is, const file_type type)

Function Documentation

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

Definition at line 24 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().

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

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

Definition at line 49 of file field_meat.hpp.

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

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

construct a field from a given field

Definition at line 63 of file field_meat.hpp.

References field< oT >::init().

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

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 80 of file field_meat.hpp.

References field< oT >::init().

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

00081   {
00082   arma_extra_debug_sigprint();
00083   
00084   init(x);
00085   return *this;
00086   }

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 93 of file field_meat.hpp.

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

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

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 110 of file field_meat.hpp.

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

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 124 of file field_meat.hpp.

References field< oT >::init().

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

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 140 of file field_meat.hpp.

References field< oT >::init().

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

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 158 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().

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

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 171 of file field_meat.hpp.

References field< oT >::init().

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

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

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

Definition at line 185 of file field_meat.hpp.

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

00186   {
00187   arma_extra_debug_sigprint();
00188   
00189   init(x.n_rows, x.n_cols);
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.

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

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

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

Definition at line 572 of file field_meat.hpp.

References field< oT >::save().

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

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

Definition at line 584 of file field_meat.hpp.

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

00585   {
00586   arma_extra_debug_sigprint();
00587   
00588   field_aux::load(*this, name, type);
00589   }

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

Definition at line 596 of file field_meat.hpp.

References field< oT >::load().

00597   {
00598   arma_extra_debug_sigprint();
00599   
00600   field_aux::load(*this, is, type);
00601   }

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

construct a field from a given field

Definition at line 609 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().

00610   {
00611   arma_extra_debug_sigprint();
00612   
00613   if(this != &x)
00614     {
00615     init(x.n_rows, x.n_cols);
00616     
00617     field& t = *this;
00618     
00619     for(u32 col=0; col<x.n_cols; ++col)
00620     for(u32 row=0; row<x.n_rows; ++row)
00621       {
00622       t.at(row,col) = x.at(row,col);
00623       }
00624     }
00625   
00626   }

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 634 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().

00635   {
00636   arma_extra_debug_sigprint( arma_boost::format("n_rows_in = %d, n_cols_in = %d") % n_rows_in % n_cols_in );
00637   
00638   const u32 n_elem_new = n_rows_in * n_cols_in;
00639 
00640   if(n_elem == n_elem_new)
00641     {
00642     // delete_objects();
00643     // create_objects();
00644     access::rw(n_rows) = n_rows_in;
00645     access::rw(n_cols) = n_cols_in;
00646     }
00647   else
00648     {
00649     delete_objects();
00650     
00651     if(n_elem > sizeof(mem_local)/sizeof(oT*) )
00652       {
00653       delete [] mem;
00654       }
00655     
00656     if(n_elem_new <= sizeof(mem_local)/sizeof(oT*) )
00657       {
00658       mem = mem_local;
00659       }
00660     else
00661       {
00662       mem = new(std::nothrow) oT* [n_elem_new];
00663       arma_check( (mem == 0), "field::init(): out of memory" );
00664       }
00665     
00666     access::rw(n_elem) = n_elem_new;
00667     
00668     if(n_elem_new == 0)
00669       {
00670       access::rw(n_rows) = 0;
00671       access::rw(n_cols) = 0;
00672       }
00673     else
00674       {
00675       access::rw(n_rows) = n_rows_in;
00676       access::rw(n_cols) = n_cols_in;
00677       }
00678     
00679     create_objects();
00680     
00681     }
00682   
00683   }

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

Definition at line 690 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().

00691   {
00692   arma_extra_debug_sigprint( arma_boost::format("n_elem = %d") % n_elem );
00693   
00694   for(u32 i=0; i<n_elem; ++i)
00695     {
00696     if(mem[i] != 0)
00697       {
00698       delete mem[i];
00699       mem[i] = 0;
00700       }
00701     }
00702   
00703   }

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

Definition at line 710 of file field_meat.hpp.

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

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

00711   {
00712   arma_extra_debug_sigprint( arma_boost::format("n_elem = %d") % n_elem );
00713   
00714   for(u32 i=0; i<n_elem; ++i)
00715     {
00716     mem[i] = new oT;
00717     }
00718   
00719   }

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

Definition at line 732 of file field_meat.hpp.

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

00733   {
00734   arma_extra_debug_sigprint();
00735   
00736   x.delete_objects();
00737   x.create_objects();
00738   }

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

Definition at line 745 of file field_meat.hpp.

00746   {
00747   arma_extra_debug_sigprint();
00748   
00749   for(u32 i=0; i<x.n_elem; ++i)
00750     {
00751     (*(x.mem[i])).reset();
00752     }
00753   }

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

Definition at line 760 of file field_meat.hpp.

00761   {
00762   arma_extra_debug_sigprint();
00763   
00764   for(u32 i=0; i<x.n_elem; ++i)
00765     {
00766     (*(x.mem[i])).reset();
00767     }
00768   }

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

Definition at line 775 of file field_meat.hpp.

00776   {
00777   arma_extra_debug_sigprint();
00778   
00779   for(u32 i=0; i<x.n_elem; ++i)
00780     {
00781     (*(x.mem[i])).reset();
00782     }
00783   }

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

Definition at line 790 of file field_meat.hpp.

00791   {
00792   arma_extra_debug_sigprint();
00793   
00794   for(u32 i=0; i<x.n_elem; ++i)
00795     {
00796     (*(x.mem[i])).reset();
00797     }
00798   }

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

Definition at line 804 of file field_meat.hpp.

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

00805   {
00806   arma_extra_debug_sigprint();
00807   
00808   for(u32 i=0; i<x.n_elem; ++i)
00809     {
00810     (*(x.mem[i])).clear();
00811     }
00812   }

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 825 of file field_meat.hpp.

References arma_print().

00826   {
00827   arma_extra_debug_sigprint();
00828   
00829   arma_print("field_aux::save(): sorry, saving this type of field is currently not supported");
00830   }

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

Definition at line 837 of file field_meat.hpp.

References arma_print().

00838   {
00839   arma_extra_debug_sigprint();
00840   
00841   arma_print("field_aux::save(): sorry, saving this type of field is currently not supported");
00842   }

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

Definition at line 849 of file field_meat.hpp.

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

00850   {
00851   arma_extra_debug_sigprint();
00852   
00853   arma_print("field_aux::load(): sorry, loading this type of field is currently not supported");
00854   x.reset();
00855   }

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

Definition at line 862 of file field_meat.hpp.

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

00863   {
00864   arma_extra_debug_sigprint();
00865   
00866   arma_print("field_aux::load(): sorry, loading this type of field is currently not supported");
00867   x.reset();
00868   }

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 875 of file field_meat.hpp.

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

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

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

Definition at line 899 of file field_meat.hpp.

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

00900   {
00901   arma_extra_debug_sigprint();
00902   
00903   switch(type)
00904     {
00905     case arma_binary:
00906       diskio::save_arma_binary(x, "[ostream]", os);
00907       break;
00908       
00909     case ppm_binary:
00910       diskio::save_ppm_binary(x, "[ostream]", os);
00911       break;
00912     
00913     default:
00914       arma_stop("field_aux::save(): unsupported type");
00915     }
00916   }

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 923 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.

00924   {
00925   arma_extra_debug_sigprint();
00926   
00927   switch(type)
00928     {
00929     case auto_detect:
00930       diskio::load_auto_detect(x, name);
00931       break;
00932     
00933     case arma_binary:
00934       diskio::load_arma_binary(x, name);
00935       break;
00936       
00937     case ppm_binary:
00938       diskio::load_ppm_binary(x, name);
00939       break;
00940     
00941     default:
00942       arma_stop("field_aux::load(): unsupported type");
00943     }
00944   }

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

Definition at line 951 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.

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

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 979 of file field_meat.hpp.

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

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

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

Definition at line 1003 of file field_meat.hpp.

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

01004   {
01005   arma_extra_debug_sigprint();
01006   
01007   switch(type)
01008     {
01009     case arma_binary:
01010       diskio::save_arma_binary(x, "[ostream]", os);
01011       break;
01012       
01013     case ppm_binary:
01014       diskio::save_ppm_binary(x, "[ostream]", os);
01015       break;
01016     
01017     default:
01018       arma_stop("field_aux::save(): unsupported type");
01019     }
01020   }

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 1027 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.

01028   {
01029   arma_extra_debug_sigprint();
01030   
01031   switch(type)
01032     {
01033     case auto_detect:
01034       diskio::load_auto_detect(x, name);
01035       break;
01036     
01037     case arma_binary:
01038       diskio::load_arma_binary(x, name);
01039       break;
01040       
01041     case ppm_binary:
01042       diskio::load_ppm_binary(x, name);
01043       break;
01044     
01045     default:
01046       arma_stop("field_aux::load(): unsupported type");
01047     }
01048   }

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

Definition at line 1055 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.

01056   {
01057   arma_extra_debug_sigprint();
01058   
01059   switch(type)
01060     {
01061     case auto_detect:
01062       diskio::load_auto_detect(x, "[istream]", is);
01063       break;
01064     
01065     case arma_binary:
01066       diskio::load_arma_binary(x, "[istream]", is);
01067       break;
01068       
01069     case ppm_binary:
01070       diskio::load_ppm_binary(x, "[istream]", is);
01071       break;
01072     
01073     default:
01074       arma_stop("field_aux::load(): unsupported type");
01075     }
01076   }

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 1083 of file field_meat.hpp.

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

01084   {
01085   arma_extra_debug_sigprint();
01086   
01087   switch(type)
01088     {
01089     case arma_binary:
01090       diskio::save_arma_binary(x, name);
01091       break;
01092       
01093     case ppm_binary:
01094       diskio::save_ppm_binary(x, name);
01095       break;
01096     
01097     default:
01098       arma_stop("field_aux::save(): unsupported type");
01099     }
01100   }

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

Definition at line 1107 of file field_meat.hpp.

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

01108   {
01109   arma_extra_debug_sigprint();
01110   
01111   switch(type)
01112     {
01113     case arma_binary:
01114       diskio::save_arma_binary(x, "[ostream]", os);
01115       break;
01116       
01117     case ppm_binary:
01118       diskio::save_ppm_binary(x, "[ostream]", os);
01119       break;
01120     
01121     default:
01122       arma_stop("field_aux::save(): unsupported type");
01123     }
01124   }

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 1131 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.

01132   {
01133   arma_extra_debug_sigprint();
01134   
01135   switch(type)
01136     {
01137     case auto_detect:
01138       diskio::load_auto_detect(x, name);
01139       break;
01140     
01141     case arma_binary:
01142       diskio::load_arma_binary(x, name);
01143       break;
01144       
01145     case ppm_binary:
01146       diskio::load_ppm_binary(x, name);
01147       break;
01148     
01149     default:
01150       arma_stop("field_aux::load(): unsupported type");
01151     }
01152   }

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

Definition at line 1159 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.

01160   {
01161   arma_extra_debug_sigprint();
01162   
01163   switch(type)
01164     {
01165     case auto_detect:
01166       diskio::load_auto_detect(x, "[istream]", is);
01167       break;
01168     
01169     case arma_binary:
01170       diskio::load_arma_binary(x, "[istream]", is);
01171       break;
01172       
01173     case ppm_binary:
01174       diskio::load_ppm_binary(x, "[istream]", is);
01175       break;
01176     
01177     default:
01178       arma_stop("field_aux::load(): unsupported type");
01179     }
01180   }

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 1187 of file field_meat.hpp.

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

01188   {
01189   arma_extra_debug_sigprint();
01190   
01191   switch(type)
01192     {
01193     case arma_binary:
01194       diskio::save_arma_binary(x, name);
01195       break;
01196       
01197     case ppm_binary:
01198       diskio::save_ppm_binary(x, name);
01199       break;
01200     
01201     default:
01202       arma_stop("field_aux::save(): unsupported type");
01203     }
01204   }

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

Definition at line 1211 of file field_meat.hpp.

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

01212   {
01213   arma_extra_debug_sigprint();
01214   
01215   switch(type)
01216     {
01217     case arma_binary:
01218       diskio::save_arma_binary(x, "[ostream]", os);
01219       break;
01220       
01221     case ppm_binary:
01222       diskio::save_ppm_binary(x, "[ostream]", os);
01223       break;
01224     
01225     default:
01226       arma_stop("field_aux::save(): unsupported type");
01227     }
01228   }

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 1235 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.

01236   {
01237   arma_extra_debug_sigprint();
01238   
01239   switch(type)
01240     {
01241     case auto_detect:
01242       diskio::load_auto_detect(x, name);
01243       break;
01244     
01245     case arma_binary:
01246       diskio::load_arma_binary(x, name);
01247       break;
01248       
01249     case ppm_binary:
01250       diskio::load_ppm_binary(x, name);
01251       break;
01252     
01253     default:
01254       arma_stop("field_aux::load(): unsupported type");
01255     }
01256   }

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

Definition at line 1263 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.

01264   {
01265   arma_extra_debug_sigprint();
01266   
01267   switch(type)
01268     {
01269     case auto_detect:
01270       diskio::load_auto_detect(x, "[istream]", is);
01271       break;
01272     
01273     case arma_binary:
01274       diskio::load_arma_binary(x, "[istream]", is);
01275       break;
01276       
01277     case ppm_binary:
01278       diskio::load_ppm_binary(x, "[istream]", is);
01279       break;
01280     
01281     default:
01282       arma_stop("field_aux::load(): unsupported type");
01283     }
01284   }

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

Definition at line 1290 of file field_meat.hpp.

References diskio::save_std_string().

01291   {
01292   arma_extra_debug_sigprint();
01293   
01294   diskio::save_std_string(x, name);
01295   }

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

Definition at line 1301 of file field_meat.hpp.

References diskio::save_std_string().

01302   {
01303   arma_extra_debug_sigprint();
01304   
01305   diskio::save_std_string(x, "[ostream]", os);
01306   }

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

Definition at line 1312 of file field_meat.hpp.

References diskio::load_std_string().

01313   {
01314   arma_extra_debug_sigprint();
01315   
01316   diskio::load_std_string(x, name);
01317   }

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

Definition at line 1323 of file field_meat.hpp.

References diskio::load_std_string().

01324   {
01325   arma_extra_debug_sigprint();
01326   
01327   diskio::load_std_string(x, "[istream]", is);
01328   }