Freon793/moonopt/core does not have a README file

    CompensatedSum

    pub struct CompensatedSum {
    total : Double
    correction : Double
    }

    Neumaier compensated summation.

    Plain += loses low order bits when a large accumulator receives many small terms, which is exactly the pattern of a simplex pivot row. The compensated form keeps a second accumulator holding the rounding error.

    CompensatedSum::add

    fn CompensatedSum::add(self : CompensatedSum, x : Double) -> Unit

    Adds one term, preserving the bits that a plain addition would drop.

    CompensatedSum::new

    Creates an empty accumulator.

    CompensatedSum::value

    fn CompensatedSum::value(self : CompensatedSum) -> Double

    Current compensated value of the accumulated terms.

    SparseMatrix

    pub struct SparseMatrix {
    nrows : Int
    ncols : Int
    col_ptr : Array[Int]
    row_idx : Array[Int]
    values : Array[Double]
    } derive(
    Debug
    )

    A sparse matrix in compressed sparse column form.

    SparseMatrix::col_nnz

    fn SparseMatrix::col_nnz(self : SparseMatrix, j : Int) -> Int

    Number of stored entries in column j.

    SparseMatrix::col_pointers

    fn SparseMatrix::col_pointers(self : SparseMatrix) -> ArrayView[Int]

    Raw column pointers, for kernels whose inner loops must not allocate.

    With row_indices and values_view this exposes the storage so a solver can walk the entries of a column in place: column(j) builds a fresh (row, value) list per call, which is convenient but costs an allocation per entry per pivot in a hot loop. The invariants documented at the top of this file still hold for everything reached this way; the views must not outlive a call that rebuilds the matrix.

    SparseMatrix::column

    fn SparseMatrix::column(self : SparseMatrix, j : Int) -> Array[(Int, Double)]

    (row, value) pairs of column j, row index ascending.

    SparseMatrix::from_columns

    fn SparseMatrix::from_columns(nrows : Int, columns : Array[Array[(Int, Double)]]) -> SparseMatrix

    Builds a matrix from per-column (row, value) pairs.

    Entries are sorted by row index, duplicate rows inside a column are summed, and exact zeros are dropped. Passing a row index outside [0, nrows) is a programming error and aborts.

    SparseMatrix::get

    fn SparseMatrix::get(self : SparseMatrix, i : Int, j : Int) -> Double

    Entry at (i, j); missing entries read as 0.0.

    SparseMatrix::mul_vec

    fn SparseMatrix::mul_vec(self : SparseMatrix, x : Array[Double]) -> Array[Double]

    Matrix–vector product self * x.

    SparseMatrix::ncols

    fn SparseMatrix::ncols(self : SparseMatrix) -> Int

    Number of columns.

    SparseMatrix::nnz

    fn SparseMatrix::nnz(self : SparseMatrix) -> Int

    Number of stored (non-zero) entries.

    SparseMatrix::nrows

    fn SparseMatrix::nrows(self : SparseMatrix) -> Int

    Number of rows.

    SparseMatrix::row_indices

    fn SparseMatrix::row_indices(self : SparseMatrix) -> ArrayView[Int]

    Raw row indices of the stored entries.

    SparseMatrix::to_dense

    fn SparseMatrix::to_dense(self : SparseMatrix) -> Array[Array[Double]]

    Row-major dense copy. Intended for tests and for the reference solver, not for production paths.

    SparseMatrix::transpose

    fn SparseMatrix::transpose(self : SparseMatrix) -> SparseMatrix

    Transposes the matrix. Row i of self becomes column i of the result, so the result has ncols rows and nrows columns.

    SparseMatrix::values_view

    fn SparseMatrix::values_view(self : SparseMatrix) -> ArrayView[Double]

    Raw values of the stored entries, aligned with row_indices.

    SparseMatrix::zeros

    fn SparseMatrix::zeros(nrows : Int, ncols : Int) -> SparseMatrix

    Builds an all-zero matrix with the given shape.

    approx_eq

    fn approx_eq(a : Double, b : Double, rel? : Double, abs? : Double) -> Bool

    Scale-aware equality test with an explicit tolerance.

    approx_negative

    fn approx_negative(x : Double, abs? : Double) -> Bool

    Returns true when x counts as strictly negative at the given tolerance.

    approx_positive

    fn approx_positive(x : Double, abs? : Double) -> Bool

    Returns true when x counts as strictly positive at the given tolerance.

    approx_zero

    fn approx_zero(x : Double, abs? : Double) -> Bool

    Returns true when x counts as zero at the given absolute tolerance.

    default_abs_tolerance

    let default_abs_tolerance : Double

    Absolute part of the default comparison tolerance.

    default_rel_tolerance

    let default_rel_tolerance : Double

    Relative part of the default comparison tolerance.

    dot_compensated

    fn dot_compensated(xs : Array[Double], ys : Array[Double]) -> Double

    Dot product with compensation. The second argument is guarded: a shorter ys simply contributes nothing for the missing tail.

    fabs

    fn fabs(x : Double) -> Double

    Absolute value of a Double without depending on the standard library float helpers, so this package stays dependency free.

    fmax

    fn fmax(a : Double, b : Double) -> Double

    Larger of two Double values.

    fmax_int

    fn fmax_int(a : Int, b : Int) -> Int

    Larger of two integers.

    fmin

    fn fmin(a : Double, b : Double) -> Double

    Smaller of two Double values.

    fmin_int

    fn fmin_int(a : Int, b : Int) -> Int

    Smaller of two integers (kept local to stay dependency free).

    is_finite

    fn is_finite(x : Double) -> Bool

    Returns true when x is neither NaN nor an infinity.

    x - x is 0.0 for every finite value and NaN for ±inf and NaN.

    is_nan

    fn is_nan(x : Double) -> Bool

    Returns true when x is NaN.

    A NaN is the only value that is not equal to itself.

    sum_compensated

    fn sum_compensated(xs : Array[Double]) -> Double

    Sums an array with compensation.