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.