]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/example/cppcon_2014/ring.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / cppcon_2014 / ring.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5#include <boost/hana/assert.hpp>
6#include <boost/hana/equal.hpp>
7#include <boost/hana/mult.hpp>
8#include <boost/hana/one.hpp>
9
10#include "matrix/comparable.hpp"
11#include "matrix/ring.hpp"
12namespace hana = boost::hana;
13using namespace cppcon;
14
15
16int main() {
17 // mult
18 {
b32b8144 19 BOOST_HANA_CONSTEXPR_LAMBDA auto a = matrix(
7c673cae
FG
20 row(1, 2, 3),
21 row(4, 5, 6)
22 );
23
b32b8144 24 BOOST_HANA_CONSTEXPR_LAMBDA auto b = matrix(
7c673cae
FG
25 row(1, 2),
26 row(3, 4),
27 row(5, 6)
28 );
29
30 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
31 hana::mult(a, b),
32 matrix(
33 row(1*1 + 2*3 + 5*3, 1*2 + 2*4 + 3*6),
34 row(4*1 + 3*5 + 5*6, 4*2 + 5*4 + 6*6)
35 )
36 ));
37 }
38
39 // one
40 {
41 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
42 hana::one<Matrix<1, 1>>(),
43 matrix(
44 row(1)
45 )
46 ));
47
48 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
49 hana::one<Matrix<2, 2>>(),
50 matrix(
51 row(1, 0),
52 row(0, 1)
53 )
54 ));
55
56 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
57 hana::one<Matrix<3, 3>>(),
58 matrix(
59 row(1, 0, 0),
60 row(0, 1, 0),
61 row(0, 0, 1)
62 )
63 ));
64
65 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
66 hana::one<Matrix<4, 4>>(),
67 matrix(
68 row(1, 0, 0, 0),
69 row(0, 1, 0, 0),
70 row(0, 0, 1, 0),
71 row(0, 0, 0, 1)
72 )
73 ));
74
75 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
76 hana::one<Matrix<4, 5>>(),
77 matrix(
78 row(1, 0, 0, 0, 0),
79 row(0, 1, 0, 0, 0),
80 row(0, 0, 1, 0, 0),
81 row(0, 0, 0, 1, 0)
82 )
83 ));
84
85 BOOST_HANA_CONSTEXPR_CHECK(hana::equal(
86 hana::one<Matrix<5, 4>>(),
87 matrix(
88 row(1, 0, 0, 0),
89 row(0, 1, 0, 0),
90 row(0, 0, 1, 0),
91 row(0, 0, 0, 1),
92 row(0, 0, 0, 0)
93 )
94 ));
95 }
96}