27 #ifndef ANTIOCH_VECTOR_UTILS_H
28 #define ANTIOCH_VECTOR_UTILS_H
30 #ifdef ANTIOCH_METAPROGRAMMING_H
31 # ifndef ANTIOCH_VECTOR_UTILS_DECL_H
32 # error vector_utils_decl.h must be included before metaprogramming.h
52 operator<< (std::ostream& output, const std::vector<T>& a)
55 const std::size_t size = a.size();
58 for (std::size_t i=1; i<size; ++i)
59 output <<
',' << a[i];
67 operator* (
const std::vector<T>& src,
const T & mul)
69 std::vector<T> output(src);
70 const std::size_t size = src.size();
71 for (std::size_t i=1; i<size; ++i)
72 output[i] = src[i] * mul;
80 operator/ (
const std::vector<T>& src,
const T & mul)
82 std::vector<T> output(src);
83 const std::size_t size = src.size();
84 for (std::size_t i=1; i<size; ++i)
85 output[i] = src[i] / mul;
95 template <
typename T,
typename NewScalar>
98 typedef std::vector<NewScalar>
type;
101 template <
typename T>
104 static const bool value =
true;
107 template <
typename T>
110 static const bool value =
true;
113 template <
typename T>
116 typedef typename std::vector<T>::size_type
type;
119 template <
typename T>
125 template <
typename T>
131 template <
typename T>
137 return std::vector<T>(example.size(),
zero_clone(example[0]));
139 return std::vector<T>();
142 template <
typename T1,
typename T2>
145 zero_clone(std::vector<T1>& output,
const std::vector<T2>& example)
147 const std::size_t sz = example.size();
149 for (std::size_t i=0; i != sz; ++i)
153 template <
typename T,
typename Scalar>
156 zero_clone(
const std::vector<T>& example,
const Scalar& value)
159 return std::vector<T>(example.size(),value);
161 return std::vector<T>();
165 template <
typename T>
170 std::fill(a.begin(), a.end(),
zero_clone(a[0]));
173 template <
typename T,
typename VectorScalar>
175 std::vector<T>
custom_clone(
const std::vector<T> & ,
const VectorScalar & vecsrc, std::vector<unsigned int> & indexes)
177 std::vector<T> returnval;
178 returnval.resize(indexes.size());
179 for (std::size_t i=0; i != indexes.size(); ++i)
180 returnval[i] = vecsrc[indexes[i]];
187 #endif //ANTIOCH_VECTOR_UTILS_H
std::vector< NewScalar > type
std::vector< T > operator/(const std::vector< T > &src, const T &mul)
T custom_clone(const T &, const VectorScalar &values, unsigned int indexes)
std::vector< T > operator*(const std::vector< T > &src, const T &mul)
raw_value_type< T >::type type
void set_zero(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a)
std::vector< T >::size_type type
The parameters are reduced parameters.
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > zero_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex)