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>
401template <
typename T,
size_t n_rows,
size_t n_cols,
size_t n_slices, MatType type = MatType::NORMAL>
411template <
typename T,
size_t N>
421template <
typename T,
size_t N>
432template <
typename T,
size_t n_rows,
size_t n_cols, MatType type = MatType::NORMAL>
435template <
typename T,
size_t n_rows,
size_t n_cols, MatType type = MatType::NORMAL>
446template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
457template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
469template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent = MATTYPE_NORMAL>
481template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent = MATTYPE_NORMAL>
493template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent = MATTYPE_NORMAL>
505template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent = MATTYPE_NORMAL>
517template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent = MATTYPE_NORMAL>
520template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent = MATTYPE_NORMAL>
532template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent = MATTYPE_NORMAL>
544template <
size_t first_col,
size_t last_col,
typename T,
size_t n_rows,
size_t n_cols,
MatType type,
557template <
size_t first_row,
size_t last_row,
typename T,
size_t n_rows,
size_t n_cols,
MatType type,
574template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
576 friend class MatView<T, n_rows, n_cols, type>;
577 friend class MatViewOpp<T, n_rows, n_cols, type>;
578 friend class MatViewT<T, n_cols, n_rows, type>;
579 friend class MatViewT<T, n_rows, n_cols, type>;
580 template <
typename View_T,
size_t View_N,
size_t View_N_, MatType View_type,
typename type_parent>
582 template <
typename View_T,
size_t View_N,
size_t View_N_, MatType View_type,
typename type_parent>
584 template <
typename View_T,
size_t View_N,
size_t View_N_, MatType View_type,
typename type_parent>
586 template <
typename View_T,
size_t View_N,
size_t View_N_, MatType View_type,
typename type_parent>
588 template <
typename View_T,
size_t View_n_rows,
size_t View_n_cols, MatType View_type,
typename type_parent>
590 template <
typename View_T,
size_t View_n_rows,
size_t View_n_cols, MatType View_type,
typename type_parent>
592 template <
size_t first_col,
size_t last_col,
typename View_T,
size_t View_n_rows,
size_t View_n_cols,
593 MatType View_type,
typename type_parent>
595 template <
size_t first_row,
size_t last_row,
typename View_T,
size_t View_n_rows,
size_t View_n_cols,
596 MatType View_type,
typename type_parent>
598 template <
typename View_T_T,
size_t T_n_rows,
size_t T_n_cols,
size_t T_n_slices, MatType T_type>
615 static_assert(n_rows != 0,
"'rows' should be no smaller than 1.");
616 static_assert(n_cols != 0,
"'n_cols' should be no smaller than 1.");
617 static_assert(type ==
MatType::NORMAL || n_rows == n_cols,
"Square matrix 'rows' should be equal to 'n_cols'.");
618#ifdef FLAMES_MAT_PARTITION_COMPLETE
634 static_assert(n_rows != 0,
"'n_rows' should be no smaller than 1.");
635 static_assert(n_cols != 0,
"'n_cols' should be no smaller than 1.");
636 static_assert(type ==
MatType::NORMAL || n_rows == n_cols,
"Square matrix 'rows' should be equal to 'n_cols'.");
637#ifdef FLAMES_MAT_PARTITION_COMPLETE
656 for (
size_t i = 0; i !=
size(); ++i) {
660#ifdef FLAMES_MAT_PARTITION_COMPLETE
665#ifdef FLAMES_PRINT_PER_MAT_COPY
666 std::cout <<
"Mat copy!" << std::endl;
670 template <
typename T2,
size_t _rows,
size_t _cols,
MatType _type,
671 std::enable_if_t<!std::is_same<T, T2>::value && type == _type && n_rows == _rows && n_cols == _cols,
675 for (
size_t i = 0; i !=
size(); ++i) {
679#ifdef FLAMES_MAT_PARTITION_COMPLETE
684#ifdef FLAMES_PRINT_PER_MAT_COPY
685 std::cout <<
"Mat copy!" << std::endl;
689 template <
typename T2,
size_t _rows,
size_t _cols,
MatType _type,
690 std::enable_if_t<type != _type && n_rows == _rows && n_cols == _cols, bool> =
true>
693 for (
size_t r = 0; r != n_rows; ++r) {
695 for (
size_t c = 0; c != n_cols; ++c) {
700#ifdef FLAMES_MAT_PARTITION_COMPLETE
705#ifdef FLAMES_PRINT_PER_MAT_COPY
706 std::cout <<
"Mat copy!" << std::endl;
718 Mat(
const std::vector<T>& vec) {
719 assert(vec.size() ==
size() &&
"Initialization vector size disagrees.");
720 MAT_COPY_FROM_STD_VEC:
721 for (
size_t i = 0; i !=
size(); ++i) {
725#ifdef FLAMES_MAT_PARTITION_COMPLETE
730#ifdef FLAMES_PRINT_PER_MAT_COPY
731 std::cout <<
"Mat copy!" << std::endl;
735 template <
typename T2>
736 Mat(std::initializer_list<T2> list) {
737 auto list_size = list.size();
738 assert(list_size <=
size() &&
"Initializer list size should not exceed size().");
739 MAT_COPY_FROM_INIT_LIST:
740 for (
size_t i = 0; i != list_size; ++i) {
742 _data[i] = *(list.begin() + i);
744#ifdef FLAMES_MAT_PARTITION_COMPLETE
749#ifdef FLAMES_PRINT_PER_MAT_COPY
750 std::cout <<
"Mat copy!" << std::endl;
768 for (
size_t i = 0; i !=
size(); ++i) {
774 for (
size_t i = 0; i !=
size(); ++i) {
782#ifdef FLAMES_MAT_PARTITION_COMPLETE
787#ifdef FLAMES_PRINT_PER_MAT_COPY
788 std::cout <<
"Mat copy!" << std::endl;
795 for (
size_t i = 0; i !=
size(); ++i) {
801 for (
size_t i = 0; i !=
size(); ++i) {
809#ifdef FLAMES_MAT_PARTITION_COMPLETE
814#ifdef FLAMES_PRINT_PER_MAT_COPY
815 std::cout <<
"Mat copy!" << std::endl;
842 inline static constexpr size_t size() noexcept {
849 : (1 + n_rows) * n_rows / 2;
862 assert(index <
size() &&
"Matrix index should be within range");
876 assert(index <
size() &&
"Matrix index should be within range");
889 assert(r < n_rows &&
"Matrix row index should be within range");
890 assert(c < n_cols &&
"Matrix col index should be within range");
892 return _data[r * n_cols + c];
894 if (r == c)
return _data[r];
897 if (r == c)
return _data[0];
900 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
903 if (r >= c)
return _data[(1 + r) * r / 2 + c];
906 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
909 if (r > c)
return _data[(1 + r) * r / 2 + c - r];
912 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
913 else return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
915 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
916 else if (r > c)
return -
_data[(2 * n_cols + 1 - c) * c / 2 + r - 1 - 2 * c];
920 assert(!
"Impossible! Unknown MatType!");
933 assert(r < n_rows &&
"Matrix row index should be within range");
934 assert(c < n_cols &&
"Matrix col index should be within range");
936 return _data[r * n_cols + c];
938 if (r == c)
return _data[r];
939 else assert(!
"This element cannot be modified (DIAGONAL).");
941 assert(!
"This element cannot be modified (SCALAR).");
943 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
944 else assert(!
"This element cannot be modified (UPPER).");
946 if (r >= c)
return _data[(1 + r) * r / 2 + c];
947 else assert(!
"This element cannot be modified (LOWER).");
949 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
950 else assert(!
"This element cannot be modified (SUPPER).");
952 if (r > c)
return _data[(1 + r) * r / 2 + c - r];
953 else assert(!
"This element cannot be modified (SLOWER).");
955 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
956 else return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
958 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
959 else if (r > c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - 1 - 2 * c];
964 else assert(!
"This element cannot be modified (ASYM).");
967 assert(!
"Impossible! Unknown MatType!");
979 for (
size_t i = 0; i !=
size(); ++i) {
991 bool read(
const std::string& file_name) {
993 std::ifstream f(file_name);
995 size_t in_rows, in_cols;
996 f >> in_rows >> in_cols;
997 if (n_rows != in_rows || n_cols != in_cols)
return false;
998 std::string complex_real, mat_type;
999 f >> complex_real >> mat_type;
1006 if (type ==
MatType::SYM && mat_type !=
"sym")
return false;
1007 if (type ==
MatType::ASYM && mat_type !=
"asym")
return false;
1008 if (complex_real ==
"complex") {
1016 assert(!
"Read from a complex matrix is not currently supported.");
1020 for (
size_t i = 0; i !=
size(); ++i) {
1021 std::getline(f, buf,
',');
1022 _data[i] = std::stod(buf);
1050 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1051 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1053 Mat&
add(
const M1<T1, n_rows, n_cols, type, _unused1...>& mat_L,
1054 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
1056 for (
size_t i = 0; i !=
size(); ++i) {
1058 this->
_data[i] = mat_L[i] + mat_R[i];
1081 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1082 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1086 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1087 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1088 MAT_PLUS_MAT_NORMAL:
1089 for (
size_t i = 0; i != n_rows; ++i) {
1091 for (
size_t j = 0; j != n_cols; ++j) {
1093 this->
_data[i * n_cols + j] = mat_L(i, j) + mat_R(i, j);
1117 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1118 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1122 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1123 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1125 for (
size_t i = 0; i != n_rows; ++i) {
1127 this->
_data[i] = mat_L(i, i) + mat_R(i, i);
1148 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1149 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1153 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1154 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1155 MAT_PLUS_MAT_SCALAR:
1156 this->
_data[0] = mat_L(0, 0) + mat_R(0, 0);
1179 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1180 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1183 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1184 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1186 for (
size_t i = 0; i != n_rows; ++i) {
1188 for (
size_t j = i; j != n_cols; ++j) {
1190 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i] = mat_L(i, j) + mat_R(i, j);
1215 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1216 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1219 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1220 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1222 for (
size_t i = 0; i != n_rows; ++i) {
1224 for (
size_t j = i; j != n_cols; ++j) {
1226 this->
_data[(1 + i) * i / 2 + j] = mat_L(i, j) + mat_R(i, j);
1250 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1251 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1255 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1256 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1257 MAT_PLUS_MAT_SUPPER:
1258 for (
size_t i = 0; i != n_rows - 1; ++i) {
1260 for (
size_t j = i + 1; j != n_cols; ++j) {
1262 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - 2 * i - 1] = mat_L(i, j) + mat_R(i, j);
1286 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1287 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1291 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1292 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1293 MAT_PLUS_MAT_SLOWER:
1294 for (
size_t i = 1; i != n_rows; ++i) {
1296 for (
size_t j = 0; j != n_cols - 1; ++j) {
1298 this->
_data[(1 + i) * i / 2 + j - i] = mat_L(i, j) + mat_R(i, j);
1322 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1323 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1326 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1327 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1329 for (
size_t i = 0; i != n_rows; ++i) {
1331 for (
size_t j = i; j != n_cols; ++j) {
1333 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i] = mat_L(i, j) + mat_R(i, j);
1358 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1359 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1362 Mat&
add(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1363 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1365 for (
size_t i = 0; i != n_rows; ++i) {
1367 for (
size_t j = i + 1; j != n_cols; ++j) {
1369 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i * 2 - 1] = mat_L(i, j) + mat_R(i, j);
1385 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
1389 return this->
add(*
this, mat_R);
1408 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1409 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1411 Mat&
sub(
const M1<T1, n_rows, n_cols, type, _unused1...>& mat_L,
1412 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
1414 for (
size_t i = 0; i !=
size(); ++i) {
1416 this->
_data[i] = mat_L[i] - mat_R[i];
1439 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1440 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1444 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1445 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1446 MAT_MINUS_MAT_NORMAL:
1447 for (
size_t i = 0; i != n_rows; ++i) {
1449 for (
size_t j = 0; j != n_cols; ++j) {
1451 this->
_data[i * n_cols + j] = mat_L(i, j) - mat_R(i, j);
1475 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1476 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1480 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1481 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1482 MAT_MINUS_MAT_DIAGONAL:
1483 for (
size_t i = 0; i != n_rows; ++i) {
1485 this->
_data[i] = mat_L(i, i) - mat_R(i, i);
1507 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1508 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1512 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1513 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1514 MAT_MINUS_MAT_SCALAR:
1515 this->
_data[0] = mat_L(0, 0) - mat_R(0, 0);
1538 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1539 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1542 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1543 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1544 MAT_MINUS_MAT_UPPER:
1545 for (
size_t i = 0; i != n_rows; ++i) {
1547 for (
size_t j = i; j != n_cols; ++j) {
1549 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i] = mat_L(i, j) - mat_R(i, j);
1574 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1575 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1578 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1579 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1580 MAT_MINUS_MAT_LOWER:
1581 for (
size_t i = 0; i != n_rows; ++i) {
1583 for (
size_t j = i; j != n_cols; ++j) {
1585 this->
_data[(1 + i) * i / 2 + j] = mat_L(i, j) - mat_R(i, j);
1609 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1610 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1614 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1615 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1616 MAT_MINUS_MAT_SUPPER:
1617 for (
size_t i = 0; i != n_rows - 1; ++i) {
1619 for (
size_t j = i + 1; j != n_cols; ++j) {
1621 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - 2 * i - 1] = mat_L(i, j) - mat_R(i, j);
1645 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1646 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1650 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1651 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1652 MAT_MINUS_MAT_SLOWER:
1653 for (
size_t i = 1; i != n_rows; ++i) {
1655 for (
size_t j = 0; j != n_cols - 1; ++j) {
1657 this->
_data[(1 + i) * i / 2 + j - i] = mat_L(i, j) - mat_R(i, j);
1681 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1682 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1685 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1686 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1688 for (
size_t i = 0; i != n_rows; ++i) {
1690 for (
size_t j = i; j != n_cols; ++j) {
1692 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i] = mat_L(i, j) - mat_R(i, j);
1717 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1718 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
1721 Mat&
sub(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
1722 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
1724 for (
size_t i = 0; i != n_rows; ++i) {
1726 for (
size_t j = i + 1; j != n_cols; ++j) {
1728 this->
_data[(2 * n_cols + 1 - i) * i / 2 + j - i * 2 - 1] = mat_L(i, j) - mat_R(i, j);
1747 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
1752 for (
size_t i = 0; i !=
size(); ++i) {
1754 _data[i] -= mat_R[i];
1776 template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename ScalarT,
1778 std::enable_if_t<std::is_arithmetic<std::remove_cv_t<std::remove_reference_t<ScalarT>>>
::value,
bool> =
true>
1781 for (
size_t i = 0; i !=
size(); ++i) {
1783 _data[i] = mat[i] * s;
1804 template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename ScalarT,
1806 std::enable_if_t<std::is_arithmetic<std::remove_cv_t<std::remove_reference_t<ScalarT>>>
::value,
bool> =
true>
1809 for (
size_t i = 0; i !=
size(); ++i) {
1811 _data[i] = mat[i] * s;
1830 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
int AP_W,
1834 for (
size_t i = 0; i !=
size(); ++i) {
1836 _data[i] = mat[i] * s;
1859 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
int AP_W,
int AP_I,
1860 ap_q_mode AP_Q, ap_o_mode AP_O,
int AP_N,
typename T2>
1863 for (
size_t i = 0; i !=
size(); ++i) {
1865 _data[i] = mat[i] * s;
1883 std::enable_if_t<std::is_arithmetic<std::remove_cv_t<std::remove_reference_t<ScalarT>>>
::value,
bool> =
true>
1885 MAT_SCALAR_TIMES_SELF:
1886 for (
size_t i = 0; i !=
size(); ++i) {
1905 std::enable_if_t<std::is_arithmetic<std::remove_cv_t<std::remove_reference_t<ScalarT>>>
::value,
bool> =
true>
1907 MAT_SCALAR_TIMES_SELF:
1908 for (
size_t i = 0; i !=
size(); ++i) {
1927 MAT_SCALAR_TIMES_SELF:
1928 for (
size_t i = 0; i !=
size(); ++i) {
1949 template <
int AP_W,
int AP_I, ap_q_mode AP_Q, ap_o_mode AP_O,
int AP_N>
1950 Mat&
mul(ap_fixed<AP_W, AP_I, AP_Q, AP_O, AP_N> s) {
1951 MAT_SCALAR_TIMES_SELF:
1952 for (
size_t i = 0; i !=
size(); ++i) {
1981 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
1982 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
1983 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
1984 std::enable_if_t<(!(std::is_same<T1, bool>::value) && !(std::is_same<T2, bool>::value)) &&
1990 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
1991 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
1993 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
1994 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
1996 for (
size_t i = 0; i != comm; ++i) {
1998 for (
size_t r = 0; r != n_rows; ++r) {
2005 for (
size_t c = 0; c != n_cols; ++c) {
2007 if (i == 0) (*this)(r, c) = T(0);
2008 (*this)(r, c) += mat_L(r, i) * mat_R(i, c);
2037 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2038 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
2039 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2041 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2042 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2044 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2045 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2046 MAT_NORAML_OR_SYM_TIMES_MAT_ASYM:
2047 for (
size_t i = 0; i != comm; ++i) {
2049 for (
size_t r = 0; r != n_rows; ++r) {
2052 for (
size_t c = 0; c != n_cols; ++c) {
2054 if (i == 0) (*this)(r, c) = T(0);
2055 if (i != c) (*this)(r, c) += mat_L(r, i) * mat_R(i, c);
2083 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2084 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2085 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2088 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2089 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2090 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2091 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2092 MAT_NORAML_OR_SYM_TIMES_DIAG:
2093 for (
size_t i = 0; i != n_rows; ++i) {
2095 for (
size_t j = 0; j != n_cols; ++j) {
2097 (*this)(i, j) = mat_L(i, j) * mat_R[j];
2124 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2125 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2126 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2129 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2130 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2131 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2132 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2133 MAT_NORAML_OR_MAT_SYM_TIMES_SCAL:
2134 for (
size_t i = 0; i != n_rows; ++i) {
2136 for (
size_t j = 0; j != n_rows; ++j) {
2138 (*this)(i, j) = mat_L(i, j) * mat_R[0];
2166 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2167 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
2168 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2170 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2171 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2172 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2173 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2174 static const size_t r[288] = {
2175 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,
2176 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,
2177 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,
2178 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,
2179 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,
2180 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,
2181 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,
2182 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
2184 static const size_t i[288] = {
2185 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 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 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
2197 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,
2198 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,
2199 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,
2200 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,
2201 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,
2202 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
2204 MAT_NORAML_OR_MAT_SYM_TIMES_UPPER:
2205 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
2207 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
2208 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2235 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2236 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
2237 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2239 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2240 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2241 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2242 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2243 static const size_t r[288] = {
2244 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,
2245 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,
2246 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,
2247 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,
2248 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,
2249 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,
2250 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,
2251 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, 0,
2265 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,
2266 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,
2267 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,
2268 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,
2269 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,
2270 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,
2271 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
2273 MAT_NORAML_OR_MAT_SYM_TIMES_LOWER:
2274 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
2276 if (i[n] == c[n]) (*this)(r[n], c[n]) = 0;
2277 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2303 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2304 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2305 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2308 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2309 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2310 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2311 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2312 static const size_t r[224] = {
2313 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,
2314 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,
2315 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,
2316 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,
2317 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,
2318 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,
2319 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,
2321 static const size_t i[224] = {
2322 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,
2323 1, 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, 7, 7, 7, 7, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6,
2336 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,
2337 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,
2339 MAT_NORAML_OR_MAT_SYM_TIMES_SUPPER:
2340 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
2342 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
2343 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2345 for (
size_t i = 0; i != n_rows; i++) { (*this)(i, 0) = 0; }
2370 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2371 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2372 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2375 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2376 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2377 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2378 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2379 static const size_t r[224] = {
2380 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,
2381 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,
2382 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,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5, 6, 7, 1, 2, 3,
2395 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,
2397 static const size_t c[224] = {
2398 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,
2399 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,
2400 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,
2401 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,
2402 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,
2403 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,
2404 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,
2406 MAT_NORAML_OR_MAT_SYM_TIMES_SLOWER:
2407 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
2409 if (i[n] == c[n] + 1) (*this)(r[n], c[n]) = 0;
2410 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2412 for (
size_t i = 0; i != n_rows; i++) { (*this)(i, n_rows - 1) = 0; }
2436 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2437 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2438 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2440 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2441 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2442 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2443 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2444 MAT_DIAG_TIMES_MAT_DIAG:
2445 for (
size_t i = 0; i != n_rows; ++i) {
2447 (*this)(i, i) = mat_L[i] * mat_R[i];
2473 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2474 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2475 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2477 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2478 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2479 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2480 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2481 MAT_DIAG_TIMES_MAT_SCAL:
2482 for (
size_t i = 0; i != n_cols; ++i) {
2484 _data[i] = mat_L[i] * mat_R[0];
2510 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2511 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2512 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2514 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2515 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2516 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2517 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2518 static const size_t r[36] = {
2519 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,
2521 static const size_t i[36] = {
2522 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,
2524 static const size_t c[36] = {
2525 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,
2527 MAT_DIAG_TIMES_UPPER:
2528 for (
size_t n = 0; n != n_rows * (n_rows + 1) / 2; n++) {
2530 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2556 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2557 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2558 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2560 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2561 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2562 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2563 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2564 static const size_t r[36] = {
2565 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,
2567 static const size_t i[36] = {
2568 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,
2570 static const size_t c[36] = {
2571 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,
2573 MAT_DIAG_TIMES_LOWER:
2574 for (
size_t n = 0; n != n_rows * (n_rows + 1) / 2; n++) {
2576 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2602 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2603 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2604 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2606 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2607 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2608 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2609 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2610 static const size_t r[28] = {
2611 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
2613 static const size_t i[28] = {
2614 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
2616 static const size_t c[28] = {
2617 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
2619 MAT_DIAG_TIMES_SUPPER:
2620 for (
size_t n = 0; n != n_rows * (n_rows - 1) / 2; n++) {
2622 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2648 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2649 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2650 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2652 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2653 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2654 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2655 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2656 static const size_t r[28] = {
2657 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
2659 static const size_t i[28] = {
2660 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
2662 static const size_t c[28] = {
2663 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
2665 MAT_DIAG_TIMES_SLOWER:
2666 for (
size_t n = 0; n != n_rows * (n_rows - 1) / 2; n++) {
2668 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
2694 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2695 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2696 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2699 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2700 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2701 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2702 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2703 MAT_DIAG_TIMES_MAT_NORMAL_or_SYM:
2704 for (
size_t j = 0; j != n_cols; ++j) {
2706 for (
size_t i = 0; i != n_rows; ++i) {
2708 (*this)(i, j) = mat_L(i, i) * mat_R(i, j);
2735 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2736 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2737 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2739 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2740 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2741 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2742 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2743 MAT_DIAG_TIMES_MAT_ASYM:
2744 for (
size_t j = 0; j != n_cols; ++j) {
2746 for (
size_t i = 0; i != n_rows; ++i) {
2748 if (i != j) (*this)(i, j) = mat_L(i, i) * mat_R(i, j);
2749 else (*
this)(i, j) = T(0);
2774 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2775 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2776 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2778 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2779 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2780 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2781 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2782 MAT_SCAL_TIMES_MAT_SCAL:
2783 _data[0] = mat_L[0] * mat_R[0];
2808 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2809 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2810 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2812 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2813 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2814 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2815 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2816 MAT_SCAL_TIMES_MAT_DIAG:
2817 for (
size_t i = 0; i != n_cols; ++i) {
2819 _data[i] = mat_L[0] * mat_R[i];
2845 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2846 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2847 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2849 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2850 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2851 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2852 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2853 MAT_SCAL_TIMES_MAT_UPPER:
2854 for (
size_t i = 0; i != (1 + n_rows) * n_rows / 2; ++i) {
2856 _data[i] = mat_L[0] * mat_R[i];
2882 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2883 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2884 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2886 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2887 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2888 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2889 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2890 MAT_SCAL_TIMES_MAT_LOWER:
2891 for (
size_t i = 0; i != (1 + n_rows) * n_rows / 2; ++i) {
2893 _data[i] = mat_L[0] * mat_R[i];
2919 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2920 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2921 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2923 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2924 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2925 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2926 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2927 MAT_SCAL_TIMES_MAT_SUPPER:
2928 for (
size_t i = 0; i != (n_rows - 1) * n_rows / 2; ++i) {
2930 _data[i] = mat_L[0] * mat_R[i];
2956 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2957 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2958 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2960 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2961 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2962 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
2963 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
2964 MAT_SCAL_TIMES_MAT_SLOWER:
2965 for (
size_t i = 0; i != (n_rows - 1) * n_rows / 2; ++i) {
2967 _data[i] = mat_L[0] * mat_R[i];
2993 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
2994 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
2995 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
2997 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
2998 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
2999 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3000 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3001 MAT_SCAL_TIMES_MAT_SLOWER:
3002 for (
size_t i = 1; i != n_rows; ++i) {
3004 for (
size_t j = 0; j != n_cols; ++j) {
3006 if (i != j) (*this)(i, j) = mat_L[0] * mat_R(i, j);
3007 else (*
this)(i, j) = T(0);
3034 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3035 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3036 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3038 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3039 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3040 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3041 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3042 MAT_SCAL_TIMES_MAT_NORMAL_OR_MAT_SYM:
3043 for (
size_t i = 0; i != n_rows; ++i) {
3045 for (
size_t j = 0; j != n_cols; ++j) {
3047 (*this)(i, j) = mat_L[0] * mat_R(i, j);
3074 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3075 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3076 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3078 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3079 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3080 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3081 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3082 MAT_UPPER_TIMES_MAT_SCALAR:
3083 for (
size_t i = 0; i != (n_rows + 1) * n_rows / 2; ++i) {
3085 _data[i] = mat_L[i] * mat_R[0];
3111 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3112 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3113 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3115 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3116 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3117 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3118 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3119 static const size_t r[36] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
3120 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7 };
3121 static const size_t i[36] = { 0, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4,
3122 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7 };
3123 static const size_t c[36] = { 0, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4,
3124 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 5, 6, 7, 6, 7, 7 };
3125 MAT_UPPER_TIMES_DIAG:
3126 for (
size_t n = 0; n != n_rows * (n_rows + 1) / 2; n++) {
3128 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3154 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3155 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3156 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3158 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3159 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3161 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3162 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3163 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,
3164 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 0, 0, 0, 0, 1, 1, 1, 1,
3165 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2,
3166 2, 2, 2, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
3167 2, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
3168 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,
3169 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 0, 1, 2, 3, 1, 2, 3, 4,
3170 2, 3, 4, 5, 3, 4, 5, 6, 4, 5, 6, 7, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3,
3171 4, 5, 6, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5,
3172 6, 7, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7 };
3173 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,
3174 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 3, 3, 3, 3, 4, 4, 4, 4,
3175 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6,
3176 6, 6, 6, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7,
3177 7, 7, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 };
3178 MAT_UPPER_TIMES_UPPER:
3179 for (
size_t n = 0; n != n_rows * (n_rows + 1) * (n_rows + 2) / 6; n++) {
3181 if (i[n] == r[n]) (*this)(r[n], c[n]) = 0;
3182 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3208 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3209 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3210 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3212 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3213 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3215 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3216 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3217 static const size_t r[120] = {
3218 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,
3219 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,
3220 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,
3221 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,
3223 static const size_t i[120] = {
3224 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,
3225 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,
3226 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,
3227 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,
3229 static const size_t c[120] = {
3230 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,
3231 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,
3232 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,
3233 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,
3235 MAT_UPPER_TIMES_MAT_LOWER:
3236 for (
size_t n = 0; n != n_rows * (n_rows + 1) * (n_rows + 2) / 6; n++) {
3238 if (i[n] == r[n]) (*this)(r[n], c[n]) = 0;
3239 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3265 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3266 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3267 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3269 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3270 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3272 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3273 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3274 static const size_t c[84] = {
3275 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,
3276 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,
3277 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,
3279 static const size_t i[84] = {
3280 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,
3281 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,
3282 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,
3284 static const size_t r[84] = {
3285 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,
3286 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,
3287 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,
3289 MAT_UPPER_TIMES_MAT_SUPPER:
3290 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 6; n++) {
3292 if (i[n] == r[n]) (*this)(r[n], c[n]) = 0;
3293 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3319 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3320 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3321 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3323 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3324 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3326 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3327 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3328 static const size_t r[168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4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7,
3342 static const size_t c[168] = {
3343 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,
3344 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,
3345 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,
3346 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,
3347 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,
3349 MAT_UPPER_TIMES_MAT_SLOWER:
3350 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 3; n++) {
3352 if (i[n] == r[n] || i[n] == (c[n] + 1)) (*this)(r[n], c[n]) = 0;
3353 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3379 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3380 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3381 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3383 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3384 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3386 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3387 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3388 static const size_t r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 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,
3412 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,
3413 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,
3414 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,
3415 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,
3416 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,
3418 MAT_UPPER_TIMES_MAT_ASYM:
3419 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
3421 if (i[n] == r[n]) (*this)(r[n], c[n]) = 0;
3422 if (i[n] != c[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3449 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3450 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
3451 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3453 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3454 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3456 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3457 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3458 static const size_t r[288] = {
3459 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,
3460 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,
3461 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,
3462 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,
3463 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,
3464 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,
3465 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,
3466 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,
3468 static const size_t c[288] = {
3469 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
3481 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,
3482 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,
3483 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,
3484 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,
3485 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,
3486 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,
3488 MAT_LOWER_TIMES_NORAML_OR_MAT_SYM:
3489 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
3491 if (i[n] == r[n]) (*this)(r[n], c[n]) = 0;
3492 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3518 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3519 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3520 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3522 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3523 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3524 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3525 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3526 MAT_LOWER_TIMES_MAT_SCALAR:
3527 for (
size_t i = 0; i != (n_rows + 1) * n_rows / 2; ++i) {
3529 _data[i] = mat_L[i] * mat_R[0];
3555 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3556 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3557 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3559 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3560 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3561 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3562 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3563 static const size_t r[36] = {
3564 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,
3566 static const size_t i[36] = {
3567 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,
3569 static const size_t c[36] = {
3570 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,
3572 MAT_LOWER_TIMES_DIAG:
3573 for (
size_t n = 0; n != n_rows * (n_rows + 1) / 2; n++) {
3575 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3601 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3602 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3603 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3605 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3606 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3608 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3609 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3610 static const size_t r[204] = {
3611 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,
3612 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,
3613 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,
3614 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,
3615 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,
3616 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,
3618 static const size_t i[204] = {
3619 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,
3620 1, 0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 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7,
3632 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,
3634 MAT_LOWER_TIMES_MAT_UPPER:
3635 for (
size_t n = 0; n != (2 * n_rows * n_rows * n_rows + 3 * n_rows * n_rows + n_rows) / 6; n++) {
3637 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
3638 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3664 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3665 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3666 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3668 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3669 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3671 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3672 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3673 static const size_t c[120] = {
3674 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,
3675 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,
3676 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,
3677 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,
3679 static const size_t i[120] = {
3680 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,
3681 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,
3682 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,
3683 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,
3685 static const size_t r[120] = {
3686 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,
3687 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,
3688 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,
3689 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,
3691 MAT_LOWER_TIMES_MAT_LOWER:
3692 for (
size_t n = 0; n != n_rows * (n_rows + 1) * (n_rows + 2) / 6; n++) {
3694 if (i[n] == c[n]) (*this)(r[n], c[n]) = 0;
3695 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3721 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3722 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3723 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3725 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3726 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3728 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3729 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3730 static const size_t r[168] = {
3731 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,
3732 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,
3733 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,
3734 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,
3735 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,
3737 static const size_t i[168] = {
3738 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,
3739 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,
3740 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,
3741 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,
3742 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,
3744 static const size_t c[168] = {
3745 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,
3746 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,
3747 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,
3748 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,
3749 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,
3751 MAT_LOWER_TIMES_MAT_SUPPER:
3752 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 3; n++) {
3754 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
3755 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3757 for (
size_t r = 0; r != n_cols; r++) { (*this)(r, 0) = T(0); }
3783 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3784 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3785 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3787 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3788 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3790 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3791 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3792 static const size_t c[84] = {
3793 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,
3794 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,
3795 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,
3797 static const size_t i[84] = {
3798 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,
3799 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,
3800 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,
3802 static const size_t r[84] = {
3803 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,
3804 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,
3805 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,
3807 MAT_LOWER_TIMES_MAT_SLOWER:
3808 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 6; n++) {
3810 if (i[n] == c[n] + 1) (*this)(r[n], c[n]) = 0;
3811 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3837 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3838 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3839 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3841 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3842 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3844 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3845 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3846 static const size_t c[288] = {
3847 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,
3848 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,
3849 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,
3850 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,
3851 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,
3852 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,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, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7,
3876 MAT_LOWER_TIMES_MAT_ASYM:
3877 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
3879 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
3880 if (i[n] != c[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3907 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3908 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
3909 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3911 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3912 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3914 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3915 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3916 static const size_t c[288] = {
3917 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,
3918 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,
3919 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,
3920 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,
3921 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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
3944 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,
3946 MAT_LOWER_TIMES_MAT_NORMAL_OR_MAT_SYM:
3947 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
3949 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
3950 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
3976 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
3977 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
3978 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
3980 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
3981 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
3982 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
3983 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
3984 MAT_SUPPER_TIMES_MAT_SCALAR:
3985 for (
size_t i = 0; i != (n_rows - 1) * n_rows / 2; ++i) {
3987 _data[i] = mat_L[i] * mat_R[0];
4013 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4014 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4015 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4017 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4018 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4019 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4020 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4021 static const size_t c[28] = {
4022 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,
4024 static const size_t i[28] = {
4025 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,
4027 static const size_t r[28] = {
4028 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,
4030 MAT_SUPPER_TIMES_MAT_DIAG:
4031 for (
size_t n = 0; n != n_rows * (n_rows - 1) / 2; n++) {
4033 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4059 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4060 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4061 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4063 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4064 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4066 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4067 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4068 static const size_t r[84] = {
4069 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,
4070 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,
4071 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,
4073 static const size_t i[84] = {
4074 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,
4075 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,
4076 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,
4078 static const size_t c[84] = {
4079 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,
4080 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,
4081 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,
4083 MAT_SUPPER_TIMES_MAT_UPPER:
4084 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 6; n++) {
4086 if (i[n] == r[n] + 1) (*this)(r[n], c[n]) = 0;
4087 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4113 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4114 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4115 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4117 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4118 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4120 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4121 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4122 static const size_t c[168] = {
4123 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,
4124 1, 1, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4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 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,
4139 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,
4140 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,
4141 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,
4143 MAT_UPPER_TIMES_MAT_SLOWER:
4144 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 3; n++) {
4146 if (i[n] == c[n] || i[n] == (r[n] + 1)) (*this)(r[n], c[n]) = 0;
4147 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4149 for (
size_t c = 0; c != n_cols; c++) { (*this)(n_rows - 1, c) = T(0); }
4175 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4176 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4177 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4179 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4180 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4182 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4183 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4184 static const size_t r[56] = {
4185 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,
4186 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,
4188 static const size_t i[56] = {
4189 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,
4190 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,
4192 static const size_t c[56] = {
4193 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,
4194 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,
4196 MAT_SUPPER_TIMES_MAT_SUPPER:
4197 for (
size_t n = 0; n != ((n_rows - 1) * (n_rows - 1) * (n_rows - 1) - (n_rows - 1)) / 6; n++) {
4199 if (i[n] == 1 + r[n]) (*this)(r[n], c[n]) = 0;
4200 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4202 for (
size_t i = 0; i != n_rows - 1; i++) { (*this)(i, i + 1) = T(0); }
4228 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4229 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
4230 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4234 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4235 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4237 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4238 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4239 static const size_t c[140] = {
4240 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, 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, 1, 1,
4254 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,
4255 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,
4257 MAT_SUPPER_TIMES_MAT_SLOWER:
4259 n != (2 * (n_rows - 1) * (n_rows - 1) * (n_rows - 1) + 3 * (n_rows - 1) * (n_rows - 1) + (n_rows - 1)) / 6;
4262 if (i[n] == r[n] + 1 || i[n] == c[n] + 1) (*this)(r[n], c[n]) = T(0);
4263 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4265 for (
size_t r = 0; r != n_rows; r++) { (*this)(r, n_cols - 1) = T(0); }
4266 for (
size_t c = 0; c != n_cols - 1; c++) { (*this)(n_rows - 1, c) = T(0); }
4292 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4293 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4294 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4296 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4297 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4299 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4300 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4301 static const size_t c[224] = {
4302 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,
4303 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,
4304 2, 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, 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3,
4317 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,
4319 static const size_t r[224] = {
4320 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,
4321 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,
4322 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,
4323 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,
4324 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,
4325 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,
4326 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,
4328 MAT_SUPPER_TIMES_MAT_ASYM:
4329 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
4331 if (i[n] == r[n] + 1) (*this)(r[n], c[n]) = T(0);
4332 if (i[n] != c[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4334 for (
size_t c = 0; c != n_cols; c++) { (*this)(n_rows - 1, c) = T(0); }
4360 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4361 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4362 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4365 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4366 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4368 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4369 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4370 static const size_t c[224] = {
4371 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,
4372 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,
4373 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,
4374 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,
4375 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,
4376 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,
4377 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7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 5, 4, 4, 4, 3, 3, 3, 3, 2, 2,
4392 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,
4393 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,
4394 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,
4395 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,
4397 MAT_SUPPER_TIMES_MAT_NORMAL_OR_SYM:
4398 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
4400 if (i[n] == r[n] + 1) (*this)(r[n], c[n]) = T(0);
4401 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4403 for (
size_t c = 0; c != n_cols; c++) { (*this)(n_rows - 1, c) = T(0); }
4428 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4429 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4430 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4432 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4433 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4434 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4435 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4436 MAT_SLOWER_TIMES_MAT_SCALAR:
4437 for (
size_t i = 0; i != (n_rows - 1) * n_rows / 2; ++i) {
4439 _data[i] = mat_L[i] * mat_R[0];
4465 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4466 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4467 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4469 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4470 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4471 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4472 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4473 static const size_t c[28] = {
4474 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,
4476 static const size_t i[28] = {
4477 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,
4479 static const size_t r[28] = {
4480 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,
4482 MAT_SLOWER_TIMES_MAT_DIAG:
4483 for (
size_t n = 0; n != n_rows * (n_rows - 1) / 2; n++) {
4485 (*this)(r[n], c[n]) = mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4511 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4512 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4513 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4515 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4516 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4518 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4519 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4520 static const size_t c[168] = {
4521 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 1,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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,
4536 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,
4537 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,
4538 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,
4539 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,
4541 MAT_SLOWER_TIMES_MAT_UPPER:
4542 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 3; n++) {
4544 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
4545 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4547 for (
size_t c = 0; c != n_cols; c++) { (*this)(0, c) = T(0); }
4573 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4574 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4575 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4577 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4578 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4580 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4581 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4582 static const size_t c[84] = {
4583 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,
4584 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,
4585 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,
4587 static const size_t i[84] = {
4588 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,
4589 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,
4590 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,
4592 static const size_t r[84] = {
4593 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,
4594 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,
4595 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,
4597 MAT_SLOWER_TIMES_MAT_LOWER:
4598 for (
size_t n = 0; n != (n_rows * n_rows * n_rows - n_rows) / 6; n++) {
4600 if (i[n] == c[n]) (*this)(r[n], c[n]) = 0;
4601 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4627 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4628 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4629 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4631 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4632 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4634 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4635 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4636 static const size_t c[140] = {
4637 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,
4638 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,
4639 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,
4640 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,
4642 static const size_t i[140] = {
4643 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,
4644 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,
4645 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,
4646 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,
4648 static const size_t r[140] = {
4649 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,
4650 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,
4651 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,
4652 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,
4654 MAT_SLOWER_TIMES_MAT_SUPPER:
4656 n != (2 * (n_rows - 1) * (n_rows - 1) * (n_rows - 1) + 3 * (n_rows - 1) * (n_rows - 1) + (n_rows - 1)) / 6;
4659 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
4660 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4662 for (
size_t r = 0; r != n_rows; r++) { (*this)(r, 0) = T(0); }
4663 for (
size_t c = 1; c != n_cols; c++) { (*this)(0, c) = T(0); }
4690 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4691 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4692 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4694 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4695 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4697 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4698 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4699 static const size_t c[56] = {
4700 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,
4701 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,
4703 static const size_t i[56] = {
4704 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,
4705 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,
4707 static const size_t r[56] = {
4708 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,
4709 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,
4711 MAT_SLOWER_TIMES_MAT_SLOWER:
4712 for (
size_t n = 0; n != ((n_rows - 1) * (n_rows - 1) * (n_rows - 1) - (n_rows - 1)) / 6; n++) {
4714 if (i[n] == 1 + c[n]) (*this)(r[n], c[n]) = 0;
4715 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4717 for (
size_t i = 0; i != n_rows - 1; i++) { (*this)(i, i - 1) = T(0); }
4743 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4744 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4745 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4747 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4748 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4750 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4751 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4752 static const size_t c[224] = {
4753 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,
4754 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,
4755 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,
4756 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,
4757 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,
4758 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,
4759 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,
4761 static const size_t i[224] = {
4762 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,
4763 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,
4764 2, 3, 0, 1,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2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7,
4777 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,
4779 MAT_SLOWER_TIMES_MAT_ASYM:
4780 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
4782 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
4783 if (i[n] != c[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4785 for (
size_t c = 0; c != n_cols; ++c) { (*this)(0, c) = T(0); }
4810 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4811 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4812 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4815 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4816 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4818 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4819 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4820 static const size_t c[224] = {
4821 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,
4822 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,
4823 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,
4824 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4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 2, 3, 4, 5, 6,
4838 static const size_t r[224] = {
4839 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,
4840 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,
4841 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,
4842 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,
4843 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,
4844 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,
4845 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,
4847 MAT_SLOWER_TIMES_MAT_NORMAL_OR_MAT_SYM:
4848 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
4850 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
4851 (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
4853 for (
size_t c = 0; c != n_cols; ++c) { (*this)(0, c) = T(0); }
4878 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4879 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4880 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4882 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4883 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4884 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4885 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4886 MAT_ASYM_TIMES_MAT_DIAG:
4887 for (
size_t i = 0; i != n_rows; ++i) {
4889 for (
size_t j = 0; j != n_rows; ++j) {
4891 if (i != j) (*this)(i, j) = mat_L(i, j) * mat_R[j];
4894 for (
size_t c = 0; c != n_cols; ++c) { (*this)(c, c) = T(0); }
4919 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4920 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4921 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4923 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4924 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4925 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4926 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4927 MAT_ASYM_TIMES_MAT_SCAL:
4928 for (
size_t i = 0; i != n_rows; ++i) {
4930 for (
size_t j = i + 1; j != n_rows; ++j) {
4932 if (i != j) (*this)(i, j) = mat_L(i, j) * mat_R[0];
4959 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
4960 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
4961 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
4963 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
4964 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
4965 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
4966 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
4967 static const size_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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,
4991 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,
4992 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,
4993 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,
4994 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,
4995 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,
4997 MAT_ASYM_TIMES_MAT_UPPER:
4998 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
5000 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
5001 if (r[n] != i[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
5027 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5028 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5029 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5031 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5032 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5033 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5034 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5035 static const size_t r[288] = {
5036 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,
5037 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,
5038 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,
5039 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,
5040 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,
5041 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,
5042 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,
5043 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,
5045 static const size_t i[288] = {
5046 7, 6, 7, 5, 6, 7, 4, 5, 6, 7, 3, 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, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
5058 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,
5059 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,
5060 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,
5061 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,
5062 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,
5063 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,
5065 MAT_ASYM_TIMES_MAT_LOWER:
5066 for (
size_t n = 0; n != n_rows * n_rows * (n_rows + 1) / 2; n++) {
5068 if (i[n] == c[n]) (*this)(r[n], c[n]) = 0;
5069 if (r[n] != i[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
5095 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5096 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5097 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5099 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5100 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5101 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5102 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5103 static const size_t r[224] = {
5104 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,
5105 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,
5106 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,
5107 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,
5108 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,
5109 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,
5110 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,
5112 static const size_t i[224] = {
5113 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,
5114 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5,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5, 5, 5, 5, 6, 6, 6, 6, 6,
5127 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,
5128 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,
5130 MAT_ASYM_TIMES_SUPPER:
5131 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
5133 if (i[n] == 0) (*this)(r[n], c[n]) = 0;
5134 if (r[n] != i[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
5136 for (
size_t r = 0; r != n_rows; r++) { (*this)(r, 0) = T(0); }
5162 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5163 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5164 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5166 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5167 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5168 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5169 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5170 static const size_t r[224] = {
5171 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,
5172 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,
5173 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,
5174 3, 3,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6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7,
5188 static const size_t c[224] = {
5189 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,
5190 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,
5191 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,
5192 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,
5193 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,
5194 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,
5195 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,
5197 MAT_ASYM_TIMES_SLOWER:
5198 for (
size_t n = 0; n != n_rows * n_rows * (n_rows - 1) / 2; n++) {
5200 if (i[n] == c[n] + 1) (*this)(r[n], c[n]) = 0;
5201 if (r[n] != i[n]) (*this)(r[n], c[n]) += mat_L(r[n], i[n]) * mat_R(i[n], c[n]);
5203 for (
size_t r = 0; r != n_rows; r++) { (*this)(r, n_cols - 1) = T(0); }
5231 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5232 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
5233 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5235 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5236 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5238 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5239 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5240 MAT_ASYM_TIMES_MAT_NORMAL:
5241 for (
size_t i = 0; i != comm; ++i) {
5243 for (
size_t r = 0; r != n_rows; ++r) {
5246 for (
size_t c = 0; c != n_cols; ++c) {
5248 if (i == 0) (*this)(r, c) = T(0);
5249 if (r != i) (*this)(r, c) += mat_L(r, i) * mat_R(i, c);
5277 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5278 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5279 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5281 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5282 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5284 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5285 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5286 MAT_ASYM_TIMES_MAT_ASYM:
5288 for (
size_t r = 0; r != n_rows; ++r) {
5291 for (
size_t c = 0; c != n_cols; ++c) {
5292 for (
size_t i = 0; i != comm; ++i) {
5294 if (i == 0) (*this)(r, c) = T(0);
5295 if (i != c && i != r) (*this)(r, c) += mat_L(r, i) * mat_R(i, c);
5325 template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5326 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
typename T2,
5327 MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5333 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5334 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5336 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5337 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5339 for (
size_t c = 0; c < n_cols; ++c) {
5340 for (
size_t i = 0; i < comm; ++i) {
5342 for (
size_t r = 0; r < n_rows; ++r) {
5344 (*this)(r, c) += mat_L(r, i) * mat_R(i, c);
5374 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5375 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5376 typename T2,
MatType type1,
MatType type2,
size_t rows_,
size_t cols_,
size_t comm,
5377 std::enable_if_t<(std::is_same<T2, bool>::value && !std::is_same<T1, bool>::value) &&
5383 Mat&
mul(
const M1<T1, rows_, comm, type1, _unused1...>& mat_L,
5384 const M2<T2, comm, cols_, type2, _unused2...>& mat_R) {
5386 static_assert(n_rows == rows_,
"Matrix dimension should meet.");
5387 static_assert(n_cols == cols_,
"Matrix dimension should meet.");
5389 for (
size_t r = 0; r != n_rows; ++r) {
5392 for (
size_t c = 0; c != n_cols; ++c) {
5394 for (
size_t i = 0; i != comm; ++i) {
5396 if (i == 0) (*this)(r, c) = T(0);
5397 if (mat_R(i, c) != 0) (*this)(r, c) += mat_L(r, i);
5423 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
5424 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
5425 typename T2,
size_t rows_,
size_t cols_,
MatType type1,
MatType type2,
5426 std::enable_if_t<rows_ == n_rows && cols_ == n_cols && type1 == type && type2 == type, bool> =
true>
5427 Mat&
emul(
const M1<T1, rows_, cols_, type1, _unused1...>& mat_L,
5428 const M2<T2, rows_, cols_, type2, _unused2...>& mat_R) {
5429 for (
size_t i = 0; i !=
size(); ++i) {
5431 _data[i] = mat_L[i] * mat_R[i];
5450 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5451 MatType type2,
size_t rows_,
size_t cols_>
5453 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
5454 "the matrix's columns.'.");
5455 static_assert(
size() == rows_,
"Element number should be rows_ in Mat::col(mat, index).");
5456 for (
size_t i = 0; i !=
size(); ++i) {
5458 _data[i] = mat(i, c);
5463 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5464 MatType type2,
size_t rows_,
size_t cols_>
5465 [[deprecated(
"Use .col_ to create a MatRefCol to write a column instead.")]]
void
5467 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
5468 "the matrix's columns.'.");
5469 assert(mat.size() == n_rows &&
"Element number should be n_rows in Mat::col(index, mat).");
5470 for (
int i = 0; i != mat.size(); ++i) {
5472 (*this)(i, c) = mat[i];
5491 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
5492 "the matrix's columns.'.");
5494 for (
size_t i = 0; i != n_rows; ++i) {
5496 mat(i, 0) = (*this)(i, c);
5507 assert(index < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number "
5508 "of the matrix's columns.'.");
5509 return { *
this, index };
5513 assert(index < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number "
5514 "of the matrix's columns.'.");
5515 return { *
this, index };
5533 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5534 MatType type2,
size_t rows_,
size_t cols_>
5536 assert(r < rows_ &&
"row should be smaller than rows_ of mat in Mat::row.");
5537 static_assert(
size() == cols_,
"The number of the Matrices' n_cols should meet.");
5538 for (
size_t j = 0; j !=
size(); ++j) {
5540 _data[j] = mat(r, j);
5560 assert(r < n_rows &&
"Take the specific row by index requires 'The index should be smaller than the number of "
5561 "the matrix's rows.'.");
5563 for (
size_t j = 0; j != n_cols; ++j) {
5565 mat(0, j) = (*this)(r, j);
5599 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5600 MatType type2,
size_t rows_,
size_t cols_>
5602 assert(first_col < n_cols &&
"Take the successive n_cols by index requires 'The indexes should be smaller than "
5603 "the number of the matrix's columns.'.");
5604 assert(first_col >
int(0) &&
5605 "Take the successive n_cols by index requires 'The indexes can't be smaller than 0'.");
5606 static_assert(n_rows == rows_,
"The number of the Matrices' rows should meet.");
5607 for (
size_t j = 0; j != n_cols; ++j) {
5609 for (
size_t i = 0; i != n_rows; ++i) {
5611 (*this)(i, j) = mat(i, j + first_col);
5636 template <
size_t _cols>
5638 assert(first_col < n_cols &&
"Take the successive n_cols by index requires 'The indexes should be smaller than "
5639 "the number of the matrix's columns.'.");
5640 assert(first_col >
int(0) &&
5641 "Take the successive n_cols by index requires 'The indexes can't be smaller than 0'.");
5642 static_assert(_cols > int(1),
5643 "Take the successive n_cols by index requires 'The total number can't be smaller than 1'.");
5646 for (
size_t j = 0; j != _cols; ++j) {
5648 for (
size_t i = 0; i != n_rows; ++i) {
5650 mat(i, j) = (*this)(i, j + first_col);
5661 template <
size_t first_col,
size_t last_col>
5663 static_assert(first_col > int(0),
5664 "Take the successive cols by index requires 'The first index can't be smaller than 0'.");
5666 first_col < last_col,
5667 "Take the successive cols by index requires 'The first index should be smaller than the last index'.");
5668 static_assert(last_col < n_cols,
"Take the successive cols by index requires 'The last index should be smaller "
5669 "than the number of the matrix's cols.'.");
5689 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5690 MatType type2,
size_t rows_,
size_t cols_>
5692 assert(first_row < n_rows &&
"Take the successive n_rows by index requires 'The indexes should be smaller than "
5693 "the number of the matrix's rows.'.");
5694 assert(first_row >
int(0) &&
5695 "Take the successive n_rows by index requires 'The indexes can't be smaller than 0'.");
5696 static_assert(n_cols == cols_,
"The number of the Matrices' cols should meet.");
5697 for (
size_t i = 0; i != n_rows; ++i) {
5699 for (
size_t j = 0; j != n_cols; ++j) {
5701 (*this)(i, j) = mat(i + first_row, j);
5727 template <
size_t _rows>
5729 assert(first_row < n_rows &&
"Take the successive n_rows by index requires 'The indexes should be smaller than "
5730 "the number of the matrix's rows.'.");
5731 assert(first_row >
int(0) &&
5732 "Take the successive n_rows by index requires 'The indexes can't be smaller than 0'.");
5733 static_assert(_rows > int(1),
5734 "Take the successive n_rows by index requires 'The total number can't be smaller than 1'.");
5737 for (
size_t i = 0; i != _rows; ++i) {
5739 for (
size_t j = 0; j != n_cols; ++j) {
5741 mat(i, j) = (*this)(i + first_row, j);
5753 template <
size_t first_row,
size_t last_row>
5756 first_row < last_row,
5757 "Take the successive rows by index requires 'The first index should be smaller than the last index'.");
5758 static_assert(last_row < n_rows,
"Take the successive rows by index requires 'The last index should be smaller "
5759 "than the number of the matrix's rows.'.");
5781 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
typename M2,
5782 typename T1,
MatType type1,
size_t rows_,
size_t cols_>
5783 Mat&
rows(
const M1<T1, rows_, cols_, type1, _unused1...>& mat, M2 vector) {
5784 static_assert(n_cols == cols_,
"The number of the Matrices' cols should meet.");
5785 for (
size_t i = 0; i != n_rows; ++i) {
5787 assert(vector[i] >
int(0) &&
5788 "Take the discrete n_rows by index requires 'The indexes can't be smaller than 0'.");
5789 assert(vector[i] < n_rows &&
"Take the discrete n_rows by index requires 'The indexes should be smaller "
5790 "than the number of the matrix's rows.'.");
5791 for (
size_t j = 0; j != n_cols; ++j) {
5793 (*this)(i, j) = mat(vector[i], j);
5818 template <
size_t _rows,
typename M2>
5821 for (
size_t i = 0; i != _rows; ++i) {
5823 assert(vector[i] >=
int(0) &&
5824 "Take the discrete n_rows by index requires 'The indexes can't be smaller than 0'.");
5825 assert(vector[i] < n_rows &&
"Take the discrete n_rows by index requires 'The indexes should be smaller "
5826 "than the number of the matrix's rows.'.");
5827 for (
size_t j = 0; j != n_cols; ++j) {
5829 mat(i, j) = (*this)(vector[i], j);
5853 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
typename M2,
5854 typename T1,
MatType type1,
size_t rows_,
size_t cols_>
5855 Mat&
cols(
const M1<T1, rows_, cols_, type1, _unused1...>& mat, M2 vector) {
5856 static_assert(n_rows == rows_,
"The number of the Matrices' rows should meet.");
5857 for (
size_t j = 0; j != n_cols; ++j) {
5859 assert(vector[j] >=
int(0) &&
5860 "Take the discrete n_cols by index requires 'The indexes can't be smaller than 0'.");
5861 assert(vector[j] < n_cols &&
"Take the discrete n_cols by index requires 'The indexes should be smaller "
5862 "than the number of the matrix's cols.'.");
5863 for (
size_t i = 0; i != n_rows; ++i) {
5865 (*this)(i, j) = mat(i, vector[j]);
5890 template <
size_t _cols,
typename M2>
5893 for (
size_t j = 0; j != _cols; ++j) {
5895 assert(vector[j] >=
int(0) &&
5896 "Take the discrete n_cols by index requires 'The indexes can't be smaller than 0'.");
5897 assert(vector[j] < n_cols &&
"Take the discrete n_cols by index requires 'The indexes should be smaller "
5898 "than the number of the matrix's cols.'.");
5899 for (
size_t i = 0; i != n_cols; ++i) {
5901 mat(i, j) = (*this)(i, vector[j]);
5914 for (
size_t i = 0; i !=
size(); ++i) {
5935 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
5941 MAT_TRANSPOSE_NORMAL:
5942 for (
size_t i = 0; i != n_cols; ++i) {
5944 for (
size_t j = 0; j != n_rows; ++j) {
5946 _data[n_rows * i + j] = mat._data[n_rows * j + i];
5950 MAT_TRANSPOSE_UPPER:
5951 for (
size_t i = 0; i != n_cols; ++i) {
5953 for (
size_t j = i; j != n_rows; ++j) {
5955 (*this)(i, j) = mat(j, i);
5959 MAT_TRANSPOSE_LOWER:
5960 for (
size_t i = 0; i != n_cols; ++i) {
5962 for (
size_t j = 0; j <= i; ++j) {
5964 (*this)(i, j) = mat(j, i);
5968 MAT_TRANSPOSE_SUPPER:
5969 for (
size_t i = 0; i != n_cols; ++i) {
5971 for (
size_t j = i; j != n_rows; ++j) {
5973 (*this)(i, j) = mat(j, i);
5977 MAT_TRANSPOSE_SLOWER:
5978 for (
size_t i = 0; i != n_cols; ++i) {
5980 for (
size_t j = i; j != n_rows; ++j) {
5982 (*this)(i, j) = mat(j, i);
5987 for (
size_t i = 0; i != n_cols; ++i) {
5989 for (
size_t j = i + 1; j != n_rows; ++j) {
5991 (*this)(i, j) = mat(j, i);
5995 assert(!
"Impossible");
6014 template <
typename... _unused,
MatType _type = type,
6015 typename std::enable_if_t<_type == MatType::NORMAL, bool> =
true>
6018 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6019 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6021 MAT_TRANSPOSE_NORMAL:
6022 for (
size_t i = 0; i != n_cols; ++i) {
6024 for (
size_t j = 0; j != n_rows; ++j) {
6026 mat(i, j) = (*this)(j, i);
6044 template <
typename... _unused,
MatType _type = type,
6045 typename std::enable_if_t<
6048 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6066 template <
typename... _unused,
MatType _type = type,
6067 typename std::enable_if_t<_type == MatType::UPPER, bool> =
true>
6069 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6070 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6072 MAT_TRANSPOSE_NORMAL:
6073 for (
size_t i = 0; i != n_cols; ++i) {
6075 for (
size_t j = 0; j != n_rows; ++j) {
6077 mat(i, j) = (*this)(j, i);
6097 template <
typename... _unused,
MatType _type = type,
6098 typename std::enable_if_t<_type == MatType::LOWER, bool> =
true>
6100 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6101 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6103 MAT_TRANSPOSE_LOWER:
6104 for (
size_t i = 0; i != n_cols; ++i) {
6106 for (
size_t j = i; j <= i; ++j) {
6108 mat(j, i) = (*this)(i, j);
6128 template <
typename... _unused,
MatType _type = type,
6129 typename std::enable_if_t<_type == MatType::SUPPER, bool> =
true>
6131 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6132 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6134 MAT_TRANSPOSE_SUPPER:
6135 for (
size_t i = 0; i != n_cols - 1; ++i) {
6137 for (
size_t j = i + 1; j != n_rows; ++j) {
6139 mat(j, i) = (*this)(i, j);
6159 template <
typename... _unused,
MatType _type = type,
6160 typename std::enable_if_t<_type == MatType::SLOWER, bool> =
true>
6162 static_assert(
sizeof...(_unused) == 0,
"Do not specify template arguments for Mat::t()!");
6163 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6165 MAT_TRANSPOSE_SLOWER:
6166 for (
size_t i = 1; i != n_cols; ++i) {
6168 for (
size_t j = i + 1; j != n_rows - 1; ++j) {
6170 mat(j, i) = (*this)(i, j);
6190 template <
typename... _unused,
MatType _type = type,
typename std::enable_if_t<_type == MatType::ASYM, bool> =
true>
6192 static_assert(n_cols > 0 && n_rows > 0,
"The matrix should have size when transposing.");
6195 for (
size_t i = 1; i != n_cols; ++i) {
6197 for (
size_t j = i + 1; j != n_rows - 1; ++j) {
6199 mat(j, i) = (*this)(i, j);
6224 static_assert(type !=
MatType::UPPER,
"Upper matrix cannot perform in place transpose.");
6225 static_assert(type !=
MatType::LOWER,
"Lower matrix cannot perform in place transpose.");
6226 static_assert(type !=
MatType::SUPPER,
"Strict upper matrix cannot perform in place transpose.");
6227 static_assert(type !=
MatType::SLOWER,
"Strict lower matrix cannot perform in place transpose.");
6228 static_assert(n_rows == n_cols,
"In-place transpose requires a square matrix.");
6230 MAT_NORMAL_TRANSPOSE_SELF:
6231 for (
size_t i = 0; i != n_cols; ++i) {
6233 for (
size_t j = i; j != n_cols; ++j) {
6235 std::swap(
_data[n_cols * i + j],
_data[n_cols * j + i]);
6239 MAT_AYSM_TRANSPOSE_SELF:
6240 for (
size_t i = 0; i != n_cols * (n_cols - 1) / 2; ++i) {
6261 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2>
6264 for (
size_t i = 0; i !=
size(); ++i) {
6288 for (
size_t i = 0; i !=
size(); ++i) {
6316 for (
size_t i = 0; i !=
size(); ++i) {
6335 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6338 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6339 for (
size_t i = 0; i != n_rows; ++i) {
6341 (*this)(i, i) = mat(i, i);
6362 for (
size_t i = 0; i != n_rows; ++i) {
6364 mat(i, i) = (*this)(i, i);
6375 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6392 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6395 static_assert(n_cols == 1,
"Diagonal vector has column number as 1.");
6396 for (
size_t i = 0; i != n_rows; ++i) {
6398 _data[i] = mat(i, i);
6418 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6420 for (
size_t i = 0; i != n_rows; ++i) {
6422 mat.
_data[i] = (*this)(i, i);
6433 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6450 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6453 static_assert(n_rows == 1,
"Diagonal vector has column number as 1.");
6454 for (
size_t i = 0; i != n_cols; ++i) {
6456 _data[i] = mat(i, i);
6476 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6478 for (
size_t i = 0; i != n_cols; ++i) {
6480 mat.
_data[i] = (*this)(i, i);
6491 static_assert(n_rows == n_cols,
"Take the diagonal requires 'n_rows == n_cols'.");
6508 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6511 static_assert(n_rows == n_cols,
"Take the off diagonal requires 'n_rows == n_cols'.");
6512 static_assert(type ==
MatType::NORMAL,
"Take the off diagonal requires the matrix to be NORMAL.");
6513 for (
size_t i = 0; i != n_rows; ++i) {
6515 for (
size_t j = 0; j != n_cols; ++j) {
6517 if (i != j) (*this)(i, j) = mat(i, j);
6518 else (*
this)(i, j) = T(0);
6539 static_assert(n_rows == n_cols,
"Take the off diagonal requires 'n_rows == n_cols'.");
6540 static_assert(type ==
MatType::NORMAL,
"Take the off diagonal requires the matrix to be NORMAL.");
6542 for (
size_t i = 0; i != n_rows; ++i) {
6544 for (
size_t j = 0; j != n_cols; ++j) {
6546 if (i != j) mat(i, j) = (*this)(i, j);
6547 else mat(i, j) = T(0);
6559 static_assert(n_rows == n_cols,
"Take the off diagonal requires 'n_rows == n_cols'.");
6579 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6582 static_assert(type ==
MatType::DIAGONAL,
"'invDiag' is only used for diagonal matrix.");
6583 for (
size_t i = 0; i != n_rows; ++i) {
6585 _data[i] = T(1.0) / mat(i, i);
6597 static_assert(type ==
MatType::DIAGONAL,
"'invDiag' is only used for diagonal matrix.");
6599 for (
size_t i = 0; i != n_rows; ++i) {
6616 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6619 static_assert(n_rows == n_cols,
"Calculate inverse needs to be a square matrix.");
6620 assert(iter >= 1 &&
"At least one iteration is needed.");
6621 const auto D = mat.diagMat_();
6622 const auto E = mat.offDiag_();
6627 auto D_inv_opp = -D_inv;
6632 for (
size_t i = 1; i < iter; ++i) {
6633 tmp.
mul(*
this, product);
6637 this->
mul(sum_tmp, D_inv);
6638 return *
this += D_inv;
6652 static_assert(n_rows == n_cols,
"Calculate inverse needs to be a square matrix.");
6673 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
6674 MatType type2,
typename coeff_type>
6676 static_assert(n_rows == n_cols,
"Calculate inverse needs to be a square matrix.");
6677 assert(iter >= 1 &&
"At least one iteration is needed.");
6689 template <
typename coeff_type>
6691 static_assert(n_rows == n_cols,
"Calculate inverse needs to be a square matrix.");
6698 template <
typename Tp = T>
6701 for (
size_t i = 0; i !=
size(); ++i) {
6714 static_assert(n_rows == 1 && n_cols == 1,
"This only applies to matrix of size 1x1.");
6724 static_assert(n_rows == 1 && n_cols == 1,
"This only applies to matrix of size 1x1.");
6734 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const {
6735#ifndef __SYNTHESIS__
6736 static_assert(n_rows > 0 && n_cols > 0,
"Print requires this matrix be of valid size.");
6738 for (
size_t i = 0; i + 1 < n_rows; ++i) {
6740 for (
size_t j = 0; j + 1 < n_cols; ++j) os <<
static_cast<T
>((*
this)(i, j)) <<
", ";
6741 os << static_cast<T>((*
this)(i, n_cols - 1)) <<
"]," << std::endl;
6744 for (
size_t j = 0; j + 1 < n_cols; ++j) os <<
static_cast<T
>((*
this)(n_rows - 1, j)) <<
", ";
6745 os << static_cast<T>((*
this)(n_rows - 1, n_cols - 1)) <<
"]]" << std::endl;
6796 if (r == c) (*this)(r, c) =
value;
6798 if (r <= c) (*this)(r, c) =
value;
6800 if (r >= c) (*this)(r, c) =
value;
6802 if (r < c) (*this)(r, c) =
value;
6804 if (r > c) (*this)(r, c) =
value;
6806 if (r <= c) (*this)(r, c) =
value;
6808 if (r < c) (*this)(r, c) =
value;
6810 (*this)(r, c) =
value;
6812 assert(!
"Impossible! Unknown type!");
6826 if (r >= n_rows || c >= n_cols)
return;
6842 if (r == c) (*this)(r, c) +=
value;
6844 if (r <= c) (*this)(r, c) +=
value;
6846 if (r >= c) (*this)(r, c) +=
value;
6848 if (r < c) (*this)(r, c) +=
value;
6850 if (r > c) (*this)(r, c) +=
value;
6852 if (r != c) (*this)(r, c) +=
value;
6854 (*this)(r, c) +=
value;
6856 (*this)(r, c) +=
value;
6858 assert(!
"Impossible! Unknown type!");
6875 template <
typename Tmp,
typename M,
typename Comm,
typename Zero>
6877 Comm __attribute__((unused)) _comm_foo, Zero zero)
const {
6879 constexpr size_t comm = Comm::value;
6881 for (
size_t j = 0; j < n_rows; ++j) {
6883 tmp_L[j][0] = ((j <= i + begin_shift) && (i + begin_shift - j < comm))
6884 ? mat_L(j, comm - 1 - (i + begin_shift - j))
6902 template <
typename Tmp,
typename M,
typename Comm,
typename Zero>
6904 Comm __attribute__((unused)) _comm_foo, Zero zero)
const {
6906 constexpr size_t comm = Comm::value;
6908 for (
size_t j = 0; j < n_cols; ++j) {
6910 tmp_R[0][j] = ((j <= i + begin_shift) && (i + begin_shift - j < comm))
6911 ? mat_R(comm - 1 - (i + begin_shift - j), j)
6926 template <
typename T1,
typename T2,
typename HLSVec>
6927 inline void _sa_multiply(
const T1& tmp_L,
const T2& tmp_R,
const HLSVec& use_assign) {
6930 for (
size_t r = 0; r != n_rows; ++r) {
6932 for (
size_t c = 0; c != n_cols; ++c) {
6934 T result = tmp_L[r][c] * tmp_R[r][c];
6935 if (use_assign[r * n_cols + c]) {
6966 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
6967 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
6970 const M2<T2, comm, n_cols, type2, _unused2...>& mat_R,
size_t begin_shift = 0,
6971 size_t end_shift = 0) {
6974 T1 tmp_L[n_rows][n_cols];
6975 T2 tmp_R[n_rows][n_cols];
6976 std::vector<bool> use_assign(n_rows * n_cols,
true);
6978#ifdef FLAMES_MAT_PARTITION_COMPLETE
6979 FLAMES_PRAGMA(ARRAY_PARTITION variable = tmp_L type = complete)
6980 FLAMES_PRAGMA(ARRAY_PARTITION variable = tmp_R type = complete)
6985 auto write_L = [&](
size_t i) {
6986 if (i + 1 != n_rows + comm + n_cols - 2 - begin_shift - end_shift) {
6988 for (
size_t c = n_cols; c > 1; --c) {
6990 for (
size_t r = 0; r < n_rows; ++r) {
6992 if (c <= i + 2 && r + c <= i + begin_shift + 2 && r <= i) { tmp_L[r][c - 1] = tmp_L[r][c - 2]; }
6998 auto write_R = [&](
size_t i) {
6999 if (i + 1 != n_rows + comm + n_cols - 2 - begin_shift - end_shift) {
7001 for (
size_t r = n_rows; r > 1; --r) {
7003 for (
size_t c = 0; c < n_cols; ++c) {
7005 if (r <= i + 2 && c + r <= i + begin_shift + 2 && c <= i) { tmp_R[r - 1][c] = tmp_R[r - 2][c]; }
7011 auto set_assign_ctl = [&](
size_t i) {
7014 for (
size_t r = 0; r < n_rows; ++r) {
7017 if (c < n_cols) { use_assign[r * n_cols + c] =
false; }
7020 std::integral_constant<int, comm> _comm_foo = {};
7021 SYSTOLIC_ARRAY_MAT_MUL:
7022 for (
size_t i = 0; i < n_rows + comm + n_cols - 2 - begin_shift - end_shift; ++i) {
7052 : type ==
MatType::
ASYM ? (n_rows - 1) * n_rows / 2
7053 : (1 + n_rows) * n_rows / 2];
7056template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
7081 inline static constexpr size_t size() noexcept {
7088 : (1 + n_rows) * n_rows / 2;
7092 for (
size_t i = 0; i !=
size(); ++i) {
7099 template <
typename M>
7101 for (
size_t i = 0; i !=
size(); ++i) {
7116 assert(r < n_rows &&
"Matrix row index should be within range");
7117 assert(c < n_cols &&
"Matrix col index should be within range");
7119 return _data[r * n_cols + c];
7121 if (r == c)
return _data[r];
7124 if (r == c)
return _data[0];
7127 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7130 if (r >= c)
return _data[(1 + r) * r / 2 + c];
7133 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 2 * r - 1];
7136 if (r >= c)
return _data[(1 + r) * r / 2 + c - r];
7139 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7140 else return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7142 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r * 2 - 1];
7143 else if (r > c)
return -
_data[(2 * n_cols + 1 - c) * c / 2 + r - c * 2 - 1];
7147 assert(!
"Impossible! Unknown MatType!");
7160 assert(index <
size() &&
"[index] should be in range in MatView");
7161 return _data[index];
7178 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7179 MatType type2,
size_t rows_,
size_t cols_>
7181 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7182 "the matrix's columns.'.");
7183 static_assert(
size() == rows_,
"Element number should be rows_ in Mat::col(mat, index).");
7184 for (
size_t i = 0; i !=
size(); ++i) {
7186 _data[i] = mat(i, c);
7191 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7192 MatType type2,
size_t rows_,
size_t cols_>
7194 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7195 "the matrix's columns.'.");
7196 assert(mat.size() == n_rows &&
"Element number should be n_rows in Mat::col(index, mat).");
7197 for (
int i = 0; i != mat.size(); ++i) {
7199 (*this)(i, c) = mat[i];
7218 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7219 "the matrix's columns.'.");
7221 for (
size_t i = 0; i != n_rows; ++i) {
7223 mat(i, 0) = (*this)(i, c);
7228 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7233 for (
size_t i = 0; i !=
size(); ++i) {
7235 _data[i] += mat_R[i];
7240 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7245 for (
size_t i = 0; i !=
size(); ++i) {
7247 _data[i] -= mat_R[i];
7254 template <
typename Tp = T>
7257 for (
size_t i = 0; i !=
size(); ++i) {
7264 template <
typename Tp = T>
7267 for (
size_t i = 0; i !=
size(); ++i) {
7270 if (d > 0) p +=
static_cast<Tp
>(d);
7295 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
7302template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
7326 inline static constexpr size_t size() noexcept {
7333 : (1 + n_rows) * n_rows / 2;
7337 for (
size_t i = 0; i !=
size(); ++i) {
7344 template <
typename M>
7346 for (
size_t i = 0; i !=
size(); ++i) {
7361 assert(r < n_rows &&
"Matrix row index should be within range");
7362 assert(c < n_cols &&
"Matrix col index should be within range");
7364 return _data[r * n_cols + c];
7366 if (r == c)
return _data[r];
7369 if (r == c)
return _data[0];
7372 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7375 if (r >= c)
return _data[(1 + r) * r / 2 + c];
7378 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 2 * r - 1];
7381 if (r >= c)
return _data[(1 + r) * r / 2 + c - r];
7384 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7385 else return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7387 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r * 2 - 1];
7388 else if (r > c)
return -
_data[(2 * n_cols + 1 - c) * c / 2 + r - c * 2 - 1];
7392 assert(!
"Impossible! Unknown MatType!");
7406 assert(r < n_rows &&
"Matrix row index should be within range");
7407 assert(c < n_cols &&
"Matrix col index should be within range");
7409 return _data[r * n_cols + c];
7411 if (r == c)
return _data[r];
7412 else assert(!
"This element cannot be modified (DIAGONAL).");
7414 assert(!
"This element cannot be modified (SCALAR).");
7416 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7417 else assert(!
"This element cannot be modified (UPPER).");
7419 if (r >= c)
return _data[(1 + r) * r / 2 + c];
7420 else assert(!
"This element cannot be modified (LOWER).");
7422 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
7423 else assert(!
"This element cannot be modified (SUPPER).");
7425 if (r > c)
return _data[(1 + r) * r / 2 + c - r];
7426 else assert(!
"This element cannot be modified (SLOWER).");
7428 if (r <= c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7429 else return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7431 if (r < c)
return _data[(2 * n_cols + 1 - r) * r / 2 + c - 1 - 2 * r];
7432 else if (r > c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - 1 - 2 * c];
7437 else assert(!
"This element cannot be modified (ASYM).");
7440 assert(!
"Impossible! Unknown MatType!");
7454 assert(index <
size() &&
"[index] should be in range in MatView");
7455 return _data[index];
7466 assert(index <
size() &&
"[index] should be in range in MatView");
7467 return _data[index];
7476 for (
size_t i = 0; i !=
size(); ++i) {
7502 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7503 MatType type2,
size_t rows_,
size_t cols_>
7505 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7506 "the matrix's columns.'.");
7507 static_assert(
size() == rows_,
"Element number should be rows_ in Mat::col(mat, index).");
7508 for (
size_t i = 0; i !=
size(); ++i) {
7510 _data[i] = mat(i, c);
7515 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7516 MatType type2,
size_t rows_,
size_t cols_>
7518 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7519 "the matrix's columns.'.");
7520 assert(mat.size() == n_rows &&
"Element number should be n_rows in Mat::col(index, mat).");
7521 for (
int i = 0; i != mat.size(); ++i) {
7523 (*this)(i, c) = mat[i];
7542 assert(c < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number of "
7543 "the matrix's columns.'.");
7545 for (
size_t i = 0; i != n_rows; ++i) {
7547 mat(i, 0) = (*this)(i, c);
7552 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7557 for (
size_t i = 0; i !=
size(); ++i) {
7559 _data[i] += mat_R[i];
7564 template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T2,
7569 for (
size_t i = 0; i !=
size(); ++i) {
7571 _data[i] -= mat_R[i];
7578 template <
typename Tp = T>
7581 for (
size_t i = 0; i !=
size(); ++i) {
7588 template <
typename Tp = T>
7591 for (
size_t i = 0; i !=
size(); ++i) {
7594 if (d > 0) p +=
static_cast<Tp
>(d);
7619 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
7626template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
7648 inline static constexpr size_t size() noexcept {
7655 : (1 + n_rows) * n_rows / 2;
7667 assert(r < n_rows &&
"Matrix row index should be within range");
7668 assert(c < n_cols &&
"Matrix col index should be within range");
7670 return -
_data[r * n_cols + c];
7672 if (r == c)
return -
_data[r];
7675 if (r == c)
return -
_data[0];
7678 if (r <= c)
return -
_data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7681 if (r >= c)
return -
_data[(1 + r) * r / 2 + c];
7684 if (r < c)
return -
_data[(2 * n_cols + 1 - r) * r / 2 + c - 2 * r - 1];
7687 if (r >= c)
return -
_data[(1 + r) * r / 2 + c - r];
7690 if (r <= c)
return -
_data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7691 else return -
_data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7693 if (r < c)
return -
_data[(2 * n_cols + 1 - r) * r / 2 + c - r * 2 - 1];
7694 else if (r > c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - c * 2 - 1];
7698 assert(!
"Impossible! Unknown MatType!");
7710 assert(index <
size() &&
"[index] should be in range in MatViewOpp");
7711 return -
_data[index];
7738template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
7765 inline static constexpr size_t size() noexcept {
7772 : (1 + n_rows) * n_rows / 2;
7784 assert(r < n_rows &&
"Matrix row index should be within range");
7785 assert(c < n_cols &&
"Matrix col index should be within range");
7787 return _data[c * n_rows + r];
7789 if (r == c)
return _data[r];
7792 if (r == c)
return _data[0];
7795 if (r <= c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7798 if (r >= c)
return _data[(1 + c) * c / 2 + r];
7801 if (r < c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - 2 * c - 1];
7804 if (r >= c)
return _data[(1 + c) * c / 2 + r - c];
7807 if (r <= c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - c];
7808 else return _data[(2 * n_cols + 1 - r) * r / 2 + c - r];
7810 if (r < c)
return -
_data[(2 * n_cols + 1 - r) * r / 2 + c - r * 2 - 1];
7811 else if (r > c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - c * 2 - 1];
7815 assert(!
"Impossible! Unknown MatType!");
7837 c = r + index - (2 * n_cols + 1 - r) * r / 2;
7840 c = index - (r + 1) * r / 2;
7843 c = 2 * r + 1 + index - c - (2 * n_cols + 1 - r) * r / 2;
7846 c = index - (1 + r) * r / 2 + r;
7849 c = r + index - (2 * n_cols + 1 - r) * r / 2;
7852 c = 2 * r + 1 + index - c - (2 * n_cols + 1 - r) * r / 2;
7854 return (*
this)(r, c);
7887template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent>
7896 static_assert(type ==
MatType::DIAGONAL && N == N_,
"DiagMat is and comes from a square matrix.");
7914 for (
size_t i = 0; i != N; ++i) {
7916 mat[i] =
static_cast<T
>(1) / (*
this)[i];
7926 inline static constexpr size_t size() noexcept {
7951 if (r != c)
return T(0);
7954 return _data[r * N + c];
7960 return _data[(2 * N + 1 - r) * r / 2];
7962 return _data[(1 + r) * r / 2 + r];
7968 return _data[(2 * N + 1 - r) * r / 2];
7973 assert(!
"Impossible! Unknown MatType!");
7983 T
operator[](
size_t index)
const {
return (*
this)(index, index); }
7996 for (
size_t i = 0; i != N; ++i) {
7998 mat[i] = (*this)[i];
8023template <
typename T,
size_t N,
size_t n_cols, MatType type,
typename type_parent>
8032 static_assert(n_cols == 1,
"DiagVec is a column vector.");
8047 inline static constexpr size_t size() noexcept {
8065 for (
size_t i = 0; i != N; ++i) {
8067 mat[i] =
static_cast<T
>(1) / (*
this)[i];
8087 assert(c == 0 &&
"Column vector's column index should always be 0.");
8090 return _data[r * N + r];
8096 return _data[(2 * N + 1 - r) * r / 2];
8098 return _data[(1 + r) * r / 2 + r];
8104 return _data[(2 * N + 1 - r) * r / 2];
8109 assert(!
"Impossible! Unknown MatType!");
8129 for (
size_t i = 0; i != N; ++i) {
8131 mat[i] = (*this)[i];
8165template <
typename T,
size_t n_rows,
size_t N, MatType type,
typename type_parent>
8174 static_assert(n_rows == 1,
"DiagRowVec is a row vector.");
8189 inline static constexpr size_t size() noexcept {
8214 assert(r == 0 &&
"Row vector's row index should always be 0.");
8217 return _data[c * N + c];
8223 return _data[(2 * N + 1 - c) * c / 2];
8225 return _data[(1 + c) * c / 2 + c];
8231 return _data[(2 * N + 1 - c) * c / 2];
8236 assert(!
"Impossible! Unknown MatType!");
8256 for (
size_t i = 0; i != N; ++i) {
8258 mat[i] = (*this)[i];
8292template <
typename T,
size_t N,
size_t N_, MatType type,
typename type_parent>
8301 static_assert(type ==
MatType::NORMAL && N == N_,
"OffDiag is and comes from a square and normal matrix.");
8316 inline static constexpr size_t size() noexcept {
8341 if (r == c)
return T(0);
8344 return _data[r * N + c];
8346 if (r == c)
return _data[r];
8349 if (r == c)
return _data[0];
8352 if (r <= c)
return _data[(2 * N + 1 - r) * r / 2 + c - r];
8355 if (r >= c)
return _data[(1 + r) * r / 2 + c];
8358 if (r < c)
return _data[(2 * N + 1 - r) * r / 2 + c - 2 * r - 1];
8361 if (r >= c)
return _data[(1 + r) * r / 2 + c - r];
8364 if (r <= c)
return _data[(2 * N + 1 - r) * r / 2 + c - r];
8365 else return _data[(2 * N + 1 - c) * c / 2 + r - c];
8367 if (r < c)
return _data[(2 * N + 1 - r) * r / 2 + c - r * 2 - 1];
8368 else if (r > c)
return -
_data[(2 * N + 1 - c) * c / 2 + r - c * 2 - 1];
8372 assert(!
"Impossible! Unknown MatType!");
8384 if (index % (N + 1) == 0)
return T(0);
8385 else return this->
_data[index];
8396 for (
size_t i = 0; i != N * N; ++i) {
8398 if (i % (N + 1) == 0) mat[i] = 0;
8399 else mat[i] = this->
_data[i];
8423template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent>
8432 static_assert(type ==
MatType::NORMAL,
"We only support limited matType.");
8433 assert(index < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number "
8434 "of the matrix's cols.'");
8449 inline static constexpr size_t size() noexcept {
return n_rows; }
8466 assert(c == 0 &&
"Column vector's column index should always be 0.");
8467 assert(r < n_rows &&
"Matrix row index should be within range");
8470 return _data[r * n_cols];
8473 assert(!
"Impossible! Unknown MatType!");
8493 for (
size_t i = 0; i != n_rows; ++i) {
8495 mat[i] = (*this)[i];
8520 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
8531template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent>
8540 :
_data(m.rawDataPtr() + index * n_cols) {
8541 static_assert(type ==
MatType::NORMAL,
"We only support limited matType.");
8542 assert(index < n_rows &&
"Take the specific row by index requires 'The index should be smaller than the number "
8543 "of the matrix's rows.'");
8558 inline static constexpr size_t size() noexcept {
return n_cols; }
8575 assert(r == 0 &&
"Row vector's row index should always be 0.");
8576 assert(c < n_cols &&
"Matrix column index should be within range");
8582 assert(!
"Impossible! Unknown MatType!");
8602 for (
size_t i = 0; i != n_cols; ++i) {
8604 mat[i] = (*this)[i];
8629 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
8640template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent>
8649 static_assert(type ==
MatType::NORMAL,
"We only support limited matType.");
8650 assert(index < n_cols &&
"Take the specific col by index requires 'The index should be smaller than the number "
8651 "of the matrix's cols.'");
8662 template <
typename T_,
size_t n_rows_,
size_t n_cols_, MatType type_>
8664 for (
size_t i = 0; i !=
size(); ++i) {
8666 _data[i * n_rows] = m[i];
8671 template <
typename M>
8673 for (
size_t i = 0; i !=
size(); ++i) {
8675 _data[i * n_rows] = m[i];
8684 inline static constexpr size_t size() noexcept {
return n_rows; }
8701 assert(c == 0 &&
"Column vector's column index should always be 0.");
8702 assert(r < n_rows &&
"Matrix row index should be within range");
8705 return _data[r * n_cols];
8708 assert(!
"Impossible! Unknown MatType!");
8714 assert(c == 0 &&
"Column vector's column index should always be 0.");
8715 assert(r < n_rows &&
"Matrix row index should be within range");
8718 return _data[r * n_cols];
8721 assert(!
"Impossible! Unknown MatType!");
8743 for (
size_t i = 0; i != n_rows; ++i) {
8745 mat[i] = (*this)[i];
8770 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
8781template <
typename T,
size_t n_rows,
size_t n_cols, MatType type,
typename type_parent>
8790 :
_data(m.rawDataPtr() + index * n_cols) {
8791 static_assert(type ==
MatType::NORMAL,
"We only support limited matType.");
8792 assert(index < n_rows &&
"Take the specific row by index requires 'The index should be smaller than the number "
8793 "of the matrix's rows.'");
8804 template <
typename T_,
size_t n_rows_,
size_t n_cols_, MatType type_>
8806 for (
size_t i = 0; i !=
size(); ++i) {
8813 template <
typename M>
8815 for (
size_t i = 0; i !=
size(); ++i) {
8826 inline static constexpr size_t size() noexcept {
return n_cols; }
8843 assert(r == 0 &&
"Row vector's row index should always be 0.");
8844 assert(c < n_cols &&
"Matrix column index should be within range");
8850 assert(!
"Impossible! Unknown MatType!");
8856 assert(r == 0 &&
"Row vector's row index should always be 0.");
8857 assert(c < n_cols &&
"Matrix column index should be within range");
8863 assert(!
"Impossible! Unknown MatType!");
8885 for (
size_t i = 0; i != n_cols; ++i) {
8887 mat[i] = (*this)[i];
8912 void print(
const std::string& str =
"", std::ostream& os = std::cout)
const { this->
asMat().print(str, os); }
8923template <
size_t first_col,
size_t last_col,
typename T,
size_t n_rows,
size_t n_cols,
MatType type,
8924 typename type_parent>
8933 static_assert(last_col < n_cols,
"Take the successive cols by indexes requires 'The indexes should be smaller "
8934 "than the number of the matrix's cols.'");
8935 static_assert(first_col > 0,
"Take the specific col by index requires 'The indexes can't be smaller than 0.'");
8936 static_assert(first_col <= last_col,
"The first index should be smaller than the second one.");
8951 inline static constexpr size_t size() noexcept {
8958 : (1 + n_rows) * n_rows / 2;
8976 assert(c < (last_col - first_col + 1) &&
8977 "The col index must be small than the number of the successive columns .");
8978 assert(r > 0 &&
"The row index can't be smaller than 0.");
8981 return _data[r * n_cols + c + first_col];
8983 if (r == (c + first_col))
return _data[r];
8986 if (r == (c + first_col))
return _data[0];
8989 if (r <= (c + first_col))
return _data[(2 * n_cols + 1 - r) * r / 2 + c + first_col - r];
8992 if (r >= (c + first_col))
return _data[(1 + r) * r / 2 + c + first_col - r];
8995 if (r < (c + first_col))
return _data[(2 * n_cols + 1 - r) * r / 2 + c + first_col - 2 * r - 1];
8998 if (r >= (c + first_col))
return _data[(1 + r) * r / 2 + c + first_col - r];
9001 if (r <= (c + first_col))
return _data[(2 * n_cols + 1 - r) * r / 2 + c + first_col - r];
9002 else return _data[(2 * n_cols + 1 - (c + first_col)) * (c + first_col) / 2 + r - (c + first_col)];
9004 if (r < (c + first_col))
return -
_data[(2 * n_cols + 1 - r) * r / 2 + (c + first_col) - r * 2 - 1];
9005 else if (r > (c + first_col))
9006 return _data[(2 * n_cols + 1 - (c + first_col)) * (c + first_col) / 2 + r - (c + first_col) * 2 - 1];
9010 assert(!
"Impossible! Unknown MatType!");
9021 return (*
this)(index / (last_col - first_col + 1), index % (last_col - first_col + 1));
9031 for (
size_t i = 0; i != n_rows * (last_col - first_col + 1); ++i) {
9033 mat[i] = (*this)[i];
9045 return static_cast<Mat<T, n_rows, last_col - first_col + 1,
MatType::NORMAL>>(*this);
9057template <
size_t first_row,
size_t last_row,
typename T,
size_t n_rows,
size_t n_cols,
MatType type,
9058 typename type_parent>
9067 static_assert(last_row < n_rows,
"Take the successive rows by indexes requires 'The indexes should be smaller "
9068 "than the number of the matrix's rows.'");
9069 static_assert(first_row > 0,
"Take the specific row by index requires 'The indexes can't be smaller than 0.'");
9070 static_assert(first_row <= last_row,
"The first index should be smaller than the second one.");
9085 inline static constexpr size_t size() noexcept {
9092 : (1 + n_rows) * n_rows / 2;
9110 assert(r < last_row - first_row &&
"The row index must be small than the number of the successive rows .");
9111 assert(c > 0 &&
"The row index can't be smaller than 0.");
9114 return _data[(r + first_row) * n_cols + c];
9116 if ((r + first_row) == c)
return _data[r];
9119 if ((r + first_row) == c)
return _data[0];
9122 if ((r + first_row) <= c)
9123 return _data[(2 * n_cols + 1 - (r + first_row)) * (r + first_row) / 2 + c - (r + first_row)];
9126 if ((r + first_row) >= c)
return _data[(1 + (r + first_row)) * (r + first_row) / 2 + c];
9129 if ((r + first_row) < c)
9130 return _data[(2 * n_cols + 1 - (r + first_row)) * (r + first_row) / 2 + c - 2 * (r + first_row) - 1];
9133 if ((r + first_row) >= c)
return _data[(1 + (r + first_row)) * (r + first_row) / 2 + c - (r + first_row)];
9136 if ((r + first_row) <= c)
9137 return _data[(2 * n_cols + 1 - (r + first_row)) * (r + first_row) / 2 + c - (r + first_row)];
9138 else return _data[(2 * n_cols + 1 - c) * c / 2 + (r + first_row) - c];
9140 if ((r + first_row) < c)
9141 return -
_data[(2 * n_cols + 1 - (r + first_row)) * (r + first_row) / 2 + c - (r + first_row) * 2 - 1];
9142 else if ((r + first_row) > c)
return _data[(2 * n_cols + 1 - c) * c / 2 + r - c * 2 - 1];
9146 assert(!
"Impossible! Unknown MatType!");
9156 T
operator[](
size_t index)
const {
return (*
this)(index / n_cols, index % n_cols); }
9165 for (
size_t i = 0; i != n_rows * (last_row - first_row + 1); ++i) {
9167 mat[i] = (*this)[i];
9179 return static_cast<Mat<T, last_row - first_row + 1, n_cols,
MatType::NORMAL>>(*this);
9189 return static_cast<Mat<T, last_row - first_row + 1, n_cols,
MatType::NORMAL>>(*this);
9219template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9220 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9221 typename T2,
size_t n_rows,
size_t n_cols,
MatType type1,
MatType type2>
9222static inline Mat<T1, n_rows, n_cols,
sumType(type1, type2)>
9223operator+(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
9224 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
9227 return mat.
add(mat_L, mat_R);
9245template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T1,
typename T2,
9250 return mat_L.
add(mat_R);
9271template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9272 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9273 typename T2,
size_t n_rows,
size_t n_cols,
MatType type1,
MatType type2>
9274static inline Mat<T1, n_rows, n_cols,
sumType(type1, type2)>
9275operator-(
const M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
9276 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
9279 return mat.
sub(mat_L, mat_R);
9297template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9298 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9299 typename T2,
size_t n_rows,
size_t n_cols,
MatType type1,
MatType type2>
9300static inline M1<T1, n_rows, n_cols, type1>&
operator-=(M1<T1, n_rows, n_cols, type1, _unused1...>& mat_L,
9301 const M2<T2, n_rows, n_cols, type2, _unused2...>& mat_R) {
9303 return mat_L.
sub(mat_R);
9324template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T1,
typename T2,
9326 std::enable_if_t<(std::is_same<T1, bool>::value),
bool> =
true>
9327static inline Mat<T1, n_rows, n_cols,
mulType(type1, type2, n_rows, n_cols, n_cols)>
9330 Mat<T2, n_rows, n_cols,
mulType(type1, type2, n_rows, n_cols, n_cols)> tmp;
9331 tmp.
mul(mat, mat_R);
9350template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T1,
typename T2,
9352 std::enable_if_t<!(std::is_same<T1, bool>::value),
bool> =
true>
9353static inline Mat<T1, n_rows, n_cols,
mulType(type1, type2, n_rows, n_cols, n_cols)>
9356 Mat<T1, n_rows, n_cols,
mulType(type1, type2, n_rows, n_cols, n_cols)> tmp;
9357 tmp.
mul(mat, mat_R);
9376template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T,
9377 typename ScalarT,
size_t n_rows,
size_t n_cols,
MatType type,
9378 std::enable_if_t<std::is_arithmetic<std::remove_reference_t<ScalarT>>::value,
bool> =
true>
9401template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T,
9402 typename ScalarT,
size_t n_rows,
size_t n_cols,
MatType type,
9403 std::enable_if_t<std::is_arithmetic<std::remove_reference_t<ScalarT>>::value,
bool> =
true>
9407 return mat.
mul(mat_L, s);
9428template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T,
9429 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>
9431 ap_fixed<AP_W, AP_I, AP_Q, AP_O, AP_N> s) {
9434 return mat.
mul(mat_L, s);
9454template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T,
9455 typename ScalarT,
size_t n_rows,
size_t n_cols,
MatType type,
9456 std::enable_if_t<std::is_arithmetic<std::remove_reference_t<ScalarT>>::value,
bool> =
true>
9460 return mat.
mul(mat_R, s);
9481template <
template <
class, size_t, size_t,
MatType,
class...>
typename M,
typename... _unused,
typename T,
9482 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>
9487 return mat.
mul(mat_R, s);
9513template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9514 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9515 typename T2,
size_t n_rows,
size_t comm,
size_t n_cols,
MatType type1,
MatType type2,
9516 std::enable_if_t<(std::is_same<T1, bool>::value),
bool> =
true>
9517static inline Mat<T2, n_rows, n_cols,
mulType(type1, type2, n_rows, comm, n_cols)>
9518operator*(
const M1<T1, n_rows, comm, type1, _unused1...>& mat_L,
9519 const M2<T2, comm, n_cols, type2, _unused2...>& mat_R) {
9520 Mat<T2, n_rows, n_cols,
mulType(type1, type2, n_rows, comm, n_cols)> mat;
9521 mat.
mul(mat_L, mat_R);
9526template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9527 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9528 typename T2,
size_t n_rows,
size_t comm,
size_t n_cols,
MatType type1,
MatType type2,
9529 std::enable_if_t<!(std::is_same<T1, bool>::value),
bool> =
true>
9530static inline Mat<T1, n_rows, n_cols,
mulType(type1, type2, n_rows, comm, n_cols)>
9531operator*(
const M1<T1, n_rows, comm, type1, _unused1...>& mat_L,
9532 const M2<T2, comm, n_cols, type2, _unused2...>& mat_R) {
9533 Mat<T1, n_rows, n_cols,
mulType(type1, type2, n_rows, comm, n_cols)> mat;
9534 mat.
mul(mat_L, mat_R);
9560template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9561 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9562 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9564 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9566 return mat.
emul(mat_L, mat_R);
9587template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9588 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9589 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9591 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9594 for (
size_t i = 0; i != mat_L.size(); ++i) {
9596 mat[i] = mat_L[i] == mat_R[i];
9619template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9620 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9621 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9623 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9626 for (
size_t i = 0; i != mat_L.size(); ++i) {
9628 mat[i] = mat_L[i] != mat_R[i];
9651template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9652 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9653 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9655 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9658 for (
size_t i = 0; i != mat_L.size(); ++i) {
9660 mat[i] = mat_L[i] > mat_R[i];
9683template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9684 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9685 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9686Mat<bool, n_rows, n_cols, type>
operator<(
const M1<T1, n_rows, n_cols, type, _unused1...>& mat_L,
9687 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9688 Mat<bool, n_rows, n_cols, type> mat;
9690 for (
size_t i = 0; i != mat_L.size(); ++i) {
9692 mat[i] = mat_L[i] < mat_R[i];
9715template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9716 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9717 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9719 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9722 for (
size_t i = 0; i != mat_L.size(); ++i) {
9724 mat[i] = mat_L[i] >= mat_R[i];
9747template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9748 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9749 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9750Mat<bool, n_rows, n_cols, type>
operator<=(
const M1<T1, n_rows, n_cols, type, _unused1...>& mat_L,
9751 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9752 Mat<bool, n_rows, n_cols, type> mat;
9754 for (
size_t i = 0; i != mat_L.size(); ++i) {
9756 mat[i] = mat_L[i] <= mat_R[i];
9779template <
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9780 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9781 typename T2,
size_t n_rows,
size_t n_cols,
MatType type>
9783 const M2<T2, n_rows, n_cols, type, _unused2...>& mat_R) {
9786 for (
size_t i = 0; i != mat_L.size(); ++i) {
9788 mat[i] = mat_L[i] % mat_R[i];
9793template <
typename Tp = double,
template <
class, size_t, size_t,
MatType,
class...>
typename M1,
typename... _unused1,
9794 template <
class, size_t, size_t,
MatType,
class...>
typename M2,
typename... _unused2,
typename T1,
9795 typename T2,
size_t L_rows,
size_t L_cols,
size_t R_rows,
size_t R_cols,
MatType type,
9796 std::enable_if_t<L_rows * L_cols == R_rows * R_cols, bool> =
true>
9797Tp
innerProd(
const M1<T1, L_rows, L_cols, type, _unused1...>& mat_L,
9798 const M2<T2, R_rows, R_cols, type, _unused2...>& mat_R) {
9799 assert(mat_L.size() == mat_R.size() &&
"Dimension should meet for innerProd.");
9802 for (
size_t i = 0; i != mat_L.size(); ++i) {
9804 result +=
static_cast<Tp
>(mat_L[i] * mat_R[i]);
9821template <
typename T,
size_t n_rows,
size_t n_cols, MatType type>
9829#ifndef FLAMES_PRESERVE_WARNING
9830# ifdef __SYNTHESIS__
9831# pragma GCC diagnostic pop
9835#ifdef DEFINED_INLINE
9836# define INLINE inline
9837# undef DEFINED_INLINE
Matrix.
Definition core.hpp:575
Mat & sub(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Matrix self minus a matrix.
Definition core.hpp:1749
MatViewOpp< T, n_rows, n_cols, type > opp_() const
Matrix opposite as a read only view.
Definition core.hpp:6300
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:5819
T operator[](size_t index) const
Get read only element by row major index from the data array.
Definition core.hpp:860
Mat & mul(ap_int< AP_W > s)
Matrix self multiply ap_int integer.
Definition core.hpp:1926
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:5691
Vec< T, n_rows > diagVec() const
Take the diagonal vector of a matrix and make a copy.
Definition core.hpp:6417
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:6876
T * rawDataPtr()
Get the raw data array pointer.
Definition core.hpp:6779
MatRefCol< T, n_rows, n_cols, MatType::NORMAL, MType< type > > col_(size_t index)
Definition core.hpp:5512
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:5891
T & operator()(size_t r, size_t c)
Get writeable data element by row index and column index.
Definition core.hpp:931
void _tryAssign(size_t r, size_t c, T value)
Try to assign a value to a specific position.
Definition core.hpp:6793
Mat & t(const M< T2, n_cols, n_rows, type2, _unused... > &mat)
Transpose.
Definition core.hpp:5937
Mat< T, n_rows, n_cols, MatType::NORMAL > offDiag() const
Take the off diagonal of a matrix and make a copy.
Definition core.hpp:6538
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:5559
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:6618
Mat & diagMat(const M< T2, n_rows, n_cols, type2, _unused... > &mat)
Take the diagonal of a matrix.
Definition core.hpp:6337
Mat & diagVec(const M< T2, n_rows, n_rows, type2, _unused... > &mat)
Take the diagonal vector of a matrix.
Definition core.hpp:6394
Mat(Init init)
Definition core.hpp:754
Mat & oppSelf()
In-place matrix opposite.
Definition core.hpp:6314
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:6903
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:6824
Mat & tSelf()
In-place transpose.
Definition core.hpp:6223
Mat(T *const ptr, InitAfterwards opt=InitAfterwards::NONE)
Definition core.hpp:792
Mat & diagRowVec(const M< T2, n_cols, n_cols, type2, _unused... > &mat)
Take the diagonal row vector of a matrix.
Definition core.hpp:6452
~Mat()
Destroy the Mat object.
Definition core.hpp:825
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:6675
Mat & invDiag(const M< T2, n_cols, n_rows, type2, _unused... > &mat)
Inverse the diagonal matrix.
Definition core.hpp:6581
Mat & rows(const M1< T1, rows_, cols_, type1, _unused1... > &mat, M2 vector)
Take discrete rows of a matrix by container.
Definition core.hpp:5783
T & operator[](size_t index)
Get writeable element by row major index from the data array.
Definition core.hpp:874
void setZero()
Set all elements of the matrix to zero.
Definition core.hpp:989
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:5728
Mat & opp(const M< T2, n_rows, n_cols, type, _unused... > &mat)
Calculate the opposite of a matrix.
Definition core.hpp:6262
Mat & mul(const M< T2, n_rows, n_cols, type, _unused... > &mat, ScalarT s)
Matrix times a scalar.
Definition core.hpp:1779
const T * rawDataPtr() const
Definition core.hpp:6781
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:6558
MatViewOpp< T, n_rows, n_cols, type > operator-() const
The unary minus operator.
Definition core.hpp:6765
MatViewT< T, n_cols, n_rows, tType(type)> t_()
Transpose as a read only view.
Definition core.hpp:6210
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:5754
Mat invNSA(size_t iter=4) const
Matrix inverse using Newton-Schulz iterative method (NSA) as a copy.
Definition core.hpp:6651
Mat & cols(const M1< T1, rows_, cols_, type1, _unused1... > &mat, M2 vector)
Take discrete cols of a matrix by container.
Definition core.hpp:5855
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:5506
Mat & mul(ScalarT s)
Matrix self multiply a scalar.
Definition core.hpp:1884
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:1086
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:5490
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:1832
Mat & mul(ap_fixed< AP_W, AP_I, AP_Q, AP_O, AP_N > s)
Matrix self multiply ap_fixed float.
Definition core.hpp:1950
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:5637
Mat & mul(std::complex< ScalarT > s)
Matrix self multiply a complex number.
Definition core.hpp:1906
void col(size_t c, const M< T2, rows_, cols_, type2, _unused... > &mat)
Definition core.hpp:5466
Mat()
Construct a new Mat object.
Definition core.hpp:614
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:6432
T & value()
Get the writeable value from 1x1 matrix.
Definition core.hpp:6723
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:6374
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:7053
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:6969
static constexpr size_t size() noexcept
Get the matrix size of storage.
Definition core.hpp:842
Mat & mul(const M< T2, n_rows, n_cols, type, _unused... > &mat, std::complex< ScalarT > s)
Matrix times a complex number.
Definition core.hpp:1807
Mat< T, n_rows, n_cols, MatType::SLOWER > t() const
Transpose SUPPER matrix as a copy.
Definition core.hpp:6130
Tp power() const
Definition core.hpp:6699
Mat & cols(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t first_col)
Take a row of a matrix by index as a read only view.
Definition core.hpp:5601
Mat & row(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t r)
Take a row of a matrix by index.
Definition core.hpp:5535
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:1444
Mat & abs_()
Apply 'abs' (absolute value) to itself.
Definition core.hpp:5913
Mat(const T *ptr, InitAfterwards opt=InitAfterwards::NONE)
Construct a new Mat object from raw data pointer.
Definition core.hpp:765
bool read(const std::string &file_name)
Definition core.hpp:991
Mat< T, n_rows, n_cols, MatType::UPPER > t() const
Transpose LOWER matrix as a copy.
Definition core.hpp:6099
Mat t() const
Transpose DIAGONAL/SCALAR/SYM matrix as a copy.
Definition core.hpp:6047
T element_type
Definition core.hpp:602
Mat< T, n_rows, n_cols, MatType::LOWER > t() const
Transpose UPPER matrix as a copy.
Definition core.hpp:6068
void _sa_multiply(const T1 &tmp_L, const T2 &tmp_R, const HLSVec &use_assign)
Systolic array multiplication.
Definition core.hpp:6927
Mat(T val)
Construct a new Mat object with initial value.
Definition core.hpp:633
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:5662
void setValue(T val)
Set all elements of the matrix to a value.
Definition core.hpp:978
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:6690
Mat< T, n_cols, n_rows, type > t() const
Transpose NORMAL matrix as a copy.
Definition core.hpp:6016
Mat & col(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t c)
Take a column of a matrix by index.
Definition core.hpp:5452
Mat & offDiag(const M< T2, n_cols, n_rows, type2, _unused... > &mat)
Take the off diagonal of a matrix.
Definition core.hpp:6510
Mat invDiag() const
Inverse the diagonal matrix and makes a copy.
Definition core.hpp:6596
void print(const std::string &str="", std::ostream &os=std::cout) const
Print the matrix.
Definition core.hpp:6734
Mat opp() const
Calculate the opposite of a matrix and make a copy.
Definition core.hpp:6285
T value() const
Get the value from 1x1 matrix.
Definition core.hpp:6713
Mat(std::initializer_list< T2 > list)
Definition core.hpp:736
MatViewT< T, n_cols, n_rows, tType(type)> t_() const
Definition core.hpp:6212
RowVec< T, n_cols > diagRowVec() const
Take the diagonal row vector of a matrix and make a copy.
Definition core.hpp:6475
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:1861
Mat(const Mat &mat)
Copy constructor from a Mat object.
Definition core.hpp:654
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:1990
Mat & add(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Matrix self plus a matrix.
Definition core.hpp:1387
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:6490
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:5427
MatView< T, n_rows, n_cols, type > operator+() const
The unary plus operator.
Definition core.hpp:6754
T operator()(size_t r, size_t c) const
Get read only data element by row index and column index.
Definition core.hpp:887
Mat(const Mat< T2, _rows, _cols, _type > &mat)
Definition core.hpp:673
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:1053
Mat(const std::vector< T > &vec)
Construct a new Mat object from std::vector.
Definition core.hpp:718
Mat< T, n_rows, n_cols, MatType::DIAGONAL > diagMat() const
Take the diagonal of a matrix and make a copy.
Definition core.hpp:6360
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:1411
T value_type
Definition core.hpp:603
void _tryPlus(size_t r, size_t c, T value)
Try to plus a value to a specific position.
Definition core.hpp:6839
void assign(M m)
Definition core.hpp:8672
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:8732
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:8700
T & operator()(size_t r, size_t c)
Definition core.hpp:8713
Vec< T, n_rows > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:8755
T *const _data
Raw data pointer.
Definition core.hpp:8778
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:8648
T & operator[](size_t index)
Definition core.hpp:8734
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:8684
MatRefCol(const MatRefCol &m)
Copy constructor.
Definition core.hpp:8660
Vec< T, n_rows > asVec() const
Explicitly make a Mat (Vec) copy.
Definition core.hpp:8765
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition core.hpp:8770
MatRefCol & operator=(const Mat< T_, n_rows_, n_cols_, type_ > &m)
Definition core.hpp:8663
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition core.hpp:8691
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:7452
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:7359
void col(size_t c, const M< T2, rows_, cols_, type2, _unused... > &mat)
Definition core.hpp:7517
T *const _data
Definition core.hpp:7623
MatRef & operator=(const Mat< T, n_rows, n_cols, type > &m)
Definition core.hpp:7336
Mat< T, n_rows, n_cols, type > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:7614
T & operator[](size_t index)
Get the writeable element by array row major index.
Definition core.hpp:7464
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:7326
void assign(M m)
Definition core.hpp:7345
MatViewT< T, n_cols, n_rows, type > t_() const
Definition core.hpp:7576
void setValue(T val)
Set all elements of the matrix to a value.
Definition core.hpp:7475
MatRef & col(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t c)
Take a column of a matrix by index.
Definition core.hpp:7504
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition core.hpp:7619
MatRef & add(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Definition core.hpp:7554
MatRef & sub(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Definition core.hpp:7566
T & operator()(size_t r, size_t c)
Get writeable data element by row index and column index.
Definition core.hpp:7404
Tp abssum() const
Definition core.hpp:7589
MatRef(Mat< T, n_rows, n_cols, type > &m)
Construct a new MatView object from raw data pointer.
Definition core.hpp:7310
void setZero()
Set all elements of the matrix to zero.
Definition core.hpp:7486
MatRef(const T *const ptr)
Definition core.hpp:7312
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:7541
Tp power() const
Definition core.hpp:7579
MatRef(const MatRef &m)
Copy constructor.
Definition core.hpp:7319
T *const _data
Raw data pointer.
Definition core.hpp:8920
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:8842
void assign(M m)
Definition core.hpp:8814
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:8826
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition core.hpp:8833
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:8789
T & operator[](size_t index)
Definition core.hpp:8876
RowVec< T, n_cols > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:8897
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition core.hpp:8912
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:8874
MatRefRow & operator=(const Mat< T_, n_rows_, n_cols_, type_ > &m)
Definition core.hpp:8805
MatRefRow(const MatRefRow &m)
Copy constructor.
Definition core.hpp:8802
T & operator()(size_t r, size_t c)
Definition core.hpp:8855
RowVec< T, n_cols > asVec() const
Explicitly make a Mat (RowVec) copy.
Definition core.hpp:8907
Read only view version of a certain column as colunm vector.
Definition core.hpp:8424
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:8484
MatViewCol(const MatViewCol &m)
Copy constructor.
Definition core.hpp:8442
Vec< T, n_rows > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:8505
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:8431
Vec< T, n_rows > asVec() const
Explicitly make a Mat (Vec) copy.
Definition core.hpp:8515
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition core.hpp:8520
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:8449
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:8465
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition core.hpp:8456
const T *const _data
Raw data pointer.
Definition core.hpp:8528
Read only view version of successive columns.
Definition core.hpp:8925
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:8951
MatViewCols(const Mat< T, n_rows, n_cols, matType< type_parent >()> &m)
Construct a new MatViewCols object from raw data pointer.
Definition core.hpp:8932
MatViewCols(const MatViewCols &m)
Copy constructor.
Definition core.hpp:8944
const T * _data
Raw data pointer.
Definition core.hpp:9054
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:8975
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:9020
Mat< T, n_rows, last_col - first_col+1, MatType::NORMAL > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:9043
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition core.hpp:8966
Read only view version of a diagonal matrix.
Definition core.hpp:7888
MatViewDiagMat(const Mat< T, N, N, matType< type_parent >()> &m)
Construct a new MatViewDiagMat object from a raw data pointer.
Definition core.hpp:7895
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:7950
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:7926
Mat< T, N, N, MatType::DIAGONAL > inv() const
Return a inverse matrix.
Definition core.hpp:7911
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition core.hpp:7941
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:7983
Mat< T, N, N, MatType::DIAGONAL > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:8009
MatViewDiagMat(const MatViewDiagMat &m)
Copy constructor.
Definition core.hpp:7904
const T * _data
Raw data pointer.
Definition core.hpp:8020
Read only view version of a diagonal matrix as row vector.
Definition core.hpp:8166
MatViewDiagRowVec(const MatViewDiagRowVec &m)
Copy constructor.
Definition core.hpp:8182
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition core.hpp:8204
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:8246
MatViewDiagRowVec(const Mat< T, N, N, matType< type_parent >()> &m)
Construct a new MatViewDiagRowVec object from raw data pointer.
Definition core.hpp:8173
RowVec< T, N > asRowVec() const
Explicitly make a Mat (RowVec) copy.
Definition core.hpp:8278
const T * _data
Raw data pointer.
Definition core.hpp:8289
RowVec< T, N > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:8268
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:8213
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:8189
Read only view version of a diagonal matrix as vector.
Definition core.hpp:8024
Vec< T, N > inv() const
Return a inverse matrix.
Definition core.hpp:8062
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:8119
MatViewDiagVec(const Mat< T, N, N, matType< type_parent >()> &m)
Construct a new MatViewDiagVec object from raw data pointer.
Definition core.hpp:8031
Vec< T, N > asVec() const
Explicitly make a Mat (Vec) copy.
Definition core.hpp:8151
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:8047
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition core.hpp:8077
const T * _data
Raw data pointer.
Definition core.hpp:8162
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:8086
MatViewDiagVec(const MatViewDiagVec &m)
Copy constructor.
Definition core.hpp:8040
Vec< T, N > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:8141
Read only view version of a matrix.
Definition core.hpp:7057
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:7081
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:7217
void assign(M m)
Definition core.hpp:7100
MatView(const T *const ptr)
Definition core.hpp:7067
MatView(Mat< T, n_rows, n_cols, type > &m)
Definition core.hpp:7065
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:7114
MatView & operator=(const Mat< T, n_rows, n_cols, type > &m)
Definition core.hpp:7091
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition core.hpp:7295
MatView & sub(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Definition core.hpp:7242
const T *const _data
Definition core.hpp:7299
MatViewT< T, n_cols, n_rows, type > t_() const
Definition core.hpp:7252
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:7158
MatView(const Mat< T, n_rows, n_cols, type > &m)
Construct a new MatView object from raw data pointer.
Definition core.hpp:7064
Tp abssum() const
Definition core.hpp:7265
Tp power() const
Definition core.hpp:7255
MatView & col(const M< T2, rows_, cols_, type2, _unused... > &mat, size_t c)
Take a column of a matrix by index.
Definition core.hpp:7180
MatView(const MatView &m)
Copy constructor.
Definition core.hpp:7074
void col(size_t c, const M< T2, rows_, cols_, type2, _unused... > &mat)
Definition core.hpp:7193
Mat< T, n_rows, n_cols, type > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:7290
MatView & add(const M< T2, n_rows, n_cols, type2, _unused... > &mat_R)
Definition core.hpp:7230
Read only view version of a off diagonal.
Definition core.hpp:8293
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:8340
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:8316
MatViewOffDiag(const MatViewOffDiag &m)
Copy constructor.
Definition core.hpp:8309
const T * _data
Raw data pointer.
Definition core.hpp:8420
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:8383
Mat< T, N, N, MatType::NORMAL > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:8409
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition core.hpp:8331
MatViewOffDiag(const Mat< T, N, N, matType< type_parent >()> &m)
Construct a new MatViewOffDiag object from raw data pointer.
Definition core.hpp:8300
Read only view version of the opposite of a matrix.
Definition core.hpp:7627
MatViewOpp(const Mat< T, n_cols, n_rows, type > &m)
Construct a new MatViewOpp object from raw data pointer.
Definition core.hpp:7634
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:7665
const T * _data
Definition core.hpp:7735
MatViewOpp(const MatViewOpp &m)
Copy constructor.
Definition core.hpp:7641
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:7648
Mat< T, n_rows, n_cols, type > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:7729
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:7708
Read only view version of a certain row as row vector.
Definition core.hpp:8532
Vec< T, n_rows > asRowVec() const
Explicitly make a Mat (RowVec) copy.
Definition core.hpp:8624
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:8574
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:8593
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:8539
static constexpr MatType pType() noexcept
Parent matrix as MatType.
Definition core.hpp:8565
RowVec< T, n_cols > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:8614
const T *const _data
Raw data pointer.
Definition core.hpp:8637
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:8558
MatViewRow(const MatViewRow &m)
Copy constructor.
Definition core.hpp:8551
void print(const std::string &str="", std::ostream &os=std::cout) const
Definition core.hpp:8629
Read only view version of successive rows.
Definition core.hpp:9059
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:9085
Mat< T, last_row - first_row+1, n_cols, MatType::NORMAL > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:9177
static constexpr MatType pType() noexcept
Parent matrix as MatType.last_col.
Definition core.hpp:9100
const T * _data
Raw data pointer.
Definition core.hpp:9198
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:9156
Mat< T, last_row - first_row+1, n_cols, MatType::NORMAL > asVec() const
Explicitly make a Mat (Vec) copy.
Definition core.hpp:9187
MatViewRows(const Mat< T, n_cols, n_rows, matType< type_parent >()> &m)
Construct a new MatViewRows object from raw data pointer.
Definition core.hpp:9066
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:9109
MatViewRows(const MatViewRows &m)
Copy constructor.
Definition core.hpp:9078
Read only view version of a transposed matrix.
Definition core.hpp:7739
MatViewT(const Mat< T, n_cols, n_rows, tType(type)> &m)
Construct a new MatViewT object from raw data pointer.
Definition core.hpp:7746
T operator()(size_t r, size_t c) const
Get the read only data element from row and column index.
Definition core.hpp:7782
static constexpr size_t size() noexcept
The data element number.
Definition core.hpp:7765
MatViewT(T *ptr)
Definition core.hpp:7758
T *const _data
Raw data pointer.
Definition core.hpp:7884
MatViewT(Mat< T, n_cols, n_rows, tType(type)> &m)
Definition core.hpp:7747
T operator[](size_t index) const
Get the read only element by array row major index.
Definition core.hpp:7825
Mat< T, n_rows, n_cols, type > asMat() const
Explicitly make a Mat copy.
Definition core.hpp:7872
MatViewT(const MatViewT &m)
Copy constructor.
Definition core.hpp:7754
Tensor.
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:566
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::DIAGONAL > MATTYPE_DIAGONAL
Diagonal matrix as a class type.
Definition core.hpp:187
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:9404
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:9247
constexpr MatType sumType(MatType type1, MatType type2) noexcept
Summation type of two matrices.
Definition core.hpp:229
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::SUPPER > MATTYPE_SUPPER
Strict upper triangular matrix as a class type.
Definition core.hpp:195
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:9750
constexpr size_t supperRow(size_t index, size_t N)
Calculate the row index of a strict upper triangular matrix.
Definition core.hpp:350
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 greater or equal comparison.
Definition core.hpp:9718
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:9782
std::integral_constant< int, MatType::NORMAL > MATTYPE_NORMAL
Normal matrix as a class type.
Definition core.hpp:185
Init
Definition core.hpp:572
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:9590
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:9275
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:9328
constexpr size_t slowerRow(size_t index, size_t N)
Calculate the row index of a strict lower triangular matrix.
Definition core.hpp:366
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
Mat< T, 1, N > RowVec
Row vector.
Definition core.hpp:422
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:9563
constexpr MatType tType(MatType type) noexcept
Transpose type of a matrix.
Definition core.hpp:303
std::integral_constant< int, MatType::UPPER > MATTYPE_UPPER
Upper triangular matrix as a class type.
Definition core.hpp:191
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:9654
Mat< T, N, 1 > Vec
Column vector.
Definition core.hpp:412
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:9822
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:9300
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:9622
std::integral_constant< int, MatType::SLOWER > MATTYPE_SLOWER
Strict lower triangular matrix as a class type.
Definition core.hpp:197
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:9686
std::integral_constant< int, type > MType
Get the class form of MatType.
Definition core.hpp:220
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:9797
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:9223
constexpr MatType matType()
Get the MatType value from the class form.
Definition core.hpp:210