6 template<
class Type,
int n>
7 struct tiny_vector : std::valarray<Type> {
8 tiny_vector() : std::valarray<Type>(n) {}
10 tiny_vector(T other) : std::valarray<Type>(other) {}
11 void setZero() {
for(
int i=0; i<n; i++) (*
this)[i] = 0;}
12 std::slice_array<Type> segment(
size_t start,
size_t length) {
13 return (*
this)[std::slice(start, length, 1)];
18 for(
int i=0; i<n; i++) ans[i] = (*
this)[i];
23 template<
class Type,
int n,
class T>
24 struct tiny_vector<Type, n> operator*(
const T &x,
const tiny_vector<Type, n> &y) {
27 template<
class Type,
int n>
28 std::ostream &operator<<(std::ostream &os, tiny_vector<Type, n>
const &x) {
30 for(
int i=0; i < x.size(); i++) os << x[i] <<
" ";
Vector class used by TMB.