| 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 | |
| 15 | namespace |
| 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 | test_same_type(x,normalized(x)); |
| 29 | test_qvm::vector<V1,Dim> y=normalized(x); |
| 30 | float m=sqrtf(test_qvm::dot<float>(x.a,x.a)); |
| 31 | test_qvm::scalar_multiply_v(y.b,x.a,1/m); |
| 32 | BOOST_QVM_TEST_CLOSE(y.a,y.b,0.000001f); |
| 33 | } |
| 34 | { |
| 35 | test_qvm::vector<V1,Dim> x(42,1); |
| 36 | float m=sqrtf(test_qvm::dot<float>(x.a,x.a)); |
| 37 | test_qvm::scalar_multiply_v(x.b,x.a,1/m); |
| 38 | normalize(x); |
| 39 | BOOST_QVM_TEST_CLOSE(x.a,x.b,0.000001f); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | int |
| 45 | main() |
| 46 | { |
| 47 | test<2>(); |
| 48 | test<3>(); |
| 49 | test<4>(); |
| 50 | test<5>(); |
| 51 | return boost::report_errors(); |
| 52 | } |
| 53 | |