inertia_algebra/structures.rs
1// Copyright 2013-2014 The Algebra Developers.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Fundamental algebraic structures.
16//!
17//! For most applications requiring an abstraction over the reals, `RealField`
18//! should be sufficient.
19//!
20//! ## Algebraic properties
21//!
22//! The goal of algebraic structures is to allow elements of sets to be combined together using one
23//! or several operators. The number and properties of those operators characterize the algebraic
24//! structure. Abstract operators are usually noted `∘`, `+`, or `×`. The last two are preferred
25//! when their behavior conform with the usual meaning of addition and multiplication of reals.
26//! Let `Self` be a set. Here is a list of the most common properties those operator may fulfill:
27//!
28//! ~~~notrust
29//! (Closure) a, b ∈ Self ⇒ a ∘ b ∈ Self,
30//! (Divisibility) ∀ a, b ∈ Self, ∃! r, l ∈ Self such that l ∘ a = b and a ∘ r = b
31//! (Invertibility) ∃ e ∈ Self, ∀ a ∈ Self, ∃ r, l ∈ Self such that l ∘ a = a ∘ r = e
32//! If the right and left inverse are equal they are usually noted r = l = a⁻¹.
33//! (Associativity) ∀ a, b, c ∈ Self, (a ∘ b) ∘ c = a ∘ (b ∘ c)
34//! (Neutral Elt.) ∃ e ∈ Self, ∀ a ∈ Self, e ∘ a = a ∘ e = a
35//! (Commutativity) ∀ a, b ∈ Self, a ∘ b = b ∘ a
36//! ~~~
37//!
38//! ## Identity elements
39//!
40//! Two traits are provided that allow the definition of the additive and
41//! multiplicative identity elements:
42//!
43//! - `IdentityAdditive`
44//! - `IdentityMultiplicative`
45//!
46//! ## AbstractGroup-like structures
47//!
48//! These structures are provided for both the addition and multiplication.
49//!
50//! These can be derived automatically by `alga_traits` attribute from `alga_derive` crate.
51//!
52//! ~~~notrust
53//! AbstractMagma
54//! |
55//! _______/ \______
56//! / \
57//! divisibility associativity
58//! | |
59//! V V
60//! AbstractQuasigroup AbstractSemigroup
61//! | |
62//! identity identity
63//! | |
64//! V V
65//! AbstractLoop AbstractMonoid
66//! | |
67//! associativity invertibility
68//! \______ _______/
69//! \ /
70//! |
71//! V
72//! AbstractGroup
73//! |
74//! commutativity
75//! |
76//! V
77//! AbstractGroupAbelian
78//! ~~~
79//!
80//! The following traits are provided:
81//!
82//! - (`Abstract`|`Additive`|`Multiplicative`)`Magma`
83//! - (`Abstract`|`Additive`|`Multiplicative`)`Quasigroup`
84//! - (`Abstract`|`Additive`|`Multiplicative`)`Loop`
85//! - (`Abstract`|`Additive`|`Multiplicative`)`Semigroup`
86//! - (`Abstract`|`Additive`|`Multiplicative`)`Monoid`
87//! - (`Abstract`|`Additive`|`Multiplicative`)`Group`
88//! - (`Abstract`|`Additive`|`Multiplicative`)`GroupAbelian`
89//!
90//! ## Ring-like structures
91//!
92//! These can be derived automatically by `alga_traits` attribute from `alga_derive` crate.
93//!
94//! ~~~notrust
95//! GroupAbelian Monoid
96//! \________ ________/
97//! \ /
98//! |
99//! V
100//! Ring
101//! |
102//! commutativity_of_mul
103//! |
104//! V
105//! RingCommutative GroupAbelian
106//! \_______ ___________/
107//! \ /
108//! |
109//! V
110//! Field
111//! ~~~
112//!
113//! The following traits are provided:
114//!
115//! - `Ring`
116//! - `RingCommutative`
117//! - `Field`
118//!
119//! ## Module-like structures
120//!
121//! ~~~notrust
122//! GroupAbelian RingCommutative
123//! \______ _____/
124//! \ /
125//! | |
126//! V V
127//! Module<Scalar> Field
128//! \______ _____/
129//! \ /
130//! | |
131//! V V
132//! VectorSpace<Scalar>
133//! ~~~
134//!
135//! The following traits are provided:
136//!
137//! - `Module`
138//! - `VectorSpace`
139//!
140//! # Quickcheck properties
141//!
142//! Functions are provided to test that algebraic properties like
143//! associativity and commutativity hold for a given set of arguments.
144//!
145//! These tests can be automatically derived by `alga_quickcheck` attribute from `alga_derive` crate.
146//!
147//! For example:
148//!
149//! ~~~.ignore
150//! use algebra::general::SemigroupMultiplicative;
151//!
152//! quickcheck! {
153//! fn prop_mul_is_associative(args: (i32, i32, i32)) -> bool {
154//! SemigroupMultiplicative::prop_mul_is_associative(args)
155//! }
156//! }
157//! ~~~
158
159pub use grouplike::*;
160pub use ringlike::*;
161//pub use modulelike::*;
162pub use specialized::*;
163
164mod grouplike;
165mod ringlike;
166//mod modulelike;
167mod specialized;