Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:58

0001 /*!
0002 @file
0003 Forward declares `boost::hana::Ring`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_FWD_CONCEPT_RING_HPP
0011 #define BOOST_HANA_FWD_CONCEPT_RING_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 
0015 
0016 namespace boost { namespace hana {
0017     //! @ingroup group-concepts
0018     //! @defgroup group-Ring Ring
0019     //! The `Ring` concept represents `Group`s that also form a `Monoid`
0020     //! under a second binary operation that distributes over the first.
0021     //!
0022     //! A [Ring][1] is an algebraic structure built on top of a `Group`
0023     //! which requires a monoidal structure with respect to a second binary
0024     //! operation. This second binary operation must distribute over the
0025     //! first one. Specifically, a `Ring` is a triple `(S, +, *)` such that
0026     //! `(S, +)` is a `Group`, `(S, *)` is a `Monoid` and `*` distributes
0027     //! over `+`, i.e.
0028     //! @code
0029     //!     x * (y + z) == (x * y) + (x * z)
0030     //! @endcode
0031     //!
0032     //! The second binary operation is often written `*` with its identity
0033     //! written `1`, in reference to the `Ring` of integers under
0034     //! multiplication. The method names used here refer to this exact ring.
0035     //!
0036     //!
0037     //! Minimal complete definintion
0038     //! ----------------------------
0039     //! `one` and `mult` satisfying the laws
0040     //!
0041     //!
0042     //! Laws
0043     //! ----
0044     //! For all objects `x`, `y`, `z` of a `Ring` `R`, the following laws must
0045     //! be satisfied:
0046     //! @code
0047     //!     mult(x, mult(y, z)) == mult(mult(x, y), z)          // associativity
0048     //!     mult(x, one<R>()) == x                              // right identity
0049     //!     mult(one<R>(), x) == x                              // left identity
0050     //!     mult(x, plus(y, z)) == plus(mult(x, y), mult(x, z)) // distributivity
0051     //! @endcode
0052     //!
0053     //!
0054     //! Refined concepts
0055     //! ----------------
0056     //! `Monoid`, `Group`
0057     //!
0058     //!
0059     //! Concrete models
0060     //! ---------------
0061     //! `hana::integral_constant`
0062     //!
0063     //!
0064     //! Free model for non-boolean arithmetic data types
0065     //! ------------------------------------------------
0066     //! A data type `T` is arithmetic if `std::is_arithmetic<T>::%value` is
0067     //! true. For a non-boolean arithmetic data type `T`, a model of `Ring` is
0068     //! automatically defined by using the provided `Group` model and setting
0069     //! @code
0070     //!     mult(x, y) = (x * y)
0071     //!     one<T>() = static_cast<T>(1)
0072     //! @endcode
0073     //!
0074     //! @note
0075     //! The rationale for not providing a Ring model for `bool` is the same
0076     //! as for not providing Monoid and Group models.
0077     //!
0078     //!
0079     //! Structure-preserving functions
0080     //! ------------------------------
0081     //! Let `A` and `B` be two `Ring`s. A function `f : A -> B` is said to
0082     //! be a [Ring morphism][2] if it preserves the ring structure between
0083     //! `A` and `B`. Rigorously, for all objects `x, y` of data type `A`,
0084     //! @code
0085     //!     f(plus(x, y)) == plus(f(x), f(y))
0086     //!     f(mult(x, y)) == mult(f(x), f(y))
0087     //!     f(one<A>()) == one<B>()
0088     //! @endcode
0089     //! Because of the `Ring` structure, it is easy to prove that the
0090     //! following will then also be satisfied:
0091     //! @code
0092     //!     f(zero<A>()) == zero<B>()
0093     //!     f(negate(x)) == negate(f(x))
0094     //! @endcode
0095     //! which is to say that `f` will then also be a `Group` morphism.
0096     //! Functions with these properties interact nicely with `Ring`s,
0097     //! which is why they are given such a special treatment.
0098     //!
0099     //!
0100     //! [1]: http://en.wikipedia.org/wiki/Ring_(mathematics)
0101     //! [2]: http://en.wikipedia.org/wiki/Ring_homomorphism
0102     template <typename R>
0103     struct Ring;
0104 }} // end namespace boost::hana
0105 
0106 #endif // !BOOST_HANA_FWD_CONCEPT_RING_HPP