1// Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
2
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#ifdef BOOST_QVM_TEST_SINGLE_HEADER
7# include BOOST_QVM_TEST_SINGLE_HEADER
8#else
9# include <boost/qvm/vec_operations.hpp>
10#endif
11
12#include "test_qvm_vector.hpp"
13#include "gold.hpp"
14
15namespace
16 {
17 template <class T,class U> struct same_type_tester;
18 template <class T> struct same_type_tester<T,T> { };
19 template <class T,class U> void test_same_type( T, U ) { same_type_tester<T,U>(); }
20
21 template <int Dim>
22 void
23 test()
24 {
25 using namespace boost::qvm::sfinae;
26
27 test_qvm::vector<V1,Dim> const x(42,1);
28 {
29 test_qvm::vector<V1,Dim> const y(43,1);
30 test_same_type(float(),dot(x,y));
31 float d1=dot(x,y);
32 float d2=test_qvm::dot<float>(x.a,y.a);
33 BOOST_QVM_TEST_CLOSE(d1,d2,0.000001f);
34 }
35 {
36 test_qvm::vector<V1,Dim,double> const y(43,1);
37 test_same_type(double(),dot(x,y));
38 double d1=dot(x,y);
39 double d2=test_qvm::dot<double>(x.a,y.a);
40 BOOST_QVM_TEST_CLOSE(d1,d2,0.000001);
41 }
42 }
43 }
44
45int
46main()
47 {
48 test<2>();
49 test<3>();
50 test<4>();
51 test<5>();
52 return boost::report_errors();
53 }
54

source code of boost/libs/qvm/test/dot_vv_test.cpp