vjp_document
Stable function · Evaluate the Jacobian
Tier: stable · Kind: function · Topic: Evaluate the Jacobian
| Julia | Python | Rust |
|---|---|---|
vjp_document | vjp_document | vjp_document |
Julia
vjp_document(input; wrt, model_name, forcing, cse, cse_min_nodes)
jvp_document(input; wrt = :states, model_name = nothing, forcing = nothing,
cse = true) -> (doc, io)
vjp_document(input; …) -> (doc, io)
The product documents of esm-jacobian-spec.md §9.2 / §9.3 for one
first-order axis: a derived ESM document (model "JvpEval" / "VjpEval")
whose right-hand side, evaluated by an unmodified EarthSciAST evaluator at
(u, inputs, p, t), leaves J v (resp. Jᵀ λ) in the derivative slots of
its outputs. input is an EsmFile or a FlattenedSystem, as for
jacobian_bands
.
io names the inputs and outputs: io.v maps each column variable to its
direction input and io.jvp each state to its output (io.lam / io.vjp
for vjp_document). The consumer writes the inputs into the evaluator’s
state slots beside the source states and reads the outputs from du
through the evaluator’s variable map.
A VjpEval document is an equality-filtered faq scatter: correct under
any evaluator, linear-time only under one that implements §9.3’s
equality-filter scatter.
Python
vjp_document(obj, model_name: str | None = None, wrt: str = 'states', forcing=None, cse: bool = True, cse_min_nodes: int = 12)
The Jᵀ λ product document of spec §9.3 for one first-order axis
(model "VjpEval"), as jvp_document
: io["lam"] maps each
state to its adjoint input and io["vjp"] each column variable to its
output.
A VjpEval document is an equality-filtered faq scatter: correct
under any evaluator, linear-time only under one that implements §9.3’s
equality-filter scatter.
Rust
pub fn vjp_document(sv: &SysView<'_>, entries: &[JacEntry], wrt: Wrt, opts: &ProductOptions<'_>) -> Result<(Value, VjpIo), BandError>
The Jᵀ λ product document of spec §9.3 (model "VjpEval"): as
jvp_document
, with the cotangent inputs VjpIo::lam and the
outputs VjpIo::vjp. An equality-filtered faq scatter: correct under
any evaluator, linear-time only under one that implements §9.3’s
equality-filter scatter. entries and opts.forcing must agree, as for
jvp_document
.