Struct ExprDagBuilder
pub struct ExprDagBuilder { /* private fields */ }Description
Builder that makes forward references and cycles unrepresentable.
Implementations§
§impl ExprDagBuilder
impl ExprDagBuilder
pub fn finite_unary(
&mut self,
operation: FiniteUnaryOperation,
value: ExprId,
) -> Result<ExprId, Diagnostic>
pub fn finite_unary( &mut self, operation: FiniteUnaryOperation, value: ExprId, ) -> Result<ExprId, Diagnostic>
Add a finite unary operation such as a transpose or adjoint; types are checked during semantic admission.
pub fn finite_binary(
&mut self,
operation: FiniteBinaryOperation,
left: ExprId,
right: ExprId,
) -> Result<ExprId, Diagnostic>
pub fn finite_binary( &mut self, operation: FiniteBinaryOperation, left: ExprId, right: ExprId, ) -> Result<ExprId, Diagnostic>
Add a finite binary operation; endpoint types are checked during inference.
§impl ExprDagBuilder
impl ExprDagBuilder
pub fn property(
&mut self,
release: PropertyRelease,
arguments: impl IntoIterator<Item = ExprId>,
) -> Result<ExprId, Diagnostic>
pub fn property( &mut self, release: PropertyRelease, arguments: impl IntoIterator<Item = ExprId>, ) -> Result<ExprId, Diagnostic>
Add a property value together with its scientific identity. Equal values from different releases get distinct arena IDs.
§Errors
Rejects arguments to a constant or an invalid typed application.
pub fn bind_property(
&mut self,
id: ExprId,
release: PropertyRelease,
) -> Result<(), Diagnostic>
pub fn bind_property( &mut self, id: ExprId, release: PropertyRelease, ) -> Result<(), Diagnostic>
Reattach a scientific identity to an existing node during replay.
§Errors
Rejects a foreign root, a duplicate annotation, a changed constant, or a substituted analytic definition: each annotation must match the value it is attached to.
§impl ExprDagBuilder
impl ExprDagBuilder
pub fn project_operator_component<I>(
&mut self,
instance: &PureOperatorInstantiation<'_, I>,
arguments: &[impl AsRef<[ExprId]>],
component: &[u32],
max_nodes: usize,
) -> Result<ExprId, Diagnostic>
pub fn project_operator_component<I>( &mut self, instance: &PureOperatorInstantiation<'_, I>, arguments: &[impl AsRef<[ExprId]>], component: &[u32], max_nodes: usize, ) -> Result<ExprId, Diagnostic>
Append one ordered scalar component of a checked pure instantiation.
Each argument supplies its complete row-major scalar coordinates.
The Model itself keeps the original application and definition.
max_nodes bounds the whole destination arena before expansion allocates.
§impl ExprDagBuilder
impl ExprDagBuilder
pub fn gradient(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
pub fn gradient(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
Take the physical-space gradient.
pub fn divergence(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
pub fn divergence(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
Take the physical-space divergence.
pub fn symmetric_part(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
pub fn symmetric_part(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
Take the symmetric part of a square Cartesian rank-two tensor.
pub fn isotropic_lift(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
pub fn isotropic_lift(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
Lift a supported invariant scalar to an isotropic Cartesian tensor.
pub fn trace(
&mut self,
value: ExprId,
on: Id<Domain>,
) -> Result<ExprId, Diagnostic>
pub fn trace( &mut self, value: ExprId, on: Id<Domain>, ) -> Result<ExprId, Diagnostic>
Take a full trace on a boundary or physical-interface Domain. The operand’s support selects the adjacent parent.
pub fn normal_component(
&mut self,
value: ExprId,
on: Id<Domain>,
) -> Result<ExprId, Diagnostic>
pub fn normal_component( &mut self, value: ExprId, on: Id<Domain>, ) -> Result<ExprId, Diagnostic>
Contract with the normal of a boundary or physical-interface Domain. Exterior boundaries use the parent-outward normal; physical interfaces use the common normal of their first declared boundary.
pub fn pullback(
&mut self,
value: ExprId,
source: Vec<ExprId>,
at: Vec<(ExprId, ExprId)>,
) -> Result<ExprId, Diagnostic>
pub fn pullback( &mut self, value: ExprId, source: Vec<ExprId>, at: Vec<(ExprId, ExprId)>, ) -> Result<ExprId, Diagnostic>
Pull a value back along a map between coordinate supports, before any numerical sampling. Type admission requires every coordinate to be bound, each with its own unit.
pub fn coordinate_map_factor(
&mut self,
factor: CoordinateMapFactor,
source: Vec<ExprId>,
at: Vec<(ExprId, ExprId)>,
) -> Result<ExprId, Diagnostic>
pub fn coordinate_map_factor( &mut self, factor: CoordinateMapFactor, source: Vec<ExprId>, at: Vec<(ExprId, ExprId)>, ) -> Result<ExprId, Diagnostic>
Derive a local Jacobian factor from a complete coordinate map.
§Errors
Rejects empty inventories and operands outside this expression arena.
pub fn coordinate_map_factor_action(
&mut self,
value: ExprId,
parameter: ExprId,
directions: Vec<ExprId>,
) -> Result<ExprId, Diagnostic>
pub fn coordinate_map_factor_action( &mut self, value: ExprId, parameter: ExprId, directions: Vec<ExprId>, ) -> Result<ExprId, Diagnostic>
Apply a dimensioned direction, one per mapped row, to a Jacobian factor. The directions are not assumed to be time derivatives; a conservation correspondence has to establish that separately.
§Errors
Rejects a non-factor value, a wrong row count, or unavailable operands.
§impl ExprDagBuilder
impl ExprDagBuilder
pub fn from_dag(expression: &ExprDag) -> ExprDagBuilder
pub fn from_dag(expression: &ExprDag) -> ExprDagBuilder
Start from an existing DAG, keeping its node indices, definitions, and releases.
pub fn push(&mut self, node: ExprNode) -> Result<ExprId, Diagnostic>
pub fn push(&mut self, node: ExprNode) -> Result<ExprId, Diagnostic>
Append one node and return its stable local ID.
pub fn validate_prior_operand(&self, operand: ExprId) -> Result<(), Diagnostic>
pub fn validate_prior_operand(&self, operand: ExprId) -> Result<(), Diagnostic>
Check that an operand references an existing arena node without appending nodes.
§Errors
Rejects an ID outside the current arena using the ordinary operand diagnostic.
pub fn array(
&mut self,
elements: impl IntoIterator<Item = ExprId>,
) -> Result<ExprId, Diagnostic>
pub fn array( &mut self, elements: impl IntoIterator<Item = ExprId>, ) -> Result<ExprId, Diagnostic>
Construct an ordered outer channel array from existing DAG nodes.
pub fn index(&mut self, value: ExprId, index: u32) -> Result<ExprId, Diagnostic>
pub fn index(&mut self, value: ExprId, index: u32) -> Result<ExprId, Diagnostic>
Select one outer channel-array element; type checking verifies the bound.
pub fn complex(
&mut self,
real: ExprId,
imag: ExprId,
) -> Result<ExprId, Diagnostic>
pub fn complex( &mut self, real: ExprId, imag: ExprId, ) -> Result<ExprId, Diagnostic>
Construct a complex scalar; typing checks both real scalar operands.
pub fn sample(
&mut self,
value: ExprId,
clock: Id<ClockDomain>,
) -> Result<ExprId, Diagnostic>
pub fn sample( &mut self, value: ExprId, clock: Id<ClockDomain>, ) -> Result<ExprId, Diagnostic>
Sample a continuous expression on a nominal clock. Semantic admission checks the clock and the owning activation.
pub fn hold(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
pub fn hold(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
Read a clocked State continuously. The operand must be a State symbol with explicit initialization and updates; no memory or initial value is created.
pub fn constant<V>(&mut self, value: V) -> Result<ExprId, Diagnostic>where
V: TryInto<ValueLiteral>,
<V as TryInto<ValueLiteral>>::Error: Display,
pub fn constant<V>(&mut self, value: V) -> Result<ExprId, Diagnostic>where
V: TryInto<ValueLiteral>,
<V as TryInto<ValueLiteral>>::Error: Display,
Add a checked constant; a numerical quantity supplies an explicit real scalar type.
pub fn symbol(&mut self, symbol: SymbolRef) -> Result<ExprId, Diagnostic>
pub fn symbol(&mut self, symbol: SymbolRef) -> Result<ExprId, Diagnostic>
Add a typed symbol reference.
pub fn require(
&mut self,
condition: ExprId,
value: ExprId,
) -> Result<ExprId, Diagnostic>
pub fn require( &mut self, condition: ExprId, value: ExprId, ) -> Result<ExprId, Diagnostic>
Require a true domain condition before demanding the complete value.
pub fn select(
&mut self,
condition: ExprId,
then_value: ExprId,
else_value: ExprId,
) -> Result<ExprId, Diagnostic>
pub fn select( &mut self, condition: ExprId, then_value: ExprId, else_value: ExprId, ) -> Result<ExprId, Diagnostic>
Select one complete value lazily from a Boolean condition.
pub fn min(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
pub fn min(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
Select the smaller scalar, retaining the first operand on ties. Both operands are demanded; typing requires identical ordered scalar types.
pub fn max(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
pub fn max(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
Select the larger scalar, retaining the first operand on ties. Both operands are demanded; typing requires identical ordered scalar types.
pub fn compare(
&mut self,
op: ComparisonOp,
left: ExprId,
right: ExprId,
) -> Result<ExprId, Diagnostic>
pub fn compare( &mut self, op: ComparisonOp, left: ExprId, right: ExprId, ) -> Result<ExprId, Diagnostic>
Compare two scalar expressions.
pub fn not(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
pub fn not(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
Negate a Boolean expression.
pub fn and(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
pub fn and(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
Short-circuit Boolean conjunction.
pub fn or(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
pub fn or(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
Short-circuit Boolean disjunction.
pub fn neg(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
pub fn neg(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
Add unary negation.
pub fn add(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
pub fn add(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
Add two expressions.
pub fn sub(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
pub fn sub(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
Subtract two expressions.
pub fn mul(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
pub fn mul(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
Multiply two expressions.
pub fn div(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
pub fn div(&mut self, left: ExprId, right: ExprId) -> Result<ExprId, Diagnostic>
Divide two expressions.
pub fn quotient(
&mut self,
left: ExprId,
right: ExprId,
) -> Result<ExprId, Diagnostic>
pub fn quotient( &mut self, left: ExprId, right: ExprId, ) -> Result<ExprId, Diagnostic>
Checked integer quotient.
pub fn remainder(
&mut self,
left: ExprId,
right: ExprId,
) -> Result<ExprId, Diagnostic>
pub fn remainder( &mut self, left: ExprId, right: ExprId, ) -> Result<ExprId, Diagnostic>
Checked integer remainder.
pub fn ordinal(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
pub fn ordinal(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
Explicit nominal index ordinal projection.
pub fn to_real(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
pub fn to_real(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
Explicit integer-to-real conversion.
pub fn to_integer(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
pub fn to_integer(&mut self, value: ExprId) -> Result<ExprId, Diagnostic>
Checked integral real-to-integer conversion.
pub fn powi(
&mut self,
base: ExprId,
exponent: i32,
) -> Result<ExprId, Diagnostic>
pub fn powi( &mut self, base: ExprId, exponent: i32, ) -> Result<ExprId, Diagnostic>
Raise an expression to an integer power.
pub fn coordinate(
&mut self,
support: Id<Domain>,
factor: Id<Domain>,
axis: usize,
) -> Result<ExprId, Diagnostic>
pub fn coordinate( &mut self, support: Id<Domain>, factor: Id<Domain>, axis: usize, ) -> Result<ExprId, Diagnostic>
Read one coordinate-factor axis on a declared support. Whole-Model admission checks factor membership, axis bounds, and units.
pub fn unary_math(
&mut self,
function: UnaryMathFunction,
value: ExprId,
) -> Result<ExprId, Diagnostic>
pub fn unary_math( &mut self, function: UnaryMathFunction, value: ExprId, ) -> Result<ExprId, Diagnostic>
Apply a dimension-aware unary mathematical function.
pub fn coordinate_partial(
&mut self,
value: ExprId,
wrt: ExprId,
) -> Result<ExprId, Diagnostic>
pub fn coordinate_partial( &mut self, value: ExprId, wrt: ExprId, ) -> Result<ExprId, Diagnostic>
Add a coordinate partial derivative; the numerical representation decides whether it is supported.
§Errors
Rejects operands outside this builder or beyond the expression arena limits.
pub fn evaluate_at(
&mut self,
value: ExprId,
at: Vec<(ExprId, ExprId)>,
side: Option<BoundarySide>,
) -> Result<ExprId, Diagnostic>
pub fn evaluate_at( &mut self, value: ExprId, at: Vec<(ExprId, ExprId)>, side: Option<BoundarySide>, ) -> Result<ExprId, Diagnostic>
Evaluate an expression at a point that gives every coordinate, without choosing a numerical representation.
§Errors
Rejects an empty or oversized point and operands outside the expression arena.
pub fn pure_operator(
&mut self,
definition: &PureOperatorDefinition,
arguments: impl IntoIterator<Item = ExprId>,
) -> Result<ExprId, Diagnostic>
pub fn pure_operator( &mut self, definition: &PureOperatorDefinition, arguments: impl IntoIterator<Item = ExprId>, ) -> Result<ExprId, Diagnostic>
Apply a closed pure-operator definition to earlier expressions.
The definition is deduplicated by content digest and stored in the finished expression. Arguments are matched to formal slots by position; there is no lookup by name and no implicit commutativity.
§Errors
Returns EQ0301 for an empty or wrongly sized argument list, a forward
reference, or a digest collision between different canonical definitions.
pub fn finish(
self,
roots: impl IntoIterator<Item = ExprId>,
) -> Result<ExprDag, Diagnostic>
pub fn finish( self, roots: impl IntoIterator<Item = ExprId>, ) -> Result<ExprDag, Diagnostic>
Finish a DAG with one or more output roots.
§Errors
Returns EQ0301 when the arena or root set is empty, or a root is not
present in this arena.
Trait Implementations§
§impl Debug for ExprDagBuilder
impl Debug for ExprDagBuilder
§impl Default for ExprDagBuilder
impl Default for ExprDagBuilder
§fn default() -> ExprDagBuilder
fn default() -> ExprDagBuilder
Auto Trait Implementations§
impl Freeze for ExprDagBuilder
impl RefUnwindSafe for ExprDagBuilder
impl Send for ExprDagBuilder
impl Sync for ExprDagBuilder
impl Unpin for ExprDagBuilder
impl UnsafeUnpin for ExprDagBuilder
impl UnwindSafe for ExprDagBuilder
Blanket Implementations§
Source§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Source§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§fn approx(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
§fn into_as<Dst>(self) -> Dstwhere
Self: Sized + Into<Dst>,
fn into_as<Dst>(self) -> Dstwhere
Self: Sized + Into<Dst>,
§fn try_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + TryInto<Dst>,
fn try_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + TryInto<Dst>,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> From<T> for T
impl<T> From<T> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Same for T
impl<T> Same for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.