Skip to content

elreal Phase 6: negation, multiplication, division #930

@Ravenwater

Description

@Ravenwater

Parent epic: #923
Depends on: Phase 5 (summation)

Goal

Round out the field operations. With addition and summation in place, the remaining algebraic operations are derived constructions.

Primitives

  • `negate(ZBCL x) -> ZBCL`: flip the sign on each block. Trivially preserves 0-overlap. (Section 4.2.4)
  • `mul(ZBCL x, ZBCL y) -> ZBCL`: distribute over co-lists using `twoMult` for partial products, gather with `sum`. (Section 4.2.5)
  • `div(ZBCL x, ZBCL y) -> ZBCL`: long-division-style refinement using `twoDiv`. (Section 4.2.6)

Acceptance criteria

  • `negate`, `mul`, `div` implemented per dissertation 4.2.4 / 4.2.5 / 4.2.6
  • Validity proofs sketched inline (value preservation + 0-overlap preservation)
  • Algebraic laws: `-(-x) = x`, `x * 1 = x`, `x / x = 1` (modulo zero), `x * y == y * x`, distributivity `x * (y + z) == (xy) + (xz)` -- all checked stream-wise to depth N
  • Edge cases: zero, signed zero, very small / very large operands, blocks with extreme `exp_offset`
  • Division by zero behaviour (under elreal's exception macro guard, consistent with existing types)
  • Tests parameterised over FpType in `{double, float, bfloat16}`
  • Tests live in `elastic/elreal/arithmetic/`

Out of scope

  • sqrt and transcendentals (Phase 7)
  • Optimised multiplication algorithms (Karatsuba etc.) -- defer

Reference

McCleeary 2019 dissertation, Sections 4.2.4 (negation), 4.2.5 (multiplication), 4.2.6 (division).

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions