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:
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 Ratio;
let a = new;
let b = new;
assert_eq!;
assert_eq!;
Feature flags
serde—Serialize/Deserializefor the concrete types.
License
This library is licensed under the MIT License.
This README was generated by Claude.