27 #ifndef ANTIOCH_EIGEN_UTILS_H
28 #define ANTIOCH_EIGEN_UTILS_H
30 #ifdef ANTIOCH_METAPROGRAMMING_H
31 # ifndef ANTIOCH_EIGEN_UTILS_DECL_H
32 # error eigen_utils_decl.h must be included before metaprogramming.h
36 #include "antioch_config.h"
38 #ifdef ANTIOCH_HAVE_EIGEN
43 #include <Eigen/Dense>
56 template <
typename,
int,
int,
int,
int,
int>
class _Matrix,
57 typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols
60 ANTIOCH_AUTO(_Matrix<_Scalar ANTIOCH_COMMA _Rows ANTIOCH_COMMA _Cols ANTIOCH_COMMA _Options ANTIOCH_COMMA _MaxRows ANTIOCH_COMMA _MaxCols>)
61 max(
const _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> & a,
62 const _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> & b)
63 ANTIOCH_AUTOFUNC(_Matrix<_Scalar ANTIOCH_COMMA _Rows ANTIOCH_COMMA _Cols ANTIOCH_COMMA _Options ANTIOCH_COMMA _MaxRows ANTIOCH_COMMA _MaxCols>,
64 a.array().max(b.array()))
67 template <
typename,
int,
int,
int,
int,
int>
class _Matrix,
68 typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols
71 ANTIOCH_AUTO(_Matrix<_Scalar ANTIOCH_COMMA _Rows ANTIOCH_COMMA _Cols ANTIOCH_COMMA _Options ANTIOCH_COMMA _MaxRows ANTIOCH_COMMA _MaxCols>)
72 min(const _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> & a,
73 const _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> & b)
86 typename value_type<T>::type
96 typename value_type<T>::type
100 return in.minCoeff();
103 template <
typename T>
106 const static bool value =
true;
109 template <
typename T>
112 const static bool value =
true;
115 template <
typename T>
118 typedef typename T::Index
type;
122 template <
typename,
int,
int,
int,
int,
int>
class _Matrix,
123 typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols
125 struct value_type<_Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
131 template <
typename,
int,
int,
int,
int,
int>
class _Matrix,
132 typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols
134 struct raw_value_type<_Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> >
140 template <
typename,
int,
int,
int,
int,
int>
class _Matrix,
141 typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols
144 _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
145 zero_clone(
const _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& ex)
150 _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
151 (ex.rows(), ex.cols()).setConstant(
zero_clone(ex[0]));
154 _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
155 (ex.rows(), ex.cols());
159 template <
typename,
int,
int,
int,
int,
int>
class _Matrix,
160 typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols,
165 zero_clone(_Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& output,
166 const _Matrix<Scalar2, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& ex)
169 output.resize(ex.rows(), ex.cols());
175 template <
typename,
int,
int,
int,
int,
int>
class _Matrix,
176 typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols,
180 _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
182 _MaxRows, _MaxCols>& ex,
188 _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
189 (ex.rows(), ex.cols()).setConstant(value);
192 _Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>
193 (ex.rows(), ex.cols());
198 template <
typename,
int,
int,
int,
int,
int>
class _Matrix,
199 typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols,
212 template <
typename,
int,
int,
int,
int,
int>
class _Matrix,
213 typename _Scalar,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols
217 set_zero(_Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& a)
243 template <
typename Condition,
typename T1,
typename T2>
245 typename enable_if_c<
246 is_eigen<T1>::value &&
248 typename state_type<T1>::type
251 const Condition& condition,
255 return condition.select(if_true, if_false);
259 template <
typename VectorT,
260 template <
typename ,
int,
int,
int,
int,
int>
class _Matrix,
261 typename _UIntT,
int _Rows,
int _Cols,
int _Options,
int _MaxRows,
int _MaxCols
264 typename enable_if_c<
265 is_eigen<typename value_type<VectorT>::type>::value,
266 typename value_type<VectorT>::type
268 eval_index(
const VectorT& vec,
const _Matrix<_UIntT, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& index)
271 for (
unsigned int i=0; i != index.size(); ++i)
272 returnval[i] = vec[index[i]][i];
276 template <
typename T>
283 template <
typename T>
293 #endif //ANTIOCH_EIGEN_UTILS_H
raw_value_type< _Scalar >::type type
bool conjunction_root(const T &vec, eigen_library_tag)
bool disjunction_root(const T &vec, eigen_library_tag)
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)
void set_zero(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a)
#define ANTIOCH_AUTOFUNC(Type, Expr)
void constant_fill(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &output, const Scalar &value)
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 >
void zero_clone(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &output, const _Matrix< Scalar2, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex)
#define ANTIOCH_AUTO(Type)
a array().max(b.array())) template< template< typename