identity_mat_test.cpp 926 B

123456789101112131415161718192021222324252627282930313233343536
  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 "test_qvm_matrix.hpp"
  6. namespace
  7. {
  8. template <int Dim>
  9. void
  10. test()
  11. {
  12. using namespace boost::qvm;
  13. test_qvm::matrix<M1,Dim,Dim> m=identity_mat<float,Dim>();
  14. for( int i=0; i!=Dim; ++i )
  15. for( int j=0; j!=Dim; ++j )
  16. BOOST_TEST(m.a[i][j]==float(i==j));
  17. test_qvm::matrix<M2,Dim,Dim> n(42,1);
  18. set_identity(n);
  19. for( int i=0; i!=Dim; ++i )
  20. for( int j=0; j!=Dim; ++j )
  21. BOOST_TEST(n.a[i][j]==float(i==j));
  22. }
  23. }
  24. int
  25. main()
  26. {
  27. test<2>();
  28. test<3>();
  29. test<4>();
  30. test<5>();
  31. return boost::report_errors();
  32. }