Expand description
§yui-core
The foundational crate of the yui workspace: algebraic trait hierarchy, concrete numeric types, polynomials, linear combinations, and supporting algorithms / extension traits.
§Layout
src/
├── abst/ — algebraic trait hierarchy: Ring, EucRing, Field, RMod, ...
├── conc/ — concrete instantiations: Ratio, FF, Sign, Poly, Lc, BitSeq
├── ext/ — extension traits: IteratorExt, RangeExt, IntoDigits, ...
├── algo/ — TopSort, UnionFind, KeyedUnionFind, rep_comb
└── util/ — formatting, data-dir resolution, thread-safe counter§Algebraic hierarchy
The traits in abst/ form the algebraic supertrait stack that everything else is generic over:
MathType (basic shape + math_symbol())
│
┌─────┴─────┐
↓ ↓
AddMon Mon (zero, +) (one, ×)
↓ │
AddGrp │ (negation)
└─────┬─────┘
↓
Ring ──────► RMod (module over a ring R)
↓
EucRing (gcd, div_rem)
↓
Field (every nonzero invertible)Arrows ↓ denote supertrait inheritance: Ring: AddGrp + Mon, EucRing: Ring, etc.
RMod takes its scalar ring R: Ring as an associated type, not a supertrait.
A typical where-clause:
ⓘ
fn foo<R>(x: &R) -> R
where R: Ring, for<'x> &'x R: RingOps<R>
{ ... }The for<'x> HRTB on the reference impl is required throughout; the auto_impl_ops crate derives the four Add/Mul reference variants from a single +=/*=.
§Concrete types
conc/num/:
IntTypeimpls fori32 / i64 / i128 / BigInt.Ratio<T>— fractions over a Euclidean ring;Ratio<i64>andRatio<BigInt>are the rationals.FF<p>— finite field 𝔽ₚ for primep. For 𝔽₂, prefer the specializedFF2(uses XOR/AND directly on abool).QuadInt<I, D>— quadratic integers in ℤ[ω] forω = (1+√D)/2or√D; aliasesGaussInt,EisenInt.Sign— the multiplicative group{±1}, with theGetSigntrait.
conc/poly/:
Poly<X, R>— univariate polynomial.LPoly<X, R>— univariate Laurent variant.Poly2,Poly3(fixed arity),PolyN<X, R>(multivariate), plus their Laurent variants.
conc/lc/:
Lc<X, R>— formal linear combinationΣ rᵢxᵢwith keysX: LcKeyand coefficients inR: Ring. Elements of the freeR-module over the key set.
conc/misc/:
bitseq::BitSeq<I>— packed sequence of bits over a wordI, length up toI::BITS. AliasesBitSeq8,BitSeq16,BitSeq32,BitSeq64,BitSeq128pin the width.
§Quick example
use yui_core::num::Ratio;
let a = Ratio::new(1_i64, 2);
let b = Ratio::new(1_i64, 3);
assert_eq!((&a + &b).to_string(), "5/6");
assert_eq!((&a * &b).to_string(), "1/6");§Feature flags
serde—Serialize/Deserializefor the concrete types.
§License
This library is licensed under the MIT License.
This README was generated by Claude.
Modules§
- abst
- The algebraic trait hierarchy:
MathTypeandIndexTypeat the base, thenAddMon → AddGrp,Mon → Ring → EucRing → Field, andRModfor modules. - algo
- General-purpose algorithms: topological sort, disjoint sets, and a stars-and-bars combinatorics helper.
- bitmap
- Compact bitmap over a small element type.
BitMap<E, S>is a single wordS(the storage) whose bite.into()is set iffeis present.S = u128covers element indices0..128, andU256doubles that; extend by impl-ingBitStoragefor a wider type. - bitseq
- A single
Bit, and a packed sequence of bitsBitSeqover a generic wordI. - ext
- Extension traits adding small conveniences to std and num types.
- lc
Lc<X, R>: a formal linear combination of keysXwith coefficients in a ringR— the element type of every chain module in this workspace.- num
- Concrete number types: integers, rationals, finite fields, quadratic integers, and the multiplicative sign group.
- poly
- Polynomials and their monomials, in one, two, three or indexed-many variables, ordinary or Laurent.
- u256
U256: a 256-bit word, used as a wideBitStorageforBitMap.- util
- Non-mathematical support code: formatting, parse errors, LaTeX rendering, data-directory resolution, logging and a thread-safe counter.