1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* SPDX-License-Identifier: MIT
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
*/
use crate::;
use ;
/// Represents a **Module** over a `Ring`.
///
/// A module is a generalization of a vector space, where the scalars are
/// elements of a `Ring` `R` rather than being restricted to a `Field`.
///
/// # Mathematical Definition
///
/// A left module `M` over a ring `R` consists of an abelian group `(M, +)` and
/// an operation `R × M → M` (scalar multiplication) such that for all
/// `r, s` in `R` and `x, y` in `M`, the following axioms hold:
///
/// 1. `r * (x + y) = r*x + r*y`
/// 2. `(r + s) * x = r*x + s*x`
/// 3. `(r * s) * x = r * (s * x)`
/// 4. `1 * x = x` (if `R` is a unital ring)
///
/// ## Structure in this Crate
/// - The "vectors" (`Self`) form an `AbelianGroup`.
/// - The "scalars" (`R`) form a `Ring`.
/// - Scalar multiplication is provided by implementing `Mul<R>` and `MulAssign<R>`.
///
/// ## Examples
/// - Any `AbelianGroup` `G` is a module over the ring of integers `Z`.
/// - A vector space is a module where the ring of scalars is a `Field`.
/// - `Complex<T>` is a module over the `RealField` `T`.
// Blanket implementation for any type that satisfies the bounds