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
/// Field

use crate::algebra::abstr::Ring;
use std::ops::{Sub, SubAssign, Div, DivAssign};


/// Field
///
/// <a href="https://en.wikipedia.org/wiki/Field_(mathematics)">https://en.wikipedia.org/wiki/Field_(mathematics)</a>
///
pub trait Field : Ring + Sub<Self, Output = Self> + SubAssign<Self> + Sign + Div<Self, Output = Self> +
DivAssign<Self> + Abs
{
	fn epsilon() -> Self;
}


/// Sign trait
pub trait Sign
{
	/// Returns the sign of a number
	///
	/// # Param
	///
	/// # Return
	///
	/// -1 if self < 0
	/// 0 if self = 0
	/// 1 if self > 0
	fn sgn(self: &Self) -> Self;
}

/// Abs trait
pub trait Abs
{
	/// returns the absolute value of a field
	fn abs(self: &Self) -> Self;
}