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