]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/arithmetic/dot_product.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / geometry / test / arithmetic / dot_product.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7
8 // This file was modified by Oracle on 2020.
9 // Modifications copyright (c) 2020, Oracle and/or its affiliates.
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
14
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
18
19
20 #include <geometry_test_common.hpp>
21
22 #include <boost/geometry/arithmetic/dot_product.hpp>
23
24
25 #include <boost/geometry/algorithms/assign.hpp>
26
27 #include <boost/geometry/geometries/point.hpp>
28 #include <boost/geometry/geometries/adapted/c_array.hpp>
29 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
30 #include <test_common/test_point.hpp>
31
32 BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
33 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
34
35
36 template <typename P>
37 void test_all()
38 {
39 P p1;
40 bg::assign_values(p1, 1, 2, 3);
41 P p2;
42 bg::assign_values(p2, 4, 5, 6);
43 BOOST_CHECK(bg::dot_product(p1, p2) == 1*4 + 2*5 + 3*6);
44 }
45
46 template <typename P>
47 void test_constexpr()
48 {
49 constexpr P p1 = P(1, 2, 3);
50 constexpr P p2 = P(4, 5, 6);
51 constexpr auto d = bg::dot_product(p1, p2);
52 BOOST_CHECK(d == 1 * 4 + 2 * 5 + 3 * 6);
53 }
54
55 int test_main(int, char* [])
56 {
57 test_all<int[3]>();
58 test_all<float[3]>();
59 test_all<double[3]>();
60 test_all<test::test_point>();
61 test_all<bg::model::point<int, 3, bg::cs::cartesian> >();
62 test_all<bg::model::point<float, 3, bg::cs::cartesian> >();
63 test_all<bg::model::point<double, 3, bg::cs::cartesian> >();
64
65 test_constexpr<bg::model::point<double, 3, bg::cs::cartesian> >();
66
67 return 0;
68 }