Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_MATH_BIG_BIG_IS_ORTHONORMAL_H
00002 #define OPENTISSUE_CORE_MATH_BIG_BIG_IS_ORTHONORMAL_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/math/math_value_traits.h>
00013 #include <boost/cast.hpp>
00014
00015 namespace OpenTissue
00016 {
00017 namespace math
00018 {
00019 namespace big
00020 {
00021
00034 template<typename matrix_type>
00035 inline bool is_orthonormal( matrix_type const & A )
00036 {
00037 using namespace ublas;
00038
00039 using std::fabs;
00040
00041 typedef typename matrix_type::value_type value_type;
00042 typedef OpenTissue::math::ValueTraits<value_type> value_traits;
00043 typedef typename matrix_type::size_type size_type;
00044
00045 size_type const & m = A.size1();
00046 size_type const & n = A.size2();
00047
00048 assert( m>0 || !"is_orthonormal(): m was out of range");
00049 assert( n>0 || !"is_orthonormal(): n was out of range");
00050 assert( m==n || !"is_orthonormal(): m and n was not equal");
00051
00052 value_type const precision = ::boost::numeric_cast<value_type>(10e-6);
00053
00054 for ( size_type i = 0; i < n; ++i )
00055 {
00056 value_type tmp = inner_prod( column(A,i), column(A,i) );
00057 if( fabs(tmp-value_traits::one()) > precision )
00058 return false;
00059 }
00060 for ( size_type i = 0; i < n; ++i )
00061 for ( size_type j = i+1; j < n; ++j )
00062 {
00063 value_type tmp = inner_prod( column(A,i), column(A,j) );
00064 if( fabs(tmp) > precision )
00065 return false;
00066 }
00067 return true;
00068 }
00069
00070
00071 }
00072 }
00073 }
00074
00075
00076 #endif