Kronecker product: Difference between revisions
m
C++ - changed output formatting
m (C++ - faster Kronecker product calculation) |
m (C++ - changed output formatting) |
||
Line 924:
template <typename scalar_type>
void print(std::
const wchar_t* box_top_left = L"\x250c";
const wchar_t* box_top_right = L"\x2510";
const wchar_t* box_bottom_left = L"\x2514";
const wchar_t* box_bottom_right = L"\x2518";
const wchar_t* box_vertical = L"\x2502";
const wchar_t nl = L'\n';
const wchar_t space = L' ';
const int width = 2;
size_t rows = a.rows(), columns = a.columns();
std::wstring spaces((width + 1) * columns, space);
out << box_top_left << spaces << box_top_right << nl;
for (size_t row = 0; row < rows; ++row) {
out << box_vertical;
for (size_t column = 0; column < columns; ++column) {
if (column > 0)
out <<
out << std::setw(
}
out <<
}
out << box_bottom_left << spaces << box_bottom_right << nl;
}
Line 940 ⟶ 953:
matrix<int> matrix2(2, 2, {{0,5}, {6,7}});
matrix<int> kp = kronecker_product(matrix1, matrix2);
std::
print(std::
}
Line 948 ⟶ 961:
matrix<int> matrix2(3, 4, {{1,1,1,1}, {1,0,0,1}, {1,1,1,1}});
matrix<int> kp = kronecker_product(matrix1, matrix2);
std::
print(std::
}
int main() {
std::wcout.imbue(std::locale(""));
test1();
test2();
Line 961 ⟶ 975:
<pre>
Test case 1:
┌
│ 0
│ 6
│18 21 24 28 │
└ ┘
Test case 2:
┌
│ 0
│ 1
│ 0 0 0 0 1 1 1 1 0 0 0 0 │
└ ┘
</pre>
|