Skip to content

api: add finite Matrix and Vector proof types #126

@acgetchell

Description

@acgetchell

Summary

Add refined finite-entry matrix/vector types so callers can parse raw Matrix<D> / Vector<D> values once, then run numerical algorithms without repeatedly rediscovering that stored entries are finite.

Current State

Matrix<D> and Vector<D> intentionally accept raw f64 storage, including NaN and infinity, so boundary tests and fallible computations can report structured LaError::NonFinite coordinates. That keeps invalid input representable at the boundary, but hot algorithms must repeatedly validate stored entries before computation.

Proposed Changes

  • Add proof-carrying finite-entry types, likely FiniteMatrix<D> and FiniteVector<D>, with fallible constructors from raw arrays and raw Matrix<D> / Vector<D> values.
  • Keep raw Matrix<D> / Vector<D> useful at input, fixture, and deserialization boundaries.
  • Add infallible or narrower-fallible computation paths on finite types where non-finite stored-entry validation is no longer needed.
  • Decide which existing APIs should remain raw-boundary APIs and which should delegate to finite parsed forms.
  • Update prelude exports, docs, examples, tests, and benchmarks accordingly.

Benefits

  • Makes the finite-entry invariant explicit in the type system.
  • Reduces repeated validation in hot paths after parsing.
  • Gives downstream callers an ergonomic parse-don't-validate path without losing raw boundary diagnostics.

Implementation Notes

This is a public API design change and may be breaking if existing methods are moved or retargeted around refined inputs. It should land after the broader parse-don't-validate audit work and before adding Semgrep guardrails for examples, benches, and doctests so the examples reflect the settled API.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions