Algebra Crate
A Rust library providing algebraic structures and operations, with a focus on modular arithmetic and abstract algebra concepts.
Features
- Modular Arithmetic: Create custom modular number types with the
modular!macro - Abstract Algebra: Implementations of fundamental algebraic structures:
- Groups (both Abelian and Non-Abelian)
- Rings
- Fields
- Modules
- Vector Spaces
Usage
Add this to your Cargo.toml:
[]
= "*"
Modular Arithmetic
Create a new modular number type using the modular! macro:
use ;
// Create a type for numbers modulo 7
modular!;
let a = new;
let b = new;
// Addition: 3 + 5 = 8 ≡ 1 (mod 7)
let sum = a + b;
assert_eq!;
// Multiplication: 3 * 5 = 15 ≡ 1 (mod 7)
let product = a * b;
assert_eq!;
Vector Spaces
Create and manipulate vectors over any field, such as the finite field of integers modulo 7:
use ;
modular!;
prime_field!;
let v1 = ;
let v2 = ;
let sum = v1 + v2;
Documentation
The complete API documentation is available on docs.rs.
Modules
arithmetic: Basic arithmetic traits and operationsgroup: Group theory abstractions and implementationsring: Ring theory abstractions and implementationsmodule: Module theory abstractions and implementationsvector: Vector space abstractions and implementationsmodular: Modular arithmetic abstractions and implementations
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.
Examples
use ;
modular!;
// Group operations
let a = new;
let inverse = a.inverse; // 4 (mod 7)
let identity = identity; // 0 (mod 7)
// Ring operations
let one = one; // 1 (mod 7)
let zero = zero; // 0 (mod 7)