Routines written once in pseudo and checked at every level, so programs can use them by name instead of rewriting and re-verifying them: - stats: Mean, Variance (two-pass) - numerics: KahanSum, LinearInterp, Trapezoid - align: LinearGapPenalty, AffineGapPenalty, MatchScore, NeedlemanWunschScore - md: LennardJones, LennardJonesForce, MinimumImage, PairDistance - seq: GCContent, HammingDistance - special: ErfApprox (Abramowitz and Stegun 7.1.26) Each has contracts, cases, reference implementations in Python, Mojo and (for the numerical ones) C at more than one level, and nine have a Dafny proof over exact numbers. status.json and STATUS.md are written by pplus-core's library-check: every check passes or is open/unverified as listed there. The Mojo references still need the pinned compiler's answers (library-verify-mojo, network). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
18 lines
426 B
Mojo
18 lines
426 B
Mojo
def mean(x: List[Float64]) -> Float64:
|
|
var s0: Float64 = 0.0
|
|
var s1: Float64 = 0.0
|
|
var s2: Float64 = 0.0
|
|
var s3: Float64 = 0.0
|
|
var n = len(x)
|
|
var i = 0
|
|
while i + 4 <= n:
|
|
s0 = s0 + x[i]
|
|
s1 = s1 + x[i + 1]
|
|
s2 = s2 + x[i + 2]
|
|
s3 = s3 + x[i + 3]
|
|
i = i + 4
|
|
while i < n:
|
|
s0 = s0 + x[i]
|
|
i = i + 1
|
|
return ((s0 + s1) + (s2 + s3)) / Float64(n)
|