Skip to content

feat: expose exact determinant value (det_exact) #43

@acgetchell

Description

@acgetchell

Summary

Expose the internal bareiss_det() function as a public API that returns the exact determinant as a BigRational, not just its sign.

Current State

det_sign_exact() returns only the sign (i8) of the determinant. Internally, it calls bareiss_det() which computes the full exact BigRational determinant, but this value is discarded after extracting the sign.

Proposed Changes

Add a public method:

pub fn det_exact(&self) -> Result<BigRational, LaError>

This would:

  1. Validate entries are finite (same as det_sign_exact)
  2. Run the Bareiss algorithm in BigRational arithmetic
  3. Return the full exact determinant value

Optionally, also provide a convenience method that converts the result to f64:

pub fn det_exact_f64(&self) -> Result<f64, LaError>

Benefits

  • Exact volume computation: Consumers like delaunay compute simplex volumes via det(Gram matrix). An exact determinant value would let them distinguish truly-degenerate simplices from near-degenerate ones.
  • Minimal implementation effort: bareiss_det() already exists and is tested; this is primarily an API exposure change.
  • Composable: Callers who need both the sign and value can use det_exact() instead of calling det_sign_exact() and then separately computing the value.

Implementation Notes

  • Gate behind #[cfg(feature = "exact")]
  • BigRational would become part of the public API surface — consider re-exporting it or documenting the num-rational dependency
  • The fast f64 filter from det_sign_exact could optionally be used to return an exact f64 result when the error bound is small enough (i.e., det_direct() is already exact to full precision)

Co-Authored-By: Oz oz-agent@warp.dev

Metadata

Metadata

Assignees

No one assigned

    Labels

    apienhancementNew feature or requestrustPull requests that update rust code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions