12#ifndef _FLAMES_CORE_HPP_
13#define _FLAMES_CORE_HPP_
21#include <hls_vector.h>
22#include <initializer_list>
28# error "FLAMES library can only be used for Vitis HLS."
38#ifndef FLAMES_KEEP_WARNING
40# pragma GCC diagnostic push
41# pragma GCC diagnostic ignored "-Weverything"
46# define PRAGMA_SUB(x) _Pragma(# x)
50# define FLAMES_PRAGMA(x) PRAGMA_SUB(HLS x)
53#ifndef FLAMES_MAT_PLUS_UNROLL_FACTOR
54# ifdef FLAMES_UNROLL_FACTOR
55# define FLAMES_MAT_PLUS_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
57# define FLAMES_MAT_PLUS_UNROLL_FACTOR 32
60#ifndef FLAMES_MAT_MINUS_UNROLL_FACTOR
61# ifdef FLAMES_UNROLL_FACTOR
62# define FLAMES_MAT_MINUS_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
64# define FLAMES_MAT_MINUS_UNROLL_FACTOR 32
67#ifndef FLAMES_MAT_SET_VALUE_UNROLL_FACTOR
68# ifdef FLAMES_UNROLL_FACTOR
69# define FLAMES_MAT_SET_VALUE_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
71# define FLAMES_MAT_SET_VALUE_UNROLL_FACTOR 32
74#ifndef FLAMES_MAT_POWER_UNROLL_FACTOR
75# ifdef FLAMES_UNROLL_FACTOR
76# define FLAMES_MAT_POWER_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
78# define FLAMES_MAT_POWER_UNROLL_FACTOR 32
81#ifndef FLAMES_MAT_COPY_UNROLL_FACTOR
82# ifdef FLAMES_UNROLL_FACTOR
83# define FLAMES_MAT_COPY_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
85# define FLAMES_MAT_COPY_UNROLL_FACTOR 32
88#ifndef FLAMES_MAT_SCALAR_TIMES_UNROLL_FACTOR
89# ifdef FLAMES_MAT_TIMES_UNROLL_FACTOR
90# define FLAMES_MAT_SCALAR_TIMES_UNROLL_FACTOR FLAMES_MAT_TIMES_UNROLL_FACTOR
92# ifdef FLAMES_UNROLL_FACTOR
93# define FLAMES_MAT_SCALAR_TIMES_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
95# define FLAMES_MAT_SCALAR_TIMES_UNROLL_FACTOR 32
99#ifndef FLAMES_MAT_TIMES_UNROLL_FACTOR
100# ifdef FLAMES_UNROLL_FACTOR
101# define FLAMES_MAT_TIMES_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
103# define FLAMES_MAT_TIMES_UNROLL_FACTOR 32
106#ifndef FLAMES_MAT_EMUL_UNROLL_FACTOR
107# ifdef FLAMES_UNROLL_FACTOR
108# define FLAMES_MAT_EMUL_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
110# define FLAMES_MAT_EMUL_UNROLL_FACTOR 32
113#ifndef FLAMES_MAT_BOOL_OPER_UNROLL_FACTOR
114# ifdef FLAMES_UNROLL_FACTOR
115# define FLAMES_MAT_BOOL_OPER_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
117# define FLAMES_MAT_BOOL_OPER_UNROLL_FACTOR 32
120#ifndef FLAMES_MAT_ABS_UNROLL_FACTOR
121# ifdef FLAMES_UNROLL_FACTOR
122# define FLAMES_MAT_ABS_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
124# define FLAMES_MAT_ABS_UNROLL_FACTOR 32
127#ifndef FLAMES_MAT_TRANSPOSE_UNROLL_FACTOR
128# ifdef FLAMES_UNROLL_FACTOR
129# define FLAMES_MAT_TRANSPOSE_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
131# define FLAMES_MAT_TRANSPOSE_UNROLL_FACTOR 32
134#ifndef FLAMES_MAT_INV_UNROLL_FACTOR
135# ifdef FLAMES_UNROLL_FACTOR
136# define FLAMES_MAT_INV_UNROLL_FACTOR FLAMES_UNROLL_FACTOR
138# define FLAMES_MAT_INV_UNROLL_FACTOR 32
141#ifndef FLAMES_MAT_PARTITION_COMPLETE
142# ifndef FLAMES_MAT_PARTITION_FACTOR
143# define FLAMES_MAT_PARTITION_FACTOR 8
146#ifndef FLAMES_SORT_PARTITION_COMPLETE
147# ifndef FLAMES_SORT_PARTITION_FACTOR
148# define FLAMES_SORT_PARTITION_FACTOR 32
152#if defined __SYNTHESIS__ && defined FLAMES_PRINT_PER_MAT_COPY
153# undef FLAMES_PRINT_PER_MAT_COPY
157# define DEFINED_INLINE
220using MType = std::integral_constant<int, type>;
230 if (type1 == type2)
return type1;
277 if (n_rows == comm && comm == n_cols) {
278 if (type1 == type2) {
279 if (type1 !=
SYM && type1 !=
ASYM)
return type1;
318inline constexpr size_t upperRow(
size_t index,
size_t N) {
320 while (index >= N - r) {
334inline constexpr size_t lowerRow(
size_t index,
size_t N) {
336 while (index >= r + 1) {
350inline constexpr size_t supperRow(
size_t index,
size_t N) {
352 while (index >= N - 1 - r) {
366inline constexpr size_t slowerRow(
size_t index,
size_t N) {
388template <
typename T,
size_t n_rows,
size_t n_cols, MatType type = MatType::NORMAL>
391template <
typename T,
size_t n_rows,
size_t n_cols,
size_t n_slices, MatType type = MatType::NORMAL>
401template <
typename T,
size_t N>
411template <
typename T,
size_t N>
422template <
typename T,
size_t n_rows,
size_t n_cols, MatType type = MatType::NORMAL>
425template <
typename T,
size_t n_rows,
size_t n_cols, MatType type = MatType::NORMAL>
436template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
447template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
459template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent = MATTYPE_NORMAL>
471template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent = MATTYPE_NORMAL>
483template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent = MATTYPE_NORMAL>
495template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent = MATTYPE_NORMAL>
507template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent = MATTYPE_NORMAL>
510template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent = MATTYPE_NORMAL>
522template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent = MATTYPE_NORMAL>
534template <
size_t first_col,
size_t last_col,
typename T,
size_t n_rows,
size_t n_cols,
MatType type,
547template <
size_t first_row,
size_t last_row,
typename T,
size_t n_rows,
size_t n_cols,
MatType type,
564template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
566 friend class MatView<T, n_rows, n_cols, type>;
567 friend class MatViewOpp<T, n_rows, n_cols, type>;
568 friend class MatViewT<T, n_cols, n_rows, type>;
569 friend class MatViewT<T, n_rows, n_cols, type>;
570 template <
typename View_T,
size_t View_N,
size_t View_N_, MatType View_type,
typename type_parent>
572 template <
typename View_T,
size_t View_N,
size_t View_N_, MatType View_type,
typename type_parent>
574 template <
typename View_T,
size_t View_N,
size_t View_N_, MatType View_type,
typename type_parent>
576 template <
typename View_T,
size_t View_N,
size_t View_N_, MatType View_type,
typename type_parent>
578 template <
typename View_T,
size_t View_n_rows,
size_t View_n_cols, MatType View_type,
typename type_parent>
580 template <
typename View_T,
size_t View_n_rows,
size_t View_n_cols, MatType View_type,
typename type_parent>
582 template <
size_t first_col,
size_t last_col,
typename View_T,
size_t View_n_rows,
size_t View_n_cols,
583 MatType View_type,
typename type_parent>
585 template <
size_t first_row,
size_t last_row,
typename View_T,
size_t View_n_rows,
size_t View_n_cols,
586 MatType View_type,
typename type_parent>
588 template <
typename View_T_T,
size_t T_n_rows,
size_t T_n_cols,
size_t T_n_slices, MatType T_type>
605 static_assert(n_rows != 0,
"'rows' should be no smaller than 1.");
606 static_assert(n_cols != 0,
"'n_cols' should be no smaller than 1.");
607 static_assert(type ==
MatType::NORMAL || n_rows == n_cols,
"Square matrix 'rows' should be equal to 'n_cols'.");
608#ifdef FLAMES_MAT_PARTITION_COMPLETE
624 static_assert(n_rows != 0,
"'n_rows' should be no smaller than 1.");
625 static_assert(n_cols != 0,
"'n_cols' should be no smaller than 1.");
626 static_assert(type ==
MatType::NORMAL || n_rows == n_cols,
"Square matrix 'rows' should be equal to 'n_cols'.");
627#ifdef FLAMES_MAT_PARTITION_COMPLETE
646 for (
size_t i = 0; i !=
size(); ++i) {
650#ifdef FLAMES_MAT_PARTITION_COMPLETE
655#ifdef FLAMES_PRINT_PER_MAT_COPY
656 std::cout <<
"Mat copy!" << std::endl;
660 template <
typename T2,
size_t _rows,
size_t _cols,
MatType _type,
661 std::enable_if_t<!std::is_same<T, T2>::value && type == _type && n_rows == _rows && n_cols == _cols,
665 for (
size_t i = 0; i !=
size(); ++i) {
669#ifdef FLAMES_MAT_PARTITION_COMPLETE
674#ifdef FLAMES_PRINT_PER_MAT_COPY
675 std::cout <<
"Mat copy!" << std::endl;
679 template <
typename T2,
size_t _rows,
size_t _cols,
MatType _type,
680 std::enable_if_t<type != _type && n_rows == _rows && n_cols == _cols, bool> =
true>
683 for (
size_t r = 0; r != n_rows; ++r) {
685 for (
size_t c = 0; c != n_cols; ++c) {
690#ifdef FLAMES_MAT_PARTITION_COMPLETE
695#ifdef FLAMES_PRINT_PER_MAT_COPY
696 std::cout <<
"Mat copy!" << std::endl;
708 Mat(
const std::vector<T>& vec) {
709 assert(vec.size() ==
size() &&
"Initialization vector size disagrees.");
710 MAT_COPY_FROM_STD_VEC:
711 for (
size_t i = 0; i !=
size(); ++i) {
715#ifdef FLAMES_MAT_PARTITION_COMPLETE
720#ifdef FLAMES_PRINT_PER_MAT_COPY
721 std::cout <<
"Mat copy!" << std::endl;
725 template <
typename T2>
726 Mat(std::initializer_list<T2> list) {
727 auto list_size = list.size();
728 assert(list_size <=
size() &&
"Initializer list size should not exceed size().");
729 MAT_COPY_FROM_INIT_LIST:
730 for (
size_t i = 0; i != list_size; ++i) {
732 _data[i] = *(list.begin() + i);
734#ifdef FLAMES_MAT_PARTITION_COMPLETE
739#ifdef FLAMES_PRINT_PER_MAT_COPY
740 std::cout <<
"Mat copy!" << std::endl;
758 for (
size_t i = 0; i !=
size(); ++i) {
764 for (
size_t i = 0; i !=
size(); ++i) {
772#ifdef FLAMES_MAT_PARTITION_COMPLETE
777#ifdef FLAMES_PRINT_PER_MAT_COPY
778 std::cout <<
"Mat copy!" << std::endl;
785 for (
size_t i = 0; i !=
size(); ++i) {
791 for (
size_t i = 0; i !=
size(); ++i) {
799#ifdef FLAMES_MAT_PARTITION_COMPLETE
804#ifdef FLAMES_PRINT_PER_MAT_COPY
805 std::cout <<
"Mat copy!" << std::endl;
832 inline static constexpr size_t size() noexcept {
839 : (1 + n_rows) * n_rows / 2;
852 assert(index <
size() &&
"Matrix index should be within range");
866 assert(index <
size() &&
"Matrix index should be within range");
879 assert(r < n_rows &&
"Matrix row index should be within range");
880 assert(c < n_cols &&
"Matrix col index should be within range");
882 return _data[r * n_cols + c];
884 if (r == c)
return _data[r];
887 if (r == c)
return _data[0];
890 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
893 if (r >= c)
return _data[(1 + r) * r / 2 + c];
896 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
899 if (r > c)
return _data[(1 + r) * r / 2 + c - r];
902 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
903 else return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
905 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
906 else if (r > c)
return -
_data[(2 * n_cols + 1 - c) * c / 2 + r - 1 - 2 * c];
910 assert(!
"Impossible! Unknown MatType!");
923 assert(r < n_rows &&
"Matrix row index should be within range");
924 assert(c < n_cols &&
"Matrix col index should be within range");
926 return _data[r * n_cols + c];
928 if (r == c)
return _data[r];
929 else assert(!
"This element cannot be modified (DIAGONAL).");
931 assert(!
"This element cannot be modified (SCALAR).");
933 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
934 else assert(!
"This element cannot be modified (UPPER).");
936 if (r >= c)
return _data[(1 + r) * r / 2 + c];
937 else assert(!
"This element cannot be modified (LOWER).");
939 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
940 else assert(!
"This element cannot be modified (SUPPER).");
942 if (r > c)
return _data[(1 + r) * r / 2 + c - r];
943 else assert(!
"This element cannot be modified (SLOWER).");
945 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
946 else return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
948 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
949 else if (r > c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - 1 - 2 * c];
954 else assert(!
"This element cannot be modified (ASYM).");
957 assert(!
"Impossible! Unknown MatType!");
969 for (
size_t i = 0; i !=
size(); ++i) {
981 bool read(
const std::string& file_name) {
983 std::ifstream f(file_name);
985 size_t in_rows, in_cols;
986 f >> in_rows >> in_cols;
987 if (n_rows != in_rows || n_cols != in_cols)
return false;
988 std::string complex_real, mat_type;
989 f >> complex_real >> mat_type;
996 if (type ==
MatType::SYM && mat_type !=
"sym")
return false;
997 if (type ==
MatType::ASYM && mat_type !=
"asym")
return false;
998 if (complex_real ==
"complex") {
1006 assert(!
"Read from a complex matrix is not currently supported.");
1010 for (
size_t i = 0; i !=
size(); ++i) {
1011 std::getline(f, buf,
',');
1012 _data[i] = std::stod(buf);
1040 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1041 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1043 Mat&
add(
const M1<T1, n_rows, n_cols, type, _unused1...>& mat_L,
1044 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
1046 for (
size_t i = 0; i !=
size(); ++i) {
1048 this->
_data[i] = mat_L[i] + mat_R[i];
1071 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1072 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1076 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1077 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1078 MAT_PLUS_MAT_NORMAL:
1079 for (
size_t i = 0; i != n_rows; ++i) {
1081 for (
size_t j = 0; j != n_cols; ++j) {
1083 this->
_data[i * n_cols + j] = mat_L(i, j) + mat_R(i, j);
1107 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1108 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1112 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1113 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1115 for (
size_t i = 0; i != n_rows; ++i) {
1117 this->
_data[i] = mat_L(i, i) + mat_R(i, i);
1138 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1139 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1143 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1144 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1145 MAT_PLUS_MAT_SCALAR:
1146 this->
_data[0] = mat_L(0, 0) + mat_R(0, 0);
1169 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1170 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1173 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1174 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1176 for (
size_t i = 0; i != n_rows; ++i) {
1178 for (
size_t j = i; j != n_cols; ++j) {
1180 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i] = mat_L(i, j) + mat_R(i, j);
1205 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1206 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1209 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1210 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1212 for (
size_t i = 0; i != n_rows; ++i) {
1214 for (
size_t j = i; j != n_cols; ++j) {
1216 this->
_data[(1 + i) * i / 2 + j] = mat_L(i, j) + mat_R(i, j);
1240 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1241 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1245 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1246 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1247 MAT_PLUS_MAT_SUPPER:
1248 for (
size_t i = 0; i != n_rows - 1; ++i) {
1250 for (
size_t j = i + 1; j != n_cols; ++j) {
1252 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - 2 * i - 1] = mat_L(i, j) + mat_R(i, j);
1276 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1277 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1281 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1282 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1283 MAT_PLUS_MAT_SLOWER:
1284 for (
size_t i = 1; i != n_rows; ++i) {
1286 for (
size_t j = 0; j != n_cols - 1; ++j) {
1288 this->
_data[(1 + i) * i / 2 + j - i] = mat_L(i, j) + mat_R(i, j);
1312 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1313 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1316 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1317 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1319 for (
size_t i = 0; i != n_rows; ++i) {
1321 for (
size_t j = i; j != n_cols; ++j) {
1323 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i] = mat_L(i, j) + mat_R(i, j);
1348 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1349 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1352 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1353 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1355 for (
size_t i = 0; i != n_rows; ++i) {
1357 for (
size_t j = i + 1; j != n_cols; ++j) {
1359 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i * 2 - 1] = mat_L(i, j) + mat_R(i, j);
1375 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
1379 return this->
add(*
this, mat_R);
1398 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1399 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1401 Mat&
sub(
const M1<T1, n_rows, n_cols, type, _unused1...>& mat_L,
1402 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
1404 for (
size_t i = 0; i !=
size(); ++i) {
1406 this->
_data[i] = mat_L[i] - mat_R[i];
1429 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1430 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1434 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1435 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1436 MAT_MINUS_MAT_NORMAL:
1437 for (
size_t i = 0; i != n_rows; ++i) {
1439 for (
size_t j = 0; j != n_cols; ++j) {
1441 this->
_data[i * n_cols + j] = mat_L(i, j) - mat_R(i, j);
1465 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1466 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1470 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1471 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1472 MAT_MINUS_MAT_DIAGONAL:
1473 for (
size_t i = 0; i != n_rows; ++i) {
1475 this->
_data[i] = mat_L(i, i) - mat_R(i, i);
1497 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1498 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1502 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1503 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1504 MAT_MINUS_MAT_SCALAR:
1505 this->
_data[0] = mat_L(0, 0) - mat_R(0, 0);
1528 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1529 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1532 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1533 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1534 MAT_MINUS_MAT_UPPER:
1535 for (
size_t i = 0; i != n_rows; ++i) {
1537 for (
size_t j = i; j != n_cols; ++j) {
1539 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i] = mat_L(i, j) - mat_R(i, j);
1564 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1565 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1568 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1569 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1570 MAT_MINUS_MAT_LOWER:
1571 for (
size_t i = 0; i != n_rows; ++i) {
1573 for (
size_t j = i; j != n_cols; ++j) {
1575 this->
_data[(1 + i) * i / 2 + j] = mat_L(i, j) - mat_R(i, j);
1599 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1600 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1604 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1605 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1606 MAT_MINUS_MAT_SUPPER:
1607 for (
size_t i = 0; i != n_rows - 1; ++i) {
1609 for (
size_t j = i + 1; j != n_cols; ++j) {
1611 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - 2 * i - 1] = mat_L(i, j) - mat_R(i, j);
1635 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1636 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1640 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1641 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1642 MAT_MINUS_MAT_SLOWER:
1643 for (
size_t i = 1; i != n_rows; ++i) {
1645 for (
size_t j = 0; j != n_cols - 1; ++j) {
1647 this->
_data[(1 + i) * i / 2 + j - i] = mat_L(i, j) - mat_R(i, j);
1671 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1672 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1675 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1676 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1678 for (
size_t i = 0; i != n_rows; ++i) {
1680 for (
size_t j = i; j != n_cols; ++j) {
1682 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i] = mat_L(i, j) - mat_R(i, j);
1707 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1708 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1711 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1712 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1714 for (
size_t i = 0; i != n_rows; ++i) {
1716 for (
size_t j = i + 1; j != n_cols; ++j) {
1718 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i * 2 - 1] = mat_L(i, j) - mat_R(i, j);
1737 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
1742 for (
size_t i = 0; i !=
size(); ++i) {
1744 _data[i] -= mat_R[i];
1766 template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename ScalarT,
1768 std::enable_if_t<std::is_arithmetic<std::remove_cv_t<std::remove_reference_t<ScalarT>>>
::value,
bool> =
true>
1771 for (
size_t i = 0; i !=
size(); ++i) {
1773 _data[i] = mat[i] * s;
1794 template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename ScalarT,
1796 std::enable_if_t<std::is_arithmetic<std::remove_cv_t<std::remove_reference_t<ScalarT>>>
::value,
bool> =
true>
1799 for (
size_t i = 0; i !=
size(); ++i) {
1801 _data[i] = mat[i] * s;
1820 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
int AP_W,
1824 for (
size_t i = 0; i !=
size(); ++i) {
1826 _data[i] = mat[i] * s;
1849 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
int AP_W,
int AP_I,
1850 ap_q_mode AP_Q, ap_o_mode AP_O,
int AP_N,
typename T2>
1853 for (
size_t i = 0; i !=
size(); ++i) {
1855 _data[i] = mat[i] * s;
1873 std::enable_if_t<std::is_arithmetic<std::remove_cv_t<std::remove_reference_t<ScalarT>>>
::value,
bool> =
true>
1875 MAT_SCALAR_TIMES_SELF:
1876 for (
size_t i = 0; i !=
size(); ++i) {
1895 std::enable_if_t<std::is_arithmetic<std::remove_cv_t<std::remove_reference_t<ScalarT>>>
::value,
bool> =
true>
1897 MAT_SCALAR_TIMES_SELF:
1898 for (
size_t i = 0; i !=
size(); ++i) {
1917 MAT_SCALAR_TIMES_SELF:
1918 for (
size_t i = 0; i !=
size(); ++i) {
1939 template <
int AP_W,
int AP_I, ap_q_mode AP_Q, ap_o_mode AP_O,
int AP_N>
1940 Mat&
mul(ap_fixed<AP_W, AP_I, AP_Q, AP_O, AP_N> s) {
1941 MAT_SCALAR_TIMES_SELF:
1942 for (
size_t i = 0; i !=
size(); ++i) {
1971 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1972 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1973 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
1974 std::enable_if_t<(!(std::is_same<T1, bool>::value) && !(std::is_same<T2, bool>::value)) &&
1980 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
1981 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
1983 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
1984 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
1986 for (
size_t i = 0; i != comm; ++i) {
1988 for (
size_t r = 0; r != n_rows; ++r) {
1995 for (
size_t c = 0; c != n_cols; ++c) {
1997 if (i == 0) (*this)(r, c) = T(0);
1998 (*this)(r, c) += mat_L(r, i) * mat_R(i, c);
2027 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2028 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
2029 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2031 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2032 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2034 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2035 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2036 MAT_NORAML_OR_SYM_TIMES_MAT_ASYM:
2037 for (
size_t i = 0; i != comm; ++i) {
2039 for (
size_t r = 0; r != n_rows; ++r) {
2042 for (
size_t c = 0; c != n_cols; ++c) {
2044 if (i == 0) (*this)(r, c) = T(0);
2045 if (i != c) (*this)(r, c) += mat_L(r, i) * mat_R(i, c);
2073 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2074 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2075 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2078 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2079 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2080 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2081 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2082 MAT_NORAML_OR_SYM_TIMES_DIAG:
2083 for (
size_t i = 0; i != n_rows; ++i) {
2085 for (
size_t j = 0; j != n_cols; ++j) {
2087 (*this)(i, j) = mat_L(i, j) * mat_R[j];
2114 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2115 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2116 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2119 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2120 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2121 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2122 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2123 MAT_NORAML_OR_MAT_SYM_TIMES_SCAL:
2124 for (
size_t i = 0; i != n_rows; ++i) {
2126 for (
size_t j = 0; j != n_rows; ++j) {
2128 (*this)(i, j) = mat_L(i, j) * mat_R[0];
2156 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2157 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
2158 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2160 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2161 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2162 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2163 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2164 static const size_t r[288] = {
2165 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2166 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2167 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2168 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2169 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
2170 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
2171 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
2172 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
2174 static const size_t i[288] = {
2175 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 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 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
2187 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
2188 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
2189 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
2190 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
2191 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
2192 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7
2194 MAT_NORAML_OR_MAT_SYM_TIMES_UPPER:
2195 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
2197 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
2198 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2225 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2226 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
2227 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2229 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2230 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2231 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2232 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2233 static const size_t r[288] = {
2234 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2235 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2236 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2237 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2238 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
2239 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
2240 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
2241 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
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 0,
2255 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
2256 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
2257 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
2258 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
2259 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
2260 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
2261 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0
2263 MAT_NORAML_OR_MAT_SYM_TIMES_LOWER:
2264 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
2266 if (i[n] == c[n]) (*this)(r[n], c[n]) = 0;
2267 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2293 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2294 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2295 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2298 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2299 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2300 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2301 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2302 static const size_t r[224] = {
2303 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
2304 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
2305 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2306 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
2307 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
2308 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
2309 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
2311 static const size_t i[224] = {
2312 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 0, 1, 0,
2313 1, 2, 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, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6,
2326 6, 7, 7, 7, 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7,
2327 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
2329 MAT_NORAML_OR_MAT_SYM_TIMES_SUPPER:
2330 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
2332 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
2333 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2335 for (
size_t i = 0; i != n_rows; i++) { (*this)(i, 0) = 0; }
2360 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2361 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2362 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2365 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2366 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2367 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2368 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2369 static const size_t r[224] = {
2370 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
2371 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
2372 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3,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6, 7, 1, 2, 3,
2385 4, 5, 6, 7, 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7,
2387 static const size_t c[224] = {
2388 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4,
2389 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3,
2390 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2,
2391 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1,
2392 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
2393 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0,
2394 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
2396 MAT_NORAML_OR_MAT_SYM_TIMES_SLOWER:
2397 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
2399 if (i[n] == c[n] + 1) (*this)(r[n], c[n]) = 0;
2400 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2402 for (
size_t i = 0; i != n_rows; i++) { (*this)(i, n_rows - 1) = 0; }
2426 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2427 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2428 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2430 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2431 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2432 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2433 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2434 MAT_DIAG_TIMES_MAT_DIAG:
2435 for (
size_t i = 0; i != n_rows; ++i) {
2437 (*this)(i, i) = mat_L[i] * mat_R[i];
2463 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2464 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2465 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2467 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2468 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2469 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2470 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2471 MAT_DIAG_TIMES_MAT_SCAL:
2472 for (
size_t i = 0; i != n_cols; ++i) {
2474 _data[i] = mat_L[i] * mat_R[0];
2500 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2501 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2502 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2504 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2505 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2506 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2507 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2508 static const size_t r[36] = {
2509 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7,
2511 static const size_t i[36] = {
2512 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7,
2514 static const size_t c[36] = {
2515 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
2517 MAT_DIAG_TIMES_UPPER:
2518 for (
size_t n = 0; n != n_rows * (n_rows + 1) / 2; n++) {
2520 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2546 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2547 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2548 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2550 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2551 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2552 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2553 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2554 static const size_t r[36] = {
2555 0, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7,
2557 static const size_t i[36] = {
2558 0, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7,
2560 static const size_t c[36] = {
2561 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7,
2563 MAT_DIAG_TIMES_LOWER:
2564 for (
size_t n = 0; n != n_rows * (n_rows + 1) / 2; n++) {
2566 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2592 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2593 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2594 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2596 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2597 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2598 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2599 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2600 static const size_t r[28] = {
2601 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6
2603 static const size_t i[28] = {
2604 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6
2606 static const size_t c[28] = {
2607 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7
2609 MAT_DIAG_TIMES_SUPPER:
2610 for (
size_t n = 0; n != n_rows * (n_rows - 1) / 2; n++) {
2612 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2638 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2639 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2640 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2642 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2643 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2644 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2645 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2646 static const size_t r[28] = {
2647 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7
2649 static const size_t i[28] = {
2650 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7
2652 static const size_t c[28] = {
2653 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6
2655 MAT_DIAG_TIMES_SLOWER:
2656 for (
size_t n = 0; n != n_rows * (n_rows - 1) / 2; n++) {
2658 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2684 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2685 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2686 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2689 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2690 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2691 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2692 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2693 MAT_DIAG_TIMES_MAT_NORMAL_or_SYM:
2694 for (
size_t j = 0; j != n_cols; ++j) {
2696 for (
size_t i = 0; i != n_rows; ++i) {
2698 (*this)(i, j) = mat_L(i, i) * mat_R(i, j);
2725 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2726 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2727 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2729 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2730 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2731 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2732 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2733 MAT_DIAG_TIMES_MAT_ASYM:
2734 for (
size_t j = 0; j != n_cols; ++j) {
2736 for (
size_t i = 0; i != n_rows; ++i) {
2738 if (i != j) (*this)(i, j) = mat_L(i, i) * mat_R(i, j);
2739 else (*
this)(i, j) = T(0);
2764 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2765 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2766 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2768 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2769 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2770 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2771 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2772 MAT_SCAL_TIMES_MAT_SCAL:
2773 _data[0] = mat_L[0] * mat_R[0];
2798 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2799 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2800 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2802 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2803 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2804 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2805 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2806 MAT_SCAL_TIMES_MAT_DIAG:
2807 for (
size_t i = 0; i != n_cols; ++i) {
2809 _data[i] = mat_L[0] * mat_R[i];
2835 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2836 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2837 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2839 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2840 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2841 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2842 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2843 MAT_SCAL_TIMES_MAT_UPPER:
2844 for (
size_t i = 0; i != (1 + n_rows) * n_rows / 2; ++i) {
2846 _data[i] = mat_L[0] * mat_R[i];
2872 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2873 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2874 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2876 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2877 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2878 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2879 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2880 MAT_SCAL_TIMES_MAT_LOWER:
2881 for (
size_t i = 0; i != (1 + n_rows) * n_rows / 2; ++i) {
2883 _data[i] = mat_L[0] * mat_R[i];
2909 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2910 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2911 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2913 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2914 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2915 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2916 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2917 MAT_SCAL_TIMES_MAT_SUPPER:
2918 for (
size_t i = 0; i != (n_rows - 1) * n_rows / 2; ++i) {
2920 _data[i] = mat_L[0] * mat_R[i];
2946 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2947 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2948 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2950 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2951 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2952 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2953 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2954 MAT_SCAL_TIMES_MAT_SLOWER:
2955 for (
size_t i = 0; i != (n_rows - 1) * n_rows / 2; ++i) {
2957 _data[i] = mat_L[0] * mat_R[i];
2983 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2984 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2985 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2987 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2988 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2989 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2990 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2991 MAT_SCAL_TIMES_MAT_SLOWER:
2992 for (
size_t i = 1; i != n_rows; ++i) {
2994 for (
size_t j = 0; j != n_cols; ++j) {
2996 if (i != j) (*this)(i, j) = mat_L[0] * mat_R(i, j);
2997 else (*
this)(i, j) = T(0);
3024 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3025 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3026 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3028 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3029 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3030 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3031 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3032 MAT_SCAL_TIMES_MAT_NORMAL_OR_MAT_SYM:
3033 for (
size_t i = 0; i != n_rows; ++i) {
3035 for (
size_t j = 0; j != n_cols; ++j) {
3037 (*this)(i, j) = mat_L[0] * mat_R(i, j);
3064 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3065 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3066 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3068 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3069 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3070 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3071 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3072 MAT_UPPER_TIMES_MAT_SCALAR:
3073 for (
size_t i = 0; i != (n_rows + 1) * n_rows / 2; ++i) {
3075 _data[i] = mat_L[i] * mat_R[0];
3101 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3102 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3103 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3105 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3106 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3107 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3108 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3109 static const size_t r[36] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
3110 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7 };
3111 static const size_t i[36] = { 0, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4,
3112 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7 };
3113 static const size_t c[36] = { 0, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4,
3114 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7 };
3115 MAT_UPPER_TIMES_DIAG:
3116 for (
size_t n = 0; n != n_rows * (n_rows + 1) / 2; n++) {
3118 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3144 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3145 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3146 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3148 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3149 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3151 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3152 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3153 static const size_t r[120] = { 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 0, 0,
3154 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 0, 0, 0, 0, 1, 1, 1, 1,
3155 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2,
3156 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
3157 2, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
3158 static const size_t i[120] = { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 0, 1,
3159 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 0, 1, 2, 3, 1, 2, 3, 4,
3160 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3,
3161 4, 5, 6, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5,
3162 6, 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7 };
3163 static const size_t c[120] = { 0, 1, 2, 3, 4, 5, 6, 7, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 2, 2,
3164 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 3, 3, 3, 3, 4, 4, 4, 4,
3165 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6,
3166 6, 6, 6, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7,
3167 7, 7, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 };
3168 MAT_UPPER_TIMES_UPPER:
3169 for (
size_t n = 0; n != n_rows * (n_rows + 1) * (n_rows + 2) / 6; n++) {
3171 if (i[n] == r[n]) (*this)(r[n], c[n]) = 0;
3172 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3198 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3199 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3200 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3202 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3203 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3205 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3206 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3207 static const size_t r[120] = {
3208 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 0, 0, 0, 1, 1, 1, 2, 2,
3209 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4,
3210 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
3211 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
3213 static const size_t i[120] = {
3214 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 0, 1, 2, 1, 2, 3, 2, 3,
3215 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7,
3216 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4,
3217 5, 6, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3219 static const size_t c[120] = {
3220 0, 1, 2, 3, 4, 5, 6, 7, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 2, 2, 2, 3, 3, 3, 4, 4,
3221 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
3222 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
3223 6, 6, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
3225 MAT_UPPER_TIMES_MAT_LOWER:
3226 for (
size_t n = 0; n != n_rows * (n_rows + 1) * (n_rows + 2) / 6; n++) {
3228 if (i[n] == r[n]) (*this)(r[n], c[n]) = 0;
3229 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3255 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3256 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3257 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3259 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3260 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3262 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3263 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3264 static const size_t c[84] = {
3265 0, 1, 2, 3, 4, 5, 6, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 0, 0, 0, 1, 1, 1, 2, 2, 2,
3266 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 0, 1,
3267 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
3269 static const size_t i[84] = {
3270 0, 1, 2, 3, 4, 5, 6, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 0, 1, 2, 1, 2, 3, 2, 3, 4,
3271 3, 4, 5, 4, 5, 6, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 0, 1, 2, 3, 4, 1,
3272 2, 3, 4, 5, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6,
3274 static const size_t r[84] = {
3275 1, 2, 3, 4, 5, 6, 7, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 3, 3, 3, 4, 4, 4, 5, 5, 5,
3276 6, 6, 6, 7, 7, 7, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 5, 5, 5, 5, 5, 6,
3277 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
3279 MAT_UPPER_TIMES_MAT_SUPPER:
3280 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 6; n++) {
3282 if (i[n] == r[n]) (*this)(r[n], c[n]) = 0;
3283 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3309 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3310 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3311 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3313 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3314 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3316 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3317 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3318 static const size_t r[168] = {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5, 6, 7, 1, 2, 3, 4, 5, 6, 7,
3332 static const size_t c[168] = {
3333 0, 1, 2, 3, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
3334 5, 5, 5, 5, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
3335 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0,
3336 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0,
3337 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3339 MAT_UPPER_TIMES_MAT_SLOWER:
3340 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 3; n++) {
3342 if (i[n] == r[n] || i[n] == (c[n] + 1)) (*this)(r[n], c[n]) = 0;
3343 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3369 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3370 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3371 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3373 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3374 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3376 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3377 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3378 static const size_t r[288]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 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3402 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3403 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3404 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3405 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3406 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3408 MAT_UPPER_TIMES_MAT_ASYM:
3409 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
3411 if (i[n] == r[n]) (*this)(r[n], c[n]) = 0;
3412 if (i[n] != c[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3439 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3440 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
3441 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3443 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3444 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3446 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3447 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3448 static const size_t r[288] = {
3449 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
3450 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
3451 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
3452 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
3453 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
3454 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
3455 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
3456 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
3458 static const size_t c[288] = {
3459 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3471 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3472 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3473 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3474 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3475 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3476 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3478 MAT_LOWER_TIMES_NORAML_OR_MAT_SYM:
3479 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
3481 if (i[n] == r[n]) (*this)(r[n], c[n]) = 0;
3482 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3508 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3509 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3510 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3512 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3513 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3514 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3515 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3516 MAT_LOWER_TIMES_MAT_SCALAR:
3517 for (
size_t i = 0; i != (n_rows + 1) * n_rows / 2; ++i) {
3519 _data[i] = mat_L[i] * mat_R[0];
3545 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3546 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3547 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3549 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3550 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3551 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3552 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3553 static const size_t r[36] = {
3554 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
3556 static const size_t i[36] = {
3557 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7,
3559 static const size_t c[36] = {
3560 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7,
3562 MAT_LOWER_TIMES_DIAG:
3563 for (
size_t n = 0; n != n_rows * (n_rows + 1) / 2; n++) {
3565 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3591 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3592 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3593 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3595 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3596 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3598 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3599 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3600 static const size_t r[204] = {
3601 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1,
3602 1, 1, 1, 1, 1, 1, 1, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3603 2, 2, 2, 2, 2, 2, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3604 3, 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
3605 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
3606 5, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
3608 static const size_t i[204] = {
3609 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
3610 1, 0, 1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 5, 5, 5, 6, 6, 6, 6, 6, 6, 7,
3622 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
3624 MAT_LOWER_TIMES_MAT_UPPER:
3625 for (
size_t n = 0; n != (2 * n_rows * n_rows * n_rows + 3 * n_rows * n_rows + n_rows) / 6; n++) {
3627 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
3628 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3654 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3655 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3656 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3658 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3659 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3661 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3662 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3663 static const size_t c[120] = {
3664 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 0, 0, 0, 1, 1, 1, 2, 2,
3665 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4,
3666 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
3667 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
3669 static const size_t i[120] = {
3670 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 0, 1, 2, 1, 2, 3, 2, 3,
3671 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7,
3672 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4,
3673 5, 6, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3675 static const size_t r[120] = {
3676 0, 1, 2, 3, 4, 5, 6, 7, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 2, 2, 2, 3, 3, 3, 4, 4,
3677 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
3678 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
3679 6, 6, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
3681 MAT_LOWER_TIMES_MAT_LOWER:
3682 for (
size_t n = 0; n != n_rows * (n_rows + 1) * (n_rows + 2) / 6; n++) {
3684 if (i[n] == c[n]) (*this)(r[n], c[n]) = 0;
3685 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3711 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3712 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3713 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3715 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3716 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3718 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3719 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3720 static const size_t r[168] = {
3721 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5,
3722 6, 6, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7,
3723 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 4, 4,
3724 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5,
3725 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
3727 static const size_t i[168] = {
3728 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
3729 0, 1, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2,
3730 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1,
3731 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5,
3732 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6,
3734 static const size_t c[168] = {
3735 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3736 2, 2, 2, 2, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3737 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7,
3738 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7,
3739 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
3741 MAT_LOWER_TIMES_MAT_SUPPER:
3742 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 3; n++) {
3744 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
3745 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3747 for (
size_t r = 0; r != n_cols; r++) { (*this)(r, 0) = T(0); }
3773 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3774 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3775 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3777 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3778 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3780 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3781 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3782 static const size_t c[84] = {
3783 0, 1, 2, 3, 4, 5, 6, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 0, 0, 0, 1, 1, 1, 2, 2, 2,
3784 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 0, 1,
3785 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
3787 static const size_t i[84] = {
3788 1, 2, 3, 4, 5, 6, 7, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 1, 2, 3, 2, 3, 4, 3, 4, 5,
3789 4, 5, 6, 5, 6, 7, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 1, 2, 3, 4, 5, 2,
3790 3, 4, 5, 6, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7,
3792 static const size_t r[84] = {
3793 1, 2, 3, 4, 5, 6, 7, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 3, 3, 3, 4, 4, 4, 5, 5, 5,
3794 6, 6, 6, 7, 7, 7, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 5, 5, 5, 5, 5, 6,
3795 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
3797 MAT_LOWER_TIMES_MAT_SLOWER:
3798 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 6; n++) {
3800 if (i[n] == c[n] + 1) (*this)(r[n], c[n]) = 0;
3801 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3827 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3828 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3829 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3831 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3832 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3834 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3835 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3836 static const size_t c[288] = {
3837 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3838 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
3839 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3840 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3841 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
3842 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,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, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
3866 MAT_LOWER_TIMES_MAT_ASYM:
3867 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
3869 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
3870 if (i[n] != c[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3897 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3898 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
3899 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3901 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3902 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3904 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3905 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3906 static const size_t c[288] = {
3907 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3908 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
3909 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3910 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3911 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 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 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
3936 MAT_LOWER_TIMES_MAT_NORMAL_OR_MAT_SYM:
3937 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
3939 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
3940 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3966 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3967 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3968 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3970 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3971 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3972 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3973 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3974 MAT_SUPPER_TIMES_MAT_SCALAR:
3975 for (
size_t i = 0; i != (n_rows - 1) * n_rows / 2; ++i) {
3977 _data[i] = mat_L[i] * mat_R[0];
4003 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4004 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4005 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4007 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4008 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4009 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4010 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4011 static const size_t c[28] = {
4012 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7,
4014 static const size_t i[28] = {
4015 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7,
4017 static const size_t r[28] = {
4018 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6,
4020 MAT_SUPPER_TIMES_MAT_DIAG:
4021 for (
size_t n = 0; n != n_rows * (n_rows - 1) / 2; n++) {
4023 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4049 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4050 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4051 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4053 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4054 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4056 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4057 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4058 static const size_t r[84] = {
4059 0, 1, 2, 3, 4, 5, 6, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 0, 0, 0, 1, 1, 1, 2, 2, 2,
4060 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 0, 1,
4061 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
4063 static const size_t i[84] = {
4064 1, 2, 3, 4, 5, 6, 7, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 1, 2, 3, 2, 3, 4, 3, 4, 5,
4065 4, 5, 6, 5, 6, 7, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 1, 2, 3, 4, 5, 2,
4066 3, 4, 5, 6, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7,
4068 static const size_t c[84] = {
4069 1, 2, 3, 4, 5, 6, 7, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 3, 3, 3, 4, 4, 4, 5, 5, 5,
4070 6, 6, 6, 7, 7, 7, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 5, 5, 5, 5, 5, 6,
4071 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
4073 MAT_SUPPER_TIMES_MAT_UPPER:
4074 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 6; n++) {
4076 if (i[n] == r[n] + 1) (*this)(r[n], c[n]) = 0;
4077 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4103 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4104 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4105 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4107 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4108 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4110 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4111 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4112 static const size_t c[168] = {
4113 7, 7, 7, 7, 7, 7, 7, 6, 5, 4, 3, 2, 1, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2,
4114 1, 1, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 3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 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4129 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0,
4130 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0,
4131 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4133 MAT_UPPER_TIMES_MAT_SLOWER:
4134 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 3; n++) {
4136 if (i[n] == c[n] || i[n] == (r[n] + 1)) (*this)(r[n], c[n]) = 0;
4137 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4139 for (
size_t c = 0; c != n_cols; c++) { (*this)(n_rows - 1, c) = T(0); }
4165 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4166 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4167 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4169 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4170 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4172 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4173 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4174 static const size_t r[56] = {
4175 0, 1, 2, 3, 4, 5, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3,
4176 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
4178 static const size_t i[56] = {
4179 1, 2, 3, 4, 5, 6, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6,
4180 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6,
4182 static const size_t c[56] = {
4183 2, 3, 4, 5, 6, 7, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7,
4184 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
4186 MAT_SUPPER_TIMES_MAT_SUPPER:
4187 for (
size_t n = 0; n != ((n_rows - 1) * (n_rows - 1) * (n_rows - 1) - (n_rows - 1)) / 6; n++) {
4189 if (i[n] == 1 + r[n]) (*this)(r[n], c[n]) = 0;
4190 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4192 for (
size_t i = 0; i != n_rows - 1; i++) { (*this)(i, i + 1) = T(0); }
4218 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4219 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
4220 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4224 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4225 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4227 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4228 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4229 static const size_t c[140] = {
4230 6, 6, 6, 6, 6, 6, 6, 5, 4, 3, 2, 1, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 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, 1,
4244 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
4245 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
4247 MAT_SUPPER_TIMES_MAT_SLOWER:
4249 n != (2 * (n_rows - 1) * (n_rows - 1) * (n_rows - 1) + 3 * (n_rows - 1) * (n_rows - 1) + (n_rows - 1)) / 6;
4252 if (i[n] == r[n] + 1 || i[n] == c[n] + 1) (*this)(r[n], c[n]) = T(0);
4253 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4255 for (
size_t r = 0; r != n_rows; r++) { (*this)(r, n_cols - 1) = T(0); }
4256 for (
size_t c = 0; c != n_cols - 1; c++) { (*this)(n_rows - 1, c) = T(0); }
4282 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4283 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4284 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4286 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4287 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4289 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4290 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4291 static const size_t c[224] = {
4292 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
4293 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
4294 2, 2, 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, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3,
4307 4, 5, 6, 7, 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7,
4309 static const size_t r[224] = {
4310 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4,
4311 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3,
4312 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2,
4313 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1,
4314 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
4315 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0,
4316 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
4318 MAT_SUPPER_TIMES_MAT_ASYM:
4319 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
4321 if (i[n] == r[n] + 1) (*this)(r[n], c[n]) = T(0);
4322 if (i[n] != c[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4324 for (
size_t c = 0; c != n_cols; c++) { (*this)(n_rows - 1, c) = T(0); }
4350 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4351 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4352 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4355 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4356 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4358 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4359 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4360 static const size_t c[224] = {
4361 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
4362 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
4363 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4364 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4365 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
4366 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
4367 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7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 4, 4, 4, 3, 3, 3, 3, 2, 2,
4382 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1,
4383 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
4384 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0,
4385 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
4387 MAT_SUPPER_TIMES_MAT_NORMAL_OR_SYM:
4388 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
4390 if (i[n] == r[n] + 1) (*this)(r[n], c[n]) = T(0);
4391 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4393 for (
size_t c = 0; c != n_cols; c++) { (*this)(n_rows - 1, c) = T(0); }
4418 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4419 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4420 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4422 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4423 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4424 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4425 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4426 MAT_SLOWER_TIMES_MAT_SCALAR:
4427 for (
size_t i = 0; i != (n_rows - 1) * n_rows / 2; ++i) {
4429 _data[i] = mat_L[i] * mat_R[0];
4455 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4456 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4457 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4459 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4460 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4461 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4462 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4463 static const size_t c[28] = {
4464 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6,
4466 static const size_t i[28] = {
4467 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6,
4469 static const size_t r[28] = {
4470 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
4472 MAT_SLOWER_TIMES_MAT_DIAG:
4473 for (
size_t n = 0; n != n_rows * (n_rows - 1) / 2; n++) {
4475 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4501 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4502 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4503 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4505 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4506 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4508 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4509 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4510 static const size_t c[168] = {
4511 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 1, 1,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6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
4526 2, 2, 2, 2, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4527 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7,
4528 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7,
4529 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
4531 MAT_SLOWER_TIMES_MAT_UPPER:
4532 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 3; n++) {
4534 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
4535 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4537 for (
size_t c = 0; c != n_cols; c++) { (*this)(0, c) = T(0); }
4563 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4564 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4565 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4567 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4568 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4570 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4571 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4572 static const size_t c[84] = {
4573 0, 1, 2, 3, 4, 5, 6, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 0, 0, 0, 1, 1, 1, 2, 2, 2,
4574 3, 3, 3, 4, 4, 4, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 0, 1,
4575 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
4577 static const size_t i[84] = {
4578 0, 1, 2, 3, 4, 5, 6, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 0, 1, 2, 1, 2, 3, 2, 3, 4,
4579 3, 4, 5, 4, 5, 6, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 0, 1, 2, 3, 4, 1,
4580 2, 3, 4, 5, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6,
4582 static const size_t r[84] = {
4583 1, 2, 3, 4, 5, 6, 7, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 3, 3, 3, 4, 4, 4, 5, 5, 5,
4584 6, 6, 6, 7, 7, 7, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 5, 5, 5, 5, 5, 6,
4585 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
4587 MAT_SLOWER_TIMES_MAT_LOWER:
4588 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 6; n++) {
4590 if (i[n] == c[n]) (*this)(r[n], c[n]) = 0;
4591 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4617 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4618 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4619 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4621 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4622 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4624 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4625 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4626 static const size_t c[140] = {
4627 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
4628 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 4, 4, 4, 4, 4, 4, 4, 4,
4629 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
4630 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
4632 static const size_t i[140] = {
4633 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
4634 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3,
4635 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4,
4636 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6,
4638 static const size_t r[140] = {
4639 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
4640 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 7, 7, 7, 6, 6, 6, 6,
4641 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5,
4642 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
4644 MAT_SLOWER_TIMES_MAT_SUPPER:
4646 n != (2 * (n_rows - 1) * (n_rows - 1) * (n_rows - 1) + 3 * (n_rows - 1) * (n_rows - 1) + (n_rows - 1)) / 6;
4649 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
4650 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4652 for (
size_t r = 0; r != n_rows; r++) { (*this)(r, 0) = T(0); }
4653 for (
size_t c = 1; c != n_cols; c++) { (*this)(0, c) = T(0); }
4680 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4681 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4682 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4684 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4685 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4687 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4688 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4689 static const size_t c[56] = {
4690 0, 1, 2, 3, 4, 5, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3,
4691 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
4693 static const size_t i[56] = {
4694 1, 2, 3, 4, 5, 6, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6,
4695 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6,
4697 static const size_t r[56] = {
4698 2, 3, 4, 5, 6, 7, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7,
4699 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
4701 MAT_SLOWER_TIMES_MAT_SLOWER:
4702 for (
size_t n = 0; n != ((n_rows - 1) * (n_rows - 1) * (n_rows - 1) - (n_rows - 1)) / 6; n++) {
4704 if (i[n] == 1 + c[n]) (*this)(r[n], c[n]) = 0;
4705 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4707 for (
size_t i = 0; i != n_rows - 1; i++) { (*this)(i, i - 1) = T(0); }
4733 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4734 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4735 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4737 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4738 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4740 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4741 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4742 static const size_t c[224] = {
4743 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
4744 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
4745 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4746 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4747 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
4748 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
4749 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
4751 static const size_t i[224] = {
4752 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 0, 1, 0,
4753 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 0, 1, 0, 1, 2, 0, 1,
4754 2, 3, 0, 1, 2,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3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7,
4767 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
4769 MAT_SLOWER_TIMES_MAT_ASYM:
4770 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
4772 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
4773 if (i[n] != c[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4775 for (
size_t c = 0; c != n_cols; ++c) { (*this)(0, c) = T(0); }
4800 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4801 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4802 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4805 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4806 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4808 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4809 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4810 static const size_t c[224] = {
4811 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
4812 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
4813 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4814 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4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 3, 4, 5, 6,
4828 static const size_t r[224] = {
4829 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 1, 2, 2, 3,
4830 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4,
4831 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5,
4832 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6,
4833 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6,
4834 6, 7, 7, 7, 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7,
4835 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
4837 MAT_SLOWER_TIMES_MAT_NORMAL_OR_MAT_SYM:
4838 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
4840 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
4841 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4843 for (
size_t c = 0; c != n_cols; ++c) { (*this)(0, c) = T(0); }
4868 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4869 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4870 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4872 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4873 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4874 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4875 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4876 MAT_ASYM_TIMES_MAT_DIAG:
4877 for (
size_t i = 0; i != n_rows; ++i) {
4879 for (
size_t j = 0; j != n_rows; ++j) {
4881 if (i != j) (*this)(i, j) = mat_L(i, j) * mat_R[j];
4884 for (
size_t c = 0; c != n_cols; ++c) { (*this)(c, c) = T(0); }
4909 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4910 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4911 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4913 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4914 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4915 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4916 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4917 MAT_ASYM_TIMES_MAT_SCAL:
4918 for (
size_t i = 0; i != n_rows; ++i) {
4920 for (
size_t j = i + 1; j != n_rows; ++j) {
4922 if (i != j) (*this)(i, j) = mat_L(i, j) * mat_R[0];
4949 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4950 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4951 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4953 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4954 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4955 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4956 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4957 static const size_t r[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2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
4981 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
4982 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
4983 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
4984 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
4985 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
4987 MAT_ASYM_TIMES_MAT_UPPER:
4988 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
4990 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
4991 if (r[n] != i[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
5017 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5018 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5019 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5021 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5022 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5023 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5024 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5025 static const size_t r[288] = {
5026 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5027 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
5028 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
5029 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
5030 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5031 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5032 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
5033 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
5035 static const size_t i[288] = {
5036 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 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, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
5048 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
5049 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
5050 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
5051 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
5052 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
5053 7, 6, 6, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
5055 MAT_ASYM_TIMES_MAT_LOWER:
5056 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
5058 if (i[n] == c[n]) (*this)(r[n], c[n]) = 0;
5059 if (r[n] != i[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
5085 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5086 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5087 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5089 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5090 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5091 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5092 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5093 static const size_t r[224] = {
5094 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
5095 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
5096 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
5097 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5098 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5099 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
5100 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
5102 static const size_t i[224] = {
5103 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 0, 1, 0,
5104 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0,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5, 5, 5, 6, 6, 6, 6, 6,
5117 6, 7, 7, 7, 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7,
5118 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
5120 MAT_ASYM_TIMES_SUPPER:
5121 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
5123 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
5124 if (r[n] != i[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
5126 for (
size_t r = 0; r != n_rows; r++) { (*this)(r, 0) = T(0); }
5152 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5153 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5154 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5156 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5157 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5158 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5159 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5160 static const size_t r[224] = {
5161 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
5162 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2,
5163 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
5164 3, 3, 3,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7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7,
5178 static const size_t c[224] = {
5179 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4,
5180 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3,
5181 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2,
5182 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1,
5183 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
5184 1, 0, 0, 0, 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0,
5185 0, 0, 0, 0, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
5187 MAT_ASYM_TIMES_SLOWER:
5188 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
5190 if (i[n] == c[n] + 1) (*this)(r[n], c[n]) = 0;
5191 if (r[n] != i[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
5193 for (
size_t r = 0; r != n_rows; r++) { (*this)(r, n_cols - 1) = T(0); }
5221 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5222 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
5223 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5225 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5226 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5228 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5229 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5230 MAT_ASYM_TIMES_MAT_NORMAL:
5231 for (
size_t i = 0; i != comm; ++i) {
5233 for (
size_t r = 0; r != n_rows; ++r) {
5236 for (
size_t c = 0; c != n_cols; ++c) {
5238 if (i == 0) (*this)(r, c) = T(0);
5239 if (r != i) (*this)(r, c) += mat_L(r, i) * mat_R(i, c);
5267 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5268 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5269 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5271 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5272 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5274 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5275 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5276 MAT_ASYM_TIMES_MAT_ASYM:
5278 for (
size_t r = 0; r != n_rows; ++r) {
5281 for (
size_t c = 0; c != n_cols; ++c) {
5282 for (
size_t i = 0; i != comm; ++i) {
5284 if (i == 0) (*this)(r, c) = T(0);
5285 if (i != c && i != r) (*this)(r, c) += mat_L(r, i) * mat_R(i, c);
5315 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5316 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
5317 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5323 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5324 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5326 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5327 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5329 for (
size_t c = 0; c < n_cols; ++c) {
5330 for (
size_t i = 0; i < comm; ++i) {
5332 for (
size_t r = 0; r < n_rows; ++r) {
5334 (*this)(r, c) += mat_L(r, i) * mat_R(i, c);
5364 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5365 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5366 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5367 std::enable_if_t<(std::is_same<T2, bool>::value && !std::is_same<T1, bool>::value) &&
5373 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5374 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5376 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5377 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5379 for (
size_t r = 0; r != n_rows; ++r) {
5382 for (
size_t c = 0; c != n_cols; ++c) {
5384 for (
size_t i = 0; i != comm; ++i) {
5386 if (i == 0) (*this)(r, c) = T(0);
5387 if (mat_R(i, c) != 0) (*this)(r, c) += mat_L(r, i);
5413 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5414 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5415 typename T2,
size_t rows_,
size_t cols_,
MatType type1,
MatType type2,
5416 std::enable_if_t<rows_ == n_rows && cols_ == n_cols && type1 == type && type2 == type, bool> =
true>
5417 Mat&
emul(
const M1<T1, rows_, cols_, type1, _unused1...>& mat_L,
5418 const M2<T2, rows_, cols_, type2, _unused2...>& mat_R) {
5419 for (
size_t i = 0; i !=
size(); ++i) {
5421 _data[i] = mat_L[i] * mat_R[i];
5440 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5441 MatType type2,
size_t rows_,
size_t cols_>
5443 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
5444 "the matrix's columns.'.");
5445 static_assert(
size() == rows_,
"Element number should be rows_ in Mat::col(mat, index).");
5446 for (
size_t i = 0; i !=
size(); ++i) {
5448 _data[i] = mat(i, c);
5453 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5454 MatType type2,
size_t rows_,
size_t cols_>
5455 [[deprecated(
"Use .col_ to create a MatRefCol to write a column instead.")]]
void
5457 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
5458 "the matrix's columns.'.");
5459 assert(mat.size() == n_rows &&
"Element number should be n_rows in Mat::col(index, mat).");
5460 for (
int i = 0; i != mat.size(); ++i) {
5462 (*this)(i, c) = mat[i];
5481 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
5482 "the matrix's columns.'.");
5484 for (
size_t i = 0; i != n_rows; ++i) {
5486 mat(i, 0) = (*this)(i, c);
5497 assert(index < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number "
5498 "of the matrix's columns.'.");
5499 return { *
this, index };
5503 assert(index < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number "
5504 "of the matrix's columns.'.");
5505 return { *
this, index };
5523 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5524 MatType type2,
size_t rows_,
size_t cols_>
5526 assert(r < rows_ &&
"row should be smaller than rows_ of mat in Mat::row.");
5527 static_assert(
size() == cols_,
"The number of the Matrices' n_cols should meet.");
5528 for (
size_t j = 0; j !=
size(); ++j) {
5530 _data[j] = mat(r, j);
5550 assert(r < n_rows &&
"Take the specific row by index requires 'The index should be smaller than the number of "
5551 "the matrix's rows.'.");
5553 for (
size_t j = 0; j != n_cols; ++j) {
5555 mat(0, j) = (*this)(r, j);
5589 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5590 MatType type2,
size_t rows_,
size_t cols_>
5592 assert(first_col < n_cols &&
"Take the successive n_cols by index requires 'The indexes should be smaller than "
5593 "the number of the matrix's columns.'.");
5594 assert(first_col >
int(0) &&
5595 "Take the successive n_cols by index requires 'The indexes can't be smaller than 0'.");
5596 static_assert(n_rows == rows_,
"The number of the Matrices' rows should meet.");
5597 for (
size_t j = 0; j != n_cols; ++j) {
5599 for (
size_t i = 0; i != n_rows; ++i) {
5601 (*this)(i, j) = mat(i, j + first_col);
5626 template <
size_t _cols>
5628 assert(first_col < n_cols &&
"Take the successive n_cols by index requires 'The indexes should be smaller than "
5629 "the number of the matrix's columns.'.");
5630 assert(first_col >
int(0) &&
5631 "Take the successive n_cols by index requires 'The indexes can't be smaller than 0'.");
5632 static_assert(_cols > int(1),
5633 "Take the successive n_cols by index requires 'The total number can't be smaller than 1'.");
5636 for (
size_t j = 0; j != _cols; ++j) {
5638 for (
size_t i = 0; i != n_rows; ++i) {
5640 mat(i, j) = (*this)(i, j + first_col);
5651 template <
size_t first_col,
size_t last_col>
5653 static_assert(first_col > int(0),
5654 "Take the successive cols by index requires 'The first index can't be smaller than 0'.");
5656 first_col < last_col,
5657 "Take the successive cols by index requires 'The first index should be smaller than the last index'.");
5658 static_assert(last_col < n_cols,
"Take the successive cols by index requires 'The last index should be smaller "
5659 "than the number of the matrix's cols.'.");
5679 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5680 MatType type2,
size_t rows_,
size_t cols_>
5682 assert(first_row < n_rows &&
"Take the successive n_rows by index requires 'The indexes should be smaller than "
5683 "the number of the matrix's rows.'.");
5684 assert(first_row >
int(0) &&
5685 "Take the successive n_rows by index requires 'The indexes can't be smaller than 0'.");
5686 static_assert(n_cols == cols_,
"The number of the Matrices' cols should meet.");
5687 for (
size_t i = 0; i != n_rows; ++i) {
5689 for (
size_t j = 0; j != n_cols; ++j) {
5691 (*this)(i, j) = mat(i + first_row, j);
5717 template <
size_t _rows>
5719 assert(first_row < n_rows &&
"Take the successive n_rows by index requires 'The indexes should be smaller than "
5720 "the number of the matrix's rows.'.");
5721 assert(first_row >
int(0) &&
5722 "Take the successive n_rows by index requires 'The indexes can't be smaller than 0'.");
5723 static_assert(_rows > int(1),
5724 "Take the successive n_rows by index requires 'The total number can't be smaller than 1'.");
5727 for (
size_t i = 0; i != _rows; ++i) {
5729 for (
size_t j = 0; j != n_cols; ++j) {
5731 mat(i, j) = (*this)(i + first_row, j);
5743 template <
size_t first_row,
size_t last_row>
5746 first_row < last_row,
5747 "Take the successive rows by index requires 'The first index should be smaller than the last index'.");
5748 static_assert(last_row < n_rows,
"Take the successive rows by index requires 'The last index should be smaller "
5749 "than the number of the matrix's rows.'.");
5771 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
typename M2,
5772 typename T1,
MatType type1,
size_t rows_,
size_t cols_>
5773 Mat&
rows(
const M1<T1, rows_, cols_, type1, _unused1...>& mat, M2 vector) {
5774 static_assert(n_cols == cols_,
"The number of the Matrices' cols should meet.");
5775 for (
size_t i = 0; i != n_rows; ++i) {
5777 assert(vector[i] >
int(0) &&
5778 "Take the discrete n_rows by index requires 'The indexes can't be smaller than 0'.");
5779 assert(vector[i] < n_rows &&
"Take the discrete n_rows by index requires 'The indexes should be smaller "
5780 "than the number of the matrix's rows.'.");
5781 for (
size_t j = 0; j != n_cols; ++j) {
5783 (*this)(i, j) = mat(vector[i], j);
5808 template <
size_t _rows,
typename M2>
5811 for (
size_t i = 0; i != _rows; ++i) {
5813 assert(vector[i] >=
int(0) &&
5814 "Take the discrete n_rows by index requires 'The indexes can't be smaller than 0'.");
5815 assert(vector[i] < n_rows &&
"Take the discrete n_rows by index requires 'The indexes should be smaller "
5816 "than the number of the matrix's rows.'.");
5817 for (
size_t j = 0; j != n_cols; ++j) {
5819 mat(i, j) = (*this)(vector[i], j);
5843 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
typename M2,
5844 typename T1,
MatType type1,
size_t rows_,
size_t cols_>
5845 Mat&
cols(
const M1<T1, rows_, cols_, type1, _unused1...>& mat, M2 vector) {
5846 static_assert(n_rows == rows_,
"The number of the Matrices' rows should meet.");
5847 for (
size_t j = 0; j != n_cols; ++j) {
5849 assert(vector[j] >=
int(0) &&
5850 "Take the discrete n_cols by index requires 'The indexes can't be smaller than 0'.");
5851 assert(vector[j] < n_cols &&
"Take the discrete n_cols by index requires 'The indexes should be smaller "
5852 "than the number of the matrix's cols.'.");
5853 for (
size_t i = 0; i != n_rows; ++i) {
5855 (*this)(i, j) = mat(i, vector[j]);
5880 template <
size_t _cols,
typename M2>
5883 for (
size_t j = 0; j != _cols; ++j) {
5885 assert(vector[j] >=
int(0) &&
5886 "Take the discrete n_cols by index requires 'The indexes can't be smaller than 0'.");
5887 assert(vector[j] < n_cols &&
"Take the discrete n_cols by index requires 'The indexes should be smaller "
5888 "than the number of the matrix's cols.'.");
5889 for (
size_t i = 0; i != n_cols; ++i) {
5891 mat(i, j) = (*this)(i, vector[j]);
5904 for (
size_t i = 0; i !=
size(); ++i) {
5925 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5931 MAT_TRANSPOSE_NORMAL:
5932 for (
size_t i = 0; i != n_cols; ++i) {
5934 for (
size_t j = 0; j != n_rows; ++j) {
5936 _data[n_rows * i + j] = mat._data[n_rows * j + i];
5940 MAT_TRANSPOSE_UPPER:
5941 for (
size_t i = 0; i != n_cols; ++i) {
5943 for (
size_t j = i; j != n_rows; ++j) {
5945 (*this)(i, j) = mat(j, i);
5949 MAT_TRANSPOSE_LOWER:
5950 for (
size_t i = 0; i != n_cols; ++i) {
5952 for (
size_t j = 0; j <= i; ++j) {
5954 (*this)(i, j) = mat(j, i);
5958 MAT_TRANSPOSE_SUPPER:
5959 for (
size_t i = 0; i != n_cols; ++i) {
5961 for (
size_t j = i; j != n_rows; ++j) {
5963 (*this)(i, j) = mat(j, i);
5967 MAT_TRANSPOSE_SLOWER:
5968 for (
size_t i = 0; i != n_cols; ++i) {
5970 for (
size_t j = i; j != n_rows; ++j) {
5972 (*this)(i, j) = mat(j, i);
5977 for (
size_t i = 0; i != n_cols; ++i) {
5979 for (
size_t j = i + 1; j != n_rows; ++j) {
5981 (*this)(i, j) = mat(j, i);
5985 assert(!
"Impossible");
6004 template <
typename... _unused,
MatType _type = type,
6005 typename std::enable_if_t<_type == MatType::NORMAL, bool> =
true>
6008 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6009 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6011 MAT_TRANSPOSE_NORMAL:
6012 for (
size_t i = 0; i != n_cols; ++i) {
6014 for (
size_t j = 0; j != n_rows; ++j) {
6016 mat(i, j) = (*this)(j, i);
6034 template <
typename... _unused,
MatType _type = type,
6035 typename std::enable_if_t<
6038 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6056 template <
typename... _unused,
MatType _type = type,
6057 typename std::enable_if_t<_type == MatType::UPPER, bool> =
true>
6059 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6060 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6062 MAT_TRANSPOSE_NORMAL:
6063 for (
size_t i = 0; i != n_cols; ++i) {
6065 for (
size_t j = 0; j != n_rows; ++j) {
6067 mat(i, j) = (*this)(j, i);
6087 template <
typename... _unused,
MatType _type = type,
6088 typename std::enable_if_t<_type == MatType::LOWER, bool> =
true>
6090 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6091 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6093 MAT_TRANSPOSE_LOWER:
6094 for (
size_t i = 0; i != n_cols; ++i) {
6096 for (
size_t j = i; j <= i; ++j) {
6098 mat(j, i) = (*this)(i, j);
6118 template <
typename... _unused,
MatType _type = type,
6119 typename std::enable_if_t<_type == MatType::SUPPER, bool> =
true>
6121 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6122 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6124 MAT_TRANSPOSE_SUPPER:
6125 for (
size_t i = 0; i != n_cols - 1; ++i) {
6127 for (
size_t j = i + 1; j != n_rows; ++j) {
6129 mat(j, i) = (*this)(i, j);
6149 template <
typename... _unused,
MatType _type = type,
6150 typename std::enable_if_t<_type == MatType::SLOWER, bool> =
true>
6152 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6153 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6155 MAT_TRANSPOSE_SLOWER:
6156 for (
size_t i = 1; i != n_cols; ++i) {
6158 for (
size_t j = i + 1; j != n_rows - 1; ++j) {
6160 mat(j, i) = (*this)(i, j);
6180 template <
typename... _unused,
MatType _type = type,
typename std::enable_if_t<_type == MatType::ASYM, bool> =
true>
6182 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6185 for (
size_t i = 1; i != n_cols; ++i) {
6187 for (
size_t j = i + 1; j != n_rows - 1; ++j) {
6189 mat(j, i) = (*this)(i, j);
6214 static_assert(type !=
MatType::UPPER,
"Upper matrix cannot perform in place transpose.");
6215 static_assert(type !=
MatType::LOWER,
"Lower matrix cannot perform in place transpose.");
6216 static_assert(type !=
MatType::SUPPER,
"Strict upper matrix cannot perform in place transpose.");
6217 static_assert(type !=
MatType::SLOWER,
"Strict lower matrix cannot perform in place transpose.");
6218 static_assert(n_rows == n_cols,
"In-place transpose requires a square matrix.");
6220 MAT_NORMAL_TRANSPOSE_SELF:
6221 for (
size_t i = 0; i != n_cols; ++i) {
6223 for (
size_t j = i; j != n_cols; ++j) {
6225 std::swap(
_data[n_cols * i + j],
_data[n_cols * j + i]);
6229 MAT_AYSM_TRANSPOSE_SELF:
6230 for (
size_t i = 0; i != n_cols * (n_cols - 1) / 2; ++i) {
6251 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2>
6254 for (
size_t i = 0; i !=
size(); ++i) {
6278 for (
size_t i = 0; i !=
size(); ++i) {
6306 for (
size_t i = 0; i !=
size(); ++i) {
6325 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6328 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6329 for (
size_t i = 0; i != n_rows; ++i) {
6331 (*this)(i, i) = mat(i, i);
6352 for (
size_t i = 0; i != n_rows; ++i) {
6354 mat(i, i) = (*this)(i, i);
6365 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6382 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6385 static_assert(n_cols == 1,
"Diagonal vector has column number as 1.");
6386 for (
size_t i = 0; i != n_rows; ++i) {
6388 _data[i] = mat(i, i);
6408 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6410 for (
size_t i = 0; i != n_rows; ++i) {
6412 mat.
_data[i] = (*this)(i, i);
6423 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6440 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6443 static_assert(n_rows == 1,
"Diagonal vector has column number as 1.");
6444 for (
size_t i = 0; i != n_cols; ++i) {
6446 _data[i] = mat(i, i);
6466 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6468 for (
size_t i = 0; i != n_cols; ++i) {
6470 mat.
_data[i] = (*this)(i, i);
6481 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6498 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6501 static_assert(n_rows == n_cols,
"Take the off diagonal requires 'n_rows == n_cols'.");
6502 static_assert(type ==
MatType::NORMAL,
"Take the off diagonal requires the matrix to be NORMAL.");
6503 for (
size_t i = 0; i != n_rows; ++i) {
6505 for (
size_t j = 0; j != n_cols; ++j) {
6507 if (i != j) (*this)(i, j) = mat(i, j);
6508 else (*
this)(i, j) = T(0);
6529 static_assert(n_rows == n_cols,
"Take the off diagonal requires 'n_rows == n_cols'.");
6530 static_assert(type ==
MatType::NORMAL,
"Take the off diagonal requires the matrix to be NORMAL.");
6532 for (
size_t i = 0; i != n_rows; ++i) {
6534 for (
size_t j = 0; j != n_cols; ++j) {
6536 if (i != j) mat(i, j) = (*this)(i, j);
6537 else mat(i, j) = T(0);
6549 static_assert(n_rows == n_cols,
"Take the off diagonal requires 'n_rows == n_cols'.");
6569 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6572 static_assert(type ==
MatType::DIAGONAL,
"'invDiag' is only used for diagonal matrix.");
6573 for (
size_t i = 0; i != n_rows; ++i) {
6575 _data[i] = T(1.0) / mat(i, i);
6587 static_assert(type ==
MatType::DIAGONAL,
"'invDiag' is only used for diagonal matrix.");
6589 for (
size_t i = 0; i != n_rows; ++i) {
6606 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6609 static_assert(n_rows == n_cols,
"Calculate inverse needs to be a square matrix.");
6610 assert(iter >= 1 &&
"At least one iteration is needed.");
6611 const auto D = mat.diagMat_();
6612 const auto E = mat.offDiag_();
6617 auto D_inv_opp = -D_inv;
6622 for (
size_t i = 1; i < iter; ++i) {
6623 tmp.
mul(*
this, product);
6627 this->
mul(sum_tmp, D_inv);
6628 return *
this += D_inv;
6642 static_assert(n_rows == n_cols,
"Calculate inverse needs to be a square matrix.");
6663 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6664 MatType type2,
typename coeff_type>
6666 static_assert(n_rows == n_cols,
"Calculate inverse needs to be a square matrix.");
6667 assert(iter >= 1 &&
"At least one iteration is needed.");
6679 template <
typename coeff_type>
6681 static_assert(n_rows == n_cols,
"Calculate inverse needs to be a square matrix.");
6688 template <
typename Tp = T>
6691 for (
size_t i = 0; i !=
size(); ++i) {
6704 static_assert(n_rows == 1 && n_cols == 1,
"This only applies to matrix of size 1x1.");
6714 static_assert(n_rows == 1 && n_cols == 1,
"This only applies to matrix of size 1x1.");
6724 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const {
6725#ifndef __SYNTHESIS__
6726 static_assert(n_rows > 0 && n_cols > 0,
"Print requires this matrix be of valid size.");
6728 for (
size_t i = 0; i + 1 < n_rows; ++i) {
6730 for (
size_t j = 0; j + 1 < n_cols; ++j) os <<
static_cast<T
>((*
this)(i, j)) <<
", ";
6731 os << static_cast<T>((*
this)(i, n_cols - 1)) <<
"]," << std::endl;
6734 for (
size_t j = 0; j + 1 < n_cols; ++j) os <<
static_cast<T
>((*
this)(n_rows - 1, j)) <<
", ";
6735 os << static_cast<T>((*
this)(n_rows - 1, n_cols - 1)) <<
"]]" << std::endl;
6786 if (r == c) (*this)(r, c) =
value;
6788 if (r <= c) (*this)(r, c) =
value;
6790 if (r >= c) (*this)(r, c) =
value;
6792 if (r < c) (*this)(r, c) =
value;
6794 if (r > c) (*this)(r, c) =
value;
6796 if (r <= c) (*this)(r, c) =
value;
6798 if (r < c) (*this)(r, c) =
value;
6800 (*this)(r, c) =
value;
6802 assert(!
"Impossible! Unknown type!");
6816 if (r >= n_rows || c >= n_cols)
return;
6832 if (r == c) (*this)(r, c) +=
value;
6834 if (r <= c) (*this)(r, c) +=
value;
6836 if (r >= c) (*this)(r, c) +=
value;
6838 if (r < c) (*this)(r, c) +=
value;
6840 if (r > c) (*this)(r, c) +=
value;
6842 if (r != c) (*this)(r, c) +=
value;
6844 (*this)(r, c) +=
value;
6846 (*this)(r, c) +=
value;
6848 assert(!
"Impossible! Unknown type!");
6865 template <
typename Tmp,
typename M,
typename Comm,
typename Zero>
6867 Comm __attribute__((unused)) _comm_foo, Zero zero)
const {
6869 constexpr size_t comm = Comm::value;
6871 for (
size_t j = 0; j < n_rows; ++j) {
6873 tmp_L[j][0] = ((j <= i + begin_shift) && (i + begin_shift - j < comm))
6874 ? mat_L(j, comm - 1 - (i + begin_shift - j))
6892 template <
typename Tmp,
typename M,
typename Comm,
typename Zero>
6894 Comm __attribute__((unused)) _comm_foo, Zero zero)
const {
6896 constexpr size_t comm = Comm::value;
6898 for (
size_t j = 0; j < n_cols; ++j) {
6900 tmp_R[0][j] = ((j <= i + begin_shift) && (i + begin_shift - j < comm))
6901 ? mat_R(comm - 1 - (i + begin_shift - j), j)
6916 template <
typename T1,
typename T2,
typename HLSVec>
6917 inline void _sa_multiply(
const T1& tmp_L,
const T2& tmp_R,
const HLSVec& use_assign) {
6920 for (
size_t r = 0; r != n_rows; ++r) {
6922 for (
size_t c = 0; c != n_cols; ++c) {
6924 T result = tmp_L[r][c] * tmp_R[r][c];
6925 if (use_assign[r * n_cols + c]) {
6956 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
6957 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
6960 const M2<T2, comm, n_cols, type2, _unused2...>& mat_R,
size_t begin_shift = 0,
6961 size_t end_shift = 0) {
6964 T1 tmp_L[n_rows][n_cols];
6965 T2 tmp_R[n_rows][n_cols];
6966 std::vector<bool> use_assign(n_rows * n_cols,
true);
6968#ifdef FLAMES_MAT_PARTITION_COMPLETE
6969 FLAMES_PRAGMA(ARRAY_PARTITION variable = tmp_L type = complete)
6970 FLAMES_PRAGMA(ARRAY_PARTITION variable = tmp_R type = complete)
6975 auto write_L = [&](
size_t i) {
6976 if (i + 1 != n_rows + comm + n_cols - 2 - begin_shift - end_shift) {
6978 for (
size_t c = n_cols; c > 1; --c) {
6980 for (
size_t r = 0; r < n_rows; ++r) {
6982 if (c <= i + 2 && r + c <= i + begin_shift + 2 && r <= i) { tmp_L[r][c - 1] = tmp_L[r][c - 2]; }
6988 auto write_R = [&](
size_t i) {
6989 if (i + 1 != n_rows + comm + n_cols - 2 - begin_shift - end_shift) {
6991 for (
size_t r = n_rows; r > 1; --r) {
6993 for (
size_t c = 0; c < n_cols; ++c) {
6995 if (r <= i + 2 && c + r <= i + begin_shift + 2 && c <= i) { tmp_R[r - 1][c] = tmp_R[r - 2][c]; }
7001 auto set_assign_ctl = [&](
size_t i) {
7004 for (
size_t r = 0; r < n_rows; ++r) {
7007 if (c < n_cols) { use_assign[r * n_cols + c] =
false; }
7010 std::integral_constant<int, comm> _comm_foo = {};
7011 SYSTOLIC_ARRAY_MAT_MUL:
7012 for (
size_t i = 0; i < n_rows + comm + n_cols - 2 - begin_shift - end_shift; ++i) {
7043 : (1 + n_rows) * n_rows / 2];
7046template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
7071 inline static constexpr size_t size() noexcept {
7078 : (1 + n_rows) * n_rows / 2;
7082 for (
size_t i = 0; i !=
size(); ++i) {
7089 template <
typename M>
7091 for (
size_t i = 0; i !=
size(); ++i) {
7106 assert(r < n_rows &&
"Matrix row index should be within range");
7107 assert(c < n_cols &&
"Matrix col index should be within range");
7109 return _data[r * n_cols + c];
7111 if (r == c)
return _data[r];
7114 if (r == c)
return _data[0];
7117 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7120 if (r >= c)
return _data[(1 + r) * r / 2 + c];
7123 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 2 * r - 1];
7126 if (r >= c)
return _data[(1 + r) * r / 2 + c - r];
7129 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7130 else return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7132 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r * 2 - 1];
7133 else if (r > c)
return -
_data[(2 * n_cols + 1 - c) * c / 2 + r - c * 2 - 1];
7137 assert(!
"Impossible! Unknown MatType!");
7150 assert(index <
size() &&
"[index] should be in range in MatView");
7151 return _data[index];
7168 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7169 MatType type2,
size_t rows_,
size_t cols_>
7171 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7172 "the matrix's columns.'.");
7173 static_assert(
size() == rows_,
"Element number should be rows_ in Mat::col(mat, index).");
7174 for (
size_t i = 0; i !=
size(); ++i) {
7176 _data[i] = mat(i, c);
7181 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7182 MatType type2,
size_t rows_,
size_t cols_>
7184 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7185 "the matrix's columns.'.");
7186 assert(mat.size() == n_rows &&
"Element number should be n_rows in Mat::col(index, mat).");
7187 for (
int i = 0; i != mat.size(); ++i) {
7189 (*this)(i, c) = mat[i];
7208 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7209 "the matrix's columns.'.");
7211 for (
size_t i = 0; i != n_rows; ++i) {
7213 mat(i, 0) = (*this)(i, c);
7218 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7223 for (
size_t i = 0; i !=
size(); ++i) {
7225 _data[i] += mat_R[i];
7230 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7235 for (
size_t i = 0; i !=
size(); ++i) {
7237 _data[i] -= mat_R[i];
7244 template <
typename Tp = T>
7247 for (
size_t i = 0; i !=
size(); ++i) {
7254 template <
typename Tp = T>
7257 for (
size_t i = 0; i !=
size(); ++i) {
7260 if (d > 0) p +=
static_cast<Tp
>(d);
7285 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
7292template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
7316 inline static constexpr size_t size() noexcept {
7323 : (1 + n_rows) * n_rows / 2;
7327 for (
size_t i = 0; i !=
size(); ++i) {
7334 template <
typename M>
7336 for (
size_t i = 0; i !=
size(); ++i) {
7351 assert(r < n_rows &&
"Matrix row index should be within range");
7352 assert(c < n_cols &&
"Matrix col index should be within range");
7354 return _data[r * n_cols + c];
7356 if (r == c)
return _data[r];
7359 if (r == c)
return _data[0];
7362 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7365 if (r >= c)
return _data[(1 + r) * r / 2 + c];
7368 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 2 * r - 1];
7371 if (r >= c)
return _data[(1 + r) * r / 2 + c - r];
7374 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7375 else return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7377 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r * 2 - 1];
7378 else if (r > c)
return -
_data[(2 * n_cols + 1 - c) * c / 2 + r - c * 2 - 1];
7382 assert(!
"Impossible! Unknown MatType!");
7396 assert(r < n_rows &&
"Matrix row index should be within range");
7397 assert(c < n_cols &&
"Matrix col index should be within range");
7399 return _data[r * n_cols + c];
7401 if (r == c)
return _data[r];
7402 else assert(!
"This element cannot be modified (DIAGONAL).");
7404 assert(!
"This element cannot be modified (SCALAR).");
7406 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7407 else assert(!
"This element cannot be modified (UPPER).");
7409 if (r >= c)
return _data[(1 + r) * r / 2 + c];
7410 else assert(!
"This element cannot be modified (LOWER).");
7412 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
7413 else assert(!
"This element cannot be modified (SUPPER).");
7415 if (r > c)
return _data[(1 + r) * r / 2 + c - r];
7416 else assert(!
"This element cannot be modified (SLOWER).");
7418 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7419 else return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7421 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
7422 else if (r > c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - 1 - 2 * c];
7427 else assert(!
"This element cannot be modified (ASYM).");
7430 assert(!
"Impossible! Unknown MatType!");
7444 assert(index <
size() &&
"[index] should be in range in MatView");
7445 return _data[index];
7456 assert(index <
size() &&
"[index] should be in range in MatView");
7457 return _data[index];
7466 for (
size_t i = 0; i !=
size(); ++i) {
7492 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7493 MatType type2,
size_t rows_,
size_t cols_>
7495 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7496 "the matrix's columns.'.");
7497 static_assert(
size() == rows_,
"Element number should be rows_ in Mat::col(mat, index).");
7498 for (
size_t i = 0; i !=
size(); ++i) {
7500 _data[i] = mat(i, c);
7505 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7506 MatType type2,
size_t rows_,
size_t cols_>
7508 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7509 "the matrix's columns.'.");
7510 assert(mat.size() == n_rows &&
"Element number should be n_rows in Mat::col(index, mat).");
7511 for (
int i = 0; i != mat.size(); ++i) {
7513 (*this)(i, c) = mat[i];
7532 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7533 "the matrix's columns.'.");
7535 for (
size_t i = 0; i != n_rows; ++i) {
7537 mat(i, 0) = (*this)(i, c);
7542 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7547 for (
size_t i = 0; i !=
size(); ++i) {
7549 _data[i] += mat_R[i];
7554 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7559 for (
size_t i = 0; i !=
size(); ++i) {
7561 _data[i] -= mat_R[i];
7568 template <
typename Tp = T>
7571 for (
size_t i = 0; i !=
size(); ++i) {
7578 template <
typename Tp = T>
7581 for (
size_t i = 0; i !=
size(); ++i) {
7584 if (d > 0) p +=
static_cast<Tp
>(d);
7609 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
7616template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
7638 inline static constexpr size_t size() noexcept {
7645 : (1 + n_rows) * n_rows / 2;
7657 assert(r < n_rows &&
"Matrix row index should be within range");
7658 assert(c < n_cols &&
"Matrix col index should be within range");
7660 return -
_data[r * n_cols + c];
7662 if (r == c)
return -
_data[r];
7665 if (r == c)
return -
_data[0];
7668 if (r <= c)
return -
_data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7671 if (r >= c)
return -
_data[(1 + r) * r / 2 + c];
7674 if (r < c)
return -
_data[(2 * n_cols + 1 - r) * r / 2 + c - 2 * r - 1];
7677 if (r >= c)
return -
_data[(1 + r) * r / 2 + c - r];
7680 if (r <= c)
return -
_data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7681 else return -
_data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7683 if (r < c)
return -
_data[(2 * n_cols + 1 - r) * r / 2 + c - r * 2 - 1];
7684 else if (r > c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - c * 2 - 1];
7688 assert(!
"Impossible! Unknown MatType!");
7700 assert(index <
size() &&
"[index] should be in range in MatViewOpp");
7701 return -
_data[index];
7728template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
7755 inline static constexpr size_t size() noexcept {
7762 : (1 + n_rows) * n_rows / 2;
7774 assert(r < n_rows &&
"Matrix row index should be within range");
7775 assert(c < n_cols &&
"Matrix col index should be within range");
7777 return _data[c * n_rows + r];
7779 if (r == c)
return _data[r];
7782 if (r == c)
return _data[0];
7785 if (r <= c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7788 if (r >= c)
return _data[(1 + c) * c / 2 + r];
7791 if (r < c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - 2 * c - 1];
7794 if (r >= c)
return _data[(1 + c) * c / 2 + r - c];
7797 if (r <= c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7798 else return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7800 if (r < c)
return -
_data[(2 * n_cols + 1 - r) * r / 2 + c - r * 2 - 1];
7801 else if (r > c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - c * 2 - 1];
7805 assert(!
"Impossible! Unknown MatType!");
7827 c = r + index - (2 * n_cols + 1 - r) * r / 2;
7830 c = index - (r + 1) * r / 2;
7833 c = 2 * r + 1 + index - c - (2 * n_cols + 1 - r) * r / 2;
7836 c = index - (1 + r) * r / 2 + r;
7839 c = r + index - (2 * n_cols + 1 - r) * r / 2;
7842 c = 2 * r + 1 + index - c - (2 * n_cols + 1 - r) * r / 2;
7844 return (*
this)(r, c);
7877template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent>
7886 static_assert(type ==
MatType::DIAGONAL && N == N_,
"DiagMat is and comes from a square matrix.");
7904 for (
size_t i = 0; i != N; ++i) {
7906 mat[i] =
static_cast<T
>(1) / (*
this)[i];
7916 inline static constexpr size_t size() noexcept {
7931 inline static constexpr MatType pType() noexcept {
return matType<type_parent>(); }
7941 if (r != c)
return T(0);
7944 return _data[r * N + c];
7950 return _data[(2 * N + 1 - r) * r / 2];
7952 return _data[(1 + r) * r / 2 + r];
7958 return _data[(2 * N + 1 - r) * r / 2];
7963 assert(!
"Impossible! Unknown MatType!");
7973 T
operator[](
size_t index)
const {
return (*
this)(index, index); }
7986 for (
size_t i = 0; i != N; ++i) {
7988 mat[i] = (*this)[i];
8013template <
typename T,
size_t N,
size_t n_cols, MatType type,
typename type_parent>
8022 static_assert(n_cols == 1,
"DiagVec is a column vector.");
8037 inline static constexpr size_t size() noexcept {
8055 for (
size_t i = 0; i != N; ++i) {
8057 mat[i] =
static_cast<T
>(1) / (*
this)[i];
8067 inline static constexpr MatType pType() noexcept {
return matType<type_parent>(); }
8077 assert(c == 0 &&
"Column vector's column index should always be 0.");
8080 return _data[r * N + r];
8086 return _data[(2 * N + 1 - r) * r / 2];
8088 return _data[(1 + r) * r / 2 + r];
8094 return _data[(2 * N + 1 - r) * r / 2];
8099 assert(!
"Impossible! Unknown MatType!");
8119 for (
size_t i = 0; i != N; ++i) {
8121 mat[i] = (*this)[i];
8155template <
typename T,
size_t n_rows,
size_t N, MatType type,
typename type_parent>
8164 static_assert(n_rows == 1,
"DiagRowVec is a row vector.");
8179 inline static constexpr size_t size() noexcept {
8194 inline static constexpr MatType pType() noexcept {
return matType<type_parent>(); }
8204 assert(r == 0 &&
"Row vector's row index should always be 0.");
8207 return _data[c * N + c];
8213 return _data[(2 * N + 1 - c) * c / 2];
8215 return _data[(1 + c) * c / 2 + c];
8221 return _data[(2 * N + 1 - c) * c / 2];
8226 assert(!
"Impossible! Unknown MatType!");
8246 for (
size_t i = 0; i != N; ++i) {
8248 mat[i] = (*this)[i];
8282template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent>
8291 static_assert(type ==
MatType::NORMAL && N == N_,
"OffDiag is and comes from a square and normal matrix.");
8306 inline static constexpr size_t size() noexcept {
8321 inline static constexpr MatType pType() noexcept {
return matType<type_parent>(); }
8331 if (r == c)
return T(0);
8334 return _data[r * N + c];
8336 if (r == c)
return _data[r];
8339 if (r == c)
return _data[0];
8342 if (r <= c)
return _data[(2 * N + 1 - r) * r / 2 + c - r];
8345 if (r >= c)
return _data[(1 + r) * r / 2 + c];
8348 if (r < c)
return _data[(2 * N + 1 - r) * r / 2 + c - 2 * r - 1];
8351 if (r >= c)
return _data[(1 + r) * r / 2 + c - r];
8354 if (r <= c)
return _data[(2 * N + 1 - r) * r / 2 + c - r];
8355 else return _data[(2 * N + 1 - c) * c / 2 + r - c];
8357 if (r < c)
return _data[(2 * N + 1 - r) * r / 2 + c - r * 2 - 1];
8358 else if (r > c)
return -
_data[(2 * N + 1 - c) * c / 2 + r - c * 2 - 1];
8362 assert(!
"Impossible! Unknown MatType!");
8374 if (index % (N + 1) == 0)
return T(0);
8375 else return this->
_data[index];
8386 for (
size_t i = 0; i != N * N; ++i) {
8388 if (i % (N + 1) == 0) mat[i] = 0;
8389 else mat[i] = this->
_data[i];
8413template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent>
8421 MatViewCol(
const Mat<T, n_rows, n_cols, matType<type_parent>()>& m,
size_t index) :
_data(m.rawDataPtr() + index) {
8422 static_assert(type ==
MatType::NORMAL,
"We only support limited matType.");
8423 assert(index < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number "
8424 "of the matrix's cols.'");
8439 inline static constexpr size_t size() noexcept {
return n_rows; }
8446 inline static constexpr MatType pType() noexcept {
return matType<type_parent>(); }
8456 assert(c == 0 &&
"Column vector's column index should always be 0.");
8457 assert(r < n_rows &&
"Matrix row index should be within range");
8460 return _data[r * n_cols];
8463 assert(!
"Impossible! Unknown MatType!");
8483 for (
size_t i = 0; i != n_rows; ++i) {
8485 mat[i] = (*this)[i];
8510 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
8521template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent>
8529 MatViewRow(
const Mat<T, n_rows, n_cols, matType<type_parent>()>& m,
size_t index)
8530 :
_data(m.rawDataPtr() + index * n_cols) {
8531 static_assert(type ==
MatType::NORMAL,
"We only support limited matType.");
8532 assert(index < n_rows &&
"Take the specific row by index requires 'The index should be smaller than the number "
8533 "of the matrix's rows.'");
8548 inline static constexpr size_t size() noexcept {
return n_cols; }
8555 inline static constexpr MatType pType() noexcept {
return matType<type_parent>(); }
8565 assert(r == 0 &&
"Row vector's row index should always be 0.");
8566 assert(c < n_cols &&
"Matrix column index should be within range");
8572 assert(!
"Impossible! Unknown MatType!");
8592 for (
size_t i = 0; i != n_cols; ++i) {
8594 mat[i] = (*this)[i];
8619 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
8630template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent>
8638 MatRefCol(
Mat<T, n_rows, n_cols, matType<type_parent>()>& m,
size_t index) :
_data(m.rawDataPtr() + index) {
8639 static_assert(type ==
MatType::NORMAL,
"We only support limited matType.");
8640 assert(index < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number "
8641 "of the matrix's cols.'");
8652 template <
typename T_,
size_t n_rows_,
size_t n_cols_, MatType type_>
8654 for (
size_t i = 0; i !=
size(); ++i) {
8656 _data[i * n_rows] = m[i];
8661 template <
typename M>
8663 for (
size_t i = 0; i !=
size(); ++i) {
8665 _data[i * n_rows] = m[i];
8674 inline static constexpr size_t size() noexcept {
return n_rows; }
8681 inline static constexpr MatType pType() noexcept {
return matType<type_parent>(); }
8691 assert(c == 0 &&
"Column vector's column index should always be 0.");
8692 assert(r < n_rows &&
"Matrix row index should be within range");
8695 return _data[r * n_cols];
8698 assert(!
"Impossible! Unknown MatType!");
8704 assert(c == 0 &&
"Column vector's column index should always be 0.");
8705 assert(r < n_rows &&
"Matrix row index should be within range");
8708 return _data[r * n_cols];
8711 assert(!
"Impossible! Unknown MatType!");
8733 for (
size_t i = 0; i != n_rows; ++i) {
8735 mat[i] = (*this)[i];
8760 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
8771template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent>
8780 :
_data(m.rawDataPtr() + index * n_cols) {
8781 static_assert(type ==
MatType::NORMAL,
"We only support limited matType.");
8782 assert(index < n_rows &&
"Take the specific row by index requires 'The index should be smaller than the number "
8783 "of the matrix's rows.'");
8794 template <
typename T_,
size_t n_rows_,
size_t n_cols_, MatType type_>
8796 for (
size_t i = 0; i !=
size(); ++i) {
8803 template <
typename M>
8805 for (
size_t i = 0; i !=
size(); ++i) {
8816 inline static constexpr size_t size() noexcept {
return n_cols; }
8823 inline static constexpr MatType pType() noexcept {
return matType<type_parent>(); }
8833 assert(r == 0 &&
"Row vector's row index should always be 0.");
8834 assert(c < n_cols &&
"Matrix column index should be within range");
8840 assert(!
"Impossible! Unknown MatType!");
8846 assert(r == 0 &&
"Row vector's row index should always be 0.");
8847 assert(c < n_cols &&
"Matrix column index should be within range");
8853 assert(!
"Impossible! Unknown MatType!");
8875 for (
size_t i = 0; i != n_cols; ++i) {
8877 mat[i] = (*this)[i];
8902 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
8913template <
size_t first_col,
size_t last_col,
typename T,
size_t n_rows,
size_t n_cols,
MatType type,
8914 typename type_parent>
8923 static_assert(last_col < n_cols,
"Take the successive cols by indexes requires 'The indexes should be smaller "
8924 "than the number of the matrix's cols.'");
8925 static_assert(first_col > 0,
"Take the specific col by index requires 'The indexes can't be smaller than 0.'");
8926 static_assert(first_col <= last_col,
"The first index should be smaller than the second one.");
8941 inline static constexpr size_t size() noexcept {
8948 : (1 + n_rows) * n_rows / 2;
8956 inline static constexpr MatType pType() noexcept {
return matType<type_parent>(); }
8966 assert(c < (last_col - first_col + 1) &&
8967 "The col index must be small than the number of the successive columns .");
8968 assert(r > 0 &&
"The row index can't be smaller than 0.");
8971 return _data[r * n_cols + c + first_col];
8973 if (r == (c + first_col))
return _data[r];
8976 if (r == (c + first_col))
return _data[0];
8979 if (r <= (c + first_col))
return _data[(2 * n_cols + 1 - r) * r / 2 + c + first_col - r];
8982 if (r >= (c + first_col))
return _data[(1 + r) * r / 2 + c + first_col - r];
8985 if (r < (c + first_col))
return _data[(2 * n_cols + 1 - r) * r / 2 + c + first_col - 2 * r - 1];
8988 if (r >= (c + first_col))
return _data[(1 + r) * r / 2 + c + first_col - r];
8991 if (r <= (c + first_col))
return _data[(2 * n_cols + 1 - r) * r / 2 + c + first_col - r];
8992 else return _data[(2 * n_cols + 1 - (c + first_col)) * (c + first_col) / 2 + r - (c + first_col)];
8994 if (r < (c + first_col))
return -
_data[(2 * n_cols + 1 - r) * r / 2 + (c + first_col) - r * 2 - 1];
8995 else if (r > (c + first_col))
8996 return _data[(2 * n_cols + 1 - (c + first_col)) * (c + first_col) / 2 + r - (c + first_col) * 2 - 1];
9000 assert(!
"Impossible! Unknown MatType!");
9011 return (*
this)(index / (last_col - first_col + 1), index % (last_col - first_col + 1));
9021 for (
size_t i = 0; i != n_rows * (last_col - first_col + 1); ++i) {
9023 mat[i] = (*this)[i];
9035 return static_cast<Mat<T, n_rows, last_col - first_col + 1,
MatType::NORMAL>>(*this);
9047template <
size_t first_row,
size_t last_row,
typename T,
size_t n_rows,
size_t n_cols,
MatType type,
9048 typename type_parent>
9057 static_assert(last_row < n_rows,
"Take the successive rows by indexes requires 'The indexes should be smaller "
9058 "than the number of the matrix's rows.'");
9059 static_assert(first_row > 0,
"Take the specific row by index requires 'The indexes can't be smaller than 0.'");
9060 static_assert(first_row <= last_row,
"The first index should be smaller than the second one.");
9075 inline static constexpr size_t size() noexcept {
9082 : (1 + n_rows) * n_rows / 2;
9090 inline static constexpr MatType pType() noexcept {
return matType<type_parent>(); }
9100 assert(r < last_row - first_row &&
"The row index must be small than the number of the successive rows .");
9101 assert(c > 0 &&
"The row index can't be smaller than 0.");
9104 return _data[(r + first_row) * n_cols + c];
9106 if ((r + first_row) == c)
return _data[r];
9109 if ((r + first_row) == c)
return _data[0];
9112 if ((r + first_row) <= c)
9113 return _data[(2 * n_cols + 1 - (r + first_row)) * (r + first_row) / 2 + c - (r + first_row)];
9116 if ((r + first_row) >= c)
return _data[(1 + (r + first_row)) * (r + first_row) / 2 + c];
9119 if ((r + first_row) < c)
9120 return _data[(2 * n_cols + 1 - (r + first_row)) * (r + first_row) / 2 + c - 2 * (r + first_row) - 1];
9123 if ((r + first_row) >= c)
return _data[(1 + (r + first_row)) * (r + first_row) / 2 + c - (r + first_row)];
9126 if ((r + first_row) <= c)
9127 return _data[(2 * n_cols + 1 - (r + first_row)) * (r + first_row) / 2 + c - (r + first_row)];
9128 else return _data[(2 * n_cols + 1 - c) * c / 2 + (r + first_row) - c];
9130 if ((r + first_row) < c)
9131 return -
_data[(2 * n_cols + 1 - (r + first_row)) * (r + first_row) / 2 + c - (r + first_row) * 2 - 1];
9132 else if ((r + first_row) > c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - c * 2 - 1];
9136 assert(!
"Impossible! Unknown MatType!");
9146 T
operator[](
size_t index)
const {
return (*
this)(index / n_cols, index % n_cols); }
9155 for (
size_t i = 0; i != n_rows * (last_row - first_row + 1); ++i) {
9157 mat[i] = (*this)[i];
9169 return static_cast<Mat<T, last_row - first_row + 1, n_cols,
MatType::NORMAL>>(*this);
9179 return static_cast<Mat<T, last_row - first_row + 1, n_cols,
MatType::NORMAL>>(*this);
9209template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9210 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9211 typename T2,
size_t n_rows,
size_t n_cols,
MatType type1,
MatType type2>
9212static inline Mat<T1, n_rows, n_cols,
sumType(type1, type2)>
9213operator+(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
9214 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
9217 return mat.
add(mat_L, mat_R);
9235template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T1,
typename T2,
9240 return mat_L.
add(mat_R);
9261template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9262 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9263 typename T2,
size_t n_rows,
size_t n_cols,
MatType type1,
MatType type2>
9264static inline Mat<T1, n_rows, n_cols,
sumType(type1, type2)>
9265operator-(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
9266 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
9269 return mat.
sub(mat_L, mat_R);
9287template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9288 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9289 typename T2,
size_t n_rows,
size_t n_cols,
MatType type1,
MatType type2>
9290static inline M1<T1, n_rows, n_cols, type1>&
operator-=(M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
9291 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
9293 return mat_L.sub(mat_R);
9314template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T1,
typename T2,
9316 std::enable_if_t<(std::is_same<T1, bool>::value),
bool> =
true>
9317static inline Mat<T1, n_rows, n_cols,
mulType(type1, type2, n_rows, n_cols, n_cols)>
9320 Mat<T2, n_rows, n_cols,
mulType(type1, type2, n_rows, n_cols, n_cols)> tmp;
9321 tmp.
mul(mat, mat_R);
9340template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T1,
typename T2,
9342 std::enable_if_t<!(std::is_same<T1, bool>::value),
bool> =
true>
9343static inline Mat<T1, n_rows, n_cols,
mulType(type1, type2, n_rows, n_cols, n_cols)>
9346 Mat<T1, n_rows, n_cols,
mulType(type1, type2, n_rows, n_cols, n_cols)> tmp;
9347 tmp.mul(mat, mat_R);
9366template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T,
9367 typename ScalarT,
size_t n_rows,
size_t n_cols,
MatType type,
9368 std::enable_if_t<std::is_arithmetic<std::remove_reference_t<ScalarT>>::value,
bool> =
true>
9391template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T,
9392 typename ScalarT,
size_t n_rows,
size_t n_cols,
MatType type,
9393 std::enable_if_t<std::is_arithmetic<std::remove_reference_t<ScalarT>>::value,
bool> =
true>
9397 return mat.
mul(mat_L, s);
9418template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T,
9419 size_t n_rows,
size_t n_cols,
MatType type,
int AP_W,
int AP_I, ap_q_mode AP_Q, ap_o_mode AP_O,
int AP_N>
9421 ap_fixed<AP_W, AP_I, AP_Q, AP_O, AP_N> s) {
9424 return mat.
mul(mat_L, s);
9444template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T,
9445 typename ScalarT,
size_t n_rows,
size_t n_cols,
MatType type,
9446 std::enable_if_t<std::is_arithmetic<std::remove_reference_t<ScalarT>>::value,
bool> =
true>
9450 return mat.
mul(mat_R, s);
9471template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T,
9472 size_t n_rows,
size_t n_cols,
MatType type,
int AP_W,
int AP_I, ap_q_mode AP_Q, ap_o_mode AP_O,
int AP_N>
9477 return mat.
mul(mat_R, s);
9503template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9504 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9505 typename T2,
size_t n_rows,
size_t comm,
size_t n_cols,
MatType type1,
MatType type2,
9506 std::enable_if_t<(std::is_same<T1, bool>::value),
bool> =
true>
9507static inline Mat<T2, n_rows, n_cols,
mulType(type1, type2, n_rows, comm, n_cols)>
9508operator*(
const M1<T1, n_rows, comm, type1, _unused1...>& mat_L,
9509 const M2<T2, comm, n_cols, type2, _unused2...>& mat_R) {
9510 Mat<T2, n_rows, n_cols,
mulType(type1, type2, n_rows, comm, n_cols)> mat;
9511 mat.
mul(mat_L, mat_R);
9516template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9517 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9518 typename T2,
size_t n_rows,
size_t comm,
size_t n_cols,
MatType type1,
MatType type2,
9519 std::enable_if_t<!(std::is_same<T1, bool>::value),
bool> =
true>
9520static inline Mat<T1, n_rows, n_cols,
mulType(type1, type2, n_rows, comm, n_cols)>
9521operator*(
const M1<T1, n_rows, comm, type1, _unused1...>& mat_L,
9522 const M2<T2, comm, n_cols, type2, _unused2...>& mat_R) {
9523 Mat<T1, n_rows, n_cols,
mulType(type1, type2, n_rows, comm, n_cols)> mat;
9524 mat.
mul(mat_L, mat_R);
9550template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9551 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9552 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9554 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9556 return mat.
emul(mat_L, mat_R);
9577template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9578 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9579 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9581 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9584 for (
size_t i = 0; i != mat_L.size(); ++i) {
9586 mat[i] = mat_L[i] == mat_R[i];
9609template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9610 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9611 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9613 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9616 for (
size_t i = 0; i != mat_L.size(); ++i) {
9618 mat[i] = mat_L[i] != mat_R[i];
9641template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9642 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9643 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9645 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9648 for (
size_t i = 0; i != mat_L.size(); ++i) {
9650 mat[i] = mat_L[i] > mat_R[i];
9673template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9674 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9675 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9676Mat<bool, n_rows, n_cols, type>
operator<(
const M1<T1, n_rows, n_cols, type, _unused1...>& mat_L,
9677 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9678 Mat<bool, n_rows, n_cols, type> mat;
9680 for (
size_t i = 0; i != mat_L.size(); ++i) {
9682 mat[i] = mat_L[i] < mat_R[i];
9705template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9706 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9707 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9709 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9712 for (
size_t i = 0; i != mat_L.size(); ++i) {
9714 mat[i] = mat_L[i] >= mat_R[i];
9737template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9738 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9739 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9740Mat<bool, n_rows, n_cols, type>
operator<=(
const M1<T1, n_rows, n_cols, type, _unused1...>& mat_L,
9741 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9742 Mat<bool, n_rows, n_cols, type> mat;
9744 for (
size_t i = 0; i != mat_L.size(); ++i) {
9746 mat[i] = mat_L[i] <= mat_R[i];
9769template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9770 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9771 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9773 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9776 for (
size_t i = 0; i != mat_L.size(); ++i) {
9778 mat[i] = mat_L[i] % mat_R[i];
9783template <
typename Tp = double,
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9784 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9785 typename T2,
size_t L_rows,
size_t L_cols,
size_t R_rows,
size_t R_cols,
MatType type,
9786 std::enable_if_t<L_rows * L_cols == R_rows * R_cols, bool> =
true>
9787Tp
innerProd(
const M1<T1, L_rows, L_cols, type, _unused1...>& mat_L,
9788 const M2<T2, R_rows, R_cols, type, _unused2...>& mat_R) {
9789 assert(mat_L.size() == mat_R.size() &&
"Dimension should meet for innerProd.");
9792 for (
size_t i = 0; i != mat_L.size(); ++i) {
9794 result +=
static_cast<Tp
>(mat_L[i] * mat_R[i]);
9811template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
9819#ifndef FLAMES_PRESERVE_WARNING
9820# ifdef __SYNTHESIS__
9821# pragma GCC diagnostic pop
9825#ifdef DEFINED_INLINE
9826# define INLINE inline
9827# undef DEFINED_INLINE
Matrix.
Definition: core.hpp:565
Mat & sub(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Matrix self minus a matrix.
Definition: core.hpp:1739
MatViewOpp< T, n_rows, n_cols, type > opp_() const
Matrix opposite as a read only view.
Definition: core.hpp:6290
Mat< T, _rows, n_cols, MatType::NORMAL > rows(M2 vector)
Take discrete rows of a matrix by container and make a copy.
Definition: core.hpp:5809
T operator[](size_t index) const
Get read only element by row major index from the data array.
Definition: core.hpp:850
Mat & mul(ap_int< AP_W > s)
Matrix self multiply ap_int integer.
Definition: core.hpp:1916
Mat & rows(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t first_row)
Take successive rows of a matrix by index.
Definition: core.hpp:5681
Vec< T, n_rows > diagVec() const
Take the diagonal vector of a matrix and make a copy.
Definition: core.hpp:6407
void _sa_read_first_col_L(size_t i, Tmp &tmp_L, const M &mat_L, size_t begin_shift, Comm __attribute__((unused)) _comm_foo, Zero zero) const
Systolic array read the first column from the left matrix.
Definition: core.hpp:6866
T * rawDataPtr()
Get the raw data array pointer.
Definition: core.hpp:6769
MatRefCol< T, n_rows, n_cols, MatType::NORMAL, MType< type > > col_(size_t index)
Definition: core.hpp:5502
Mat< T, n_rows, _cols, MatType::NORMAL > cols(M2 vector)
Take discrete cols of a matrix by container and make a copy.
Definition: core.hpp:5881
T & operator()(size_t r, size_t c)
Get writeable data element by row index and column index.
Definition: core.hpp:921
void _tryAssign(size_t r, size_t c, T value)
Try to assign a value to a specific position.
Definition: core.hpp:6783
Mat & t(const M< T2, n_cols, n_rows, type2, _unused... > &mat)
Transpose.
Definition: core.hpp:5927
Mat< T, n_rows, n_cols, MatType::NORMAL > offDiag() const
Take the off diagonal of a matrix and make a copy.
Definition: core.hpp:6528
Mat< T, 1, n_cols, MatType::NORMAL > row(size_t r) const
Take a row of a matrix by index and make a copy.
Definition: core.hpp:5549
Mat & invNSA(const M< T2, n_rows, n_cols, type2, _unused... > &mat, size_t iter=4)
Matrix inverse using Newton-Schulz iterative method (NSA).
Definition: core.hpp:6608
Mat & diagMat(const M< T2, n_rows, n_cols, type2, _unused... > &mat)
Take the diagonal of a matrix.
Definition: core.hpp:6327
Mat & diagVec(const M< T2, n_rows, n_rows, type2, _unused... > &mat)
Take the diagonal vector of a matrix.
Definition: core.hpp:6384
Mat(Init init)
Definition: core.hpp:744
Mat & oppSelf()
In-place matrix opposite.
Definition: core.hpp:6304
void _sa_read_first_row_R(size_t i, Tmp &tmp_R, const M &mat_R, size_t begin_shift, Comm __attribute__((unused)) _comm_foo, Zero zero) const
Systolic array read the first column from the right matrix.
Definition: core.hpp:6893
void _tryAssignOutRange(size_t r, size_t c, T value)
Try to assign a value to a specific position that may have out-of-range index.
Definition: core.hpp:6814
Mat & tSelf()
In-place transpose.
Definition: core.hpp:6213
Mat(T *const ptr, InitAfterwards opt=InitAfterwards::NONE)
Definition: core.hpp:782
Mat & diagRowVec(const M< T2, n_cols, n_cols, type2, _unused... > &mat)
Take the diagonal row vector of a matrix.
Definition: core.hpp:6442
~Mat()
Destroy the Mat object.
Definition: core.hpp:815
Mat & invINSA(const M< T2, n_rows, n_cols, type2, _unused... > &mat, size_t iter=3, coeff_type beta=2)
Matrix inverse using improved Newton-Schulz iterative method (INSA).
Definition: core.hpp:6665
Mat & invDiag(const M< T2, n_cols, n_rows, type2, _unused... > &mat)
Inverse the diagonal matrix.
Definition: core.hpp:6571
Mat & rows(const M1< T1, rows_, cols_, type1, _unused1... > &mat, M2 vector)
Take discrete rows of a matrix by container.
Definition: core.hpp:5773
T & operator[](size_t index)
Get writeable element by row major index from the data array.
Definition: core.hpp:864
void setZero()
Set all elements of the matrix to zero.
Definition: core.hpp:979
Mat< T, _rows, n_cols, MatType::NORMAL > rows(size_t first_row)
Take successive rows of a matrix by index and make a copy.
Definition: core.hpp:5718
Mat & opp(const M< T2, n_rows, n_cols, type, _unused... > &mat)
Calculate the opposite of a matrix.
Definition: core.hpp:6252
Mat & mul(const M< T2, n_rows, n_cols, type, _unused... > &mat, ScalarT s)
Matrix times a scalar.
Definition: core.hpp:1769
const T * rawDataPtr() const
Definition: core.hpp:6771
MatViewOffDiag< T, n_rows, n_cols, MatType::NORMAL, MType< type > > offDiag_() const
Take the diagonal of a matrix as a read only view.
Definition: core.hpp:6548
MatViewOpp< T, n_rows, n_cols, type > operator-() const
The unary minus operator.
Definition: core.hpp:6755
MatViewT< T, n_cols, n_rows, tType(type)> t_()
Transpose as a read only view.
Definition: core.hpp:6200
MatViewRows< first_row, last_row, T, n_rows, n_cols, MatType::NORMAL, MType< type > > Rows_() const
Take successive rows of a matrix by indexes as a read only view.
Definition: core.hpp:5744
Mat invNSA(size_t iter=4) const
Matrix inverse using Newton-Schulz iterative method (NSA) as a copy.
Definition: core.hpp:6641
Mat & cols(const M1< T1, rows_, cols_, type1, _unused1... > &mat, M2 vector)
Take discrete cols of a matrix by container.
Definition: core.hpp:5845
MatViewCol< T, n_rows, n_cols, MatType::NORMAL, MType< type > > col_(size_t index) const
Take a column of a matrix by index as a read only view.
Definition: core.hpp:5496
Mat & mul(ScalarT s)
Matrix self multiply a scalar.
Definition: core.hpp:1874
Mat & add(const M1< T1, n_rows, n_cols, type1, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type2, _unused2... > &mat_R)
Matrix plus matrix into NORMAL.
Definition: core.hpp:1076
Mat< T, n_rows, 1, MatType::NORMAL > col(size_t c) const
Take a column of a matrix by index and make a copy.
Definition: core.hpp:5480
Mat & mul(const M< T2, n_rows, n_cols, type, _unused... > &mat, ap_int< AP_W > s)
Matrix times ap_int integer.
Definition: core.hpp:1822
Mat & mul(ap_fixed< AP_W, AP_I, AP_Q, AP_O, AP_N > s)
Matrix self multiply ap_fixed float.
Definition: core.hpp:1940
Mat< T, n_rows, _cols, MatType::NORMAL > cols(size_t first_col)
Take successive columns of a matrix by index and make a copy.
Definition: core.hpp:5627
Mat & mul(std::complex< ScalarT > s)
Matrix self multiply a complex number.
Definition: core.hpp:1896
void col(size_t c, const M< T2, rows_, cols_, type2, _unused... > &mat)
Definition: core.hpp:5456
Mat()
Construct a new Mat object.
Definition: core.hpp:604
MatViewDiagVec< T, n_rows, 1, MatType::NORMAL, MType< type > > diagVec_() const
Take the diagonal vector of a matrix as a read only view.
Definition: core.hpp:6422
T & value()
Get the writeable value from 1x1 matrix.
Definition: core.hpp:6713
MatViewDiagMat< T, n_rows, n_cols, MatType::DIAGONAL, MType< type > > diagMat_() const
Take the diagonal of a matrix as a read only view.
Definition: core.hpp:6364
T _data[type==MatType::NORMAL ? n_rows *n_cols :type==MatType::DIAGONAL ? n_rows :type==MatType::SCALAR ? 1 :type==MatType::SUPPER ?(n_rows - 1) *n_rows/2 :type==MatType::SLOWER ?(n_rows - 1) *n_rows/2 :type==MatType::ASYM ?(n_rows - 1) *n_rows/2 :(1+n_rows) *n_rows/2]
The raw data array in row major.
Definition: core.hpp:7043
Mat & _systolicArrayMul(const M1< T1, n_rows, comm, type1, _unused1... > &mat_L, const M2< T2, comm, n_cols, type2, _unused2... > &mat_R, size_t begin_shift=0, size_t end_shift=0)
The systolic array multiplication.
Definition: core.hpp:6959
static constexpr size_t size() noexcept
Get the matrix size of storage.
Definition: core.hpp:832
Mat & mul(const M< T2, n_rows, n_cols, type, _unused... > &mat, std::complex< ScalarT > s)
Matrix times a complex number.
Definition: core.hpp:1797
Mat< T, n_rows, n_cols, MatType::SLOWER > t() const
Transpose SUPPER matrix as a copy.
Definition: core.hpp:6120
Tp power() const
Definition: core.hpp:6689
Mat & cols(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t first_col)
Take successive columns of a matrix by index.
Definition: core.hpp:5591
Mat & row(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t r)
Take a row of a matrix by index.
Definition: core.hpp:5525
Mat & sub(const M1< T1, n_rows, n_cols, type1, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type2, _unused2... > &mat_R)
Matrix minus matrix into NORMAL.
Definition: core.hpp:1434
Mat & abs_()
Apply 'abs' (absolute value) to itself.
Definition: core.hpp:5903
Mat(const T *ptr, InitAfterwards opt=InitAfterwards::NONE)
Construct a new Mat object from raw data pointer.
Definition: core.hpp:755
bool read(const std::string &file_name)
Definition: core.hpp:981
Mat< T, n_rows, n_cols, MatType::UPPER > t() const
Transpose LOWER matrix as a copy.
Definition: core.hpp:6089
Mat t() const
Transpose DIAGONAL/SCALAR/SYM matrix as a copy.
Definition: core.hpp:6037
T element_type
Definition: core.hpp:592
Mat< T, n_rows, n_cols, MatType::LOWER > t() const
Transpose UPPER matrix as a copy.
Definition: core.hpp:6058
void _sa_multiply(const T1 &tmp_L, const T2 &tmp_R, const HLSVec &use_assign)
Systolic array multiplication.
Definition: core.hpp:6917
Mat(T val)
Construct a new Mat object with initial value.
Definition: core.hpp:623
MatViewCols< first_col, last_col, T, n_rows, n_cols, MatType::NORMAL, MType< type > > Cols_() const
Take seccessive columns of a matrix by indexes as a read only view.
Definition: core.hpp:5652
void setValue(T val)
Set all elements of the matrix to a value.
Definition: core.hpp:968
Mat invINSA(size_t iter=3, coeff_type beta=1.0) const
Matrix inverse using improved Newton-Schulz iterative method (INSA) as a copy.
Definition: core.hpp:6680
Mat< T, n_cols, n_rows, type > t() const
Transpose NORMAL matrix as a copy.
Definition: core.hpp:6006
Mat & col(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t c)
Take a column of a matrix by index.
Definition: core.hpp:5442
Mat & offDiag(const M< T2, n_cols, n_rows, type2, _unused... > &mat)
Take the off diagonal of a matrix.
Definition: core.hpp:6500
Mat invDiag() const
Inverse the diagonal matrix and makes a copy.
Definition: core.hpp:6586
void print(const std::string &str="", std::ostream &os=std::cout) const
Print the matrix.
Definition: core.hpp:6724
Mat opp() const
Calculate the opposite of a matrix and make a copy.
Definition: core.hpp:6275
T value() const
Get the value from 1x1 matrix.
Definition: core.hpp:6703
Mat(std::initializer_list< T2 > list)
Definition: core.hpp:726
MatViewT< T, n_cols, n_rows, tType(type)> t_() const
Definition: core.hpp:6202
RowVec< T, n_cols > diagRowVec() const
Take the diagonal row vector of a matrix and make a copy.
Definition: core.hpp:6465
Mat & mul(const M< T2, n_rows, n_cols, type, _unused... > &mat, ap_fixed< AP_W, AP_I, AP_Q, AP_O, AP_N > s)
Matrix times ap_fixed float.
Definition: core.hpp:1851
Mat(const Mat &mat)
Copy constructor from a Mat object.
Definition: core.hpp:644
Mat & mul(const M1< T1, rows_, comm, type1, _unused1... > &mat_L, const M2< T2, comm, cols_, type2, _unused2... > &mat_R)
General matrix matrix multiplication.(Including SYM or NORMAL matrix times a SYM or NORMAL matrix )
Definition: core.hpp:1980
Mat & add(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Matrix self plus a matrix.
Definition: core.hpp:1377
MatViewDiagRowVec< T, 1, n_cols, MatType::NORMAL, MType< type > > diagRowVec_() const
Take the diagonal row vector of a matrix as a read only view.
Definition: core.hpp:6480
Mat & emul(const M1< T1, rows_, cols_, type1, _unused1... > &mat_L, const M2< T2, rows_, cols_, type2, _unused2... > &mat_R)
Element-wise product of two matrices.
Definition: core.hpp:5417
MatView< T, n_rows, n_cols, type > operator+() const
The unary plus operator.
Definition: core.hpp:6744
T operator()(size_t r, size_t c) const
Get read only data element by row index and column index.
Definition: core.hpp:877
Mat(const Mat< T2, _rows, _cols, _type > &mat)
Definition: core.hpp:663
Mat & add(const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
Matrix plus matrix with same MatType.
Definition: core.hpp:1043
Mat(const std::vector< T > &vec)
Construct a new Mat object from std::vector.
Definition: core.hpp:708
Mat< T, n_rows, n_cols, MatType::DIAGONAL > diagMat() const
Take the diagonal of a matrix and make a copy.
Definition: core.hpp:6350
Mat & sub(const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
Matrix minus matrix with same MatType.
Definition: core.hpp:1401
T value_type
Definition: core.hpp:593
void _tryPlus(size_t r, size_t c, T value)
Try to plus a value to a specific position.
Definition: core.hpp:6829
Definition: core.hpp:8631
void assign(M m)
Definition: core.hpp:8662
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:8722
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:8690
T & operator()(size_t r, size_t c)
Definition: core.hpp:8703
Vec< T, n_rows > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:8745
T *const _data
Raw data pointer.
Definition: core.hpp:8768
MatRefCol(Mat< T, n_rows, n_cols, matType< type_parent >()> &m, size_t index)
Construct a new MatRefCol object from raw data pointer.
Definition: core.hpp:8638
T & operator[](size_t index)
Definition: core.hpp:8724
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:8674
MatRefCol(const MatRefCol &m)
Copy constructor.
Definition: core.hpp:8650
Vec< T, n_rows > asVec() const
Explicitly make a Mat (Vec) copy.
Definition: core.hpp:8755
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition: core.hpp:8760
MatRefCol & operator=(const Mat< T_, n_rows_, n_cols_, type_ > &m)
Definition: core.hpp:8653
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition: core.hpp:8681
Definition: core.hpp:7293
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:7442
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:7349
void col(size_t c, const M< T2, rows_, cols_, type2, _unused... > &mat)
Definition: core.hpp:7507
T *const _data
Definition: core.hpp:7613
MatRef & operator=(const Mat< T, n_rows, n_cols, type > &m)
Definition: core.hpp:7326
Mat< T, n_rows, n_cols, type > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:7604
T & operator[](size_t index)
Get the writeable element by array row major index.
Definition: core.hpp:7454
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:7316
void assign(M m)
Definition: core.hpp:7335
MatViewT< T, n_cols, n_rows, type > t_() const
Definition: core.hpp:7566
void setValue(T val)
Set all elements of the matrix to a value.
Definition: core.hpp:7465
MatRef & col(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t c)
Take a column of a matrix by index.
Definition: core.hpp:7494
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition: core.hpp:7609
MatRef & add(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Definition: core.hpp:7544
MatRef & sub(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Definition: core.hpp:7556
T & operator()(size_t r, size_t c)
Get writeable data element by row index and column index.
Definition: core.hpp:7394
Tp abssum() const
Definition: core.hpp:7579
MatRef(Mat< T, n_rows, n_cols, type > &m)
Construct a new MatView object from raw data pointer.
Definition: core.hpp:7300
void setZero()
Set all elements of the matrix to zero.
Definition: core.hpp:7476
MatRef(const T *const ptr)
Definition: core.hpp:7302
Mat< T, n_rows, 1, MatType::NORMAL > col(size_t c) const
Take a column of a matrix by index and make a copy.
Definition: core.hpp:7531
Tp power() const
Definition: core.hpp:7569
MatRef(const MatRef &m)
Copy constructor.
Definition: core.hpp:7309
Definition: core.hpp:8772
T *const _data
Raw data pointer.
Definition: core.hpp:8910
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:8832
void assign(M m)
Definition: core.hpp:8804
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:8816
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition: core.hpp:8823
MatRefRow(Mat< T, n_rows, n_cols, matType< type_parent >()> &m, size_t index)
Construct a new MatRefRow object from raw data pointer.
Definition: core.hpp:8779
T & operator[](size_t index)
Definition: core.hpp:8866
RowVec< T, n_cols > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:8887
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition: core.hpp:8902
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:8864
MatRefRow & operator=(const Mat< T_, n_rows_, n_cols_, type_ > &m)
Definition: core.hpp:8795
MatRefRow(const MatRefRow &m)
Copy constructor.
Definition: core.hpp:8792
T & operator()(size_t r, size_t c)
Definition: core.hpp:8845
RowVec< T, n_cols > asVec() const
Explicitly make a Mat (RowVec) copy.
Definition: core.hpp:8897
Read only view version of a certain column as colunm vector.
Definition: core.hpp:8414
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:8474
MatViewCol(const MatViewCol &m)
Copy constructor.
Definition: core.hpp:8432
Vec< T, n_rows > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:8495
MatViewCol(const Mat< T, n_rows, n_cols, matType< type_parent >()> &m, size_t index)
Construct a new MatViewCol object from raw data pointer.
Definition: core.hpp:8421
Vec< T, n_rows > asVec() const
Explicitly make a Mat (Vec) copy.
Definition: core.hpp:8505
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition: core.hpp:8510
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:8439
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:8455
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition: core.hpp:8446
const T *const _data
Raw data pointer.
Definition: core.hpp:8518
Read only view version of successive columns.
Definition: core.hpp:8915
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:8941
MatViewCols(const Mat< T, n_rows, n_cols, matType< type_parent >()> &m)
Construct a new MatViewCols object from raw data pointer.
Definition: core.hpp:8922
MatViewCols(const MatViewCols &m)
Copy constructor.
Definition: core.hpp:8934
const T * _data
Raw data pointer.
Definition: core.hpp:9044
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:8965
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:9010
Mat< T, n_rows, last_col - first_col+1, MatType::NORMAL > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:9033
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition: core.hpp:8956
Read only view version of a diagonal matrix.
Definition: core.hpp:7878
MatViewDiagMat(const Mat< T, N, N, matType< type_parent >()> &m)
Construct a new MatViewDiagMat object from a raw data pointer.
Definition: core.hpp:7885
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:7940
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:7916
Mat< T, N, N, MatType::DIAGONAL > inv() const
Return a inverse matrix.
Definition: core.hpp:7901
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition: core.hpp:7931
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:7973
Mat< T, N, N, MatType::DIAGONAL > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:7999
MatViewDiagMat(const MatViewDiagMat &m)
Copy constructor.
Definition: core.hpp:7894
const T * _data
Raw data pointer.
Definition: core.hpp:8010
Read only view version of a diagonal matrix as row vector.
Definition: core.hpp:8156
MatViewDiagRowVec(const MatViewDiagRowVec &m)
Copy constructor.
Definition: core.hpp:8172
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition: core.hpp:8194
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:8236
MatViewDiagRowVec(const Mat< T, N, N, matType< type_parent >()> &m)
Construct a new MatViewDiagRowVec object from raw data pointer.
Definition: core.hpp:8163
RowVec< T, N > asRowVec() const
Explicitly make a Mat (RowVec) copy.
Definition: core.hpp:8268
const T * _data
Raw data pointer.
Definition: core.hpp:8279
RowVec< T, N > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:8258
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:8203
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:8179
Read only view version of a diagonal matrix as vector.
Definition: core.hpp:8014
Vec< T, N > inv() const
Return a inverse matrix.
Definition: core.hpp:8052
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:8109
MatViewDiagVec(const Mat< T, N, N, matType< type_parent >()> &m)
Construct a new MatViewDiagVec object from raw data pointer.
Definition: core.hpp:8021
Vec< T, N > asVec() const
Explicitly make a Mat (Vec) copy.
Definition: core.hpp:8141
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:8037
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition: core.hpp:8067
const T * _data
Raw data pointer.
Definition: core.hpp:8152
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:8076
MatViewDiagVec(const MatViewDiagVec &m)
Copy constructor.
Definition: core.hpp:8030
Vec< T, N > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:8131
Read only view version of a matrix.
Definition: core.hpp:7047
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:7071
Mat< T, n_rows, 1, MatType::NORMAL > col(size_t c) const
Take a column of a matrix by index and make a copy.
Definition: core.hpp:7207
void assign(M m)
Definition: core.hpp:7090
MatView(const T *const ptr)
Definition: core.hpp:7057
MatView(Mat< T, n_rows, n_cols, type > &m)
Definition: core.hpp:7055
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:7104
MatView & operator=(const Mat< T, n_rows, n_cols, type > &m)
Definition: core.hpp:7081
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition: core.hpp:7285
MatView & sub(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Definition: core.hpp:7232
const T *const _data
Definition: core.hpp:7289
MatViewT< T, n_cols, n_rows, type > t_() const
Definition: core.hpp:7242
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:7148
MatView(const Mat< T, n_rows, n_cols, type > &m)
Construct a new MatView object from raw data pointer.
Definition: core.hpp:7054
Tp abssum() const
Definition: core.hpp:7255
Tp power() const
Definition: core.hpp:7245
MatView & col(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t c)
Take a column of a matrix by index.
Definition: core.hpp:7170
MatView(const MatView &m)
Copy constructor.
Definition: core.hpp:7064
void col(size_t c, const M< T2, rows_, cols_, type2, _unused... > &mat)
Definition: core.hpp:7183
Mat< T, n_rows, n_cols, type > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:7280
MatView & add(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Definition: core.hpp:7220
Read only view version of a off diagonal.
Definition: core.hpp:8283
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:8330
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:8306
MatViewOffDiag(const MatViewOffDiag &m)
Copy constructor.
Definition: core.hpp:8299
const T * _data
Raw data pointer.
Definition: core.hpp:8410
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:8373
Mat< T, N, N, MatType::NORMAL > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:8399
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition: core.hpp:8321
MatViewOffDiag(const Mat< T, N, N, matType< type_parent >()> &m)
Construct a new MatViewOffDiag object from raw data pointer.
Definition: core.hpp:8290
Read only view version of the opposite of a matrix.
Definition: core.hpp:7617
MatViewOpp(const Mat< T, n_cols, n_rows, type > &m)
Construct a new MatViewOpp object from raw data pointer.
Definition: core.hpp:7624
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:7655
const T * _data
Definition: core.hpp:7725
MatViewOpp(const MatViewOpp &m)
Copy constructor.
Definition: core.hpp:7631
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:7638
Mat< T, n_rows, n_cols, type > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:7719
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:7698
Read only view version of a certain row as row vector.
Definition: core.hpp:8522
Vec< T, n_rows > asRowVec() const
Explicitly make a Mat (RowVec) copy.
Definition: core.hpp:8614
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:8564
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:8583
MatViewRow(const Mat< T, n_rows, n_cols, matType< type_parent >()> &m, size_t index)
Construct a new MatViewRow object from raw data pointer.
Definition: core.hpp:8529
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition: core.hpp:8555
RowVec< T, n_cols > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:8604
const T *const _data
Raw data pointer.
Definition: core.hpp:8627
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:8548
MatViewRow(const MatViewRow &m)
Copy constructor.
Definition: core.hpp:8541
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition: core.hpp:8619
Read only view version of successive rows.
Definition: core.hpp:9049
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:9075
Mat< T, last_row - first_row+1, n_cols, MatType::NORMAL > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:9167
static constexpr MatType pType() noexcept
Parent matrix as MatType.last_col.
Definition: core.hpp:9090
const T * _data
Raw data pointer.
Definition: core.hpp:9188
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:9146
Mat< T, last_row - first_row+1, n_cols, MatType::NORMAL > asVec() const
Explicitly make a Mat (Vec) copy.
Definition: core.hpp:9177
MatViewRows(const Mat< T, n_cols, n_rows, matType< type_parent >()> &m)
Construct a new MatViewRows object from raw data pointer.
Definition: core.hpp:9056
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:9099
MatViewRows(const MatViewRows &m)
Copy constructor.
Definition: core.hpp:9068
Read only view version of a transposed matrix.
Definition: core.hpp:7729
MatViewT(const Mat< T, n_cols, n_rows, tType(type)> &m)
Construct a new MatViewT object from raw data pointer.
Definition: core.hpp:7736
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition: core.hpp:7772
static constexpr size_t size() noexcept
The data element number.
Definition: core.hpp:7755
MatViewT(T *ptr)
Definition: core.hpp:7748
T *const _data
Raw data pointer.
Definition: core.hpp:7874
MatViewT(Mat< T, n_cols, n_rows, tType(type)> &m)
Definition: core.hpp:7737
T operator[](size_t index) const
Get the read only element by array row major index.
Definition: core.hpp:7815
Mat< T, n_rows, n_cols, type > asMat() const
Explicitly make a Mat copy.
Definition: core.hpp:7862
MatViewT(const MatViewT &m)
Copy constructor.
Definition: core.hpp:7744
Definition: tensor.hpp:27
#define FLAMES_MAT_EMUL_UNROLL_FACTOR
Definition: core.hpp:110
#define FLAMES_MAT_POWER_UNROLL_FACTOR
Definition: core.hpp:78
#define FLAMES_MAT_MINUS_UNROLL_FACTOR
Definition: core.hpp:64
#define FLAMES_MAT_SCALAR_TIMES_UNROLL_FACTOR
Definition: core.hpp:95
#define FLAMES_PRAGMA(x)
Definition: core.hpp:50
#define FLAMES_MAT_PARTITION_FACTOR
Definition: core.hpp:143
#define FLAMES_MAT_INV_UNROLL_FACTOR
Definition: core.hpp:138
#define FLAMES_MAT_ABS_UNROLL_FACTOR
Definition: core.hpp:124
#define FLAMES_MAT_TIMES_UNROLL_FACTOR
Definition: core.hpp:103
#define FLAMES_MAT_SET_VALUE_UNROLL_FACTOR
Definition: core.hpp:71
#define FLAMES_MAT_PLUS_UNROLL_FACTOR
Definition: core.hpp:57
#define FLAMES_MAT_COPY_UNROLL_FACTOR
Definition: core.hpp:85
#define FLAMES_MAT_TRANSPOSE_UNROLL_FACTOR
Definition: core.hpp:131
#define FLAMES_MAT_BOOL_OPER_UNROLL_FACTOR
Definition: core.hpp:117
Mat< dtype, 4, 4 > M
Definition: mat-inv-nsa-expanded.cpp:4
Namespace for the FLAMES library.
Definition: core.hpp:166
InitAfterwards
Afterwards action with initialization.
Definition: core.hpp:556
std::integral_constant< int, MatType::UPPER > MATTYPE_UPPER
Upper triangular matrix as a class type.
Definition: core.hpp:191
constexpr MatType mulType(MatType type1, MatType type2, size_t n_rows, size_t comm, size_t n_cols) noexcept
Multiplication type of two matrices.
Definition: core.hpp:276
std::integral_constant< int, MatType::SLOWER > MATTYPE_SLOWER
Strict lower triangular matrix as a class type.
Definition: core.hpp:197
static Mat< T, n_rows, n_cols, type > operator*(const M< T, n_rows, n_cols, type, _unused... > &mat_L, ScalarT s)
Matrix times a scalar.
Definition: core.hpp:9394
constexpr size_t lowerRow(size_t index, size_t N)
Calculate the row index of a lower triangular matrix.
Definition: core.hpp:334
static Mat< T1, n_rows, n_cols, type1 > & operator+=(Mat< T1, n_rows, n_cols, type1 > &mat_L, const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Matrix self plus a matrix.
Definition: core.hpp:9237
constexpr MatType sumType(MatType type1, MatType type2) noexcept
Summation type of two matrices.
Definition: core.hpp:229
std::integral_constant< int, MatType::SYM > MATTYPE_SYM
Symmetrical matrix as a class type.
Definition: core.hpp:199
std::integral_constant< int, MatType::ASYM > MATTYPE_ASYM
Antisymmetrical matrix as a class type.
Definition: core.hpp:201
constexpr size_t upperRow(size_t index, size_t N)
Calculate the row index of a upper triangular matrix.
Definition: core.hpp:318
std::integral_constant< int, MatType::LOWER > MATTYPE_LOWER
Lower triangular matrix as a class type.
Definition: core.hpp:193
Mat< bool, n_rows, n_cols, type > operator<=(const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
Element-wise less or equal comparison.
Definition: core.hpp:9740
constexpr size_t supperRow(size_t index, size_t N)
Calculate the row index of a strict upper triangular matrix.
Definition: core.hpp:350
Mat< bool, n_rows, n_cols, type > operator>=(const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
Element-wise greater or equal comparison.
Definition: core.hpp:9708
Mat< T1, n_rows, n_cols, type > mod(const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
Element-wise modulus.
Definition: core.hpp:9772
std::integral_constant< int, MatType::SUPPER > MATTYPE_SUPPER
Strict upper triangular matrix as a class type.
Definition: core.hpp:195
Init
Definition: core.hpp:562
std::integral_constant< int, type > MType
Get the class form of MatType.
Definition: core.hpp:220
std::integral_constant< int, MatType::SCALAR > MATTYPE_SCALAR
Scalar matrix matrix as a class type.
Definition: core.hpp:189
Mat< bool, n_rows, n_cols, type > operator==(const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
Element-wise equal comparison.
Definition: core.hpp:9580
static Mat< T1, n_rows, n_cols, sumType(type1, type2)> operator-(const M1< T1, n_rows, n_cols, type1, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type2, _unused2... > &mat_R)
Minus two matrices and make a copy.
Definition: core.hpp:9265
static Mat< T1, n_rows, n_cols, mulType(type1, type2, n_rows, n_cols, n_cols)> operator*=(Mat< T1, n_rows, n_cols, type1 > &mat, const M< T2, n_cols, n_cols, type2, _unused... > &mat_R)
Matrix self times a matrix.
Definition: core.hpp:9318
constexpr size_t slowerRow(size_t index, size_t N)
Calculate the row index of a strict lower triangular matrix.
Definition: core.hpp:366
Mat< T1, n_rows, n_cols, type > operator%(const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
Element-wise product of two matrices.
Definition: core.hpp:9553
constexpr MatType tType(MatType type) noexcept
Transpose type of a matrix.
Definition: core.hpp:303
Mat< bool, n_rows, n_cols, type > operator>(const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
Element-wise greater comparison.
Definition: core.hpp:9644
static std::ostream & operator<<(std::ostream &os, const Mat< T, n_rows, n_cols, type > &mat)
Print matrix in a out stream.
Definition: core.hpp:9812
static M1< T1, n_rows, n_cols, type1 > & operator-=(M1< T1, n_rows, n_cols, type1, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type2, _unused2... > &mat_R)
Matrix self minus a matrix.
Definition: core.hpp:9290
Mat< bool, n_rows, n_cols, type > operator!=(const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
Element-wise unequal comparison.
Definition: core.hpp:9612
Mat< bool, n_rows, n_cols, type > operator<(const M1< T1, n_rows, n_cols, type, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type, _unused2... > &mat_R)
Element-wise less comparison.
Definition: core.hpp:9676
std::integral_constant< int, MatType::NORMAL > MATTYPE_NORMAL
Normal matrix as a class type.
Definition: core.hpp:185
std::integral_constant< int, MatType::DIAGONAL > MATTYPE_DIAGONAL
Diagonal matrix as a class type.
Definition: core.hpp:187
Tp innerProd(const M1< T1, L_rows, L_cols, type, _unused1... > &mat_L, const M2< T2, R_rows, R_cols, type, _unused2... > &mat_R)
Definition: core.hpp:9787
MatType
Matrix type for storage.
Definition: core.hpp:172
@ SCALAR
Definition: core.hpp:175
@ SLOWER
Definition: core.hpp:179
@ DIAGONAL
Definition: core.hpp:174
@ NORMAL
Definition: core.hpp:173
@ UPPER
Definition: core.hpp:176
@ ASYM
Definition: core.hpp:181
@ LOWER
Definition: core.hpp:177
@ SUPPER
Definition: core.hpp:178
@ SYM
Definition: core.hpp:180
static Mat< T1, n_rows, n_cols, sumType(type1, type2)> operator+(const M1< T1, n_rows, n_cols, type1, _unused1... > &mat_L, const M2< T2, n_rows, n_cols, type2, _unused2... > &mat_R)
Add two matrices and make a copy.
Definition: core.hpp:9213
constexpr MatType matType()
Get the MatType value from the class form.
Definition: core.hpp:210