35 #include <itpp/itexports.h>
41 template<
class Num_T>
class Vec;
43 template<
class Num_T>
class Mat;
56 Mat<Num_T>
operator+(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2);
59 Mat<Num_T>
operator+(
const Mat<Num_T> &m, Num_T t);
62 Mat<Num_T>
operator+(Num_T t,
const Mat<Num_T> &m);
66 Mat<Num_T>
operator-(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2);
69 Mat<Num_T>
operator-(
const Mat<Num_T> &m, Num_T t);
72 Mat<Num_T>
operator-(Num_T t,
const Mat<Num_T> &m);
75 Mat<Num_T>
operator-(
const Mat<Num_T> &m);
79 Mat<Num_T>
operator*(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2);
82 Vec<Num_T>
operator*(
const Mat<Num_T> &m,
const Vec<Num_T> &v);
85 Mat<Num_T>
operator*(
const Mat<Num_T> &m, Num_T t);
88 Mat<Num_T>
operator*(Num_T t,
const Mat<Num_T> &m);
92 Mat<Num_T>
elem_mult(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2);
95 void elem_mult_out(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2,
99 void elem_mult_out(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2,
100 const Mat<Num_T> &m3, Mat<Num_T> &out);
102 template<
class Num_T>
103 void elem_mult_out(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2,
104 const Mat<Num_T> &m3,
const Mat<Num_T> &m4,
107 template<
class Num_T>
110 template<
class Num_T>
111 Num_T
elem_mult_sum(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2);
114 template<
class Num_T>
115 Mat<Num_T>
operator/(
const Mat<Num_T> &m, Num_T t);
117 template<
class Num_T>
118 Mat<Num_T>
operator/(Num_T t,
const Mat<Num_T> &m);
121 template<
class Num_T>
122 Mat<Num_T>
elem_div(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2);
124 template<
class Num_T>
125 void elem_div_out(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2,
128 template<
class Num_T>
129 Num_T
elem_div_sum(
const Mat<Num_T> &m1,
const Mat<Num_T> &m2);
200 template<
class Num_T>
228 Mat(
const Num_T *c_array,
int rows,
int cols,
bool row_major =
true,
249 void set(
const std::string &str);
251 void set(
const char *str);
262 const Num_T &
get(
int r,
int c)
const;
264 const Num_T &
get(
int i)
const;
266 void set(
int r,
int c, Num_T t);
279 Mat<Num_T> get(
int r1,
int r2,
int c1,
int c2)
const;
463 bool in_range(
int r,
int c)
const {
467 bool row_in_range(
int r)
const {
return ((r >= 0) && (r <
no_rows)); }
469 bool col_in_range(
int c)
const {
return ((c >= 0) && (c <
no_cols)); }
471 bool in_range(
int i)
const {
return ((i >= 0) && (i <
datasize)); }
482 typedef Mat<double> mat;
488 typedef Mat<std::complex<double> > cmat;
494 typedef Mat<int> imat;
500 typedef Mat<short int> smat;
526 template <
class Num_T>
527 std::ostream &operator<<(std::ostream &os, const Mat<Num_T> &m);
540 template <
class Num_T>
541 std::istream &
operator>>(std::istream &is, Mat<Num_T> &m);
547 template<
class Num_T>
inline
550 if ((rows > 0) && (cols > 0)) {
551 datasize = rows * cols;
564 template<
class Num_T>
inline
574 template<
class Num_T>
inline
576 datasize(0), no_rows(0), no_cols(0), data(0), factory(f) {}
578 template<
class Num_T>
inline
580 datasize(0), no_rows(0), no_cols(0), data(0), factory(f)
582 it_assert_debug((rows >= 0) && (cols >= 0),
"Mat<>::Mat(): Wrong size");
586 template<
class Num_T>
inline
588 datasize(0), no_rows(0), no_cols(0), data(0), factory(m.factory)
594 template<
class Num_T>
inline
596 datasize(0), no_rows(0), no_cols(0), data(0), factory(f)
602 template<
class Num_T>
inline
604 datasize(0), no_rows(0), no_cols(0), data(0), factory(f)
611 template<
class Num_T>
inline
613 datasize(0), no_rows(0), no_cols(0), data(0), factory(f)
618 template<
class Num_T>
inline
620 datasize(0), no_rows(0), no_cols(0), data(0), factory(f)
622 set(std::string(str));
625 template<
class Num_T>
628 datasize(0), no_rows(0), no_cols(0), data(0), factory(f)
634 for (
int i = 0; i <
rows; i++)
635 for (
int j = 0; j <
cols; j++)
639 template<
class Num_T>
inline
646 template<
class Num_T>
650 "Mat<>::set_size(): Wrong size");
652 if ((no_rows == rows) && (no_cols == cols))
655 if ((rows == 0) || (cols == 0)) {
664 int old_datasize = datasize;
665 int old_rows = no_rows;
667 int min_r = (no_rows < rows) ? no_rows : rows;
668 int min_c = (no_cols < cols) ? no_cols : cols;
672 for (
int i = 0; i < min_c; ++i) {
673 copy_vector(min_r, &tmp[i*old_rows], &data[i*no_rows]);
676 for (
int i = min_r; i < rows; ++i)
677 for (
int j = 0; j < cols; ++j)
678 data[i+j*rows] = Num_T(0);
679 for (
int j = min_c; j < cols; ++j)
680 for (
int i = 0; i < min_r; ++i)
681 data[i+j*rows] = Num_T(0);
686 else if (datasize == rows * cols) {
697 template<
class Num_T>
inline
700 for (
int i = 0; i < datasize; i++)
704 template<
class Num_T>
inline
707 for (
int i = 0; i < datasize; i++)
711 template<
class Num_T>
inline
715 "Mat<>::operator(): Indexing out of range");
716 return data[r+c*no_rows];
719 template<
class Num_T>
inline
723 "Mat<>::operator(): Indexing out of range");
724 return data[r+c*no_rows];
727 template<
class Num_T>
inline
734 template<
class Num_T>
inline
741 template<
class Num_T>
inline
744 return (*
this)(r, c);
747 template<
class Num_T>
inline
753 template<
class Num_T>
inline
756 it_assert_debug(in_range(r, c),
"Mat<>::set(): Indexing out of range");
757 data[r+c*no_rows] = t;
761 template<
class Num_T>
773 std::string::size_type beg = 0;
774 std::string::size_type end = 0;
775 while (end != std::string::npos) {
777 end = str.find(
';', beg);
780 int v_size = v.
size();
784 if ((end != std::string::npos) || (v_size > 0)) {
787 set_size(maxrows, v_size,
true);
792 if ((rows == maxrows) || (v_size != no_cols)) {
794 if (rows == maxrows) {
798 if (v_size > no_cols) {
799 set_size(maxrows, v_size,
true);
802 set_size(maxrows, no_cols,
true);
804 v.set_size(no_cols,
true);
816 set_size(rows, no_cols,
true);
819 template<
class Num_T>
inline
822 set(std::string(str));
825 template<
class Num_T>
inline
828 if (r1 == -1) r1 = no_rows - 1;
829 if (r2 == -1) r2 = no_rows - 1;
830 if (c1 == -1) c1 = no_cols - 1;
831 if (c2 == -1) c2 = no_cols - 1;
834 (c1 >= 0) && (c1 <= c2) && (c2 < no_cols),
835 "Mat<>::operator()(r1, r2, c1, c2): Wrong indexing");
839 for (
int i = 0;i < s.
no_cols;i++)
845 template<
class Num_T>
inline
848 return (*
this)(r1, r2, c1, c2);
851 template<
class Num_T>
inline
854 it_assert_debug(row_in_range(r),
"Mat<>::get_row(): Index out of range");
857 copy_vector(no_cols, data + r, no_rows, a.
_data(), 1);
861 template<
class Num_T>
865 "Mat<>::get_rows(): Wrong indexing");
868 for (
int i = 0; i < m.
rows(); i++)
869 copy_vector(no_cols, data + i + r1, no_rows, m.
data + i, m.
no_rows);
874 template<
class Num_T>
879 for (
int i = 0;i < indexlist.
size();i++) {
881 "Mat<>::get_rows(indexlist): Indexing out of range");
882 copy_vector(no_cols, data + indexlist(i), no_rows, m.data + i, m.no_rows);
888 template<
class Num_T>
inline
891 it_assert_debug(col_in_range(c),
"Mat<>::get_col(): Index out of range");
894 copy_vector(no_rows, data + c*no_rows, a.
_data());
899 template<
class Num_T>
903 "Mat<>::get_cols(): Wrong indexing");
906 for (
int i = 0; i < m.
cols(); i++)
907 copy_vector(no_rows, data + (i + c1)*no_rows, m.
data + i*m.
no_rows);
912 template<
class Num_T>
917 for (
int i = 0; i < indexlist.
size(); i++) {
919 "Mat<>::get_cols(indexlist): Indexing out of range");
920 copy_vector(no_rows, data + indexlist(i)*no_rows, m.data + i*m.no_rows);
926 template<
class Num_T>
inline
929 it_assert_debug(row_in_range(r),
"Mat<>::set_row(): Index out of range");
931 "Mat<>::set_row(): Wrong size of input vector");
932 copy_vector(v.
size(), v.
_data(), 1, data + r, no_rows);
935 template<
class Num_T>
inline
938 it_assert_debug(col_in_range(c),
"Mat<>::set_col(): Index out of range");
940 "Mat<>::set_col(): Wrong size of input vector");
941 copy_vector(v.
size(), v.
_data(), data + c*no_rows);
945 template<
class Num_T>
948 it_assert_debug(row_in_range(r),
"Mat<>::set_rows(): Index out of range");
950 "Mat<>::set_rows(): Column sizes do not match");
952 "Mat<>::set_rows(): Not enough rows");
954 for (
int i = 0; i < m.
rows(); ++i) {
955 copy_vector(no_cols, m.
data + i, m.
no_rows, data + i + r, no_rows);
959 template<
class Num_T>
962 it_assert_debug(col_in_range(c),
"Mat<>::set_cols(): Index out of range");
964 "Mat<>::set_cols(): Row sizes do not match");
966 "Mat<>::set_cols(): Not enough colums");
968 for (
int i = 0; i < m.
cols(); ++i) {
969 copy_vector(no_rows, m.
data + i*no_rows, data + (i + c)*no_rows);
974 template<
class Num_T>
inline
978 "Mat<>::copy_row(): Indexing out of range");
982 copy_vector(no_cols, data + from, no_rows, data + to, no_rows);
985 template<
class Num_T>
inline
989 "Mat<>::copy_col(): Indexing out of range");
993 copy_vector(no_rows, data + from*no_rows, data + to*no_rows);
996 template<
class Num_T>
inline
1000 "Mat<>::swap_rows(): Indexing out of range");
1004 swap_vector(no_cols, data + r1, no_rows, data + r2, no_rows);
1007 template<
class Num_T>
inline
1011 "Mat<>::swap_cols(): Indexing out of range");
1015 swap_vector(no_rows, data + c1*no_rows, data + c2*no_rows);
1018 template<
class Num_T>
1021 it_warning(
"Mat<>::set_submatrix(r1, r2, r3, r4, m): This function is "
1022 "deprecated and might be removed from future IT++ releases. "
1023 "Please use Mat<>::set_submatrix(r, c, m) function instead.");
1024 set_submatrix(r1, c1, m);
1027 template<
class Num_T>
inline
1031 (c >= 0) && (c + m.
no_cols <= no_cols),
1032 "Mat<>::set_submatrix(): Indexing out of range "
1033 "or wrong input matrix");
1034 for (
int i = 0; i < m.
no_cols; i++)
1040 template<
class Num_T>
inline
1043 if (r1 == -1) r1 = no_rows - 1;
1044 if (r2 == -1) r2 = no_rows - 1;
1045 if (c1 == -1) c1 = no_cols - 1;
1046 if (c2 == -1) c2 = no_cols - 1;
1048 (c1 >= 0) && (c1 <= c2) && (c2 < no_cols),
1049 "Mat<>::set_submatrix(): Wrong indexing");
1050 for (
int i = c1; i <= c2; i++) {
1051 int pos = i * no_rows + r1;
1052 for (
int j = r1; j <= r2; j++)
1057 template<
class Num_T>
1060 it_assert_debug(row_in_range(r),
"Mat<>::del_row(): Index out of range");
1062 set_size(no_rows - 1, no_cols,
false);
1063 for (
int i = 0 ; i < r ; i++) {
1064 copy_vector(no_cols, &Temp.
data[i], no_rows + 1, &data[i], no_rows);
1066 for (
int i = r ; i < no_rows ; i++) {
1067 copy_vector(no_cols, &Temp.
data[i+1], no_rows + 1, &data[i], no_rows);
1072 template<
class Num_T>
1076 "Mat<>::del_rows(): Indexing out of range");
1078 int no_del_rows = r2 - r1 + 1;
1079 set_size(no_rows - no_del_rows, no_cols,
false);
1080 for (
int i = 0; i < r1 ; ++i) {
1081 copy_vector(no_cols, &Temp.
data[i], Temp.
no_rows, &data[i], no_rows);
1083 for (
int i = r2 + 1; i < Temp.
no_rows; ++i) {
1084 copy_vector(no_cols, &Temp.
data[i], Temp.
no_rows, &data[i-no_del_rows],
1089 template<
class Num_T>
1092 it_assert_debug(col_in_range(c),
"Mat<>::del_col(): Index out of range");
1095 set_size(no_rows, no_cols - 1,
false);
1096 copy_vector(c*no_rows, Temp.
data, data);
1097 copy_vector((no_cols - c)*no_rows, &Temp.
data[(c+1)*no_rows], &data[c*no_rows]);
1100 template<
class Num_T>
1104 "Mat<>::del_cols(): Indexing out of range");
1106 int n_deleted_cols = c2 - c1 + 1;
1107 set_size(no_rows, no_cols - n_deleted_cols,
false);
1108 copy_vector(c1*no_rows, Temp.
data, data);
1109 copy_vector((no_cols - c1)*no_rows, &Temp.
data[(c2+1)*no_rows], &data[c1*no_rows]);
1112 template<
class Num_T>
1116 "Mat<>::ins_row(): Index out of range");
1118 "Mat<>::ins_row(): Wrong size of the input vector");
1125 set_size(no_rows + 1, no_cols,
false);
1127 for (
int i = 0 ; i < r ; i++) {
1128 copy_vector(no_cols, &Temp.
data[i], no_rows - 1, &data[i], no_rows);
1130 copy_vector(no_cols, v.
_data(), 1, &data[r], no_rows);
1131 for (
int i = r + 1 ; i < no_rows ; i++) {
1132 copy_vector(no_cols, &Temp.
data[i-1], no_rows - 1, &data[i], no_rows);
1136 template<
class Num_T>
1140 "Mat<>::ins_col(): Index out of range");
1142 "Mat<>::ins_col(): Wrong size of the input vector");
1149 set_size(no_rows, no_cols + 1,
false);
1151 copy_vector(c*no_rows, Temp.
data, data);
1152 copy_vector(no_rows, v.
_data(), &data[c*no_rows]);
1153 copy_vector((no_cols - c - 1)*no_rows, &Temp.
data[c*no_rows], &data[(c+1)*no_rows]);
1156 template<
class Num_T>
inline
1159 ins_row(no_rows, v);
1162 template<
class Num_T>
inline
1165 ins_col(no_cols, v);
1168 template<
class Num_T>
1172 for (
int i = 0; i < no_rows; ++i) {
1173 copy_vector(no_cols, &data[i], no_rows, &temp.
data[i * no_cols], 1);
1178 template<
class Num_T>
1182 for (
int i = 0; i < no_rows; ++i) {
1183 copy_vector(no_cols, &data[i], no_rows, &temp.
data[i * no_cols], 1);
1193 template<
class Num_T>
1202 "Mat<>::concat_horizontal(): Wrong sizes");
1205 for (
int i = 0; i < m1.
no_cols; ++i) {
1206 copy_vector(no_rows, &m1.
data[i * no_rows], &temp.
data[i * no_rows]);
1208 for (
int i = 0; i < m2.
no_cols; ++i) {
1209 copy_vector(no_rows, &m2.
data[i * no_rows], &temp.
data[(m1.
no_cols + i)
1215 template<
class Num_T>
1224 "Mat<>::concat_vertical(): Wrong sizes");
1227 for (
int i = 0; i < no_cols; ++i) {
1236 template<
class Num_T>
inline
1239 for (
int i = 0; i < datasize; i++)
1244 template<
class Num_T>
inline
1255 template<
class Num_T>
inline
1259 || ((no_cols == 1) && (no_rows == v.
size())),
1260 "Mat<>::operator=(): Wrong size of the input vector");
1261 set_size(v.
size(), 1,
false);
1266 template<
class Num_T>
inline
1273 template<
class Num_T>
inline
1276 set(std::string(str));
1282 template<
class Num_T>
1288 int i, j, m_pos = 0, pos = 0;
1290 for (i = 0; i < no_cols; i++) {
1291 for (j = 0; j < no_rows; j++)
1292 data[pos+j] += m.
data[m_pos+j];
1300 template<
class Num_T>
inline
1303 for (
int i = 0; i < datasize; i++)
1308 template<
class Num_T>
1312 int i, j, m1_pos = 0, m2_pos = 0, r_pos = 0;
1315 "Mat<>::operator+(): Wrong sizes");
1317 for (i = 0; i < r.
no_cols; i++) {
1318 for (j = 0; j < r.
no_rows; j++)
1319 r.
data[r_pos+j] = m1.
data[m1_pos+j] + m2.
data[m2_pos+j];
1330 template<
class Num_T>
1335 for (
int i = 0; i < r.
datasize; i++)
1341 template<
class Num_T>
1346 for (
int i = 0; i < r.
datasize; i++)
1352 template<
class Num_T>
1355 int i, j, m_pos = 0, pos = 0;
1357 if (datasize == 0) {
1359 for (i = 0; i < no_cols; i++) {
1360 for (j = 0; j < no_rows; j++)
1361 data[pos+j] = -m.
data[m_pos+j];
1369 "Mat<>::operator-=(): Wrong sizes");
1370 for (i = 0; i < no_cols; i++) {
1371 for (j = 0; j < no_rows; j++)
1372 data[pos+j] -= m.
data[m_pos+j];
1381 template<
class Num_T>
1385 int i, j, m1_pos = 0, m2_pos = 0, r_pos = 0;
1387 "Mat<>::operator-(): Wrong sizes");
1389 for (i = 0; i < r.
no_cols; i++) {
1390 for (j = 0; j < r.
no_rows; j++)
1391 r.
data[r_pos+j] = m1.
data[m1_pos+j] - m2.
data[m2_pos+j];
1401 template<
class Num_T>
inline
1404 for (
int i = 0; i < datasize; i++)
1409 template<
class Num_T>
1413 int i, j, m_pos = 0, r_pos = 0;
1415 for (i = 0; i < r.
no_cols; i++) {
1416 for (j = 0; j < r.
no_rows; j++)
1417 r.
data[r_pos+j] = m.
data[m_pos+j] - t;
1426 template<
class Num_T>
1430 int i, j, m_pos = 0, r_pos = 0;
1432 for (i = 0; i < r.
no_cols; i++) {
1433 for (j = 0; j < r.
no_rows; j++)
1434 r.
data[r_pos+j] = t - m.
data[m_pos+j];
1443 template<
class Num_T>
1447 int i, j, m_pos = 0, r_pos = 0;
1449 for (i = 0; i < r.
no_cols; i++) {
1450 for (j = 0; j < r.
no_rows; j++)
1451 r.
data[r_pos+j] = -m.
data[m_pos+j];
1460 template<
class Num_T>
1468 int i, j, k, r_pos = 0, pos = 0, m_pos = 0;
1470 for (i = 0; i < r.
no_cols; i++) {
1471 for (j = 0; j < r.
no_rows; j++) {
1474 for (k = 0; k < no_cols; k++) {
1475 tmp += data[pos+j] * m.
data[m_pos+k];
1478 r.
data[r_pos+j] = tmp;
1488 template<> ITPP_EXPORT mat& mat::operator*=(
const mat &m);
1489 template<> ITPP_EXPORT cmat& cmat::operator*=(
const cmat &m);
1492 template<
class Num_T>
inline
1495 scal_vector(datasize, t, data);
1500 template<
class Num_T>
1504 "Mat<>::operator*(): Wrong sizes");
1509 Num_T *tr = r.
_data();
1510 const Num_T *t1;
const Num_T *t2 = m2.
_data();
1512 for (i = 0; i < r.cols(); i++) {
1513 for (j = 0; j < r.rows(); j++) {
1515 t1 = m1.
_data() + j;
1516 for (k = m1.
cols(); k > 0; k--) {
1517 tmp += *(t1) * *(t2++);
1530 template<> ITPP_EXPORT mat
operator*(
const mat &m1,
const mat &m2);
1531 template<> ITPP_EXPORT cmat
operator*(
const cmat &m1,
const cmat &m2);
1535 template<
class Num_T>
1539 "Mat<>::operator*(): Wrong sizes");
1543 for (i = 0; i < m.
rows(); i++) {
1546 for (k = 0; k < m.
cols(); k++) {
1547 r(i) += m.
_data()[m_pos+i] * v(k);
1556 template<> ITPP_EXPORT vec
operator*(
const mat &m,
const vec &v);
1557 template<> ITPP_EXPORT cvec
operator*(
const cmat &m,
const cvec &v);
1561 template<
class Num_T>
1566 const Num_T* m_data = m.
_data();
1567 Num_T* r_data = r._data();
1568 for (
int i = 0; i < r._datasize(); i++)
1569 r_data[i] = m_data[i] * t;
1575 template<
class Num_T>
inline
1581 template<
class Num_T>
inline
1589 template<
class Num_T>
1594 "Mat<>::elem_mult_out(): Wrong sizes");
1596 for (
int i = 0; i < out.
datasize; i++)
1600 template<
class Num_T>
1606 "Mat<>::elem_mult_out(): Wrong sizes");
1608 for (
int i = 0; i < out.
datasize; i++)
1612 template<
class Num_T>
1620 "Mat<>::elem_mult_out(): Wrong sizes");
1622 for (
int i = 0; i < out.
datasize; i++)
1626 template<
class Num_T>
1633 "Mat<>::elem_mult_inplace(): Wrong sizes");
1634 for (
int i = 0; i < m2.
datasize; i++)
1638 template<
class Num_T>
inline
1642 "Mat<>::elem_mult_sum(): Wrong sizes");
1645 for (
int i = 0; i < m1.
datasize; i++)
1651 template<
class Num_T>
inline
1654 for (
int i = 0; i < datasize; i++)
1659 template<
class Num_T>
inline
1663 "Mat<>::operator/=(): Wrong sizes");
1664 for (
int i = 0; i < datasize; i++)
1665 data[i] /= m.
data[i];
1669 template<
class Num_T>
1673 for (
int i = 0; i < r.
datasize; ++i)
1678 template<
class Num_T>
1682 for (
int i = 0; i < r.
datasize; ++i)
1687 template<
class Num_T>
inline
1695 template<
class Num_T>
1700 "Mat<>::elem_div_out(): Wrong sizes");
1705 for (
int i = 0; i < out.
datasize; i++)
1709 template<
class Num_T>
inline
1713 "Mat<>::elem_div_sum(): Wrong sizes");
1716 for (
int i = 0; i < m1.
datasize; i++)
1722 template<
class Num_T>
1726 for (
int i = 0;i < datasize;i++) {
1727 if (data[i] != m.
data[i])
return false;
1732 template<
class Num_T>
1736 for (
int i = 0;i < datasize;i++) {
1737 if (data[i] != m.
data[i])
return true;
1742 template <
class Num_T>
1743 std::ostream &operator<<(std::ostream &os, const Mat<Num_T> &m)
1752 os <<
'[' << m.get_row(0) <<
']';
1755 os <<
'[' << m.get_row(0) << std::endl;
1756 for (i = 1; i < m.rows() - 1; i++)
1757 os <<
' ' << m.get_row(i) << std::endl;
1758 os <<
' ' << m.get_row(m.rows() - 1) <<
']';
1764 template <
class Num_T>
1767 std::ostringstream buffer;
1768 bool started =
false;
1769 bool finished =
false;
1770 bool brackets =
false;
1771 bool within_double_brackets =
false;
1781 if (is.eof() || (c ==
'\n')) {
1784 is.setstate(std::ios_base::failbit);
1787 else if (!((c ==
'\n') && !started)) {
1791 else if ((c ==
' ') || (c ==
'\t')) {
1796 else if (c ==
'[') {
1797 if ((started && !brackets) || within_double_brackets) {
1799 is.setstate(std::ios_base::failbit);
1802 else if (!started) {
1807 within_double_brackets =
true;
1810 else if (c ==
']') {
1811 if (!started || !brackets) {
1813 is.setstate(std::ios_base::failbit);
1816 else if (within_double_brackets) {
1817 within_double_brackets =
false;
1823 while (!is.eof() && (((c =
static_cast<char>(is.peek())) ==
' ')
1827 if (!is.eof() && (c ==
'\n')) {
1842 m.
set(buffer.str());
1856 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Mat<double>;
1857 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Mat<std::complex<double> >;
1858 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Mat<int>;
1859 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Mat<short int>;
1860 ITPP_EXPORT_TEMPLATE
template class ITPP_EXPORT Mat<bin>;
1864 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator+(
const mat &m1,
const mat &m2);
1865 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator+(
const cmat &m1,
const cmat &m2);
1866 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator+(
const imat &m1,
const imat &m2);
1867 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator+(
const smat &m1,
const smat &m2);
1870 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator+(
const mat &m,
double t);
1871 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator+(
const cmat &m, std::complex<double> t);
1872 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator+(
const imat &m,
int t);
1873 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator+(
const smat &m,
short t);
1876 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator+(
double t,
const mat &m);
1877 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator+(std::complex<double> t,
const cmat &m);
1878 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator+(
int t,
const imat &m);
1879 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator+(
short t,
const smat &m);
1884 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator-(
const mat &m1,
const mat &m2);
1885 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator-(
const cmat &m1,
const cmat &m2);
1886 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator-(
const imat &m1,
const imat &m2);
1887 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator-(
const smat &m1,
const smat &m2);
1890 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator-(
const mat &m,
double t);
1891 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator-(
const cmat &m, std::complex<double> t);
1892 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator-(
const imat &m,
int t);
1893 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator-(
const smat &m,
short t);
1896 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator-(
double t,
const mat &m);
1897 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator-(std::complex<double> t,
const cmat &m);
1898 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator-(
int t,
const imat &m);
1899 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator-(
short t,
const smat &m);
1904 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator-(
const mat &m);
1905 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator-(
const cmat &m);
1906 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator-(
const imat &m);
1907 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator-(
const smat &m);
1912 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator*(
const imat &m1,
const imat &m2);
1913 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator*(
const smat &m1,
const smat &m2);
1916 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT ivec
operator*(
const imat &m,
const ivec &v);
1917 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT svec
operator*(
const smat &m,
const svec &v);
1918 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT bvec
operator*(
const bmat &m,
const bvec &v);
1920 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator*(
const mat &m,
double t);
1921 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator*(
const cmat &m, std::complex<double> t);
1922 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator*(
const imat &m,
int t);
1923 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator*(
const smat &m,
short t);
1926 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator*(
double t,
const mat &m);
1927 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator*(std::complex<double> t,
const cmat &m);
1928 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator*(
int t,
const imat &m);
1929 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator*(
short t,
const smat &m);
1934 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
elem_mult(
const mat &m1,
const mat &m2);
1935 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
elem_mult(
const cmat &m1,
const cmat &m2);
1936 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
elem_mult(
const imat &m1,
const imat &m2);
1937 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
elem_mult(
const smat &m1,
const smat &m2);
1940 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const mat &m1,
const mat &m2, mat &out);
1941 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const cmat &m1,
const cmat &m2,
1943 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const imat &m1,
const imat &m2,
1945 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const smat &m1,
const smat &m2,
1950 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const mat &m1,
const mat &m2,
1951 const mat &m3, mat &out);
1952 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const cmat &m1,
const cmat &m2,
1953 const cmat &m3, cmat &out);
1954 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const imat &m1,
const imat &m2,
1955 const imat &m3, imat &out);
1956 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const smat &m1,
const smat &m2,
1957 const smat &m3, smat &out);
1961 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const mat &m1,
const mat &m2,
1962 const mat &m3,
const mat &m4, mat &out);
1963 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const cmat &m1,
const cmat &m2,
1964 const cmat &m3,
const cmat &m4,
1966 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const imat &m1,
const imat &m2,
1967 const imat &m3,
const imat &m4,
1969 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_out(
const smat &m1,
const smat &m2,
1970 const smat &m3,
const smat &m4,
1976 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_inplace(
const mat &m1, mat &m2);
1977 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_inplace(
const cmat &m1, cmat &m2);
1978 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_inplace(
const imat &m1, imat &m2);
1979 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_mult_inplace(
const smat &m1, smat &m2);
1982 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
double elem_mult_sum(
const mat &m1,
const mat &m2);
1983 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::complex<double>
elem_mult_sum(
const cmat &m1,
1985 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
int elem_mult_sum(
const imat &m1,
const imat &m2);
1986 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
short elem_mult_sum(
const smat &m1,
const smat &m2);
1991 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator/(
double t,
const mat &m);
1992 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator/(std::complex<double> t,
const cmat &m);
1993 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator/(
int t,
const imat &m);
1994 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator/(
short t,
const smat &m);
1997 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
operator/(
const mat &m,
double t);
1998 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
operator/(
const cmat &m, std::complex<double> t);
1999 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
operator/(
const imat &m,
int t);
2000 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
operator/(
const smat &m,
short t);
2005 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
elem_div(
const mat &m1,
const mat &m2);
2006 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
elem_div(
const cmat &m1,
const cmat &m2);
2007 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
elem_div(
const imat &m1,
const imat &m2);
2008 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
elem_div(
const smat &m1,
const smat &m2);
2011 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_div_out(
const mat &m1,
const mat &m2, mat &out);
2012 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_div_out(
const cmat &m1,
const cmat &m2, cmat &out);
2013 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_div_out(
const imat &m1,
const imat &m2, imat &out);
2014 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void elem_div_out(
const smat &m1,
const smat &m2, smat &out);
2017 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
double elem_div_sum(
const mat &m1,
const mat &m2);
2018 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::complex<double>
elem_div_sum(
const cmat &m1,
2020 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
int elem_div_sum(
const imat &m1,
const imat &m2);
2021 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
short elem_div_sum(
const smat &m1,
const smat &m2);
2026 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
concat_horizontal(
const mat &m1,
const mat &m2);
2027 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
concat_horizontal(
const cmat &m1,
const cmat &m2);
2028 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
concat_horizontal(
const imat &m1,
const imat &m2);
2029 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
concat_horizontal(
const smat &m1,
const smat &m2);
2032 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
concat_vertical(
const mat &m1,
const mat &m2);
2033 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
concat_vertical(
const cmat &m1,
const cmat &m2);
2034 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT imat
concat_vertical(
const imat &m1,
const imat &m2);
2035 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT smat
concat_vertical(
const smat &m1,
const smat &m2);
2040 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const mat &m);
2041 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const cmat &m);
2042 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const imat &m);
2043 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const smat &m);
2044 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::ostream &
operator<<(std::ostream &os,
const bmat &m);
2046 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::istream &
operator>>(std::istream &is, mat &m);
2047 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::istream &
operator>>(std::istream &is, cmat &m);
2048 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::istream &
operator>>(std::istream &is, imat &m);
2049 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::istream &
operator>>(std::istream &is, smat &m);
2050 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT std::istream &
operator>>(std::istream &is,
bmat &m);
2056 #endif // #ifndef MAT_H