| 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 | # include <boost/qvm/mat_operations.hpp> |
| 11 | # include <boost/qvm/vec_mat_operations.hpp> |
| 12 | # include <boost/qvm/vec.hpp> |
| 13 | #endif |
| 14 | |
| 15 | #include "test_qvm_matrix.hpp" |
| 16 | #include "test_qvm_vector.hpp" |
| 17 | #include "gold.hpp" |
| 18 | |
| 19 | namespace |
| 20 | { |
| 21 | template <class T,class U> |
| 22 | struct same_type; |
| 23 | |
| 24 | template <class T> |
| 25 | struct |
| 26 | same_type<T,T> |
| 27 | { |
| 28 | }; |
| 29 | |
| 30 | template <class T,class U> |
| 31 | void |
| 32 | check_same_type( T const &, U const & ) |
| 33 | { |
| 34 | same_type<T,U>(); |
| 35 | } |
| 36 | |
| 37 | template <int M,int N> |
| 38 | void |
| 39 | test() |
| 40 | { |
| 41 | using namespace boost::qvm::sfinae; |
| 42 | using namespace boost::qvm; |
| 43 | test_qvm::vector<V1,M> const x(42,1); |
| 44 | test_qvm::matrix<M1,M,N> const y(42,1); |
| 45 | { |
| 46 | test_qvm::vector<V2,N> r=x*y; |
| 47 | test_qvm::multiply_vm(r.b,x.b,y.b); |
| 48 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); |
| 49 | } |
| 50 | { |
| 51 | test_qvm::vector<V2,N> r=vref(x)*y; |
| 52 | test_qvm::multiply_vm(r.b,x.b,y.b); |
| 53 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); |
| 54 | } |
| 55 | { |
| 56 | test_qvm::vector<V2,N> r=x*mref(y); |
| 57 | test_qvm::multiply_vm(r.b,x.b,y.b); |
| 58 | BOOST_QVM_TEST_CLOSE(r.a,r.b,0.0000001f); |
| 59 | } |
| 60 | check_same_type(x*y,boost::qvm::vec<float,N>()); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | int |
| 65 | main() |
| 66 | { |
| 67 | test<1,2>(); |
| 68 | test<2,1>(); |
| 69 | test<2,2>(); |
| 70 | test<1,3>(); |
| 71 | test<3,1>(); |
| 72 | test<3,3>(); |
| 73 | test<1,4>(); |
| 74 | test<4,1>(); |
| 75 | test<4,4>(); |
| 76 | test<1,5>(); |
| 77 | test<5,1>(); |
| 78 | test<5,5>(); |
| 79 | return boost::report_errors(); |
| 80 | } |
| 81 | |