28 #if defined(ARMA_USE_TBB_ALLOC) 29 scalable_free((
void *)(mem));
71 ,
n_elem(in_n_rows*in_n_cols)
99 "Mat::init(): requested size is too large" 110 #if defined(ARMA_USE_TBB_ALLOC) 123 template<
typename eT>
135 bool err_state =
false;
146 "Mat::init(): size is fixed and hence cannot be changed" 151 if( (in_n_rows == 0) && (in_n_cols == 0) )
169 ( ((t_vec_state == 1) && (in_n_cols != 1)) || ((t_vec_state == 2) && (in_n_rows != 1)) ),
170 "Mat::init(): object is a vector; requested size is not compatible" 183 ? ( (
float(in_n_rows) *
float(in_n_cols)) >
float(
ARMA_MAX_UWORD) )
186 "Mat::init(): requested size is too large" 192 const uword new_n_elem = in_n_rows * in_n_cols;
194 if(old_n_elem == new_n_elem)
206 "Mat::init(): mismatch between size of auxiliary memory and requested size" 215 #if defined(ARMA_USE_TBB_ALLOC) 216 scalable_free((
void *)(
mem));
232 #if defined(ARMA_USE_TBB_ALLOC) 233 access::rw(
mem) = (eT *) scalable_malloc(
sizeof(eT)*new_n_elem);
251 template<
typename eT>
263 init( std::string(text) );
269 template<
typename eT>
276 init( std::string(text) );
283 template<
typename eT>
301 template<
typename eT>
315 template<
typename eT>
328 bool t_n_cols_found =
false;
332 std::string::size_type line_start = 0;
333 std::string::size_type line_end = 0;
335 while( line_start < text.length() )
338 line_end = text.find(
';', line_start);
340 if(line_end == std::string::npos)
341 line_end = text.length()-1;
343 std::string::size_type line_len = line_end - line_start + 1;
344 std::stringstream line_stream( text.substr(line_start,line_len) );
347 uword line_n_cols = 0;
348 while(line_stream >> token)
356 if(t_n_cols_found ==
false)
358 t_n_cols = line_n_cols;
359 t_n_cols_found =
true;
362 arma_check( (line_n_cols != t_n_cols),
"Mat::init(): inconsistent number of columns in given string");
366 line_start = line_end+1;
378 while( line_start < text.length() )
381 line_end = text.find(
';', line_start);
383 if(line_end == std::string::npos)
384 line_end = text.length()-1;
386 std::string::size_type line_len = line_end - line_start + 1;
387 std::stringstream line_stream( text.substr(line_start,line_len) );
398 while(line_stream >> val)
405 line_start = line_end+1;
412 #if defined(ARMA_USE_CXX11) 414 template<
typename eT>
431 template<
typename eT>
449 template<
typename eT>
464 template<
typename eT>
479 template<
typename eT>
494 template<
typename eT>
509 template<
typename eT>
524 template<
typename eT>
544 template<
typename eT>
563 #if defined(ARMA_USE_CXX11) 565 template<
typename eT>
572 const uword N = list.size();
584 template<
typename eT>
585 template<
typename T1,
typename T2>
596 typedef typename T1::elem_type T;
610 init_warm(X.get_n_rows(), X.get_n_cols());
614 ea_type1 PX = X.get_ea();
615 ea_type2 PY = Y.get_ea();
617 for(
uword i=0; i<N; ++i)
619 out_mem[i] = std::complex<T>(PX[i], PY[i]);
627 template<
typename eT>
644 bool layout_ok =
false;
646 if(t_vec_state == x_vec_state)
652 if( (t_vec_state == 1) && ( x_n_cols == 1) )
657 if( (t_vec_state == 2) && ( x_n_rows == 1) )
681 (*this).operator=(x);
693 template<
typename eT>
698 ,
n_elem ( aux_n_rows*aux_n_cols )
700 ,
mem_state( copy_aux_mem ? 0 : ( strict ? 2 : 1 ) )
701 ,
mem ( copy_aux_mem ? 0 : aux_mem )
705 if(copy_aux_mem ==
true)
717 template<
typename eT>
722 ,
n_elem(aux_n_rows*aux_n_cols)
740 template<
typename eT>
745 ,
n_elem (aux_n_rows*aux_n_cols)
757 template<
typename eT>
774 template<
typename eT>
791 template<
typename eT>
806 template<
typename eT>
823 template<
typename eT>
839 template<
typename eT>
840 template<
typename T1>
852 (*this).operator=(X);
857 template<
typename eT>
858 template<
typename T1>
872 const uword in_n_rows = in.n_rows;
873 const uword in_n_cols = in.n_cols;
874 const uword in_n_slices = in.n_slices;
889 if(out_vec_state == 0)
893 out.
set_size(in_n_rows, in_n_slices);
895 for(
uword i=0; i < in_n_slices; ++i)
903 out.
set_size(in_n_cols, in_n_slices);
905 for(
uword slice=0; slice < in_n_slices; ++slice)
907 eT* out_colptr = out.
colptr(slice);
910 for(i=0, j=1; j < in_n_cols; i+=2, j+=2)
912 const eT tmp_i = in.at(0, i, slice);
913 const eT tmp_j = in.at(0, j, slice);
915 out_colptr[i] = tmp_i;
916 out_colptr[j] = tmp_j;
921 out_colptr[i] = in.at(0, i, slice);
930 eT* out_mem = out.
memptr();
932 for(
uword i=0; i<in_n_slices; ++i)
934 out_mem[i] = in.at(0, 0, i);
944 template<
typename eT>
945 template<
typename T1>
959 const uword in_n_rows = in.n_rows;
960 const uword in_n_cols = in.n_cols;
961 const uword in_n_slices = in.n_slices;
976 if(out_vec_state == 0)
978 if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
980 for(
uword i=0; i < in_n_slices; ++i)
986 if( (in_n_rows == 1) && (in_n_cols == out_n_rows) && (in_n_slices == out_n_cols) )
988 for(
uword slice=0; slice < in_n_slices; ++slice)
990 eT* out_colptr = out.
colptr(slice);
993 for(i=0, j=1; j < in_n_cols; i+=2, j+=2)
995 const eT tmp_i = in.at(0, i, slice);
996 const eT tmp_j = in.at(0, j, slice);
998 out_colptr[i] += tmp_i;
999 out_colptr[j] += tmp_j;
1004 out_colptr[i] += in.at(0, i, slice);
1011 eT* out_mem = out.
memptr();
1013 for(
uword i=0; i<in_n_slices; ++i)
1015 out_mem[i] += in.at(0, 0, i);
1025 template<
typename eT>
1026 template<
typename T1>
1040 const uword in_n_rows = in.n_rows;
1041 const uword in_n_cols = in.n_cols;
1042 const uword in_n_slices = in.n_slices;
1048 if(in_n_slices == 1)
1057 if(out_vec_state == 0)
1059 if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
1061 for(
uword i=0; i < in_n_slices; ++i)
1067 if( (in_n_rows == 1) && (in_n_cols == out_n_rows) && (in_n_slices == out_n_cols) )
1069 for(
uword slice=0; slice < in_n_slices; ++slice)
1071 eT* out_colptr = out.
colptr(slice);
1074 for(i=0, j=1; j < in_n_cols; i+=2, j+=2)
1076 const eT tmp_i = in.at(0, i, slice);
1077 const eT tmp_j = in.at(0, j, slice);
1079 out_colptr[i] -= tmp_i;
1080 out_colptr[j] -= tmp_j;
1085 out_colptr[i] -= in.at(0, i, slice);
1092 eT* out_mem = out.
memptr();
1094 for(
uword i=0; i<in_n_slices; ++i)
1096 out_mem[i] -= in.at(0, 0, i);
1106 template<
typename eT>
1107 template<
typename T1>
1116 (*this).operator*=(B);
1123 template<
typename eT>
1124 template<
typename T1>
1138 const uword in_n_rows = in.n_rows;
1139 const uword in_n_cols = in.n_cols;
1140 const uword in_n_slices = in.n_slices;
1146 if(in_n_slices == 1)
1155 if(out_vec_state == 0)
1157 if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
1159 for(
uword i=0; i < in_n_slices; ++i)
1165 if( (in_n_rows == 1) && (in_n_cols == out_n_rows) && (in_n_slices == out_n_cols) )
1167 for(
uword slice=0; slice < in_n_slices; ++slice)
1169 eT* out_colptr = out.
colptr(slice);
1172 for(i=0, j=1; j < in_n_cols; i+=2, j+=2)
1174 const eT tmp_i = in.at(0, i, slice);
1175 const eT tmp_j = in.at(0, j, slice);
1177 out_colptr[i] *= tmp_i;
1178 out_colptr[j] *= tmp_j;
1183 out_colptr[i] *= in.at(0, i, slice);
1190 eT* out_mem = out.
memptr();
1192 for(
uword i=0; i<in_n_slices; ++i)
1194 out_mem[i] *= in.at(0, 0, i);
1204 template<
typename eT>
1205 template<
typename T1>
1219 const uword in_n_rows = in.n_rows;
1220 const uword in_n_cols = in.n_cols;
1221 const uword in_n_slices = in.n_slices;
1227 if(in_n_slices == 1)
1236 if(out_vec_state == 0)
1238 if( (in_n_rows == out_n_rows) && (in_n_cols == 1) && (in_n_slices == out_n_cols) )
1240 for(
uword i=0; i < in_n_slices; ++i)
1246 if( (in_n_rows == 1) && (in_n_cols == out_n_rows) && (in_n_slices == out_n_cols) )
1248 for(
uword slice=0; slice < in_n_slices; ++slice)
1250 eT* out_colptr = out.
colptr(slice);
1253 for(i=0, j=1; j < in_n_cols; i+=2, j+=2)
1255 const eT tmp_i = in.at(0, i, slice);
1256 const eT tmp_j = in.at(0, j, slice);
1258 out_colptr[i] /= tmp_i;
1259 out_colptr[j] /= tmp_j;
1264 out_colptr[i] /= in.at(0, i, slice);
1271 eT* out_mem = out.
memptr();
1273 for(
uword i=0; i<in_n_slices; ++i)
1275 out_mem[i] /= in.at(0, 0, i);
1286 template<
typename eT>
1287 template<
typename T1,
typename T2>
1309 template<
typename eT>
1329 template<
typename eT>
1336 const bool alias = (
this == &(X.
m));
1356 template<
typename eT>
1370 template<
typename eT>
1385 template<
typename eT>
1400 template<
typename eT>
1415 template<
typename eT>
1430 template<
typename eT>
1448 template<
typename eT>
1463 template<
typename eT>
1478 template<
typename eT>
1493 template<
typename eT>
1509 template<
typename eT>
1524 template<
typename eT>
1539 template<
typename eT>
1559 template<
typename eT>
1566 const bool alias = (
this == &(X.
m));
1587 template<
typename eT>
1601 template<
typename eT>
1616 template<
typename eT>
1631 template<
typename eT>
1646 template<
typename eT>
1660 template<
typename eT>
1661 template<
typename T1>
1678 template<
typename eT>
1679 template<
typename T1>
1693 template<
typename eT>
1694 template<
typename T1>
1708 template<
typename eT>
1709 template<
typename T1>
1723 template<
typename eT>
1724 template<
typename T1>
1738 template<
typename eT>
1739 template<
typename T1>
1753 template<
typename eT>
1754 template<
typename T1>
1768 template<
typename eT>
1778 template<
typename eT>
1789 template<
typename eT>
1804 template<
typename eT>
1818 template<
typename eT>
1825 const bool col_all = col_span.
whole;
1829 const uword in_col1 = col_all ? 0 : col_span.
a;
1830 const uword in_col2 = col_span.
b;
1831 const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
1837 ( col_all ?
false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
1839 "Mat::operator(): indices out of bounds or incorrectly used" 1847 template<
typename eT>
1854 const bool col_all = col_span.
whole;
1858 const uword in_col1 = col_all ? 0 : col_span.
a;
1859 const uword in_col2 = col_span.
b;
1860 const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
1866 ( col_all ?
false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
1868 "Mat::operator(): indices out of bounds or incorrectly used" 1877 template<
typename eT>
1892 template<
typename eT>
1906 template<
typename eT>
1913 const bool row_all = row_span.
whole;
1917 const uword in_row1 = row_all ? 0 : row_span.
a;
1918 const uword in_row2 = row_span.
b;
1919 const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
1925 ( row_all ?
false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
1927 "Mat::operator(): indices out of bounds or incorrectly used" 1935 template<
typename eT>
1942 const bool row_all = row_span.
whole;
1946 const uword in_row1 = row_all ? 0 : row_span.
a;
1947 const uword in_row2 = row_span.
b;
1948 const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
1954 ( row_all ?
false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
1956 "Mat::operator(): indices out of bounds or incorrectly used" 1969 template<
typename eT>
1988 template<
typename eT>
1997 typedef const Col<eT> out_type;
1999 return out_type(const_cast<eT*>(
colptr(col_num)),
n_rows,
false,
true);
2005 template<
typename eT>
2014 (in_row1 > in_row2) || (in_row2 >=
n_rows),
2015 "Mat::rows(): indices out of bounds or incorrectly used" 2018 const uword subview_n_rows = in_row2 - in_row1 + 1;
2026 template<
typename eT>
2035 (in_row1 > in_row2) || (in_row2 >=
n_rows),
2036 "Mat::rows(): indices out of bounds or incorrectly used" 2039 const uword subview_n_rows = in_row2 - in_row1 + 1;
2047 template<
typename eT>
2056 (in_col1 > in_col2) || (in_col2 >=
n_cols),
2057 "Mat::cols(): indices out of bounds or incorrectly used" 2060 const uword subview_n_cols = in_col2 - in_col1 + 1;
2068 template<
typename eT>
2077 (in_col1 > in_col2) || (in_col2 >=
n_cols),
2078 "Mat::cols(): indices out of bounds or incorrectly used" 2081 const uword subview_n_cols = in_col2 - in_col1 + 1;
2089 template<
typename eT>
2098 (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >=
n_rows) || (in_col2 >=
n_cols),
2099 "Mat::submat(): indices out of bounds or incorrectly used" 2102 const uword subview_n_rows = in_row2 - in_row1 + 1;
2103 const uword subview_n_cols = in_col2 - in_col1 + 1;
2105 return subview<eT>(*
this, in_row1, in_col1, subview_n_rows, subview_n_cols);
2111 template<
typename eT>
2120 (in_row1 > in_row2) || (in_col1 > in_col2) || (in_row2 >=
n_rows) || (in_col2 >=
n_cols),
2121 "Mat::submat(): indices out of bounds or incorrectly used" 2124 const uword subview_n_rows = in_row2 - in_row1 + 1;
2125 const uword subview_n_cols = in_col2 - in_col1 + 1;
2127 return subview<eT>(*
this, in_row1, in_col1, subview_n_rows, subview_n_cols);
2133 template<
typename eT>
2140 const bool row_all = row_span.
whole;
2141 const bool col_all = col_span.
whole;
2146 const uword in_row1 = row_all ? 0 : row_span.
a;
2147 const uword in_row2 = row_span.
b;
2148 const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
2150 const uword in_col1 = col_all ? 0 : col_span.
a;
2151 const uword in_col2 = col_span.
b;
2152 const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
2156 ( row_all ?
false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
2158 ( col_all ?
false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
2160 "Mat::submat(): indices out of bounds or incorrectly used" 2163 return subview<eT>(*
this, in_row1, in_col1, submat_n_rows, submat_n_cols);
2169 template<
typename eT>
2176 const bool row_all = row_span.
whole;
2177 const bool col_all = col_span.
whole;
2182 const uword in_row1 = row_all ? 0 : row_span.
a;
2183 const uword in_row2 = row_span.
b;
2184 const uword submat_n_rows = row_all ? local_n_rows : in_row2 - in_row1 + 1;
2186 const uword in_col1 = col_all ? 0 : col_span.
a;
2187 const uword in_col2 = col_span.
b;
2188 const uword submat_n_cols = col_all ? local_n_cols : in_col2 - in_col1 + 1;
2192 ( row_all ?
false : ((in_row1 > in_row2) || (in_row2 >= local_n_rows)) )
2194 ( col_all ?
false : ((in_col1 > in_col2) || (in_col2 >= local_n_cols)) )
2196 "Mat::submat(): indices out of bounds or incorrectly used" 2199 return subview<eT>(*
this, in_row1, in_col1, submat_n_rows, submat_n_cols);
2204 template<
typename eT>
2211 return (*this).submat(row_span, col_span);
2216 template<
typename eT>
2223 return (*this).submat(row_span, col_span);
2228 template<
typename eT>
2229 template<
typename T1>
2241 template<
typename eT>
2242 template<
typename T1>
2281 template<
typename eT>
2288 const uword row_offset = (in_id < 0) ?
uword(-in_id) : 0;
2289 const uword col_offset = (in_id > 0) ?
uword( in_id) : 0;
2293 ((row_offset > 0) && (row_offset >=
n_rows)) || ((col_offset > 0) && (col_offset >=
n_cols)),
2294 "Mat::diag(): requested diagonal out of bounds" 2299 return diagview<eT>(*
this, row_offset, col_offset, len);
2305 template<
typename eT>
2312 const uword row_offset = (in_id < 0) ? -in_id : 0;
2313 const uword col_offset = (in_id > 0) ? in_id : 0;
2317 ((row_offset > 0) && (row_offset >=
n_rows)) || ((col_offset > 0) && (col_offset >=
n_cols)),
2318 "Mat::diag(): requested diagonal out of bounds" 2323 return diagview<eT>(*
this, row_offset, col_offset, len);
2328 template<
typename eT>
2338 "Mat::swap_rows(): out of bounds" 2344 const uword pos1 = in_row1 + offset;
2345 const uword pos2 = in_row2 + offset;
2347 const eT tmp =
mem[pos1];
2356 template<
typename eT>
2366 "Mat::swap_cols(): out of bounds" 2371 eT* ptr1 =
colptr(in_col1);
2372 eT* ptr2 =
colptr(in_col2);
2376 const eT tmp = ptr1[
row];
2386 template<
typename eT>
2401 template<
typename eT>
2416 template<
typename eT>
2425 (in_row1 > in_row2) || (in_row2 >=
n_rows),
2426 "Mat::shed_rows(): indices out of bounds or incorrectly used" 2429 const uword n_keep_front = in_row1;
2434 if(n_keep_front > 0)
2436 X.rows( 0, (n_keep_front-1) ) =
rows( 0, (in_row1-1) );
2441 X.rows( n_keep_front, (n_keep_front+n_keep_back-1) ) =
rows( (in_row2+1), (
n_rows-1) );
2450 template<
typename eT>
2459 (in_col1 > in_col2) || (in_col2 >=
n_cols),
2460 "Mat::shed_cols(): indices out of bounds or incorrectly used" 2463 const uword n_keep_front = in_col1;
2468 if(n_keep_front > 0)
2470 X.cols( 0, (n_keep_front-1) ) =
cols( 0, (in_col1-1) );
2475 X.cols( n_keep_front, (n_keep_front+n_keep_back-1) ) =
cols( (in_col2+1), (
n_cols-1) );
2485 template<
typename eT>
2495 const uword A_n_rows = row_num;
2496 const uword B_n_rows = t_n_rows - row_num;
2499 arma_debug_check( (row_num > t_n_rows),
"Mat::insert_rows(): out of bounds");
2503 Mat<eT> out(t_n_rows + N, t_n_cols);
2507 out.
rows(0, A_n_rows-1) =
rows(0, A_n_rows-1);
2512 out.
rows(row_num + N, t_n_rows + N - 1) =
rows(row_num, t_n_rows-1);
2515 if(set_to_zero ==
true)
2517 out.
rows(row_num, row_num + N - 1).zeros();
2528 template<
typename eT>
2538 const uword A_n_cols = col_num;
2539 const uword B_n_cols = t_n_cols - col_num;
2542 arma_debug_check( (col_num > t_n_cols),
"Mat::insert_cols(): out of bounds");
2546 Mat<eT> out(t_n_rows, t_n_cols + N);
2550 out.
cols(0, A_n_cols-1) =
cols(0, A_n_cols-1);
2555 out.
cols(col_num + N, t_n_cols + N - 1) =
cols(col_num, t_n_cols-1);
2558 if(set_to_zero ==
true)
2560 out.
cols(col_num, col_num + N - 1).zeros();
2571 template<
typename eT>
2572 template<
typename T1>
2582 const uword C_n_rows = C.n_rows;
2583 const uword C_n_cols = C.n_cols;
2588 const uword A_n_rows = row_num;
2589 const uword B_n_rows = t_n_rows - row_num;
2591 bool err_state =
false;
2600 (row_num > t_n_rows),
2601 "Mat::insert_rows(): out of bounds" 2608 ( (C_n_cols != t_n_cols) && ( (t_n_rows > 0) || (t_n_cols > 0) ) && ( (C_n_rows > 0) || (C_n_cols > 0) ) ),
2609 "Mat::insert_rows(): given object has an incompatible number of columns" 2622 out.
rows(0, A_n_rows-1) =
rows(0, A_n_rows-1);
2625 if( (t_n_cols > 0) && (B_n_rows > 0) )
2627 out.
rows(row_num + C_n_rows, t_n_rows + C_n_rows - 1) =
rows(row_num, t_n_rows - 1);
2633 out.
rows(row_num, row_num + C_n_rows - 1) = C;
2644 template<
typename eT>
2645 template<
typename T1>
2655 const uword C_n_rows = C.n_rows;
2656 const uword C_n_cols = C.n_cols;
2661 const uword A_n_cols = col_num;
2662 const uword B_n_cols = t_n_cols - col_num;
2664 bool err_state =
false;
2673 (col_num > t_n_cols),
2674 "Mat::insert_cols(): out of bounds" 2681 ( (C_n_rows != t_n_rows) && ( (t_n_rows > 0) || (t_n_cols > 0) ) && ( (C_n_rows > 0) || (C_n_cols > 0) ) ),
2682 "Mat::insert_cols(): given object has an incompatible number of rows" 2695 out.
cols(0, A_n_cols-1) =
cols(0, A_n_cols-1);
2700 out.
cols(col_num + C_n_cols, t_n_cols + C_n_cols - 1) =
cols(col_num, t_n_cols - 1);
2706 out.
cols(col_num, col_num + C_n_cols - 1) = C;
2715 template<
typename eT>
2716 template<
typename gen_type>
2735 template<
typename eT>
2736 template<
typename gen_type>
2752 template<
typename eT>
2753 template<
typename gen_type>
2767 template<
typename eT>
2768 template<
typename gen_type>
2782 template<
typename eT>
2783 template<
typename gen_type>
2792 return (*this).operator*=(tmp);
2797 template<
typename eT>
2798 template<
typename gen_type>
2812 template<
typename eT>
2813 template<
typename gen_type>
2828 template<
typename eT>
2829 template<
typename T1,
typename op_type>
2843 op_type::apply(*
this, X);
2849 template<
typename eT>
2850 template<
typename T1,
typename op_type>
2859 op_type::apply(*
this, X);
2867 template<
typename eT>
2868 template<
typename T1,
typename op_type>
2879 return (*this).operator+=(m);
2885 template<
typename eT>
2886 template<
typename T1,
typename op_type>
2897 return (*this).operator-=(m);
2903 template<
typename eT>
2904 template<
typename T1,
typename op_type>
2921 template<
typename eT>
2922 template<
typename T1,
typename op_type>
2933 return (*this).operator%=(m);
2939 template<
typename eT>
2940 template<
typename T1,
typename op_type>
2951 return (*this).operator/=(m);
2957 template<
typename eT>
2958 template<
typename T1,
typename eop_type>
2974 eop_type::apply(*
this, X);
2980 template<
typename eT>
2981 template<
typename T1,
typename eop_type>
2990 const bool bad_alias = (X.
P.has_subview && X.
P.is_alias(*
this));
2992 if(bad_alias ==
false)
2996 eop_type::apply(*
this, X);
3010 template<
typename eT>
3011 template<
typename T1,
typename eop_type>
3020 eop_type::apply_inplace_plus(*
this, X);
3027 template<
typename eT>
3028 template<
typename T1,
typename eop_type>
3037 eop_type::apply_inplace_minus(*
this, X);
3044 template<
typename eT>
3045 template<
typename T1,
typename eop_type>
3061 template<
typename eT>
3062 template<
typename T1,
typename eop_type>
3071 eop_type::apply_inplace_schur(*
this, X);
3078 template<
typename eT>
3079 template<
typename T1,
typename eop_type>
3088 eop_type::apply_inplace_div(*
this, X);
3096 template<
typename eT>
3097 template<
typename T1,
typename op_type>
3109 op_type::apply(*
this, X);
3115 template<
typename eT>
3116 template<
typename T1,
typename op_type>
3123 op_type::apply(*
this, X);
3131 template<
typename eT>
3132 template<
typename T1,
typename op_type>
3141 return (*this).operator+=(m);
3147 template<
typename eT>
3148 template<
typename T1,
typename op_type>
3157 return (*this).operator-=(m);
3163 template<
typename eT>
3164 template<
typename T1,
typename op_type>
3173 return (*this).operator*=(m);
3179 template<
typename eT>
3180 template<
typename T1,
typename op_type>
3189 return (*this).operator%=(m);
3195 template<
typename eT>
3196 template<
typename T1,
typename op_type>
3205 return (*this).operator/=(m);
3211 template<
typename eT>
3212 template<
typename T1,
typename T2,
typename glue_type>
3227 glue_type::apply(*
this, X);
3233 template<
typename eT>
3234 template<
typename T1,
typename T2,
typename glue_type>
3244 glue_type::apply(*
this, X);
3252 template<
typename eT>
3253 template<
typename T1,
typename T2,
typename glue_type>
3265 return (*this).operator+=(m);
3271 template<
typename eT>
3272 template<
typename T1,
typename T2,
typename glue_type>
3284 return (*this).operator-=(m);
3290 template<
typename eT>
3291 template<
typename T1,
typename T2,
typename glue_type>
3309 template<
typename eT>
3310 template<
typename T1,
typename T2,
typename glue_type>
3322 return (*this).operator%=(m);
3328 template<
typename eT>
3329 template<
typename T1,
typename T2,
typename glue_type>
3341 return (*this).operator/=(m);
3346 template<
typename eT>
3347 template<
typename T1,
typename T2>
3361 template<
typename eT>
3362 template<
typename T1,
typename T2>
3377 template<
typename eT>
3378 template<
typename T1,
typename T2,
typename eglue_type>
3395 eglue_type::apply(*
this, X);
3401 template<
typename eT>
3402 template<
typename T1,
typename T2,
typename eglue_type>
3412 const bool bad_alias = ( (X.
P1.has_subview && X.
P1.is_alias(*
this)) || ( X.
P2.has_subview && X.
P2.is_alias(*
this)) );
3414 if(bad_alias ==
false)
3418 eglue_type::apply(*
this, X);
3433 template<
typename eT>
3434 template<
typename T1,
typename T2,
typename eglue_type>
3444 eglue_type::apply_inplace_plus(*
this, X);
3452 template<
typename eT>
3453 template<
typename T1,
typename T2,
typename eglue_type>
3463 eglue_type::apply_inplace_minus(*
this, X);
3470 template<
typename eT>
3471 template<
typename T1,
typename T2,
typename eglue_type>
3487 template<
typename eT>
3488 template<
typename T1,
typename T2,
typename eglue_type>
3498 eglue_type::apply_inplace_schur(*
this, X);
3504 template<
typename eT>
3505 template<
typename T1,
typename T2,
typename eglue_type>
3515 eglue_type::apply_inplace_div(*
this, X);
3522 template<
typename eT>
3523 template<
typename T1,
typename T2,
typename glue_type>
3535 glue_type::apply(*
this, X);
3541 template<
typename eT>
3542 template<
typename T1,
typename T2,
typename glue_type>
3549 glue_type::apply(*
this, X);
3557 template<
typename eT>
3558 template<
typename T1,
typename T2,
typename glue_type>
3567 return (*this).operator+=(m);
3573 template<
typename eT>
3574 template<
typename T1,
typename T2,
typename glue_type>
3583 return (*this).operator-=(m);
3589 template<
typename eT>
3590 template<
typename T1,
typename T2,
typename glue_type>
3607 template<
typename eT>
3608 template<
typename T1,
typename T2,
typename glue_type>
3617 return (*this).operator%=(m);
3623 template<
typename eT>
3624 template<
typename T1,
typename T2,
typename glue_type>
3633 return (*this).operator/=(m);
3639 template<
typename eT>
3652 template<
typename eT>
3664 template<
typename eT>
3676 template<
typename eT>
3688 template<
typename eT>
3700 template<
typename eT>
3712 template<
typename eT>
3725 template<
typename eT>
3738 template<
typename eT>
3750 template<
typename eT>
3762 template<
typename eT>
3774 template<
typename eT>
3785 template<
typename eT>
3797 template<
typename eT>
3808 template<
typename eT>
3820 template<
typename eT>
3832 template<
typename eT>
3844 template<
typename eT>
3856 template<
typename eT>
3868 template<
typename eT>
3880 template<
typename eT>
3892 template<
typename eT>
3909 return ( (a <= b) && (b <
n_elem) );
3916 template<
typename eT>
3927 template<
typename eT>
3935 if(row_span.
whole ==
true)
3937 return (in_col <
n_cols);
3941 const uword in_row1 = row_span.
a;
3942 const uword in_row2 = row_span.
b;
3944 return ( (in_row1 <= in_row2) && (in_row2 <
n_rows) && (in_col <
n_cols) );
3950 template<
typename eT>
3958 if(col_span.
whole ==
true)
3960 return (in_row <
n_rows);
3964 const uword in_col1 = col_span.
a;
3965 const uword in_col2 = col_span.
b;
3967 return ( (in_row <
n_rows) && (in_col1 <= in_col2) && (in_col2 <
n_cols) );
3973 template<
typename eT>
3981 const uword in_row1 = row_span.
a;
3982 const uword in_row2 = row_span.
b;
3984 const uword in_col1 = col_span.
a;
3985 const uword in_col2 = col_span.
b;
3987 const bool rows_ok = row_span.
whole ?
true : ( (in_row1 <= in_row2) && (in_row2 <
n_rows) );
3988 const bool cols_ok = col_span.
whole ?
true : ( (in_col1 <= in_col2) && (in_col2 <
n_cols) );
3990 return ( (rows_ok ==
true) && (cols_ok ==
true) );
3996 template<
typename eT>
4008 template<
typename eT>
4020 template<
typename eT>
4026 return const_cast<eT*
>(
mem);
4032 template<
typename eT>
4047 template<
typename eT>
4054 if(extra_text.length() != 0)
4056 const std::streamsize orig_width = cout.width();
4058 cout << extra_text <<
'\n';
4060 cout.width(orig_width);
4072 template<
typename eT>
4079 if(extra_text.length() != 0)
4081 const std::streamsize orig_width = user_stream.width();
4083 user_stream << extra_text <<
'\n';
4085 user_stream.width(orig_width);
4094 template<
typename eT>
4110 template<
typename eT>
4129 template<
typename eT>
4136 if(extra_text.length() != 0)
4138 const std::streamsize orig_width = cout.width();
4140 cout << extra_text <<
'\n';
4142 cout.width(orig_width);
4154 template<
typename eT>
4161 if(extra_text.length() != 0)
4163 const std::streamsize orig_width = user_stream.width();
4165 user_stream << extra_text <<
'\n';
4167 user_stream.width(orig_width);
4176 template<
typename eT>
4192 template<
typename eT>
4208 template<
typename eT>
4234 template<
typename eT>
4247 template<
typename eT>
4258 (*this).resize(in_elem, 1);
4262 (*this).resize(1, in_elem);
4273 template<
typename eT>
4286 template<
typename eT>
4299 template<
typename eT>
4300 template<
typename eT2>
4313 template<
typename eT>
4328 template<
typename eT>
4340 template<
typename eT>
4354 template<
typename eT>
4368 template<
typename eT>
4380 template<
typename eT>
4394 template<
typename eT>
4408 template<
typename eT>
4420 for(i=0, j=1; j<N; i+=2, j+=2)
4439 template<
typename eT>
4448 return (*this).randu();
4453 template<
typename eT>
4462 return (*this).randu();
4467 template<
typename eT>
4477 for(
uword i=0; i<N; ++i)
4487 template<
typename eT>
4496 return (*this).randn();
4501 template<
typename eT>
4510 return (*this).randn();
4515 template<
typename eT>
4526 for(
uword i=0; i<N; ++i)
4536 template<
typename eT>
4545 return (*this).eye();
4550 template<
typename eT>
4575 template<
typename eT>
4576 template<
typename T1>
4588 template<
typename eT>
4589 template<
typename T1>
4601 template<
typename eT>
4616 template<
typename eT>
4631 template<
typename eT>
4645 template<
typename eT>
4659 template<
typename eT>
4672 row_of_min_val = i %
n_rows;
4673 col_of_min_val = i /
n_rows;
4680 template<
typename eT>
4693 row_of_max_val = i %
n_rows;
4694 col_of_max_val = i /
n_rows;
4702 template<
typename eT>
4738 arma_warn(print_status,
"Mat::save(): unsupported file type");
4742 arma_warn( (print_status && (save_okay ==
false)),
"Mat::save(): couldn't write to ", name);
4750 template<
typename eT>
4786 arma_warn(print_status,
"Mat::save(): unsupported file type");
4790 arma_warn( (print_status && (save_okay ==
false)),
"Mat::save(): couldn't write to the given stream");
4798 template<
typename eT>
4806 std::string err_msg;
4839 arma_warn(print_status,
"Mat::load(): unsupported file type");
4843 if( (print_status ==
true) && (load_okay ==
false) )
4845 if(err_msg.length() > 0)
4847 arma_warn(
true,
"Mat::load(): ", err_msg, name);
4851 arma_warn(
true,
"Mat::load(): couldn't read ", name);
4855 if(load_okay ==
false)
4866 template<
typename eT>
4874 std::string err_msg;
4907 arma_warn(print_status,
"Mat::load(): unsupported file type");
4912 if( (print_status ==
true) && (load_okay ==
false) )
4914 if(err_msg.length() > 0)
4916 arma_warn(
true,
"Mat::load(): ", err_msg,
"the given stream");
4920 arma_warn(
true,
"Mat::load(): couldn't load from the given stream");
4924 if(load_okay ==
false)
4935 template<
typename eT>
4942 return (*this).save(name, type,
false);
4948 template<
typename eT>
4955 return (*this).save(os, type,
false);
4961 template<
typename eT>
4968 return (*this).load(name, type,
false);
4974 template<
typename eT>
4981 return (*this).load(is, type,
false);
4986 template<
typename eT>
4998 template<
typename eT>
5008 template<
typename eT>
5026 template<
typename eT>
5036 template<
typename eT>
5059 template<
typename eT>
5069 template<
typename eT>
5074 return ( (
row != X.
row) || (
col != X.
col) ) ?
true :
false;
5079 template<
typename eT>
5084 return ( (
row == X.
row) && (
col == X.
col) ) ?
true :
false;
5089 template<
typename eT>
5101 template<
typename eT>
5113 template<
typename eT>
5123 template<
typename eT>
5141 template<
typename eT>
5151 template<
typename eT>
5174 template<
typename eT>
5184 template<
typename eT>
5189 return ( (
row != X.
row) || (
col != X.
col) ) ?
true :
false;
5194 template<
typename eT>
5199 return ( (
row == X.
row) && (
col == X.
col) ) ?
true :
false;
5204 template<
typename eT>
5216 template<
typename eT>
5228 template<
typename eT>
5240 template<
typename eT>
5252 template<
typename eT>
5266 template<
typename eT>
5280 template<
typename eT>
5294 template<
typename eT>
5308 template<
typename eT>
5322 template<
typename eT>
5336 template<
typename eT>
5350 template<
typename eT>
5365 template<
typename eT>
5376 template<
typename eT>
5387 template<
typename eT>
5397 template<
typename eT>
5398 template<uword fixed_n_rows, uword fixed_n_cols>
5415 template<
typename eT>
5416 template<uword fixed_n_rows, uword fixed_n_cols>
5427 template<
typename eT>
5428 template<uword fixed_n_rows, uword fixed_n_cols>
5436 eT* dest = (use_extra) ? mem_local_extra :
mem_local;
5443 template<
typename eT>
5444 template<uword fixed_n_rows, uword fixed_n_cols>
5445 template<
typename T1>
5458 template<
typename eT>
5459 template<uword fixed_n_rows, uword fixed_n_cols>
5460 template<
typename T1,
typename T2>
5473 template<
typename eT>
5474 template<uword fixed_n_rows, uword fixed_n_cols>
5486 if(copy_aux_mem ==
true)
5488 eT* dest = (use_extra) ? mem_local_extra :
mem_local;
5502 template<
typename eT>
5503 template<uword fixed_n_rows, uword fixed_n_cols>
5516 template<
typename eT>
5517 template<uword fixed_n_rows, uword fixed_n_cols>
5530 template<
typename eT>
5531 template<uword fixed_n_rows, uword fixed_n_cols>
5544 template<
typename eT>
5545 template<uword fixed_n_rows, uword fixed_n_cols>
5546 template<
typename T1>
5558 template<
typename eT>
5559 template<uword fixed_n_rows, uword fixed_n_cols>
5573 template<
typename eT>
5574 template<uword fixed_n_rows, uword fixed_n_cols>
5588 template<
typename eT>
5589 template<uword fixed_n_rows, uword fixed_n_cols>
5603 template<
typename eT>
5604 template<uword fixed_n_rows, uword fixed_n_cols>
5616 template<
typename eT>
5617 template<uword fixed_n_rows, uword fixed_n_cols>
5629 template<
typename eT>
5630 template<uword fixed_n_rows, uword fixed_n_cols>
5642 template<
typename eT>
5643 template<uword fixed_n_rows, uword fixed_n_cols>
5655 template<
typename eT>
5656 template<uword fixed_n_rows, uword fixed_n_cols>
5668 template<
typename eT>
5669 template<uword fixed_n_rows, uword fixed_n_cols>
5681 template<
typename eT>
5682 template<uword fixed_n_rows, uword fixed_n_cols>
5693 template<
typename eT>
5694 template<uword fixed_n_rows, uword fixed_n_cols>
5705 template<
typename eT>
5706 template<uword fixed_n_rows, uword fixed_n_cols>
5717 template<
typename eT>
5718 template<uword fixed_n_rows, uword fixed_n_cols>
5729 template<
typename eT>
5730 template<uword fixed_n_rows, uword fixed_n_cols>
5736 arma_debug_check( (i >= fixed_n_elem),
"Mat::fixed::operator(): out of bounds");
5743 template<
typename eT>
5744 template<uword fixed_n_rows, uword fixed_n_cols>
5750 arma_debug_check( (i >= fixed_n_elem),
"Mat::fixed::operator(): out of bounds");
5757 template<
typename eT>
5758 template<uword fixed_n_rows, uword fixed_n_cols>
5764 const uword i = in_row + in_col*fixed_n_rows;
5771 template<
typename eT>
5772 template<uword fixed_n_rows, uword fixed_n_cols>
5778 const uword i = in_row + in_col*fixed_n_rows;
5785 template<
typename eT>
5786 template<uword fixed_n_rows, uword fixed_n_cols>
5792 arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)),
"Mat::fixed::operator(): out of bounds");
5794 const uword i = in_row + in_col*fixed_n_rows;
5801 template<
typename eT>
5802 template<uword fixed_n_rows, uword fixed_n_cols>
5808 arma_debug_check( ((in_row >= fixed_n_rows) || (in_col >= fixed_n_cols)),
"Mat::fixed::operator(): out of bounds");
5810 const uword i = in_row + in_col*fixed_n_rows;
5817 template<
typename eT>
5818 template<uword fixed_n_rows, uword fixed_n_cols>
5833 template<
typename eT>
5834 template<uword fixed_n_rows, uword fixed_n_cols>
5849 template<
typename eT>
5850 template<uword fixed_n_rows, uword fixed_n_cols>
5866 template<
typename eT>
5876 for(i=0, j=1; j<
n_elem; i+=2, j+=2)
5891 template<
typename T>
5902 template<
typename eT>
5912 for(i=0, j=1; j<
n_elem; i+=2, j+=2)
5927 template<
typename T>
5938 template<
typename eT>
5948 for(i=0, j=1; j<
n_elem; i+=2, j+=2)
5963 template<
typename T>
5974 template<
typename eT>
5984 for(i=0, j=1; j<
n_elem; i+=2, j+=2)
5999 template<
typename T>
6009 template<
typename eT,
typename T1>
6026 template<
typename eT,
typename T1>
6036 template<
typename T,
typename T1>
6043 typedef typename std::complex<T> eT;
6051 eT* out_mem = out.memptr();
6052 ea_type PA = A.get_ea();
6057 out_mem[i] = std::complex<T>( PA[i], out_mem[i].imag() );
6063 template<
typename T,
typename T1>
6070 typedef typename std::complex<T> eT;
6078 eT* out_mem = out.memptr();
6079 ea_type PA = A.get_ea();
6084 out_mem[i] = std::complex<T>( out_mem[i].real(), PA[i] );
6090 #ifdef ARMA_EXTRA_MAT_MEAT 6091 #include ARMA_INCFILE_WRAP(ARMA_EXTRA_MAT_MEAT) bool quiet_save(const std::string name, const file_type type=arma_binary) const
save the matrix to a file, without printing any error messages
static void extract(Mat< eT > &out, const subview &in)
X = Y.submat(...)
static bool save_raw_binary(const Mat< eT > &x, const std::string &final_name)
Save a matrix as raw binary (no header)
get_pod_type< eT >::result pod_type
if eT is non-complex, pod_type is same as eT. otherwise, pod_type is the underlying type used by std:...
arma_inline arma_warn_unused bool is_vec() const
returns true if the object can be interpreted as a column or row vector
arma_inline arma_warn_unused eT * memptr()
returns a pointer to array of eTs used by the matrix
row_iterator(Mat< eT > &in_M, const uword in_row)
row_iterator & operator--()
arma_inline uword get_n_cols() const
static bool save_pgm_binary(const Mat< eT > &x, const std::string &final_name)
Save a matrix as a PGM greyscale image.
#define arma_debug_assert_cube_as_mat
void set_size(const uword in_elem)
change the matrix to have user specified dimensions (data is not preserved)
arma_warn_unused bool is_finite() const
returns true if all of the elements are finite
arma_aligned const Proxy< T2 > P2
arma_aligned const Mat< eT > & m
static void minus_inplace(Cube< eT > &out, const subview_cube &in)
cube X -= Y.subcube(...)
static void plus_inplace(Mat< eT > &out, const diagview &in)
X += Y.diag()
static bool load_arma_binary(Mat< eT > &x, const std::string &name, std::string &err_msg)
static const uword mat_prealloc
arma_hot static arma_inline void copy(eT *dest, const eT *src, const uword n_elem)
static void div_inplace(Mat< eT > &out, const subview &in)
X /= Y.submat(...)
static void minus_inplace(Mat< eT > &out, const diagview &in)
X -= Y.diag()
arma_inline const derived & get_ref() const
static arma_hot void inplace_minus(eT *dest, const eT *src, const uword n_elem)
void apply_inplace_minus(Mat< eT > &out) const
void shed_rows(const uword in_row1, const uword in_row2)
remove specified rows
arma_inline subview< eT > submat(const uword in_row1, const uword in_col1, const uword in_row2, const uword in_col2)
creation of subview (submatrix)
arma_inline uword get_n_rows() const
void arma_hot arma_check_bad_alloc(const bool state, const T1 &x)
static bool load_pgm_binary(Mat< eT > &x, const std::string &name, std::string &err_msg)
Load a PGM greyscale image as a matrix.
arma_inline const Mat & operator--()
prefix –
void impl_raw_print_trans(const std::string &extra_text) const
DEPRECATED FUNCTION.
arma_aligned const Proxy< T1 > P
bool operator!=(const const_row_iterator &X) const
void apply(Mat< eT > &out) const
static bool save_csv_ascii(const Mat< eT > &x, const std::string &final_name)
Save a matrix in CSV text format (human readable)
static arma_hot void inplace_mul(eT *dest, const eT *src, const uword n_elem)
uword size() const
returns the number of elements in this matrix
#define arma_debug_set_error
static void apply_inplace(Mat< typename T1::elem_type > &out, const T1 &X)
arma_inline arma_warn_unused bool is_colvec() const
returns true if the object can be interpreted as a column vector
void init_warm(uword in_rows, uword in_cols)
internal matrix construction; if the requested size is small enough, memory from the stack is used...
static arma_inline void postfix_pp(Mat< eT > &x)
postfix ++
arma_aligned const uword n_cols
static const uword n_cols
bool operator==(const const_row_iterator &X) const
const uword n_cols
number of columns in the matrix (read-only)
static eT direct_min(const eT *const X, const uword N)
support class for generator functions (eg. zeros, randu, randn, ...)
static void minus_inplace(Mat< eT > &out, const subview &in)
X -= Y.submat(...)
#define arma_debug_assert_same_size
arma_inline subview_col< eT > col(const uword col_num)
creation of subview (column vector)
void set_real(const Base< pod_type, T1 > &X)
arma_aligned const Mat< eT > & M
arma_inline subview_row< eT > row(const uword row_num)
creation of subview (row vector)
arma_inline const Mat & operator+=(const eT val)
In-place addition of a scalar to all elements of the matrix.
const uword n_elem
number of elements in the matrix (read-only)
arma_aligned Mat< eT > & M
arma_inline const Op< T1, op_max > max(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Delayed 'maximum values' operation. The dimension, along which the maxima are found, is set via 'dim'. For dim = 0, the maximum value of each column is found (i.e. searches by traversing across rows). For dim = 1, the maximum value of each row is found (i.e. searches by traversing across columns). The default is dim = 0.
const uword n_rows
number of rows in the matrix (read-only)
static void extract(Cube< eT > &out, const subview_cube &in)
cube X = Y.subcube(...)
arma_inline subview< eT > rows(const uword in_row1, const uword in_row2)
creation of subview (submatrix comprised of specified row vectors)
void arma_hot arma_assert_same_size(const uword A_n_rows, const uword A_n_cols, const uword B_n_rows, const uword B_n_cols, const char *x)
#define arma_extra_debug_print
bool empty() const
returns true if the matrix has no elements
static void set_imag(Mat< eT > &out, const Base< eT, T1 > &X)
static void minus_inplace(Mat< eT > &out, const subview_elem1 &in)
void reshape(const uword in_rows, const uword in_cols, const uword dim=0)
change the matrix to have user specified dimensions (data is preserved)
arma_inline const Op< T1, op_min > min(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Delayed 'minimum values' operation. The dimension, along which the minima are found, is set via 'dim'. For dim = 0, the minimum value of each column is found (i.e. searches by traversing across rows). For dim = 1, the minimum value of each row is found (i.e. searches by traversing across columns). The default is dim = 0.
void insert_cols(const uword col_num, const uword N, const bool set_to_zero=true)
static arma_inline void postfix_mm(Mat< eT > &x)
postfix –
arma_inline uword get_n_cols() const
static void set_real(Mat< eT > &out, const Base< eT, T1 > &X)
comma separated values (CSV), without any other information
arma_inline arma_warn_unused eT * colptr(const uword in_col)
returns a pointer to array of eTs for a specified column; no bounds check
void insert_rows(const uword row_num, const uword N, const bool set_to_zero=true)
row_iterator & operator++()
static arma_hot void inplace_plus(eT *dest, const eT *src, const uword n_elem)
#define arma_type_check(condition)
Class for column vectors (matrices with only one column)
arma_warn_unused eT min() const
static void plus_inplace(Cube< eT > &out, const subview_cube &in)
cube X += Y.subcube(...)
void init(const std::string &text)
internal function to create the matrix from a textual description
const Op< T1, op_reshape > reshape(const Base< typename T1::elem_type, T1 > &X, const uword in_n_rows, const uword in_n_cols, const uword dim=0)
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
void resize(const uword in_elem)
change the matrix to have user specified dimensions (data is preserved)
static void plus_inplace(Mat< eT > &out, const subview &in)
X += Y.submat(...)
void set_imag(const Base< pod_type, T1 > &X)
static arma_hot void inplace_div(eT *dest, const eT *src, const uword n_elem)
static bool load_raw_binary(Mat< eT > &x, const std::string &name, std::string &err_msg)
arma_aligned const uword n_rows
arma_inline arma_warn_unused bool is_rowvec() const
returns true if the object can be interpreted as a row vector
bool operator!=(const row_iterator &X) const
static void schur_inplace(Mat< eT > &out, const subview_elem1 &in)
void impl_print(const std::string &extra_text) const
col_iterator begin_col(const uword col_num)
static arma_hot void inplace_set(eT *dest, const eT val, const uword n_elem)
mat_injector< Mat > operator<<(const eT val)
arma_inline arma_warn_unused eT & at(const uword i)
linear element accessor (treats the matrix as a vector); no bounds check.
arma_inline arma_warn_unused bool is_square() const
returns true if the object has the same number of non-zero rows and columnns
subview_row< eT > operator()(const uword row_num, const span &col_span)
col_iterator end_col(const uword col_num)
#define arma_ignore(variable)
#define arma_extra_debug_sigprint_this
arma_inline const Mat & operator/=(const eT val)
In-place division of all elements of the matrix with a scalar.
arma_inline arma_warn_unused eT & operator[](const uword i)
linear element accessor (treats the matrix as a vector); no bounds check.
arma_aligned const Mat< eT > & m
const Mat & operator=(const char *text)
create the matrix from a textual description
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.
static bool save_raw_ascii(const Mat< eT > &x, const std::string &final_name)
arma_inline arma_warn_unused bool in_range(const uword i) const
returns true if the given index is currently in range
static void schur_inplace(Mat< eT > &out, const subview &in)
X %= Y.submat(...)
arma_inline diagview< eT > diag(const sword in_id=0)
creation of diagview (diagonal)
static arma_inline void prefix_mm(Mat< eT > &x)
prefix –
void copy_size(const Mat< eT2 > &m)
change the matrix (without preserving data) to have the same dimensions as the given matrix ...
static bool load_raw_ascii(Mat< eT > &x, const std::string &name, std::string &err_msg)
static void div_inplace(Mat< eT > &out, const subview_elem1 &in)
static void extract(Mat< eT > &out, const subview_elem1 &in)
void swap_cols(const uword in_col1, const uword in_col2)
static void schur_inplace(Cube< eT > &out, const subview_cube &in)
cube X %= Y.subcube(...)
arma_aligned const Proxy< T1 > P1
bool operator==(const row_iterator &X) const
#define arma_extra_debug_sigprint
void shed_col(const uword col_num)
remove specified column
const eT * const_iterator
void apply_inplace_div(Mat< eT > &out) const
bool load(const std::string name, const file_type type=auto_detect, const bool print_status=true)
load a matrix from a file
row_iterator end_row(const uword row_num)
Analog of the Base class, intended for cubes.
arma_inline uword get_n_rows() const
arma_inline const Mat & operator++()
prefix ++
bool quiet_load(const std::string name, const file_type type=auto_detect)
load a matrix from a file, without printing any error messages
static arma_hot void apply_inplace_plus(Mat< typename T1::elem_type > &out, const Glue< T1, T2, glue_times > &X, const sword sign)
ASCII format (text), without any other information.
static eT direct_max(const eT *const X, const uword N)
raw binary format, without any other information.
Col< eT > unsafe_col(const uword col_num)
row_iterator begin_row(const uword row_num)
void arma_cold arma_warn(const bool state, const T1 &x)
print a message to the warn stream
static bool load_arma_ascii(Mat< eT > &x, const std::string &name, std::string &err_msg)
static bool save_arma_ascii(const Mat< eT > &x, const std::string &final_name)
void shed_row(const uword row_num)
remove specified row
static void schur_inplace(Mat< eT > &out, const diagview &in)
X %= Y.diag()
arma_inline subview_elem1< eT, T1 > elem(const Base< uword, T1 > &a)
arma_inline const Mat & operator*=(const eT val)
In-place multiplication of all elements of the matrix with a scalar.
static void div_inplace(Mat< eT > &out, const diagview &in)
X /= Y.diag()
Portable Grey Map (greyscale image)
void shed_cols(const uword in_col1, const uword in_col2)
remove specified columns
arma_inline const derived & get_ref() const
static arma_inline void prefix_pp(Mat< eT > &x)
prefix ++
static void plus_inplace(Mat< eT > &out, const subview_elem1 &in)
arma_aligned eT mem_local[arma_config::mat_prealloc]
arma_inline subview< eT > cols(const uword in_col1, const uword in_col2)
creation of subview (submatrix comprised of specified column vectors)
static bool load_csv_ascii(Mat< eT > &x, const std::string &name, std::string &err_msg)
Load a matrix in CSV text format (human readable)
const eT * const_col_iterator
arma_aligned const eT *const mem
pointer to the memory used by the matrix (memory is read-only)
const Mat & operator%=(const Mat &m)
in-place element-wise matrix multiplication
void apply_inplace_schur(Mat< eT > &out) const
arma_hot static arma_pure bool is_finite(const eT *src, const uword n_elem)
static void extract(Mat< eT > &out, const diagview &in)
extract a diagonal and store it as a column vector
static void div_inplace(Cube< eT > &out, const subview_cube &in)
cube X /= Y.subcube(...)
Class for storing data required to extract and set the diagonals of a matrix.
const uhword vec_state
0: matrix layout; 1: column vector layout; 2: row vector layout
bool save(const std::string name, const file_type type=arma_binary, const bool print_status=true) const
save the matrix to a file
void clear()
resets this matrix to an empty matrix
void impl_raw_print(const std::string &extra_text) const
const_row_iterator & operator++()
Armadillo ASCII format (text), with information about matrix type and size.
void impl_print_trans(const std::string &extra_text) const
DEPRECATED FUNCTION.
static void apply_noalias(Mat< eT > &out, const Mat< eT > &A)
Immediate transpose of a dense matrix.
const_row_iterator & operator--()
void apply_inplace_plus(Mat< eT > &out) const
arma_hot const Mat & fill(const eT val)
fill the matrix with the specified value
arma_inline const Mat & operator-=(const eT val)
In-place subtraction of a scalar from all elements of the matrix.
const_row_iterator(const Mat< eT > &in_M, const uword in_row)
void swap_rows(const uword in_row1, const uword in_row2)
Automatically detect the file type (file must be one of the following types)
void arma_hot arma_check(const bool state, const T1 &x)
if state is true, abort program
arma_inline arma_warn_unused bool is_empty() const
returns true if the matrix has no elements
static bool save_arma_binary(const Mat< eT > &x, const std::string &final_name)
arma_warn_unused eT max() const
const Op< T1, op_resize > resize(const Base< typename T1::elem_type, T1 > &X, const uword in_n_rows, const uword in_n_cols)