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