transpose_test.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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/map_mat_mat.hpp>
  5. #include <boost/qvm/mat_operations.hpp>
  6. #include <boost/qvm/mat_traits_array.hpp>
  7. #include <boost/qvm/mat.hpp>
  8. #include "test_qvm_matrix.hpp"
  9. #include "gold.hpp"
  10. namespace
  11. {
  12. template <int Rows,int Cols>
  13. void
  14. test()
  15. {
  16. using namespace boost::qvm;
  17. test_qvm::matrix<M1,Rows,Cols> x(42,1);
  18. float r1[Cols][Rows];
  19. for( int i=0; i!=Rows; ++i )
  20. for( int j=0; j!=Cols; ++j )
  21. r1[j][i]=x.a[i][j];
  22. float r2[Cols][Rows];
  23. assign(r2,transposed(x));
  24. BOOST_QVM_TEST_EQ(r1,r2);
  25. test_qvm::scalar_multiply_m(x.b,x.a,2.0f);
  26. transposed(x) *= 2;
  27. BOOST_QVM_TEST_EQ(x.a,x.b);
  28. transposed(x) + transposed(x);
  29. -transposed(x);
  30. }
  31. }
  32. int
  33. main()
  34. {
  35. test<1,2>();
  36. test<2,1>();
  37. test<2,2>();
  38. test<1,3>();
  39. test<3,1>();
  40. test<3,3>();
  41. test<1,4>();
  42. test<4,1>();
  43. test<4,4>();
  44. test<1,5>();
  45. test<5,1>();
  46. test<5,5>();
  47. return boost::report_errors();
  48. }