boost::geometry::math::equals用法的测试程序
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                boost::geometry::math::equals用法的测试程序
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                boost::geometry::math::equals用法的測試程序
- 實現功能
- C++實現代碼
實現功能
boost::geometry::math::equals用法的測試程序
C++實現代碼
#include <geometry_test_common.hpp> #include <limits> #include <boost/geometry/util/condition.hpp> #include <boost/geometry/util/math.hpp> namespace bgm = bg::math; template <typename T> void test_all() {BOOST_CHECK(bgm::equals(0, 0));BOOST_CHECK(bgm::equals(1, 1));BOOST_CHECK(bgm::equals(123456, 123456)); T eps = std::numeric_limits<T>::epsilon();if ( eps > 0 ){BOOST_CHECK(bgm::equals(0, 0+eps));BOOST_CHECK(bgm::equals(0+eps, 0));BOOST_CHECK(bgm::equals(1, 1+eps));BOOST_CHECK(bgm::equals(1+eps, 1));BOOST_CHECK(bgm::equals(12345+eps, 12345));}if (BOOST_GEOMETRY_CONDITION(std::numeric_limits<T>::has_infinity)){T inf = std::numeric_limits<T>::infinity();BOOST_CHECK(!bgm::equals(0, inf));BOOST_CHECK(!bgm::equals(0, -inf));BOOST_CHECK(!bgm::equals(1, inf));BOOST_CHECK(!bgm::equals(1, -inf));BOOST_CHECK(!bgm::equals(12345, inf));BOOST_CHECK(!bgm::equals(12345, -inf));BOOST_CHECK(!bgm::equals(inf, 0));BOOST_CHECK(!bgm::equals(-inf, 0));BOOST_CHECK(!bgm::equals(inf, 1));BOOST_CHECK(!bgm::equals(-inf, 1));BOOST_CHECK(!bgm::equals(inf, 12345));BOOST_CHECK(!bgm::equals(-inf, 12345));BOOST_CHECK(bgm::equals(inf, inf));BOOST_CHECK(bgm::equals(-inf, -inf));BOOST_CHECK(!bgm::equals(inf, -inf));BOOST_CHECK(!bgm::equals(-inf, inf));}if (BOOST_GEOMETRY_CONDITION(std::numeric_limits<T>::has_quiet_NaN)){T nan = std::numeric_limits<T>::quiet_NaN();BOOST_CHECK(!bgm::equals(0, nan));BOOST_CHECK(!bgm::equals(nan, 0));BOOST_CHECK(!bgm::equals(nan, nan));BOOST_CHECK(!bgm::equals(1, nan));BOOST_CHECK(!bgm::equals(nan, 1));BOOST_CHECK(!bgm::equals(12345, nan));BOOST_CHECK(!bgm::equals(nan, 12345));} }int test_main(int, char* []) {test_all<int>();test_all<float>();test_all<double>(); return 0; }總結
以上是生活随笔為你收集整理的boost::geometry::math::equals用法的测试程序的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 福庆家具板是十大名牌吗?家里要装修值得用
- 下一篇: 客厅朝北真的很差吗
