]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/qvm/test/cmp_mm_test.cpp
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / boost / libs / qvm / test / cmp_mm_test.cpp
CommitLineData
1e59de90 1// Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
92f5a8d4 2
1e59de90
TL
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#ifdef BOOST_QVM_TEST_SINGLE_HEADER
7# include BOOST_QVM_TEST_SINGLE_HEADER
8#else
9# include <boost/qvm/mat_operations.hpp>
10# include <boost/qvm/mat.hpp>
11#endif
92f5a8d4 12
92f5a8d4
TL
13#include <boost/qvm/mat_traits_array.hpp>
14#include "test_qvm_matrix.hpp"
15#include "gold.hpp"
16
1e59de90
TL
17namespace
18 {
19 template <class T>
20 struct test_scalar
21 {
22 T value_;
23 test_scalar( T value ): value_(value) {}
24 }; //No operator==
25
26 struct
27 equal_to
28 {
29 template <class T,class U>
30 bool
31 operator()( T const & a, U const & b )
32 {
33 return a.value_==b.value_;
34 }
35 };
36 }
37
38namespace boost { namespace qvm {
39 template <class T>
40 struct
41 is_scalar<test_scalar<T> >
42 {
43 static bool const value = is_scalar<T>::value;
44 };
45} }
46
92f5a8d4
TL
47namespace
48 {
49 template <int Rows,int Cols>
50 void
51 test()
52 {
53 using namespace boost::qvm::sfinae;
54 test_qvm::matrix<M1,Rows,Cols> const x(42,1);
55 for( int i=0; i!=Rows; ++i )
56 for( int j=0; j!=Cols; ++j )
57 {
58 {
59 test_qvm::matrix<M1,Rows,Cols> y(x);
60 BOOST_QVM_TEST_EQ(x,y);
61 y.a[i][j]=0;
62 BOOST_QVM_TEST_NEQ(x,y);
63 }
64 {
65 test_qvm::matrix<M2,Rows,Cols> y; assign(y,x);
66 BOOST_QVM_TEST_EQ(x,y);
67 y.a[i][j]=0;
68 BOOST_QVM_TEST_NEQ(x,y);
69 }
70 }
71 }
f67539c2 72
f67539c2
TL
73 template <class A, class B>
74 void
75 test2()
76 {
77 typedef test_scalar<A> scalar_a;
78 typedef test_scalar<B> scalar_b;
79 typedef boost::qvm::mat<scalar_a, 3, 3> mat_a;
80 typedef boost::qvm::mat<scalar_b, 3, 3> mat_b;
81 mat_a const a = { { {42, 94, 96}, {72, 95, 81}, {12, 84, 33} } };
82 mat_b const b = { { {42, 94, 96}, {72, 95, 81}, {12, 84, 33} } };
83 mat_a const c = { { {21, 47, 48}, {36, 47, 65}, {79, 27, 41} } };
84 mat_b const d = { { {21, 47, 48}, {36, 47, 65}, {79, 27, 41} } };
85 BOOST_TEST(cmp(a,a,equal_to()));
86 BOOST_TEST(cmp(a,b,equal_to()));
87 BOOST_TEST(cmp(b,a,equal_to()));
88 BOOST_TEST(cmp(b,b,equal_to()));
89 BOOST_TEST(cmp(c,c,equal_to()));
90 BOOST_TEST(cmp(c,d,equal_to()));
91 BOOST_TEST(cmp(d,c,equal_to()));
92 BOOST_TEST(cmp(d,d,equal_to()));
93 BOOST_TEST(!cmp(a,c,equal_to()));
94 BOOST_TEST(!cmp(c,a,equal_to()));
95 BOOST_TEST(!cmp(a,d,equal_to()));
96 BOOST_TEST(!cmp(d,a,equal_to()));
97 BOOST_TEST(!cmp(b,c,equal_to()));
98 BOOST_TEST(!cmp(c,b,equal_to()));
99 BOOST_TEST(!cmp(b,d,equal_to()));
100 BOOST_TEST(!cmp(d,b,equal_to()));
101 }
92f5a8d4
TL
102 }
103
104int
105main()
106 {
107 test<1,2>();
108 test<2,1>();
109 test<2,2>();
110 test<1,3>();
111 test<3,1>();
112 test<3,3>();
113 test<1,4>();
114 test<4,1>();
115 test<4,4>();
116 test<1,5>();
117 test<5,1>();
118 test<5,5>();
f67539c2
TL
119 test2<int, int>();
120 test2<int, double>();
121 test2<double, int>();
122 test2<double, double>();
92f5a8d4
TL
123 return boost::report_errors();
124 }