00001 #ifndef OPENTISSUE_CORE_MATH_MATH_PRECISION_H 00002 #define OPENTISSUE_CORE_MATH_MATH_PRECISION_H 00003 // 00004 // OpenTissue Template Library 00005 // - A generic toolbox for physics-based modeling and simulation. 00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen. 00007 // 00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php 00009 // 00010 #include <OpenTissue/configuration.h> 00011 00012 #include <limits> // for std::numeric_limits<T>::epsilon() 00013 00014 00015 namespace OpenTissue 00016 { 00017 00018 namespace math 00019 { 00020 template <typename T> 00021 inline T machine_precision() 00022 { 00023 return std::numeric_limits<T>::epsilon(); 00024 } 00025 00026 template <typename T> 00027 inline T working_precision() 00028 { 00029 return std::numeric_limits<T>::epsilon()*10; 00030 } 00031 00032 template <typename T> 00033 inline T working_precision(unsigned int scale_factor) 00034 { 00035 return std::numeric_limits<T>::epsilon()*scale_factor; 00036 } 00037 00038 } 00039 } 00040 00041 //OPENTISSUE_CORE_MATH_MATH_PRECISION_H 00042 #endif