CRK stage 2 — moments
Kernel: crk/crk_moments.py
(computeCRKMoments_Kernel); JVP crk/crk_moments_jvp.py
(computeCRKMomentsGeometryJVP).
Equations
For query particle , with the apparent volume (stage 1) as weight, the uncorrected kernel value and gradient (Scatter support scheme), and :
and their derivatives with respect to the query position (the "-derivatives", needed for , ):
(the kernel stores the third-order tensor flattened to
dim**3 components, [gamma * dim*dim + alpha*dim + beta], because
Warp's rank-3 handling is awkward — the backend reshapes it back to
[N, D, D, D]).
The moments are computed with the Scatter scheme and no
corrections of any kind — crkState/gradHState/
renormalizationState are never applied while computing the
correction (see CRK overview).
The per-particle neighbor count is a genuine kernel output (same
pattern as Covariance), not read off
adjacency.numNeighbors — that field does not exist under grid
traversal, and the correction-term
limiter needs the count
under both traversal modes.
Public API
Internal backend _computeCRKMoments_stateBackend(queryParticles, operationProperties, domain, queryVolumes, referenceVolumes, adjacency=None, referenceParticles=None). The public path is through
computeCRKFactors,
which passes the apparent volume as both queryVolumes and
referenceVolumes and fixes the Scatter scheme.
Outputs: (m_0 [N], m_1 [N,D], m_2 [N,D,D], dm_0dgamma [N,D], dm_1dgamma [N,D,D], dm_2dgamma [N,D,D,D], numNeighbors [N] int32).
JVP
computeCRKMomentsGeometryJVP(queryParticles, domain, kernel, adjacency, referenceVolumes, tangentReferenceVolumes, queryTangentState, referenceParticles=None, referenceTangentState=None) — the product rule through every moment:
position/support tangents flow through , ,
(via sphKernelJVP / sphKernelGradientJVP), and the
volume weight flows through tangentReferenceVolumes (stage 1's
output). It is stage 2 of computeCRKFactorsJVP.
Tests
tests/operations/test_operations_crk_analytic.py— moments against analytic references.tests/operations/test_forward_mode_geometry_jvp_gradient.py(siblings) — through the full CRK-tangent pipeline.scripts/spikes/spike_forward_mode_tier2_crk.py— the stage assembly, float64, gated bytest_gradcheck_scripts.py.