|
||||
File indexing completed on 2025-01-18 09:37:58
0001 /*! 0002 @file 0003 Forward declares `boost::hana::EuclideanRing`. 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_EUCLIDEAN_RING_HPP 0011 #define BOOST_HANA_FWD_CONCEPT_EUCLIDEAN_RING_HPP 0012 0013 #include <boost/hana/config.hpp> 0014 0015 0016 namespace boost { namespace hana { 0017 //! @ingroup group-concepts 0018 //! @defgroup group-EuclideanRing Euclidean Ring 0019 //! The `EuclideanRing` concept represents a commutative `Ring` that 0020 //! can also be endowed with a division algorithm. 0021 //! 0022 //! A Ring defines a binary operation often called _multiplication_ that 0023 //! can be used to combine two elements of the ring into a new element of 0024 //! the ring. An [Euclidean ring][1], also called an Euclidean domain, adds 0025 //! the ability to define a special function that generalizes the Euclidean 0026 //! division of integers. 0027 //! 0028 //! However, an Euclidean ring must also satisfy one more property, which 0029 //! is that of having no non-zero zero divisors. In a Ring `(R, +, *)`, it 0030 //! follows quite easily from the axioms that `x * 0 == 0` for any ring 0031 //! element `x`. However, there is nothing that mandates `0` to be the 0032 //! only ring element sending other elements to `0`. Hence, in some Rings, 0033 //! it is possible to have elements `x` and `y` such that `x * y == 0` 0034 //! while not having `x == 0` nor `y == 0`. We call these elements divisors 0035 //! of zero, or zero divisors. For example, this situation arises in the 0036 //! Ring of integers modulo 4 (the set `{0, 1, 2, 3}`) with addition and 0037 //! multiplication `mod 4` as binary operations. In this case, we have that 0038 //! @code 0039 //! 2 * 2 == 4 0040 //! == 0 (mod 4) 0041 //! @endcode 0042 //! even though `2 != 0 (mod 4)`. 0043 //! 0044 //! Following this line of thought, an Euclidean ring requires its only 0045 //! zero divisor is zero itself. In other words, the multiplication in an 0046 //! Euclidean won't send two non-zero elements to zero. Also note that 0047 //! since multiplication in a `Ring` is not necessarily commutative, it 0048 //! is not always the case that 0049 //! @code 0050 //! x * y == 0 implies y * x == 0 0051 //! @endcode 0052 //! To be rigorous, we should then distinguish between elements that are 0053 //! zero divisors when multiplied to the right and to the left. 0054 //! Fortunately, the concept of an Euclidean ring requires the Ring 0055 //! multiplication to be commutative. Hence, 0056 //! @code 0057 //! x * y == y * x 0058 //! @endcode 0059 //! and we do not have to distinguish between left and right zero divisors. 0060 //! 0061 //! Typical examples of Euclidean rings include integers and polynomials 0062 //! over a field. The method names used here refer to the Euclidean ring 0063 //! of integers under the usual addition, multiplication and division 0064 //! operations. 0065 //! 0066 //! 0067 //! Minimal complete definition 0068 //! --------------------------- 0069 //! `div` and `mod` satisfying the laws below 0070 //! 0071 //! 0072 //! Laws 0073 //! ---- 0074 //! To simplify the reading, we will use the `+`, `*`, `/` and `%` 0075 //! operators with infix notation to denote the application of the 0076 //! corresponding methods in Monoid, Group, Ring and EuclideanRing. 0077 //! For all objects `a` and `b` of an `EuclideanRing` `R`, the 0078 //! following laws must be satisfied: 0079 //! @code 0080 //! a * b == b * a // commutativity 0081 //! (a / b) * b + a % b == a if b is non-zero 0082 //! zero<R>() % b == zero<R>() if b is non-zero 0083 //! @endcode 0084 //! 0085 //! 0086 //! Refined concepts 0087 //! ---------------- 0088 //! `Monoid`, `Group`, `Ring` 0089 //! 0090 //! 0091 //! Concrete models 0092 //! --------------- 0093 //! `hana::integral_constant` 0094 //! 0095 //! 0096 //! Free model for non-boolean integral data types 0097 //! ---------------------------------------------- 0098 //! A data type `T` is integral if `std::is_integral<T>::%value` is true. 0099 //! For a non-boolean integral data type `T`, a model of `EuclideanRing` 0100 //! is automatically defined by using the `Ring` model provided for 0101 //! arithmetic data types and setting 0102 //! @code 0103 //! div(x, y) = (x / y) 0104 //! mod(x, y) = (x % y) 0105 //! @endcode 0106 //! 0107 //! @note 0108 //! The rationale for not providing an EuclideanRing model for `bool` is 0109 //! the same as for not providing Monoid, Group and Ring models. 0110 //! 0111 //! 0112 //! [1]: https://en.wikipedia.org/wiki/Euclidean_domain 0113 template <typename R> 0114 struct EuclideanRing; 0115 }} // end namespace boost::hana 0116 0117 #endif // !BOOST_HANA_FWD_CONCEPT_EUCLIDEAN_RING_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |