日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

boost::geometry::math::equals用法的测试程序

發布時間:2024/9/30 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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用法的测试程序的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。