27 if(n_elem >
sizeof(mem_local)/
sizeof(oT*) )
104 template<
typename oT>
119 template<
typename oT>
135 template<
typename oT>
145 init(n_rows_in, n_cols_in);
152 template<
typename oT>
165 template<
typename oT>
172 init(n_rows_in, n_cols_in);
178 template<
typename oT>
179 template<
typename oT2>
192 template<
typename oT>
203 template<
typename oT>
214 template<
typename oT>
225 template<
typename oT>
236 template<
typename oT>
248 template<
typename oT>
260 template<
typename oT>
272 template<
typename oT>
284 template<
typename oT>
295 template<
typename oT>
305 template<
typename oT>
315 template<
typename oT>
326 template<
typename oT>
341 template<
typename oT>
356 template<
typename oT>
371 template<
typename oT>
386 template<
typename oT>
395 ( (in_row1 > in_row2) || (in_row2 >=
n_rows) ),
396 "field::rows(): indicies out of bounds or incorrectly used" 399 const uword sub_n_rows = in_row2 - in_row1 + 1;
407 template<
typename oT>
416 ( (in_row1 > in_row2) || (in_row2 >=
n_rows) ),
417 "field::rows(): indicies out of bounds or incorrectly used" 420 const uword sub_n_rows = in_row2 - in_row1 + 1;
428 template<
typename oT>
437 ( (in_col1 > in_col2) || (in_col2 >=
n_cols) ),
438 "field::cols(): indicies out of bounds or incorrectly used" 441 const uword sub_n_cols = in_col2 - in_col1 + 1;
449 template<
typename oT>
458 ( (in_col1 > in_col2) || (in_col2 >=
n_cols) ),
459 "field::cols(): indicies out of bounds or incorrectly used" 462 const uword sub_n_cols = in_col2 - in_col1 + 1;
470 template<
typename oT>
479 (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >=
n_rows) || (in_col2 >=
n_cols),
480 "field::subfield(): indices out of bounds or incorrectly used" 483 const uword sub_n_rows = in_row2 - in_row1 + 1;
484 const uword sub_n_cols = in_col2 - in_col1 + 1;
492 template<
typename oT>
501 (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >=
n_rows) || (in_col2 >=
n_cols),
502 "field::subfield(): indices out of bounds or incorrectly used" 505 const uword sub_n_rows = in_row2 - in_row1 + 1;
506 const uword sub_n_cols = in_col2 - in_col1 + 1;
514 template<
typename oT>
521 const bool row_all = row_span.
whole;
522 const bool col_all = col_span.
whole;
527 const uword in_row1 = row_all ? 0 : row_span.
a;
528 const uword in_row2 = row_span.
b;
529 const uword sub_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
531 const uword in_col1 = col_all ? 0 : col_span.
a;
532 const uword in_col2 = col_span.
b;
533 const uword sub_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
537 ( row_all ?
false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
539 ( col_all ?
false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
541 "field::subfield(): indices out of bounds or incorrectly used" 550 template<
typename oT>
557 const bool row_all = row_span.
whole;
558 const bool col_all = col_span.
whole;
563 const uword in_row1 = row_all ? 0 : row_span.
a;
564 const uword in_row2 = row_span.
b;
565 const uword sub_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
567 const uword in_col1 = col_all ? 0 : col_span.
a;
568 const uword in_col2 = col_span.
b;
569 const uword sub_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
573 ( row_all ?
false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
575 ( col_all ?
false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
577 "field::subfield(): indices out of bounds or incorrectly used" 585 template<
typename oT>
592 return (*this).subfield(row_span, col_span);
597 template<
typename oT>
604 return (*this).subfield(row_span, col_span);
618 template<
typename oT>
625 if(extra_text.length() != 0)
627 const std::streamsize orig_width = cout.width();
629 cout << extra_text <<
'\n';
631 cout.width(orig_width);
648 template<
typename oT>
655 if(extra_text.length() != 0)
657 const std::streamsize orig_width = user_stream.width();
659 user_stream << extra_text <<
'\n';
661 user_stream.width(orig_width);
670 template<
typename oT>
688 template<
typename oT>
701 template<
typename oT>
714 template<
typename oT>
725 template<
typename oT>
737 template<
typename oT>
754 return ( (a <= b) && (b <
n_elem) );
761 template<
typename oT>
772 template<
typename oT>
780 if(row_span.
whole ==
true)
786 const uword in_row1 = row_span.
a;
787 const uword in_row2 = row_span.
b;
789 return ( (in_row1 <= in_row2) && (in_row2 <
n_rows) && (in_col <
n_cols) );
795 template<
typename oT>
803 if(col_span.
whole ==
true)
809 const uword in_col1 = col_span.
a;
810 const uword in_col2 = col_span.
b;
812 return ( (in_row <
n_rows) && (in_col1 <= in_col2) && (in_col2 <
n_cols) );
818 template<
typename oT>
826 const uword in_row1 = row_span.
a;
827 const uword in_row2 = row_span.
b;
829 const uword in_col1 = col_span.
a;
830 const uword in_col2 = col_span.
b;
832 const bool rows_ok = row_span.
whole ?
true : ( (in_row1 <= in_row2) && (in_row2 <
n_rows) );
833 const bool cols_ok = col_span.
whole ?
true : ( (in_col1 <= in_col2) && (in_col2 <
n_cols) );
835 return ( (rows_ok ==
true) && (cols_ok ==
true) );
840 template<
typename oT>
850 if( (print_status ==
true) && (save_okay ==
false) )
852 if(err_msg.length() > 0)
854 arma_warn(
true,
"field::save(): ", err_msg, name);
858 arma_warn(
true,
"field::save(): couldn't write to ", name);
867 template<
typename oT>
877 if( (print_status ==
true) && (save_okay ==
false) )
879 if(err_msg.length() > 0)
881 arma_warn(
true,
"field::save(): ", err_msg,
"[ostream]");
885 arma_warn(
true,
"field::save(): couldn't write to [ostream]");
894 template<
typename oT>
904 if( (print_status ==
true) && (load_okay ==
false) )
906 if(err_msg.length() > 0)
908 arma_warn(
true,
"field::load(): ", err_msg, name);
912 arma_warn(
true,
"field::load(): couldn't read from ", name);
916 if(load_okay ==
false)
926 template<
typename oT>
936 if( (print_status ==
true) && (load_okay ==
false) )
938 if(err_msg.length() > 0)
940 arma_warn(
true,
"field::load(): ", err_msg,
"[istream]");
944 arma_warn(
true,
"field::load(): couldn't read from [istream]");
948 if(load_okay ==
false)
958 template<
typename oT>
965 return (*this).save(name, type,
false);
970 template<
typename oT>
977 return (*this).save(os, type,
false);
982 template<
typename oT>
989 return (*this).load(name, type,
false);
994 template<
typename oT>
1001 return (*this).load(is, type,
false);
1007 template<
typename oT>
1032 template<
typename oT>
1039 const uword n_elem_new = n_rows_in * n_cols_in;
1057 if(n_elem_new <=
sizeof(
mem_local)/
sizeof(oT*) )
1063 mem =
new(std::nothrow) oT* [n_elem_new];
1088 template<
typename oT>
1108 template<
typename oT>
1124 template<
typename oT>
1128 , i( (at_end == false) ? 0 : in_M.
n_elem )
1135 template<
typename oT>
1145 template<
typename oT>
1157 template<
typename oT>
1167 template<
typename oT>
1182 template<
typename oT>
1192 template<
typename oT>
1202 template<
typename oT>
1212 template<
typename oT>
1216 ,
i( (at_end == false) ? 0 : in_M.
n_elem )
1223 template<
typename oT>
1234 template<
typename oT>
1244 template<
typename oT>
1256 template<
typename oT>
1266 template<
typename oT>
1281 template<
typename oT>
1291 template<
typename oT>
1301 template<
typename oT>
1311 template<
typename oT>
1323 template<
typename oT>
1335 template<
typename oT>
1347 template<
typename oT>
1365 template<
typename oT>
1378 template<
typename eT>
1387 (*(x.mem[
i])).reset();
1393 template<
typename eT>
1402 (*(x.mem[
i])).reset();
1408 template<
typename eT>
1417 (*(x.mem[
i])).reset();
1423 template<
typename eT>
1432 (*(x.mem[
i])).reset();
1446 (*(x.
mem[
i])).clear();
1458 template<
typename oT>
1465 err_msg =
" [sorry, saving/loading this type of field is currently not supported] filename = ";
1472 template<
typename oT>
1479 err_msg =
" [sorry, saving/loading this type of field is currently not supported] filename = ";
1486 template<
typename oT>
1493 err_msg =
" [sorry, saving/loading this type of field is currently not supported] filename = ";
1500 template<
typename oT>
1507 err_msg =
" [sorry, saving/loading this type of field is currently not supported] filename = ";
1514 template<
typename eT>
1532 err_msg =
" [unsupported type] filename = ";
1539 template<
typename eT>
1557 err_msg =
" [unsupported type] filename = ";
1564 template<
typename eT>
1586 err_msg =
" [unsupported type] filename = ";
1593 template<
typename eT>
1615 err_msg =
" [unsupported type] filename = ";
1622 template<
typename eT>
1640 err_msg =
" [unsupported type] filename = ";
1647 template<
typename eT>
1665 err_msg =
" [unsupported type] filename = ";
1672 template<
typename eT>
1694 err_msg =
" [unsupported type] filename = ";
1701 template<
typename eT>
1723 err_msg =
" [unsupported type] filename = ";
1730 template<
typename eT>
1748 err_msg =
" [unsupported type] filename = ";
1755 template<
typename eT>
1773 err_msg =
" [unsupported type] filename = ";
1780 template<
typename eT>
1802 err_msg =
" [unsupported type] filename = ";
1809 template<
typename eT>
1831 err_msg =
" [unsupported type] filename = ";
1838 template<
typename eT>
1856 err_msg =
" [unsupported type] filename = ";
1863 template<
typename eT>
1881 err_msg =
" [unsupported type] filename = ";
1888 template<
typename eT>
1910 err_msg =
" [unsupported type] filename = ";
1917 template<
typename eT>
1939 err_msg =
" [unsupported type] filename = ";
2002 #ifdef ARMA_EXTRA_FIELD_MEAT 2003 #include ARMA_INCFILE_WRAP(ARMA_EXTRA_FIELD_MEAT) Portable Pixel Map (colour image), used by the field and cube classes.
arma_inline arma_warn_unused bool in_range(const uword i) const
returns true if the given index is currently in range
const field & operator=(const field &x)
construct a field from a given field
static bool load_arma_binary(Mat< eT > &x, const std::string &name, std::string &err_msg)
arma_inline bool is_empty() const
returns true if the field has no objects
void arma_hot arma_check_bad_alloc(const bool state, const T1 &x)
bool operator==(const iterator &X) const
const oT & operator*() const
const uword n_rows
number of rows in the field (read-only)
const uword n_cols
number of columns in the field (read-only)
void set_size(const uword n_obj_in)
const_iterator & operator--()
subview_field< oT > cols(const uword in_col1, const uword in_col2)
creation of subview_field (subfield comprised of specified columns)
arma_aligned oT ** mem
pointer to memory used by the object
subview_field< oT > rows(const uword in_row1, const uword in_row2)
creation of subview_field (subfield comprised of specified rows)
iterator(field< oT > &in_M, const bool at_end=false)
bool save(const std::string name, const file_type type=arma_binary, const bool print_status=true) const
static bool load_std_string(field< std::string > &x, const std::string &name, std::string &err_msg)
Class for column vectors (matrices with only one column)
static bool save_ppm_binary(const Cube< T1 > &x, const std::string &final_name)
arma_inline oT & operator[](const uword i)
linear element accessor (treats the field as a vector); no bounds check
bool load(const std::string name, const file_type type=auto_detect, const bool print_status=true)
static bool load_ppm_binary(Cube< T1 > &x, const std::string &final_name, std::string &err_msg)
static void print(std::ostream &o, const Mat< eT > &m, const bool modify)
Print a matrix to the specified stream.
static arma_inline T1 & rw(const T1 &x)
internal function to allow modification of data declared as read-only
subview_field< oT > col(const uword col_num)
creation of subview_field (column of a field)
bool operator!=(const iterator &X) const
bool quiet_save(const std::string name, const file_type type=arma_binary) const
void reset_objects()
reset each object
static void reset_objects(field< oT > &x)
const_iterator(const field< oT > &in_M, const bool at_end=false)
#define arma_ignore(variable)
arma_inline oT & operator()(const uword i)
linear element accessor (treats the field as a vector); bounds checking not done when ARMA_NO_DEBUG i...
#define arma_extra_debug_sigprint_this
Armadillo binary format, with information about matrix type and size.
static bool load_auto_detect(Mat< eT > &x, const std::string &name, std::string &err_msg)
Try to load a matrix by automatically determining its type.
arma_aligned field< oT > & M
static bool save(const field< oT > &x, const std::string &name, const file_type type, std::string &err_msg)
void reset()
reset the field to an empty state (i.e. the field will have no objects)
Class for row vectors (matrices with only one row)
void print(const std::string extra_text="") const
arma_aligned const field< oT > & M
#define arma_extra_debug_sigprint
static bool save_std_string(const field< std::string > &x, const std::string &name)
static void extract(field< oT > &out, const subview_field &in)
X = Y.subfield(...)
subview_field< oT > row(const uword row_num)
creation of subview_field (row of a field)
subview_field< oT > subfield(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2)
creation of subview_field (subfield with arbitrary dimensions)
void arma_cold arma_warn(const bool state, const T1 &x)
print a message to the warn stream
bool operator==(const const_iterator &X) const
bool quiet_load(const std::string name, const file_type type=auto_detect)
field_injector< field > operator<<(const oT &val)
void fill(const oT &x)
fill the field with an object
static bool load(field< oT > &x, const std::string &name, const file_type type, std::string &err_msg)
arma_aligned oT * mem_local[field_prealloc_n_elem::val]
Internal memory, to avoid calling the 'new' operator for small amounts of memory. ...
bool operator!=(const const_iterator &X) const
const_iterator & operator++()
const uword n_elem
number of elements in the field (read-only)
void init(const field< oT > &x)
construct a field from a given field
void copy_size(const field< oT2 > &x)
change the field to have the specified dimensions (data is not preserved)
Automatically detect the file type (file must be one of the following types)
static bool save_arma_binary(const Mat< eT > &x, const std::string &final_name)
arma_inline oT & at(const uword i)
linear element accessor (treats the field as a vector); no bounds check