diag_mat_test.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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.hpp>
  5. #include <boost/qvm/mat_traits_array.hpp>
  6. #include <boost/qvm/vec_operations.hpp>
  7. #include <boost/qvm/mat_operations.hpp>
  8. #include <boost/qvm/mat.hpp>
  9. #include "test_qvm_vector.hpp"
  10. #include "gold.hpp"
  11. namespace
  12. {
  13. template <int Dim>
  14. void
  15. test()
  16. {
  17. using namespace boost::qvm;
  18. test_qvm::vector<V1,Dim> x(42,1);
  19. float y[Dim][Dim]; assign(y,diag_mat(x));
  20. for( int i=0; i!=Dim; ++i )
  21. x.b[i]=y[i][i];
  22. BOOST_QVM_TEST_EQ(x.a,x.b);
  23. test_qvm::scalar_multiply_v(x.b,x.a,2.0f);
  24. diag(diag_mat(x)) *= 2;
  25. BOOST_QVM_TEST_EQ(x.a,x.b);
  26. diag_mat(x) + diag_mat(x);
  27. -diag_mat(x);
  28. }
  29. }
  30. int
  31. main()
  32. {
  33. test<2>();
  34. test<3>();
  35. test<4>();
  36. test<5>();
  37. return boost::report_errors();
  38. }