dot_product.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  5. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  6. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  7. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  8. // Use, modification and distribution is subject to the Boost Software License,
  9. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. #include <geometry_test_common.hpp>
  12. #include <boost/geometry/arithmetic/dot_product.hpp>
  13. #include <boost/geometry/algorithms/assign.hpp>
  14. #include <boost/geometry/geometries/point.hpp>
  15. #include <boost/geometry/geometries/adapted/c_array.hpp>
  16. #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
  17. #include <test_common/test_point.hpp>
  18. BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
  19. BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
  20. template <typename P>
  21. void test_all()
  22. {
  23. P p1;
  24. bg::assign_values(p1, 1, 2, 3);
  25. P p2;
  26. bg::assign_values(p2, 4, 5, 6);
  27. BOOST_CHECK(bg::dot_product(p1, p2) == 1*4 + 2*5 + 3*6);
  28. }
  29. int test_main(int, char* [])
  30. {
  31. test_all<int[3]>();
  32. test_all<float[3]>();
  33. test_all<double[3]>();
  34. test_all<test::test_point>();
  35. test_all<bg::model::point<int, 3, bg::cs::cartesian> >();
  36. test_all<bg::model::point<float, 3, bg::cs::cartesian> >();
  37. test_all<bg::model::point<double, 3, bg::cs::cartesian> >();
  38. return 0;
  39. }