19 #ifndef SNARK_MATH_TRAITS_H_
20 #define SNARK_MATH_TRAITS_H_
22 #include <boost/array.hpp>
25 namespace snark{
namespace math{
27 template <
typename T >
31 T zero() {
return T( 0 ); }
32 T one() {
return T( 1 ); }
33 T identity() {
return T( 1 ); }
36 template <
typename T,
int Rows,
int Columns >
37 struct traits< ::Eigen::Matrix< T, Rows, Columns > >
39 enum { rows = Rows, columns = Columns, size = rows * columns };
41 static const ::Eigen::Matrix< T, Rows, Columns >& zero()
43 static ::Eigen::Matrix< T, Rows, Columns > z = ::Eigen::Matrix< T, Rows, Columns >::Zero();
47 static const ::Eigen::Matrix< T, Rows, Columns >& indentity()
49 static ::Eigen::Matrix< T, Rows, Columns > i = ::Eigen::Matrix< T, Rows, Columns >::Identity();
54 template <
typename T, std::
size_t Size >
55 class traits< boost::array< T, Size > >
60 static const boost::array< T, Size >& zero() {
static boost::array< T, Size > z = zero_();
return z; }
63 static boost::array< T, Size > zero_()
65 boost::array< T, Size > z;
66 for( std::size_t i = 0; i < Size; ++i ) { z[i] = math::traits< T >::zero(); }
73 #endif //SNARK_MATH_TRAITS_H_