dot_vv_test.cpp 1.3 KB

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