23 #include <tensor/numbers.h>
24 #include <tensor/vector.h>
77 template<
typename elt_t,
size_t n>
80 StaticVector(
const StaticVector<elt_t,n-1> &other, elt_t x) :
81 inner(other), extra(x)
83 operator Vector<elt_t>()
const {
84 Vector<elt_t> output(n);
88 void push(elt_t *v)
const {
96 StaticVector<elt_t,n-1> inner;
100 template<
typename elt_t>
101 class StaticVector<elt_t,(size_t)1> {
103 StaticVector(elt_t x) :
106 operator Vector<elt_t>()
const {
107 Vector<elt_t> output(1);
108 push(output.begin());
111 void push(elt_t *v)
const {
121 template<
typename t1,
typename t2>
122 StaticVector<t1,1> operator<<(const ListGenerator<t1> &g,
const t2 x) {
123 return StaticVector<t1,1>(x);
126 template<
typename t1>
127 StaticVector<t1,1> operator<<(
const FlexiListGenerator &g,
const t1 x) {
128 return StaticVector<t1,1>(x);
131 template<
typename t1,
typename t2,
size_t n>
132 StaticVector<t1,n+1> operator<<(const StaticVector<t1,n> &g,
const t2 x) {
133 return StaticVector<t1,n+1>(g,x);
136 template<
typename t1> StaticVector<t1,1> gen(t1 r) {
137 return StaticVector<t1,1>(r);
140 template<
typename elt_t,
size_t n>
141 bool operator==(
const tensor::StaticVector<elt_t,n> &v1,
142 const tensor::Vector<elt_t> &v2)
144 tensor::Vector<elt_t> v0(v1);
145 if (v0.size() != v2.size())
return false;
146 return std::equal(v0.begin_const(), v0.end_const(), v2.begin_const());
149 template<
typename elt_t,
size_t n>
150 bool operator==(
const tensor::Vector<elt_t> &v2,
151 const tensor::StaticVector<elt_t,n> &v1)
153 tensor::Vector<elt_t> v0(v1);
154 if (v0.size() != v2.size())
return false;
155 return std::equal(v0.begin_const(), v0.end_const(), v2.begin_const());
161 #endif // TENSOR_GEN_H
Compile-time generator of vectors, tensors and indices.
Placeholder for statically creating a vector of elements, whose type is determined by the first eleme...