lin
vector_stream_reference.hpp
Go to the documentation of this file.
1 // vim: set tabstop=2:softtabstop=2:shiftwidth=2:expandtab
2 
7 #ifndef LIN_REFERENCES_VECTOR_STREAM_REFERENCE_HPP_
8 #define LIN_REFERENCES_VECTOR_STREAM_REFERENCE_HPP_
9 
10 #include "../core.hpp"
12 
13 namespace lin {
14 namespace internal {
15 
34 template <class E, size_t N, size_t MN>
35 class VectorStreamReference : public TensorStreamReference<VectorStreamReference<E, N, MN>, E> {
36  static_assert(is_col_vector<VectorStreamReference<E, N, MN>>::value,
37  "Derived types to VectorStreamReference<...> must have column vector traits");
38 
39  public:
45 
51 
52  protected:
55 
56  public:
64 
65  constexpr VectorStreamReference() = delete;
66  constexpr VectorStreamReference(VectorStreamReference<E, N, MN> const &) = default;
68  constexpr VectorStreamReference<E, N, MN> &operator=(VectorStreamReference<E, N, MN> const &) = default;
69  constexpr VectorStreamReference<E, N, MN> &operator=(VectorStreamReference<E, N, MN> &&) = default;
70 
94  constexpr VectorStreamReference(Stream<E> const &stream, size_t i, size_t j, size_t n)
95  : TensorStreamReference<VectorStreamReference<E, N, MN>, E>(stream, i, j, n, 1) { }
96 };
97 
98 template <class E, size_t N, size_t MN>
99 struct _elem<VectorStreamReference<E, N, MN>> {
100  typedef _elem_t<E> type;
101 };
102 
103 template <class E, size_t N, size_t MN>
104 struct _dims<VectorStreamReference<E, N, MN>> {
105  static constexpr size_t rows = N;
106  static constexpr size_t cols = 1;
107  static constexpr size_t max_rows = MN;
108  static constexpr size_t max_cols = 1;
109 };
110 
129 template <class E, size_t N, size_t MN>
130 class RowVectorStreamReference : public TensorStreamReference<RowVectorStreamReference<E, N, MN>, E> {
132  "Derived types to RowVectorStreamReference<...> must have row vector traits");
133 
134  public:
140 
146 
147  protected:
150 
151  public:
159 
160  constexpr RowVectorStreamReference() = delete;
163  constexpr RowVectorStreamReference<E, N, MN> &operator=(RowVectorStreamReference<E, N, MN> const &) = default;
165 
189  constexpr RowVectorStreamReference(Stream<E> const &stream, size_t i, size_t j, size_t n)
190  : TensorStreamReference<RowVectorStreamReference<E, N, MN>, E>(stream, i, j, 1, n) { }
191 };
192 
193 template <class E, size_t N, size_t MN>
194 struct _elem<RowVectorStreamReference<E, N, MN>> {
195  typedef _elem_t<E> type;
196 };
197 
198 template <class E, size_t N, size_t MN>
199 struct _dims<RowVectorStreamReference<E, N, MN>> {
200  static constexpr size_t rows = 1;
201  static constexpr size_t cols = N;
202  static constexpr size_t max_rows = 1;
203  static constexpr size_t max_cols = MN;
204 };
205 } // namespace internal
206 } // namespace lin
207 
208 #endif
Collection of compile time information describing a tensor type which is deemed a vector...
Definition: vector.hpp:103
Generic vector reference with read only access.
Definition: vector_stream_reference.hpp:35
constexpr size_t size() const
Definition: stream.hpp:90
constexpr void resize(size_t r, size_t c)
Resizes a tensor&#39;s dimensions.
Definition: dimensions.hpp:75
Provides a tensor type&#39;s element type.
Definition: tensor.hpp:28
Collection of compile time information about a specific tensor class.
Definition: tensor.hpp:75
vector_traits< VectorStreamReference< E, N, MN > > VectorTraits
Vector traits information for this type.
Definition: vector_stream_reference.hpp:50
constexpr VectorStreamReference< E, N, MN > & derived()
Definition: stream.hpp:57
vector_traits< RowVectorStreamReference< E, N, MN > > VectorTraits
Vector traits information for this type.
Definition: vector_stream_reference.hpp:145
Generic row vector reference with read only access.
Definition: vector_stream_reference.hpp:130
traits< VectorStreamReference< E, N, MN > > Traits
Traits information for this type.
Definition: vector_stream_reference.hpp:37
constexpr VectorStreamReference(Stream< E > const &stream, size_t i, size_t j, size_t n)
Constructs a new vector reference with the provided stream, anchor point, and length.
Definition: vector_stream_reference.hpp:94
constexpr size_t rows() const
Definition: stream.hpp:76
Generic tensor reference with read only access.
Definition: tensor_stream_reference.hpp:36
constexpr size_t cols() const
Definition: stream.hpp:82
Tests if a tensor type is a column vector.
Definition: vector.hpp:54
Definition: config.hpp:27
Tests if a tensor type is a row vector.
Definition: vector.hpp:33
traits< RowVectorStreamReference< E, N, MN > > Traits
Traits information for this type.
Definition: vector_stream_reference.hpp:132
constexpr RowVectorStreamReference(Stream< E > const &stream, size_t i, size_t j, size_t n)
Constructs a new row vector reference with the provided mapping, anchor point, and length...
Definition: vector_stream_reference.hpp:189
Provides a specific tensor type&#39;s compile time dimensions.
Definition: tensor.hpp:60
constexpr Traits::eval_t eval() const
Forces evaluation of this stream to a value backed type.
Definition: stream.hpp:157