]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/qvm/test/transpose_test.cpp
3fffa36f96ed96701f7f7ec71919595ac912eebc
[ceph.git] / ceph / src / boost / libs / qvm / test / transpose_test.cpp
1 //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
2
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #include <boost/qvm/map_mat_mat.hpp>
7 #include <boost/qvm/mat_operations.hpp>
8 #include <boost/qvm/mat_traits_array.hpp>
9 #include <boost/qvm/mat.hpp>
10 #include "test_qvm_matrix.hpp"
11 #include "gold.hpp"
12
13 namespace
14 {
15 template <int Rows,int Cols>
16 void
17 test()
18 {
19 using namespace boost::qvm;
20 test_qvm::matrix<M1,Rows,Cols> x(42,1);
21 float r1[Cols][Rows];
22 for( int i=0; i!=Rows; ++i )
23 for( int j=0; j!=Cols; ++j )
24 r1[j][i]=x.a[i][j];
25 float r2[Cols][Rows];
26 assign(r2,transposed(x));
27 BOOST_QVM_TEST_EQ(r1,r2);
28 test_qvm::scalar_multiply_m(x.b,x.a,2.0f);
29 transposed(x) *= 2;
30 BOOST_QVM_TEST_EQ(x.a,x.b);
31 transposed(x) + transposed(x);
32 -transposed(x);
33 }
34 }
35
36 int
37 main()
38 {
39 test<1,2>();
40 test<2,1>();
41 test<2,2>();
42 test<1,3>();
43 test<3,1>();
44 test<3,3>();
45 test<1,4>();
46 test<4,1>();
47 test<4,4>();
48 test<1,5>();
49 test<5,1>();
50 test<5,5>();
51 return boost::report_errors();
52 }