File indexing completed on 2026-05-27 07:23:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011
0012 #include "detray/algebra/concepts.hpp"
0013 #include "detray/definitions/detail/qualifiers.hpp"
0014
0015
0016 #include <iomanip>
0017 #include <iostream>
0018
0019 namespace detray {
0020
0021 namespace algebra {
0022
0023 template <typename vector_t>
0024 requires(concepts::vector<vector_t> || concepts::point<vector_t>)
0025 DETRAY_HOST std::ostream& operator<<(std::ostream& out, const vector_t& v) {
0026 using index_t = detray::traits::index_t<vector_t>;
0027
0028 constexpr index_t size{detray::traits::size<vector_t>};
0029
0030 out << "[";
0031 for (index_t i = 0; i < size; ++i) {
0032 out << v[i];
0033 if (i != size - 1) {
0034 out << ", ";
0035 }
0036 }
0037 out << "]";
0038
0039 return out;
0040 }
0041
0042
0043 template <concepts::column_matrix vector_t>
0044 DETRAY_HOST std::ostream& operator<<(std::ostream& out, const vector_t& v) {
0045 using index_t = detray::traits::index_t<vector_t>;
0046 using element_getter_t = detray::traits::element_getter_t<vector_t>;
0047
0048 constexpr index_t rows{detray::traits::rows<vector_t>};
0049
0050 out << "[";
0051 for (index_t i = 0; i < rows; ++i) {
0052
0053 out << std::setw(i == 0 ? 15 : 16) << element_getter_t{}(v, i, 0);
0054 }
0055 out << "]";
0056
0057 return out;
0058 }
0059
0060
0061 template <concepts::matrix matrix_t>
0062 DETRAY_HOST std::ostream& operator<<(std::ostream& out, const matrix_t& m) {
0063 using index_t = detray::traits::index_t<matrix_t>;
0064 using element_getter_t = detray::traits::element_getter_t<matrix_t>;
0065
0066 constexpr index_t rows{detray::traits::rows<matrix_t>};
0067 constexpr index_t columns{detray::traits::columns<matrix_t>};
0068
0069 out << "[";
0070 for (index_t i = 0; i < rows; ++i) {
0071 out << (i == 0 ? "[" : " [");
0072 for (index_t j = 0; j < columns; ++j) {
0073
0074 out << std::setw(j == 0 ? 15 : 16) << element_getter_t{}(m, i, j);
0075 }
0076 out << "]";
0077 if (i != rows - 1) {
0078 out << "\n";
0079 }
0080 }
0081 out << "]";
0082
0083 return out;
0084 }
0085
0086
0087 template <concepts::transform3D transform_t>
0088 DETRAY_HOST std::ostream& operator<<(std::ostream& out,
0089 const transform_t& trf) {
0090 out << trf.matrix();
0091
0092 return out;
0093 }
0094
0095 }
0096
0097
0098 using algebra::operator<<;
0099
0100 }