14namespace stratax::container {
22 using type = std::remove_cvref_t<T>;
24 if constexpr (std::same_as<type, dtype::bool_>)
26 os << (value ?
"true" :
"false");
29 std::same_as<type, dtype::int8> ||
30 std::same_as<type, dtype::uint8>)
32 os << static_cast<int>(value);
48 const char* sibling_separator)
50 const auto& shape = array.shape();
51 const auto logical_strides = shape.strides();
55 if (dim == shape.rank() - 1)
57 for (std::size_t i = 0; i < shape[dim]; ++i)
61 array[offset + i * logical_strides[dim]]);
63 if (i + 1 != shape[dim])
71 for (std::size_t i = 0; i < shape[dim]; ++i)
73 os << std::string((depth + 1) * 4,
' ');
78 offset + i * logical_strides[dim],
82 if (i + 1 != shape[dim])
84 os << sibling_separator;
89 os << std::string(depth * 4,
' ');
113 const char* sibling_separator =
114 array.rank() == 2 ?
"\n" :
",\n";
130std::ostream& operator<<(std::ostream& os,
const Vector<T>& vector)
132 return detail::print_array(os, vector);
137std::ostream& operator<<(std::ostream& os,
const Matrix<T>& matrix)
139 return detail::print_array(os, matrix);
144std::ostream& operator<<(std::ostream& os,
const Tensor<T>& tensor)
146 return detail::print_array(os, tensor);
151namespace stratax::core {
157 return container::detail::print_array(os, view);
Non-owning views and logical random-access iterators.
void print_value(std::ostream &os, const T &value)
Writes booleans as true/false and 8-bit integers as numbers; otherwise uses stream insertion.
std::ostream & print_array(std::ostream &os, const A &array)
Prints elements in logical row-major order with nested brackets. Empty arrays print as [],...
void print_recursive(std::ostream &os, const A &array, std::size_t dim, std::size_t offset, std::size_t depth, const char *sibling_separator)
Recursively prints a tensor using nested bracket notation.
std::ostream & operator<<(std::ostream &os, const Shape &shape)
Writes a shape using tuple notation.
Arbitrary-rank owning arrays; rank zero is empty.
Two-dimensional owning array of supported dtype values.
Arbitrary-rank owning array of supported dtype values.
One-dimensional owning array of supported dtype values.
Non-owning view of elements with unsigned element strides.