mul_mv_test.cpp 1.8 KB

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