pub trait Field:
CommutativeRing
+ InvMonoid
+ Div<Output = Self>
+ DivAssign { }Expand description
Represents a Field in abstract algebra.
A field is a set on which addition, subtraction, multiplication, and division are defined and behave as the corresponding operations on rational and real numbers do. A field is thus a fundamental algebraic structure which is widely used in algebra, number theory, and many other areas of mathematics.
§Mathematical Definition
A field is a CommutativeRing where every non-zero element has a
multiplicative inverse. This means it satisfies the following laws:
-
CommutativeRing Laws:
- Forms an
AbelianGroupunder addition (associative, commutative, identity0, inverses). - Forms a
MulMonoidunder multiplication (associative, identity1). - Multiplication is commutative (
a * b = b * a). - Multiplication distributes over addition (
a * (b + c) = a*b + a*c).
- Forms an
-
Multiplicative Inverse:
- For every element
anot equal to0, there exists an elementa⁻¹such thata * a⁻¹ = 1. (Provided by theInvMonoidtrait)
- For every element
§Examples
- Real numbers (
f32,f64) - Complex numbers (
Complex<T>) - Rational numbers (not implemented in this crate)
§Counter-examples
- Integers (
i32,i64): Lack multiplicative inverses for most elements. - Quaternions (
Quaternion<T>): Multiplication is not commutative.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.