Project

EarthSciASTDiff

Analytical sparse Jacobians for EarthSciAST (.esm) models by symbolic differentiation of the expression AST.

Contents

This is the documentation for the older version v0.7.0. For the latest release, see v0.8.0.

dscalar

Stable function · Differentiate a model

Tier: stable · Kind: function · Topic: Differentiate a model

JuliaPythonRust
dscalardscalardscalar

Julia

dscalar(e::EarthSciAST.ASTExpr, s::Site)
dscalar(e::EarthSciAST.ASTExpr, s::Site, occ::Union{IdDict{EarthSciAST.OpExpr, Bool}, EarthSciASTDiff._SiteScan})
dscalar(e::ASTExpr, s::Site) -> ASTExpr

Derivative of the scalar expression e with respect to site s, as a new ESM expression. Structural rules only; a subtree in which s does not occur differentiates to a literal zero without descent. Throws DerivativeRuleError on an op with no rule (rewrite targets, joined or value-invention faq nodes in scalar position, a dynamic read of the site’s own variable).

Source

Python

dscalar(e: Expr, s: Site) -> Expr

Derivative of the scalar expression e w.r.t. site s.

Source

Rust

pub fn dscalar(e: &Expr, s: &Site) -> Result<Expr, DerivativeRuleError>

The derivative of the scalar expression e with respect to the site s (a variable or an indexed read), by the §3 rule table.

A one-shot call scans plainly: occurrence by occurs, which stops at the first hit, and a derivative memo private to the call. Building a shared occurrence index (a pass over the whole tree with a bit set per node) pays only when many scans share it, as a band computation’s do.

Source · Rust docs