]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/qvm/test/zero_mat_test.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / qvm / test / zero_mat_test.cpp
CommitLineData
92f5a8d4
TL
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/mat_operations.hpp>
7#include <boost/qvm/mat.hpp>
8#include "test_qvm_matrix.hpp"
9
10namespace
11 {
12 template <class T,class U>
13 struct same_type;
14
15 template <class T>
16 struct
17 same_type<T,T>
18 {
19 };
20
21 template <class T,class U>
22 void
23 check_deduction( T const &, U const & )
24 {
25 same_type<T,typename boost::qvm::deduce_mat<U>::type>();
26 }
27
28 template <int Rows,int Cols>
29 void
30 test()
31 {
32 using namespace boost::qvm;
33 test_qvm::matrix<M1,Rows,Cols> m1=zero_mat<float,Rows,Cols>();
34 for( int i=0; i!=Rows; ++i )
35 for( int j=0; j!=Cols; ++j )
36 BOOST_TEST(!m1.a[i][j]);
37 test_qvm::matrix<M2,Rows,Cols> m2(42,1);
38 set_zero(m2);
39 for( int i=0; i!=Rows; ++i )
40 for( int j=0; j!=Cols; ++j )
41 BOOST_TEST(!m2.a[i][j]);
42 check_deduction(mat<float,Rows,Cols>(),zero_mat<float,Rows,Cols>());
43 check_deduction(mat<int,Rows,Cols>(),zero_mat<int,Rows,Cols>());
44 }
45
46 template <int Dim>
47 void
48 test()
49 {
50 using namespace boost::qvm;
51 test_qvm::matrix<M1,Dim,Dim> m1=zero_mat<float,Dim>();
52 for( int i=0; i!=Dim; ++i )
53 for( int j=0; j!=Dim; ++j )
54 BOOST_TEST(!m1.a[i][j]);
55 }
56 }
57
58int
59main()
60 {
61 test<1,2>();
62 test<2,1>();
63 test<2,2>();
64 test<1,3>();
65 test<3,1>();
66 test<3,3>();
67 test<1,4>();
68 test<4,1>();
69 test<4,4>();
70 test<1,5>();
71 test<5,1>();
72 test<5,5>();
73 test<2>();
74 test<3>();
75 test<4>();
76 test<5>();
77 return boost::report_errors();
78 }