6#include <stratax/containers/Matrix.hpp>
7#include <stratax/containers/Tensor.hpp>
8#include <stratax/containers/Vector.hpp>
9#include <stratax/core/ArrayView.hpp>
11namespace stratax::container {
16void print_value(std::ostream& os,
const T& value)
18 using type = std::remove_cvref_t<T>;
20 if constexpr (std::same_as<type, dtype::bool_>)
22 os << (value ?
"true" :
"false");
25 std::same_as<type, dtype::int8> ||
26 std::same_as<type, dtype::uint8>)
28 os << static_cast<int>(value);
44 const char* sibling_separator)
46 const auto& shape = array.shape();
47 const auto logical_strides = shape.strides();
51 if (dim == shape.rank() - 1)
53 for (std::size_t i = 0; i < shape[dim]; ++i)
57 array[offset + i * logical_strides[dim]]);
59 if (i + 1 != shape[dim])
67 for (std::size_t i = 0; i < shape[dim]; ++i)
69 os << std::string((depth + 1) * 4,
' ');
74 offset + i * logical_strides[dim],
78 if (i + 1 != shape[dim])
80 os << sibling_separator;
85 os << std::string(depth * 4,
' ');
92std::ostream& print_array(
102 const char* sibling_separator =
103 array.rank() == 2 ?
"\n" :
",\n";
118std::ostream& operator<<(std::ostream& os,
const Vector<T>& vector)
120 return detail::print_array(os, vector);
124std::ostream& operator<<(std::ostream& os,
const Matrix<T>& matrix)
126 return detail::print_array(os, matrix);
130std::ostream& operator<<(std::ostream& os,
const Tensor<T>& tensor)
132 return detail::print_array(os, tensor);
137namespace stratax::core {
140std::ostream& operator<<(std::ostream& os,
const ArrayView<T>& view)
142 return container::detail::print_array(os, view);