col_test.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_vec.hpp>
  5. #include <boost/qvm/vec_traits_array.hpp>
  6. #include <boost/qvm/mat_operations.hpp>
  7. #include <boost/qvm/vec_operations.hpp>
  8. #include <boost/qvm/vec.hpp>
  9. #include "test_qvm.hpp"
  10. #include "test_qvm_matrix.hpp"
  11. #include "gold.hpp"
  12. namespace
  13. {
  14. template <int Rows,int Cols,int Col>
  15. void
  16. test()
  17. {
  18. using namespace boost::qvm;
  19. test_qvm::matrix<M1,Rows,Cols> x(42,1);
  20. float r1[Rows];
  21. for( int i=0; i!=Rows; ++i )
  22. r1[i]=x.a[i][Col];
  23. float r2[Rows];
  24. assign(r2,col<Col>(x));
  25. BOOST_QVM_TEST_EQ(r1,r2);
  26. col<Col>(x) *= 2;
  27. for( int i=0; i!=Rows; ++i )
  28. r1[i]=x.a[i][Col];
  29. assign(r2,col<Col>(x));
  30. BOOST_QVM_TEST_EQ(r1,r2);
  31. col<Col>(x) + col<Col>(x);
  32. -col<Col>(x);
  33. }
  34. }
  35. int
  36. main()
  37. {
  38. test<1,2,0>();
  39. test<1,2,1>();
  40. test<1,3,0>();
  41. test<1,3,1>();
  42. test<1,3,2>();
  43. test<1,4,0>();
  44. test<1,4,1>();
  45. test<1,4,2>();
  46. test<1,4,3>();
  47. test<1,5,0>();
  48. test<1,5,1>();
  49. test<1,5,2>();
  50. test<1,5,3>();
  51. test<1,5,4>();
  52. test<2,2,0>();
  53. test<2,2,1>();
  54. test<2,3,0>();
  55. test<2,3,1>();
  56. test<2,3,2>();
  57. test<2,4,0>();
  58. test<2,4,1>();
  59. test<2,4,2>();
  60. test<2,4,3>();
  61. test<2,5,0>();
  62. test<2,5,1>();
  63. test<2,5,2>();
  64. test<2,5,3>();
  65. test<2,5,4>();
  66. test<3,2,0>();
  67. test<3,2,1>();
  68. test<3,3,0>();
  69. test<3,3,1>();
  70. test<3,3,2>();
  71. test<3,4,0>();
  72. test<3,4,1>();
  73. test<3,4,2>();
  74. test<3,4,3>();
  75. test<3,5,0>();
  76. test<3,5,1>();
  77. test<3,5,2>();
  78. test<3,5,3>();
  79. test<3,5,4>();
  80. test<4,2,0>();
  81. test<4,2,1>();
  82. test<4,3,0>();
  83. test<4,3,1>();
  84. test<4,3,2>();
  85. test<4,4,0>();
  86. test<4,4,1>();
  87. test<4,4,2>();
  88. test<4,4,3>();
  89. test<4,5,0>();
  90. test<4,5,1>();
  91. test<4,5,2>();
  92. test<4,5,3>();
  93. test<4,5,4>();
  94. test<5,2,0>();
  95. test<5,2,1>();
  96. test<5,3,0>();
  97. test<5,3,1>();
  98. test<5,3,2>();
  99. test<5,4,0>();
  100. test<5,4,1>();
  101. test<5,4,2>();
  102. test<5,4,3>();
  103. test<5,5,0>();
  104. test<5,5,1>();
  105. test<5,5,2>();
  106. test<5,5,3>();
  107. test<5,5,4>();
  108. return boost::report_errors();
  109. }