Internals
Types and functions that are not exported but that the exported entries name: the schedules a grid resolves to, the lag transports, the field shapes, culling, the second histogram axis, the polynomial contract of the operators, the increments of a pair, the per-slice covariances of a fit and the digitize plans.
StructureFunctions.AbstractSquaredDigitizePlanStructureFunctions.BucketCellStructureFunctions.BucketedBinEdgesStructureFunctions.Calculations.AbstractFieldShapeStructureFunctions.Calculations.AbstractLagTransportStructureFunctions.Calculations.AbstractMissingLagPolicyStructureFunctions.Calculations.AbstractSecondAxisSourceStructureFunctions.Calculations.AbstractSeparableScheduleStructureFunctions.Calculations.AllValidStructureFunctions.Calculations.AlwaysCullingStructureFunctions.Calculations.AutoCullingStructureFunctions.Calculations.BatchLeadingStructureFunctions.Calculations.CellGridStructureFunctions.Calculations.CullingPolicyStructureFunctions.Calculations.FrameTransportStructureFunctions.Calculations.IdentityTransportStructureFunctions.Calculations.InvariantValueAxisStructureFunctions.Calculations.NoCullingStructureFunctions.Calculations.NoWeightsStructureFunctions.Calculations.RectilinearLagScheduleStructureFunctions.Calculations.ScatteredPairsStructureFunctions.Calculations.SeparationAngleAxisStructureFunctions.Calculations.SliceCovariancesStructureFunctions.Calculations.UniformLagScheduleStructureFunctions.Calculations.ZonalLagScheduleStructureFunctions.LinearCellsStructureFunctions.Log2CellsStructureFunctions.LogTableBinEdgesStructureFunctions.StructureFunctionTypes.SymmetricMomentsStructureFunctions.Calculations.axis_boundsStructureFunctions.Calculations.batch_shares_lag_geometryStructureFunctions.Calculations.batch_validityStructureFunctions.Calculations.device_transform_sweep!StructureFunctions.Calculations.device_transform_sweep_batch!StructureFunctions.Calculations.field_validityStructureFunctions.Calculations.gridded_lag_sweep!StructureFunctions.Calculations.gridded_lag_sweep_batch!StructureFunctions.Calculations.gridded_sweep!StructureFunctions.Calculations.gridded_sweep_batch!StructureFunctions.Calculations.isotropic_kernelStructureFunctions.Calculations.lag_limitsStructureFunctions.Calculations.lag_transportStructureFunctions.Calculations.n_slabsStructureFunctions.Calculations.separable_layoutStructureFunctions.Calculations.transform_engineStructureFunctions.Calculations.uniform_axesStructureFunctions.Calculations.uniform_lag_boxStructureFunctions.HelperFunctions.increment_invariantsStructureFunctions.HelperFunctions.transverse_energyStructureFunctions.StructureFunctionTypes.is_polynomial_operatorStructureFunctions.StructureFunctionTypes.moment_contractStructureFunctions.StructureFunctionTypes.orderStructureFunctions.StructureFunctionTypes.scalar_orderStructureFunctions.StructureFunctionTypes.symmetric_indicesStructureFunctions.digitize_planStructureFunctions.squared_digitizeStructureFunctions.squared_digitize_plan
Schedules and transports
StructureFunctions.Calculations.AbstractSeparableSchedule — Type
AbstractSeparableScheduleA pair enumeration with at least one uniform direction. The cells factor into slabs, one per index on the remaining directions, and within a pair of slabs every pair of cells is named by an integer lag along the uniform directions. Both sweeps run over (slab, slab, lag): the direct one reduces the field over each lag, the transform produces every lag of a slab pair at once.
A schedule provides uniform_axes, n_slabs, enumerated_pairs, separable_layout, lag_limits, lag_transport and lag_frame.
StructureFunctions.Calculations.UniformLagSchedule — Type
UniformLagSchedule(dims, spacing, periodic)Lag enumeration for a uniform rectilinear grid of dims cells, with constant spacing along each direction, each direction wrapping or not per periodic.
A lag is an integer offset vector naming every pair (cell, cell + lag), so the separation, its direction and its distance bin are properties of the lag alone. Directions are positional and match the trailing axes of the field the schedule is swept over.
spacing is signed, as a descending axis reports it; only its magnitude enters a separation.
StructureFunctions.Calculations.RectilinearLagSchedule — Type
RectilinearLagSchedule(uniform, enumerated, axis_order)Lag enumeration for a rectilinear grid with some uniform directions and some given as coordinate lists. uniform describes the uniform directions, enumerated holds one coordinate vector per remaining direction, and axis_order[k] is the field direction at position k of (uniform..., enumerated...).
Every pair of enumerated indices is a pair of slabs, within which the pairs are named by lags along the uniform directions exactly as on a uniform grid; an enumerated direction never wraps.
StructureFunctions.Calculations.ZonalLagSchedule — Type
ZonalLagSchedule(lats, n_lon, dlon, radius, lon_periodic)Pair enumeration for a lat-lon grid: one latitude per entry of lats (radians), n_lon cells per row spaced dlon apart in longitude (radians), on a sphere of the given radius.
The field it sweeps is stored (component, longitude, latitude) with components in the local (east, north[, radial]) basis, the basis the transport matrices are written in. Each latitude row is one slab and longitude is the uniform direction, with the pair frame applied per lag (see FrameTransport).
StructureFunctions.Calculations.ScatteredPairs — Type
ScatteredPairs(points, metric)Pair enumeration for a grid with no structure to exploit: the points themselves, and the metric that measures between them. Pairs are enumerated by the unstructured path, with culling.
StructureFunctions.Calculations.AbstractLagTransport — Type
IdentityTransport()
FrameTransport()How the two ends of a pair are compared. Under IdentityTransport the increment is the plain difference u(J, i+h) - u(I, i) and the lag's displacement is its direction. Under FrameTransport each end is first expressed in the pair's own frame, B·u(J, i+h) - A·u(I, i) with W×W matrices fixed by the lag, and the longitudinal direction is ê₁.
StructureFunctions.Calculations.IdentityTransport — Type
The transport of a flat schedule: the increment is the plain difference and the lag's displacement its direction; see AbstractLagTransport.
StructureFunctions.Calculations.FrameTransport — Type
The transport of a curved schedule: each end is expressed in the pair's own frame before differencing; see AbstractLagTransport.
StructureFunctions.Calculations.uniform_axes — Function
uniform_axes(schedule) -> UniformLagScheduleThe uniform directions, in the order they run within a slab.
StructureFunctions.Calculations.n_slabs — Function
n_slabs(schedule) -> IntHow many slabs the cells factor into; one for a schedule whose every direction is uniform.
StructureFunctions.Calculations.separable_layout — Function
separable_layout(schedule, data, valid, weights) -> (data, valid, weights)The packed field, its validity and its pair weights with slab I occupying columns (I-1)·N_u + 1 : I·N_u, N_u the cells of a slab, and the uniform directions running column-major within it.
StructureFunctions.Calculations.lag_limits — Function
lag_limits(schedule, I, J, r_max) -> NTuple{Du, Int}
lag_limits(schedule, r_max) -> NTuple{Du, Int}The largest |h_d| along each uniform direction at which a pair of the two slabs can still lie within r_max; the two-argument form bounds it over every slab pair.
StructureFunctions.Calculations.uniform_lag_box — Function
uniform_lag_box(schedule) -> BoolWhether lag_limits(schedule, I, J, r_max) is the same box for every slab pair, so a device launch indexes its work items by division on one box. A schedule that answers false carries one box per pair, and the launch is indexed through the prefix sum of their volumes.
StructureFunctions.Calculations.lag_transport — Function
lag_transport(schedule) -> AbstractLagTransportSee IdentityTransport.
StructureFunctions.Calculations.batch_shares_lag_geometry — Function
batch_shares_lag_geometry(schedule) -> BoolWhether a transform batch visits each lag once and contracts every slice against it, holding all the slices' inverted columns of a slab pair at the same time.
A schedule answering false takes its slices one at a time, with the inverse scratch of a single slice. Curved schedules answer true.
StructureFunctions.Calculations.NoWeights — Type
NoWeights()Every pair counts once, as an indexable value.
StructureFunctions.Calculations.AllValid — Type
AllValid()Every cell holds a usable datum, as an indexable value.
A grid's own mask says which cells exist; the field says which hold a datum. field_validity combines the two.
StructureFunctions.Calculations.field_validity — Function
field_validity(u[, cell_mask]) -> Bool vector or AllValidWhich cells of u hold a usable datum: every component finite, and — where a cell_mask is given, as a grid carries one — the cell marked as existing. u is (components, cells...) or a Fields; the vector is in the array family of u.
Returns AllValid when nothing is excluded, so a complete field costs nothing downstream.
StructureFunctions.Calculations.batch_validity — Function
batch_validity(u[, cell_mask]) -> Bool matrix or AllValidWhich cells hold a usable datum in each slice of u, stored (components, cells..., slices): one column of cell validity per slice, in the array family of u. cell_mask, where a grid carries one, marks the cells that exist.
Returns AllValid when nothing is excluded, as field_validity does for one slice.
StructureFunctions.Calculations.BatchLeading — Type
BatchLeading(u)Wrap a velocity/position array stored batch-leading, shape (B, D, N) (batch axis innermost/contiguous). CPU batch kernels run on it zero-copy. A plain (D, N, B...) array is transposed once internally.
Gridded sweeps
StructureFunctions.Calculations.gridded_lag_sweep! — Function
gridded_lag_sweep!(sums, counts, sf, u, schedule, distance_bins[, axis_bins], ::Val{D}; valid, weights, backend, second_axis)
gridded_lag_sweep!(sums, counts, sf, fields, schedule, distance_bins[, axis_bins]; valid, weights, backend, second_axis)Accumulate every pair schedule names into the distance histogram sums/counts, or with axis_bins into the joint histogram over separation and second_axis — each pair's own value (InvariantValueAxis, on every schedule) or the angle a SeparationAngleAxis reads from each lag's direction (on a flat schedule) — sums and counts then being (n_distance, n_axis). With sf = SinglePassInvariants() the distance histogram holds the six single-pass invariants of one vector field, sums and counts (6, n_distance), each row counting every pair.
u is stored (component, cells...) with its trailing axes matching the schedule, and D is its component count, which may exceed the grid's dimension — a lag then lies in the grid's directions and is zero along the rest. A multi-field carries several fields the same way. valid says which cells hold a datum; a pair counts only when both of its ends do (see field_validity). weights, one finite weight per cell (nothing for none), multiplies each pair by w_k · w_kp in both sums and counts, so the bin average is Σ w w v / Σ w w and counts must then be floating point; cell_measure supplies a grid's cell areas. backend is the hardware, as on the unstructured entry; a threaded backend splits the slab pairs across tasks, and the lags of a schedule with a single slab.
Each unordered pair is counted once: lags are enumerated one per distinct separation and within a slab only one of ±lag is kept. A lag equal to its own reverse is swept over half of one direction.
Where a periodic direction has an even cell count, its half-period offset joins two cells by two minimal paths of equal length and opposite sign. The operator is averaged over those equal-length displacements, so an operator odd in the separation direction vanishes on the pairs whose every offset half-turns. In the joint histogram such a lag's pairs are split between their images' bins in equal halves, so counts must hold a floating-point type.
gridded_lag_sweep!(sums, counts, sf, u, schedule::ScatteredPairs, distance_bins, ::Val{D}; valid, backend)Accumulate every pair of a structureless grid, by enumerating them.
Cells holding nothing are dropped before the sweep.
StructureFunctions.Calculations.gridded_sweep! — Function
gridded_sweep!(sums, counts, sf, u, schedule, distance_bins[, axis_bins], ::Val{D}, spectral_backend; valid, weights, backend)
gridded_sweep!(sums, counts, sf, fields, schedule, distance_bins[, axis_bins], spectral_backend; valid, weights, backend)Accumulate the histogram of every pair schedule names, by the algorithm spectral_backend selects. valid and weights are as on gridded_lag_sweep!.
The lag sweep visits each lag and is exact for any pairwise operator; a transform produces the increment moment tensor of every lag at once and serves the operators that are polynomials in δu. AutoSpectralBackend picks the one with less work and resolves to the lag sweep unless a transform is loaded. backend names the hardware, as on the unstructured entry.
With axis_bins the histogram is joint in separation and second_axis: each pair's value (InvariantValueAxis), which only the lag sweep bins, or the angle a SeparationAngleAxis reads from each lag; sums and counts are then (n_distance, n_axis). With sf = SinglePassInvariants() the distance histogram holds the six single-pass invariants, sums and counts (6, n_distance).
StructureFunctions.Calculations.gridded_lag_sweep_batch! — Function
gridded_lag_sweep_batch!(sums, counts, sf, u, schedule, distance_bins[, axis_bins], ::Val{D}; valid, weights, backend)Sweep the lags of schedule once and reduce every slice of a batch against each of them, into sums/counts of shape (n_distance, n_slices) — with axis_bins, (n_distance, n_axis, n_slices); for sf = SinglePassInvariants(), (6, n_distance, n_slices).
u is (component, cells..., slices), the cells matching the schedule. valid is AllValid() or one column of cell validity per slice (batch_validity); weights is one finite weight per cell, shared by the slices, so a cell measure is given once. backend names the hardware, as on gridded_lag_sweep!, whose pair enumeration, reading rule and half-turn averaging this follows exactly: slice t of the output is that sweep on slice t of the field.
StructureFunctions.Calculations.gridded_sweep_batch! — Function
gridded_sweep_batch!(sums, counts, sf, u, schedule, distance_bins[, axis_bins], ::Val{D}, spectral_backend; valid, weights, backend)Accumulate the histogram of every pair schedule names, for every slice of a batch, by the algorithm spectral_backend selects. sums and counts are (n_distance, n_slices), or with axis_bins (n_distance, n_angle, n_slices).
u is (component, cells..., slices) with the cells matching the schedule; the packed form is (V·D + K, cells, slices), which is how a multi-field time series is passed. valid, weights and backend are as on gridded_lag_sweep_batch!.
Each pair's geometry is fixed by schedule alone, so the lag sweep visits every lag once and reduces all the slices against it. A transform shares each lag between the slices on the schedules that answer batch_shares_lag_geometry and takes one slice at a time on the rest.
StructureFunctions.Calculations.transform_engine — Function
transform_engine(sf, data, schedule, distance_bins, ::Val{D}, ::Val{V}, ::Val{K}, valid, weights, tag; to = identity, workspace = nothing, slice = (1, 1))The transform engine's prepared state for a field: the forward transforms of every masked, weighted monomial of every slab — by FFT for a grid's slabs, by non-uniform FFT for a ScatteredModesSchedule, as the spectral tag names — the inverse columns and the lag bookkeeping, every array moved by to. The field is slice t of slice = (t, nt): its FFT spectra are slice t of one (blk, nchunks, n_monomials, nt) array kept in workspace (the engine's spectra), each chunk of slabs contiguous at 64-byte alignment. Supplied by the AbstractFFTs extension.
StructureFunctions.Calculations.device_transform_sweep! — Function
device_transform_sweep!(sums, counts, backend, sf, data, schedule, distance_bins, plan, nb, ::Val{D}, ::Val{V}, ::Val{K}, valid, weights, tag, axis, workspace)The transform engine on a device backend, supplied by the KernelAbstractions extension together with an AbstractFFTs implementation for the device's arrays. axis is nothing for the distance histogram or (axis_edges, n_angle, second_axis) for the joint one; workspace is a TransformWorkspace or nothing.
StructureFunctions.Calculations.device_transform_sweep_batch! — Function
device_transform_sweep_batch!(sums, counts, backend, sf, data, schedule, distance_bins, plan, nb, ::Val{D}, ::Val{V}, ::Val{K}, valid, weights, tag, axis, workspace)The transform engine on a device backend for a batch over a trailing slice axis, supplied by the KernelAbstractions extension together with an AbstractFFTs implementation for the device's arrays. axis is nothing for the distance histogram or (axis_edges, n_angle, second_axis) for the joint one; workspace is a TransformWorkspace or nothing.
Kernels of the transforms
StructureFunctions.Calculations.isotropic_kernel — Function
isotropic_kernel(::Val{D}, x)Angular average of cos(k·r) over the directions of r in D dimensions, at x = kr.
cos on a line, J₀ on a plane and sin(x)/x in a volume. This is the kernel of the isotropic Fourier transform, so a single mode of amplitude A and wavenumber k₀ has S₂(r) = A²[1 - isotropic_kernel(Val(D), k₀ r)] after angular averaging.
StructureFunctions.Calculations.AbstractMissingLagPolicy — Type
AbstractMissingLagPolicyWhat a lag-space spectrum does with a lag no pair of held cells names. RefuseMissingLags() throws, since the structure function is undefined there. ZeroDeviationAtMissingLags() sets the autocovariance to zero at that lag.
Shapes, culling and the second axis
StructureFunctions.Calculations.AbstractFieldShape — Type
AbstractFieldShape{D}Which array-rank pattern a validated (x, u) pair forms, with D the number of velocity components on axis 1 of u. Backends dispatch on this, so D reaches the kernels as a static method parameter.
PointField:uis(D, N).SharedPositionField:uis(D, N, auxiliary...)— one set of positions, many fields.VaryingPositionField:xanduboth carry matching auxiliary axes.
The coordinate count on axis 1 of x is fixed by the metric's geometry (see HelperFunctions.coordinate_width).
StructureFunctions.Calculations.CullingPolicy — Type
CullingPolicyWhether a calculation may skip pairs that cannot land in a finite bin. Culling never changes the result, so this selects only whether sorting the points is worth paying for.
AutoCulling— cull when it removes pairs (the default)AlwaysCulling— cull whenever pairs can be skipped, and error when they cannotNoCulling— sweep every pair
StructureFunctions.Calculations.AutoCulling — Type
Cull only when the cutoff is small enough to remove pairs; see CullingPolicy.
StructureFunctions.Calculations.AlwaysCulling — Type
Cull whenever pairs can be skipped, and error when they cannot; see CullingPolicy.
StructureFunctions.Calculations.NoCulling — Type
Never cull; see CullingPolicy.
StructureFunctions.Calculations.CellGrid — Type
CellGrid{D, FT, IV, PV, OV}Uniform cell decomposition of a point set, with points sorted by cell id, so every cell is one contiguous run: cell_run(grid, c) in the permuted order.
Only occupied cells are stored, as the sorted ids cell_ids and their run boundaries run_starts; the cell-id space prod(dims) grows as (extent/cutoff)^D, while occupancy is at most the point count, so memory and block enumeration are O(N).
The index and offset arrays are type parameters, so one type serves host and device-resident copies.
StructureFunctions.Calculations.AbstractSecondAxisSource — Type
AbstractSecondAxisSourceWhat the second axis of a joint histogram bins.
The first axis is always the separation. The second is a choice: the operator's own value, giving the distribution of the structure function at each separation; or the separation's direction, giving the structure function resolved by angle. Both are digitized the same way into the same histogram.
StructureFunctions.Calculations.InvariantValueAxis — Type
InvariantValueAxis()Bin the operator's own value: the joint distribution of separation and structure-function value.
StructureFunctions.Calculations.SeparationAngleAxis — Type
SeparationAngleAxis(reference_axis)Bin the angle between the pair's separation and reference_axis, giving S(r, θ), the structure function resolved by direction.
The angle is folded so that a pair and its reverse give the same value. In two dimensions the signed azimuth is taken modulo π, giving [0, π); in three or more the polar angle to the axis is taken from |cos|, giving [0, π/2].
reference_axis need not be normalized. A pair separated along the reference axis has angle exactly 0, and bins are (lo, hi], so bins over this axis must start just below zero, as axis_bounds does, for an axis-aligned pair to fall in a bin.
StructureFunctions.Calculations.axis_bounds — Function
axis_bounds(source) -> (lo, hi)The range the source's quantity spans, for callers building bins over it. The operator's value has no bound the source knows.
The polynomial contract
StructureFunctions.StructureFunctionTypes.is_polynomial_operator — Function
is_polynomial_operator(sf) -> BoolWhether sf(δu, r̂) is a homogeneous polynomial in the packed increment δu with coefficients that depend only on r̂, so that Σ_pairs sf(δu, r̂) is moment_contract of the increment moment tensor.
StructureFunctions.StructureFunctionTypes.moment_contract — Function
moment_contract(sf, M::SymmetricMoments, r̂, ::Val{V}, ::Val{K})Σ_pairs sf(δu, r̂) from the increment moment tensor M[i₁, …, i_p] = Σ_pairs Π_k δu[i_k] of the pairs sharing the unit separation r̂. δu is packed as V vector fields of width D = length(r̂) followed by K scalar fields, so M has W = V * D + K components. Operators that are not polynomials in δu have no method.
StructureFunctions.StructureFunctionTypes.SymmetricMoments — Type
SymmetricMoments{W, P}(data::SVector)The rank-P symmetric increment moment tensor over W packed components, stored as its binomial(W + P - 1, P) independent entries M[j₁ ≤ … ≤ j_P] in the order of symmetric_indices.
StructureFunctions.StructureFunctionTypes.symmetric_indices — Function
symmetric_indices(Val(W), Val(P)) -> NTuple{N, NTuple{P, Int}}The sorted multi-indices j₁ ≤ … ≤ j_P over 1:W in storage order: entry n has n - 1 = Σ_k binomial(j_k + k - 2, k).
StructureFunctions.StructureFunctionTypes.order — Function
order(sf::AbstractStructureFunctionType)Returns the order of the structure function.
StructureFunctions.StructureFunctionTypes.scalar_order — Function
scalar_order(sf) -> IntThe total power of scalar-field increments in sf.
Reading a pair from its other end leaves every vector quantity unchanged — δu, r̂ and n̂ all flip together — and negates each scalar increment, so sf changes sign under that reading exactly when this is odd. Such an operator is evaluated with the pair read from the lower to the upper end along the first coordinate that separates its two points (on a sphere: from south to north, and along one parallel from west to east); where neither end comes first, the two readings are averaged and the moment is zero.
Pair increments
StructureFunctions.HelperFunctions.increment_invariants — Function
increment_invariants(geometry, frame, r, δu) -> (δu_L, ‖δu‖²)The longitudinal increment and the squared norm of the pair increment δu from pair_delta, given the frame and separation r from pair_frame. Every isotropic operator and every single-pass invariant is a function of these two numbers. A geometry without its own method takes δu_L along pair_direction.
StructureFunctions.HelperFunctions.transverse_energy — Function
transverse_energy(δu_L, ‖δu‖²)$‖δu‖² - δu_L²$, the squared norm of the transverse increment. Its two terms cancel to within round-off when the increment is almost parallel to the separation, so it can be a round-off below zero; a caller taking its square root floors it first.
Fits over a batch
StructureFunctions.Calculations.SliceCovariances — Type
One data covariance per slice of a batch: an array over the batch axes of variance vectors or covariance matrices.
Digitize plans
StructureFunctions.digitize_plan — Function
digitize_plan(edges) -> AbstractBinEdgesedges in the form a pair kernel digitizes against, built once per call: the same edges and the same lookup. LinearBinEdges are their own plan; the edges of a BinEdges or a LogBinEdges become a BucketedBinEdges.
StructureFunctions.BucketedBinEdges — Type
BucketedBinEdges(edges::AbstractVector{<:Base.IEEEFloat}[, cells])Sorted edges with a table that brackets every lookup. The edges are cut into cells by the cell map cells — by default LinearCells of 16(length(edges) - 1) equal cells over the finite span. Each cell holds a BucketCell: the first edge at or above it, how many edges lie in it, and that edge's value. A query in a cell of at most one edge is decided by one comparison with that value; a cell of more bisects its own edges. Built by digitize_plan once per call.
StructureFunctions.BucketCell — Type
BucketCell(first, count, edge)One cell of a BucketedBinEdges: first is the index of the first edge at or above the cell, count the number of edges inside it, and edge the value of edge first, Inf past the last edge.
StructureFunctions.LinearCells — Type
LinearCells(inv_width, offset, last_cell)Cells of equal width: cell(x) = trunc(clamp(fma(x, inv_width, offset), 0, last_cell)), which never decreases as x increases.
StructureFunctions.Log2Cells — Type
Log2Cells(lo, key0, shift, last_cell)Cells of equal width in log₂ x to within the piecewise-linear error of the float format: the cell of x > lo is the IEEE exponent and leading mantissa bits of x (its bit pattern shifted right by shift) less those of lo, clamped to last_cell; x ≤ lo takes cell 0. Never decreases as x increases.
StructureFunctions.LogTableBinEdges — Type
LogTableBinEdges(b::LogBinEdges)The edges of b as a table, searched from the index estimate ⌊a log₂x + c⌋ + 2, which is formed in the type of a and c (Float32 by default) with Base.FastMath.log2_fast and stepped to the first edge at or above x. The edges decide the bin, so the estimate's rounding does not. A device kernel digitizes LogBinEdges with it.
StructureFunctions.AbstractSquaredDigitizePlan — Type
AbstractSquaredDigitizePlanMaps a squared separation r² to the bin digitize(sqrt(r²), edges) gives, compared against the thresholds S_k, the largest s with sqrt(s) ≤ edges[k]. The two agree for every r² because sqrt is correctly rounded.
StructureFunctions.squared_digitize_plan — Function
squared_digitize_plan(edges) -> AbstractSquaredDigitizePlanBuild the r² digitize plan for edges, once per call (never in the pair loop).
StructureFunctions.squared_digitize — Function
squared_digitize(plan, r2) -> IntExact digitize(r, edges) computed from r² alone. Out-of-range gives 0 (below) or n_bins + 1 (above), matching HelperFunctions.digitize.