]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/fwd/concept/ring.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / fwd / concept / ring.hpp
1 /*!
2 @file
3 Forward declares `boost::hana::Ring`.
4
5 @copyright Louis Dionne 2013-2016
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8 */
9
10 #ifndef BOOST_HANA_FWD_CONCEPT_RING_HPP
11 #define BOOST_HANA_FWD_CONCEPT_RING_HPP
12
13 #include <boost/hana/config.hpp>
14
15
16 BOOST_HANA_NAMESPACE_BEGIN
17 //! @ingroup group-concepts
18 //! @defgroup group-Ring Ring
19 //! The `Ring` concept represents `Group`s that also form a `Monoid`
20 //! under a second binary operation that distributes over the first.
21 //!
22 //! A [Ring][1] is an algebraic structure built on top of a `Group`
23 //! which requires a monoidal structure with respect to a second binary
24 //! operation. This second binary operation must distribute over the
25 //! first one. Specifically, a `Ring` is a triple `(S, +, *)` such that
26 //! `(S, +)` is a `Group`, `(S, *)` is a `Monoid` and `*` distributes
27 //! over `+`, i.e.
28 //! @code
29 //! x * (y + z) == (x * y) + (x * z)
30 //! @endcode
31 //!
32 //! The second binary operation is often written `*` with its identity
33 //! written `1`, in reference to the `Ring` of integers under
34 //! multiplication. The method names used here refer to this exact ring.
35 //!
36 //!
37 //! Minimal complete definintion
38 //! ----------------------------
39 //! `one` and `mult` satisfying the laws
40 //!
41 //!
42 //! Laws
43 //! ----
44 //! For all objects `x`, `y`, `z` of a `Ring` `R`, the following laws must
45 //! be satisfied:
46 //! @code
47 //! mult(x, mult(y, z)) == mult(mult(x, y), z) // associativity
48 //! mult(x, one<R>()) == x // right identity
49 //! mult(one<R>(), x) == x // left identity
50 //! mult(x, plus(y, z)) == plus(mult(x, y), mult(x, z)) // distributivity
51 //! @endcode
52 //!
53 //!
54 //! Refined concepts
55 //! ----------------
56 //! `Monoid`, `Group`
57 //!
58 //!
59 //! Concrete models
60 //! ---------------
61 //! `hana::integral_constant`
62 //!
63 //!
64 //! Free model for non-boolean arithmetic data types
65 //! ------------------------------------------------
66 //! A data type `T` is arithmetic if `std::is_arithmetic<T>::%value` is
67 //! true. For a non-boolean arithmetic data type `T`, a model of `Ring` is
68 //! automatically defined by using the provided `Group` model and setting
69 //! @code
70 //! mult(x, y) = (x * y)
71 //! one<T>() = static_cast<T>(1)
72 //! @endcode
73 //!
74 //! @note
75 //! The rationale for not providing a Ring model for `bool` is the same
76 //! as for not providing Monoid and Group models.
77 //!
78 //!
79 //! Structure-preserving functions
80 //! ------------------------------
81 //! Let `A` and `B` be two `Ring`s. A function `f : A -> B` is said to
82 //! be a [Ring morphism][2] if it preserves the ring structure between
83 //! `A` and `B`. Rigorously, for all objects `x, y` of data type `A`,
84 //! @code
85 //! f(plus(x, y)) == plus(f(x), f(y))
86 //! f(mult(x, y)) == mult(f(x), f(y))
87 //! f(one<A>()) == one<B>()
88 //! @endcode
89 //! Because of the `Ring` structure, it is easy to prove that the
90 //! following will then also be satisfied:
91 //! @code
92 //! f(zero<A>()) == zero<B>()
93 //! f(negate(x)) == negate(f(x))
94 //! @endcode
95 //! which is to say that `f` will then also be a `Group` morphism.
96 //! Functions with these properties interact nicely with `Ring`s,
97 //! which is why they are given such a special treatment.
98 //!
99 //!
100 //! [1]: http://en.wikipedia.org/wiki/Ring_(mathematics)
101 //! [2]: http://en.wikipedia.org/wiki/Ring_homomorphism
102 template <typename R>
103 struct Ring;
104 BOOST_HANA_NAMESPACE_END
105
106 #endif // !BOOST_HANA_FWD_CONCEPT_RING_HPP