|
|
@@ -10,31 +10,9 @@
|
|
|
#include "expect/expect.hpp"
|
|
|
#include "math/vector/vector.hpp"
|
|
|
|
|
|
-namespace math { namespace matrix {
|
|
|
-
|
|
|
- template <typename T> struct is_matrix {
|
|
|
- static const constexpr bool value = false;
|
|
|
- };
|
|
|
-
|
|
|
- template <typename T, std::size_t R, std::size_t C> class matrix;
|
|
|
- template <typename T, size_t R, size_t C> struct is_matrix<matrix<T, R, C>> {
|
|
|
- static const constexpr bool value = true;
|
|
|
- };
|
|
|
- template <typename T, size_t N> struct is_matrix<vector::vector<T, N>> {
|
|
|
- static const constexpr bool value = true;
|
|
|
- };
|
|
|
-
|
|
|
- namespace concat_strategy {
|
|
|
- struct {
|
|
|
- } horizonal;
|
|
|
- using horizontal_concat_t = decltype(horizonal);
|
|
|
- struct {
|
|
|
- } vertical;
|
|
|
- using vertical_concat_t = decltype(vertical);
|
|
|
- struct {
|
|
|
- } diagonal;
|
|
|
- using diagonal_concat_t = decltype(diagonal);
|
|
|
- };
|
|
|
+#include "forward.h"
|
|
|
+#include "row_reference.hpp"
|
|
|
+#include "traits.hpp"
|
|
|
|
|
|
#define MATRIX_DISABLE_IF_MATRIX(_type, t, r, c) \
|
|
|
typename std::enable_if<!is_matrix<_type>::value, matrix<t, r, c>>::type
|
|
|
@@ -44,35 +22,7 @@ namespace math { namespace matrix {
|
|
|
for (size_t j = 0; j < j_max; ++j)
|
|
|
#define MATRIX_FOR_EACH(i, j) MATRIX_FOR_EACH_RANGE(i, R, j, C)
|
|
|
|
|
|
- template <typename T, std::size_t C> class row_reference {
|
|
|
- private:
|
|
|
- row_reference(T (&h)[C]) : _handle(h) {}
|
|
|
-
|
|
|
- public:
|
|
|
- row_reference(row_reference const &) = delete;
|
|
|
- row_reference(row_reference &&) = default;
|
|
|
-
|
|
|
- template <typename S>
|
|
|
- row_reference & operator=(row_reference<S, C> const & other) {
|
|
|
- VECTOR_FOR_EACH_RANGE(i, C) { _handle[i] = other[i]; }
|
|
|
- return *this;
|
|
|
- }
|
|
|
-
|
|
|
- T const & operator[](std::size_t col) const { return _handle[col]; }
|
|
|
- T & operator[](std::size_t col) { return _handle[col]; }
|
|
|
- T const & at(std::size_t col) const {
|
|
|
- expects(col < C, std::out_of_range, "column index out of range");
|
|
|
- return operator[](col);
|
|
|
- }
|
|
|
- T & at(std::size_t col) {
|
|
|
- expects(col < C, std::out_of_range, "column index out of range");
|
|
|
- return operator[](col);
|
|
|
- }
|
|
|
-
|
|
|
- private:
|
|
|
- template <typename _T, std::size_t R, std::size_t _C> friend class matrix;
|
|
|
- T (&_handle)[C];
|
|
|
- };
|
|
|
+namespace math { namespace matrix {
|
|
|
|
|
|
template <typename T, std::size_t R, std::size_t C> class matrix {
|
|
|
public:
|