27 #ifndef ANTIOCH_VALARRAY_UTILS_H
28 #define ANTIOCH_VALARRAY_UTILS_H
30 #ifdef ANTIOCH_METAPROGRAMMING_H
31 # ifndef ANTIOCH_VALARRAY_UTILS_DECL_H
32 # error valarray_utils_decl.h must be included before metaprogramming.h
57 const std::size_t size = a.size();
60 for (std::size_t i=1; i<size; ++i)
61 output <<
',' << a[i];
66 template <
typename T,
typename T2>
69 Antioch::is_valarray<T>::value,
71 pow (
const T& in,
const T2& n)
74 const size_t size = in.size();
75 for (
size_t i=0; i != size; ++i)
76 out[i] =
pow(in[i], n);
83 max (
const std::valarray<T>& a,
const std::valarray<T>& b)
87 const size_t size = a.size();
88 std::valarray<T> out(size);
89 for (
size_t i=0; i != size; ++i)
90 out[i] =
max(a[i], b[i]);
98 min (
const std::valarray<T>& a,
const std::valarray<T>& b)
102 const size_t size = a.size();
103 std::valarray<T> out(size);
104 for (
size_t i=0; i != size; ++i)
105 out[i] =
min(a[i], b[i]);
116 template <
typename T>
119 max (
const std::valarray<T>& in)
124 template <
typename T>
127 min (
const std::valarray<T>& in)
132 template <
typename T>
135 static const bool value =
false;
138 template <
typename T>
141 static const bool value =
true;
144 template <
typename T>
150 template <
typename T>
156 template <
typename T>
162 template <
typename T>
168 return std::valarray<T>(
zero_clone(example[0]),example.size());
170 return std::valarray<T>();
173 template <
typename T1,
typename T2>
176 zero_clone(std::valarray<T1>& output,
const std::valarray<T2>& example)
178 const std::size_t sz = example.size();
180 for (std::size_t i=0; i != sz; ++i)
184 template <
typename T,
typename Scalar>
190 return std::valarray<T>(value,example.size());
192 return std::valarray<T>();
197 template <
typename T>
200 init_clone(std::valarray<T>& output,
const std::valarray<T>& example)
202 const std::size_t sz = example.size();
204 for (std::size_t i=0; i != sz; ++i)
223 template <
typename T>
227 const std::valarray<T>& if_true,
228 const std::valarray<T>& if_false)
233 const std::size_t size = condition.size();
234 std::valarray<T> returnval(size);
236 for (std::size_t i=0; i != size; ++i)
237 returnval[i] = condition[i] ? if_true[i] : if_false[i];
243 template <
typename VectorT>
247 typename value_type<VectorT>::type
249 eval_index(
const VectorT& vec,
const std::valarray<unsigned int>& index)
252 std::size_t sz = index.size();
253 returnval.resize(sz);
254 for (std::size_t i=0; i != sz; ++i)
255 returnval[i] = vec[index[i]][i];
263 #endif //ANTIOCH_VALARRAY_UTILS_H
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type max(const T &in)
#define antioch_assert_equal_to(expr1, expr2)
Antioch::enable_if_c< Antioch::is_valarray< T >::value, std::ostream & >::type operator<<(std::ostream &output, const T &a)
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type min(const T &in)
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
raw_value_type< T >::type type
void init_clone(T &output, const T &example)
enable_if_c< is_eigen< typename value_type< VectorT >::type >::value, typename value_type< VectorT >::type >::type eval_index(const VectorT &vec, const _Matrix< _UIntT, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &index)
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > constant_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex, const Scalar &value)
max(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a, const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &b) ANTIOCH_AUTOFUNC(_Matrix< _Scalar ANTIOCH_COMMA _Rows ANTIOCH_COMMA _Cols ANTIOCH_COMMA _Options ANTIOCH_COMMA _MaxRows ANTIOCH_COMMA _MaxCols >
enable_if_c< is_eigen< T1 >::value &&is_eigen< T2 >::value, typename state_type< T1 >::type >::type if_else(const Condition &condition, const T1 &if_true, const T2 &if_false)
The parameters are reduced parameters.
typename _Scalar int _Rows int _Cols int _Options int _MaxRows int _MaxCols inline min(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a, const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &b) ANTIOCH_AUTOFUNC(_Matrix< _Scalar ANTIOCH_COMMA _Rows ANTIOCH_COMMA _Cols ANTIOCH_COMMA _Options ANTIOCH_COMMA _MaxRows ANTIOCH_COMMA _MaxCols >
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > zero_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex)