inverse_m_test.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/mat_operations.hpp>
  5. #include <boost/qvm/mat.hpp>
  6. #include <boost/exception/diagnostic_information.hpp>
  7. #include "test_qvm_matrix.hpp"
  8. #include "gold.hpp"
  9. namespace
  10. {
  11. template <class T,class U> struct same_type_tester;
  12. template <class T> struct same_type_tester<T,T> { };
  13. template <class T,class U> void test_same_type( T, U ) { same_type_tester<T,U>(); }
  14. template <int D>
  15. void
  16. test()
  17. {
  18. using namespace boost::qvm::sfinae;
  19. test_qvm::matrix<M1,D,D> x;
  20. test_qvm::rotation_z(x.a,42.0f);
  21. test_qvm::inverse(x.b,x.a);
  22. test_same_type(x,inverse(x));
  23. {
  24. test_qvm::matrix<M1,D,D> y=inverse(x);
  25. BOOST_QVM_TEST_CLOSE(x.b,y.a,0.000001f);
  26. }
  27. {
  28. test_qvm::matrix<M1,D,D> y=inverse(mref(x));
  29. BOOST_QVM_TEST_CLOSE(x.b,y.a,0.000001f);
  30. }
  31. }
  32. }
  33. int
  34. main()
  35. {
  36. try
  37. {
  38. test<2>();
  39. test<3>();
  40. test<4>();
  41. test<5>();
  42. return boost::report_errors();
  43. }
  44. catch(
  45. ... )
  46. {
  47. std::cerr << "Uncaught exception:\n" << boost::current_exception_diagnostic_information();
  48. return 1;
  49. }
  50. }