band
Stable type · Differentiate a model
Tier: stable · Kind: type · Topic: Differentiate a model
| Julia | Python | Rust |
|---|---|---|
Band | Band | Band |
Julia
struct Band
Band(rows::Vector{Tuple{Int64, Int64}}, ridx::Vector{Union{Int64, String}}, cidx::Vector{EarthSciAST.ASTExpr}, coef::EarthSciAST.ASTExpr, contracted::Vector{Tuple{String, Int64, Int64}}, guard::Union{Nothing, EarthSciAST.ASTExpr})
Band(rows, ridx, cidx, coef, contracted, guard)
Band(rows, ridx, cidx, coef)
Band(rows, ridx, cidx, coef, contracted)
Band
One structured block of ∂(rhs of the equation for u)/∂v:
rows::Vector{Tuple{Int,Int}}— a rectangular region ofu’s index space, per-dimension inclusive(lo, hi). Empty for a scalaru.ridx::Vector{Union{String,Int}}— per-dimension row index: a free index NAME ranging overrows[k], or a constant Int for a singleton dimension.cidx::Vector{ASTExpr}—v’s column index expressions, one per dimension ofv, in terms of the row index names. Empty for scalarv.coef::ASTExpr— scalar ESM coefficient expression in terms of the row index names (plus parameters and other states).contracted::Vector{Tuple{String,Int,Int}}— free CONTRACTED column dimensions(name, lo, hi): when non-empty the band denotes, for every row cell AND every value of the contracted names over their inclusive ranges, an entryJ[row, cidx(row, contracted…)] += coef(row, contracted…)— entries meeting at one column ACCUMULATE (this is how areduce: "+"faq node’s sum over a gathered column materializes). Empty for ordinary bands.guard::Union{Nothing,ASTExpr}— an exact point predicate (the block’swherefield) over the row and contracted index names, literals andconstgathers: a point contributes iff it holds. What a filtered faq node’s non-rectangular window (gk < gke) leaves after its box is split at affine breakpoints;nothingfor every rectangular band.
The band is the symbolic, portable analogue of the tree-walk’s _AccDesc
state-read descriptors: cidx of the form row ± const is an affine stencil
offset, cidx == ridx is a diagonal (per-cell) coupling, and a cidx
referencing a contracted name is an indirect/contracted gather
(source–receptor matrices, regrid joins, conn[]-table stencils).
Python
class Band
Band(rows: list[tuple[int, int]], ridx: list, cidx: list, coef: Expr, contracted: list[tuple[str, int, int]] = list(), guard: Expr | None = None)
One structured block of ∂(rhs of the equation for u)/∂v — see the
Julia reference docstring and esm-jacobian-spec.md §4. contracted
holds free contracted column dimensions (name, lo, hi); guard is
an exact point predicate (the entry’s where field) over the row and
contracted index names — what a filtered faq node’s non-rectangular
window leaves after its box is split at affine breakpoints — or None
for every rectangular band. Rebuild with dataclasses.replace so
the guard travels.
Rust
pub struct Band {
pub rows: Vec<(i64, i64)>,
pub ridx: Vec<RIdx>,
pub cidx: Vec<Expr>,
pub coef: Expr,
pub contracted: Vec<(String, i64, i64)>,
pub guard: Option<Expr>,
}
One rectangular region of a Jacobian block: the rows it covers
(rows, 1-based inclusive ranges, named by ridx), the column-index
expressions (cidx) and the coefficient expression (coef). contracted
lists extra column dimensions that accumulate (summed) at assembly.
guard is an exact point predicate (the entry’s where field) over the
row and contracted index names, literals and const gathers: a point
contributes iff it holds. What a filtered faq node’s non-rectangular
window (gk < gke) leaves after its box is split at affine breakpoints;
None for every rectangular band.