Skip to content

Commit 9af3d7c

Browse files
committed
suggestions
1 parent 6cbe0b8 commit 9af3d7c

3 files changed

Lines changed: 732 additions & 46 deletions

File tree

AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ This file helps AI agents discover and understand how to work with this reposito
2828

2929
- Balanced ternary bigint logic in `include/t81/core/bigint.hpp` now normalizes signed limbs more efficiently and fixes `~`/division helpers so later agents can spot the modern bitwise/division flow.
3030
- `tests/unit/test_numeric_types.cpp` now exercises `Complex`, `Polynomial`, and `F2m` helpers so the umbrella numeric helpers stay locked down.
31+
- `README.md` now documents the high-level helpers (`Float`, `Ratio`, `Complex`, `Polynomial`, `F2m`, `Fixed<N>`, `Modulus`, and `MontgomeryInt`) plus the `t81::Int` alias exposed through `t81/t81lib.hpp`.
32+
- `include/t81/t81lib.hpp` now exposes `Float::from_string`, a `Ratio``Float` conversion, the `Int81` `Fixed<48>` alias, and `std::hash` hooks for `limb`/`bigint` so hashing and string-based floats land in the umbrella header.

README.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ modular helpers, and deterministic utilities.
1515

1616
## Highlights
1717

18-
- **Balanced ternary scalar**: `limb` exposes safe, overflow-aware arithmetic, canonical I/O,
18+
- **Balanced ternary scalar**: `t81::Int` (alias of `t81::core::limb`) exposes safe, overflow-aware arithmetic, canonical I/O,
1919
and deterministic hashing when you need ternary determinism in a binary world.
2020
- **Arbitrary-precision math**: `t81::core::bigint` layers on top of limbs with sign-plus-magnitude,
2121
Karatsuba-aware multiplication, canonical normalization, and full conversion helpers.
2222
- **SIMD accelerations**: The SIMD helpers under `include/t81/core/detail/simd_impl.hpp` contain AVX-512, AVX2, and NEON implementations for tryte addition/multiplication so the core limb arithmetic can leverage vector hardware when available.
2323
- **Base81 I/O**: Formatting/parsing now supports bases 2..81 with the playful base-3⁴ alphabet (0-9, a-z, A-Z, and punctuation) so you can round-trip balanced-ternary-friendly strings without extra glue.
2424
- **Concrete helpers**: Montgomery contexts, I/O formatters, random tooling, and utility guards
2525
keep reusable patterns consistent and testable.
26+
- **High-level helpers**: The umbrella header now also exposes `t81::Float`, `t81::Ratio`,
27+
`t81::Complex`, `t81::Polynomial`, `t81::F2m`, and `t81::Fixed<N>` along with modular
28+
helpers like `t81::Modulus`/`t81::MontgomeryInt` for quick prototyping of ternary-aware
29+
algebra and number-theoretic math.
2630
- **Specs & architecture**: Normative coverage under [doc/](doc/), plus a human-friendly
2731
[ARCHITECTURE.md](ARCHITECTURE.md) walkthrough (new!) and a docs portal at [docs/index.md](docs/index.md) for quick orientation.
2832
- **Examples & proofs**: `examples/` shows runnable use cases while `tests/` and
@@ -86,11 +90,11 @@ Once installed: `find_package(t81lib REQUIRED)` + `target_link_libraries(... t81
8690

8791
```cpp
8892
#include <t81/t81lib.hpp>
89-
using t81::core::limb;
93+
using t81::Int;
9094

91-
limb a = limb::from_int(42);
92-
limb b = limb::from_int(-7);
93-
limb sum = a + b; //... deterministically balanced ternary
95+
Int a = Int::from_int(42);
96+
Int b = Int::from_int(-7);
97+
Int sum = a + b; //... deterministically balanced ternary
9498
```
9599

96100
```cpp
@@ -116,6 +120,29 @@ auto product = modular_multiply(ctx, limb::from_value(5), limb::from_value(7));
116120
117121
Callers can also rely on guard classes for const-time exponent limits.
118122
123+
## High-level numeric helpers
124+
125+
Beyond the core limb and bigint foundations, the umbrella header now exposes
126+
convenient containers for common algebraic patterns:
127+
128+
- `t81::Int` is the umbrella alias for `t81::core::limb`, letting you grab the balanced
129+
ternary scalar without importing `core` names.
130+
131+
- `t81::Float` stores a ternary mantissa/exponent pair, keeps the mantissa normalized,
132+
and supports multiplying while trimming trailing zero trits.
133+
- `t81::Ratio` keeps normalized, sign-aware rational numbers powered by `core::bigint` numerators
134+
and denominators, complete with arithmetic and comparison helpers.
135+
- `t81::Complex` and `t81::Polynomial` model simple complex arithmetic and polynomial math
136+
on any coefficient that satisfies the usual operators.
137+
- `t81::F2m` wraps extension-field arithmetic over binary polynomials using a chosen modulus,
138+
providing reduction, addition, multiplication, and exponentiation.
139+
- `t81::Fixed<N>` represents fixed-width signed ternary values with modular normalization
140+
and arithmetic in the range `-(3^N-1)/2` .. `(3^N-1)/2`.
141+
- `t81::Modulus` and `t81::MontgomeryInt` let you declaratively build Montgomery contexts,
142+
cache powers of three, and multiply/add in Montgomery space with consistent modular safety.
143+
144+
These helpers make it easy to prototype higher-level systems without leaving the umbrella header.
145+
119146
## Architecture snapshot
120147
121148
- **limb**: 48 trits (trytes), stable 16-byte packing, explicit overflow, deterministic hashing, and

0 commit comments

Comments
 (0)