skip to content
==> README.md <==
1# @ajax/mesh-ref-cubic
2
3programs/train's and programs/infer's CPU reference, written operation for operation as the programs
4compute in the cluster float mode: a cubic `p0 + p1·x + p2·x² + p3·x³` fitted by SGD to `sin(πx)` sampled
5on a 256-point grid. Each step, lane l of a warp takes sample `(8l + off) mod 256`, and the loss and the
6four gradient sums are warp butterflies; `apply` is the SGD update and `loss` the value a step records.
7`sin_pi` is train's own (an f64 Taylor polynomial after folding into [−½, ½], with flushing converts).
8
9**Ported from** `crates/mesh-ref/src/lib.rs` (`cubic_z`, `cubic`, `warp_sum`, `step_sums`, `apply`,
10`loss`, `sin_pi`, `grid`, `samples`). Freestanding.
11
12**Tested** by a golden digest from the Rust: the samples, a 64-point grid, `sin_pi` over 200 000 inputs,
13300 SGD steps (every sum, loss and parameter, and the cubic at a point) and a warp sum.
14
15## Differences
16
17- `grid` and `samples` write caller buffers instead of returning `Vec`s; `cubic` takes a float (Rust has
18  `cubic_z` on `Z` and `cubic` on `f32`, which are the same here).