pub struct Group<'a, T> { /* private fields */ }
Expand description
A monoid with inverses.
Group
is a representation of the abstract algebraic group.
Associativity, invertibility, and identity preservation are all required
of its binary operation. Its construction involves a set (specifically an
AlgaeSet
) and a BinaryOperation
with the aforementioned properties.
§Examples
use algae_rs::algaeset::AlgaeSet;
use algae_rs::mapping::{BinaryOperation, GroupOperation};
use algae_rs::magma::{Magmoid, Group};
let mut add = GroupOperation::new(&|a, b| a + b, &|a, b| a - b, 0);
let mut group = Group::new(AlgaeSet::<i32>::all(), &mut add, 0);
let sum = group.with(1, 2);
assert!(sum.is_ok());
assert!(sum.unwrap() == 3);
let difference = group.with(1, -1);
assert!(difference.is_ok());
assert!(difference.unwrap() == 0);
let mut bad_add = GroupOperation::new(&|a, b| a + b, &|a, b| a * b, 0);
let mut bad_group = Group::new(AlgaeSet::<i32>::all(), &mut bad_add, 0);
let bad_sum = bad_group.with(3, 2);
assert!(bad_sum.is_err());
let bad_difference = bad_group.with(1, -1);
assert!(bad_difference.is_err());
Implementations§
Trait Implementations§
Source§impl<'a, T: Copy + PartialEq> From<Group<'a, T>> for Quasigroup<'a, T>
impl<'a, T: Copy + PartialEq> From<Group<'a, T>> for Quasigroup<'a, T>
Source§fn from(group: Group<'a, T>) -> Quasigroup<'a, T>
fn from(group: Group<'a, T>) -> Quasigroup<'a, T>
Converts to this type from the input type.
Auto Trait Implementations§
impl<'a, T> Freeze for Group<'a, T>where
T: Freeze,
impl<'a, T> !RefUnwindSafe for Group<'a, T>
impl<'a, T> !Send for Group<'a, T>
impl<'a, T> !Sync for Group<'a, T>
impl<'a, T> Unpin for Group<'a, T>where
T: Unpin,
impl<'a, T> !UnwindSafe for Group<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more