32 #ifndef __VMML__MATRIX_FUNCTORS__HPP__
33 #define __VMML__MATRIX_FUNCTORS__HPP__
35 #include <vmmlib/enable_if.hpp>
43 template<
typename T >
46 inline void operator()( T& matrix_ )
const
48 matrix_ =
static_cast< typename T::value_type
>( 0.0 );
54 template<
typename T >
58 typename enable_if< T::ROWS == T::COLS >::type*
59 operator()( T& matrix_ )
62 for(
size_t index = 0; index < T::ROWS; ++index )
64 matrix_( index, index ) =
static_cast< typename T::value_type
>( 1.0 );
73 template<
typename T >
77 bool operator()(
const T& matrix0,
const T& matrix1 )
79 const size_t r = matrix0.get_number_of_rows();
81 for(
size_t index = 0; ok && index < r; ++index )
83 if ( matrix0.get_row( index ) != matrix1.get_row( index )
84 && matrix0.get_row( index ) != - matrix1.get_row( index ) )
93 bool operator()(
const T& matrix0,
const T& matrix1,
typename T::value_type tolerance )
95 const size_t r = matrix0.get_number_of_rows();
97 for(
size_t index = 0; ok && index < r; ++index )
100 ! matrix0.get_row( index ).equals( matrix1.get_row( index ), tolerance )
101 && ! matrix0.get_row( index ).equals( - matrix1.get_row( index ), tolerance )
114 template<
typename T >
118 bool operator()(
const T& matrix0,
const T& matrix1 )
120 const size_t r = matrix0.get_number_of_columns();
122 for(
size_t index = 0; ok && index < r; ++index )
124 if ( matrix0.get_column( index ) != matrix1.get_column( index )
125 && matrix0.get_column( index ) != - matrix1.get_column( index ) )
134 bool operator()(
const T& matrix0,
const T& matrix1,
typename T::value_type tolerance )
136 const size_t r = matrix0.get_number_of_columns();
138 for(
size_t index = 0; ok && index < r; ++index )
141 ! matrix0.get_column( index ).equals( matrix1.get_column( index ), tolerance )
142 && ! matrix0.get_column( index ).equals( - matrix1.get_column( index ), tolerance )
heavily inspired by boost::enable_if http://www.boost.org, file: boost/utility/enable_if.hpp, Copyright 2003 Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine