Struct CalculusBuilder
pub struct CalculusBuilder { /* private fields */ }Description
Builder for topologically ordered calculus definitions within the size limits.
Implementations§
§impl CalculusBuilder
impl CalculusBuilder
pub fn jvp(
&mut self,
root: CalculusNodeId,
directions: &[(u16, CalculusNodeId)],
) -> Result<CalculusNodeId, PureOperatorError>
pub fn jvp( &mut self, root: CalculusNodeId, directions: &[(u16, CalculusNodeId)], ) -> Result<CalculusNodeId, PureOperatorError>
Apply the scalar output’s Jacobian to ordered, independently typed input blocks. Each direction has its selected input’s units; the result has the output’s units. Formals that are not selected are held fixed. No matrix is assembled.
§Errors
Rejects empty, duplicate, or invalid selections, incompatible direction types, unsupported derivatives, and calculus resource limits. On error nothing is appended.
pub fn vjp(
&mut self,
root: CalculusNodeId,
cotangent: CalculusNodeId,
formals: &[u16],
) -> Result<Vec<CalculusNodeId>, PureOperatorError>
pub fn vjp( &mut self, root: CalculusNodeId, cotangent: CalculusNodeId, formals: &[u16], ) -> Result<Vec<CalculusNodeId>, PureOperatorError>
Pull a scalar output cotangent back through ordered, typed input blocks.
The real dual pairing is dimensionless: the seed has reciprocal output units,
and each returned block has the reciprocal units of its selected input.
Uses the same typed map and first-partial transform as jvp.
§Errors
Rejects empty or duplicate selections, invalid formals, a seed that is not dual to the output, unsupported derivatives, and calculus resource limits. On error the builder is left unchanged.
§impl CalculusBuilder
impl CalculusBuilder
pub fn apply_scalar(
&mut self,
definition: &PureOperatorDefinition,
arguments: &[CalculusNodeId],
) -> Result<CalculusNodeId, PureOperatorError>
pub fn apply_scalar( &mut self, definition: &PureOperatorDefinition, arguments: &[CalculusNodeId], ) -> Result<CalculusNodeId, PureOperatorError>
Substitute checked scalar argument expressions into a closed scalar definition. The caller resolves lexical names and rejects recursive definition graphs. No polynomial normalization or reassociation is performed.
§impl CalculusBuilder
impl CalculusBuilder
pub fn partial(
&mut self,
root: CalculusNodeId,
formal: u16,
) -> Result<CalculusNodeId, PureOperatorError>
pub fn partial( &mut self, root: CalculusNodeId, formal: u16, ) -> Result<CalculusNodeId, PureOperatorError>
Append the first partial derivative of an explicit real scalar polynomial with respect to one declared formal, holding all other formals fixed.
The original input occurrences and product-rule order are kept. A constant result is zero, with the quotient dimension. Explicit validity requirements keep their original predicate even when the derivative is zero; predicates are not differentiated. On error nothing is appended, and the existing node and depth limits apply.
§Errors
Rejects invalid nodes or formals, unconstrained or non-real scalar input types, unsupported derivative rules, and unrepresentable dimensions.
§impl CalculusBuilder
impl CalculusBuilder
pub fn value_type(
&self,
node: CalculusNodeId,
) -> Result<ValueType, PureOperatorError>
pub fn value_type( &self, node: CalculusNodeId, ) -> Result<ValueType, PureOperatorError>
Resolve the concrete scalar type of a component from the calculus type check. Unconstrained generic dimensions or scalar domains cannot give a concrete type.
§impl CalculusBuilder
impl CalculusBuilder
pub fn new(
formals: impl IntoIterator<Item = PureValueClass>,
result: PureValueClass,
) -> Result<CalculusBuilder, PureOperatorError>
pub fn new( formals: impl IntoIterator<Item = PureValueClass>, result: PureValueClass, ) -> Result<CalculusBuilder, PureOperatorError>
Start a definition.
§Errors
Rejects an empty or oversized formal list and invalid result references.
pub fn push(
&mut self,
node: CalculusNode,
) -> Result<CalculusNodeId, PureOperatorError>
pub fn push( &mut self, node: CalculusNode, ) -> Result<CalculusNodeId, PureOperatorError>
Append one node.
§Errors
Rejects forward references, invalid formal/axis use, excessive node count, or excessive expression depth.
pub fn finish(
self,
root: CalculusNodeId,
) -> Result<PureOperatorDefinition, PureOperatorError>
pub fn finish( self, root: CalculusNodeId, ) -> Result<PureOperatorDefinition, PureOperatorError>
Finish a non-empty definition.
§Errors
Rejects a missing root or a body whose dimensional type does not match the declared result rule for every admissible formal dimension.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CalculusBuilder
impl RefUnwindSafe for CalculusBuilder
impl Send for CalculusBuilder
impl Sync for CalculusBuilder
impl Unpin for CalculusBuilder
impl UnsafeUnpin for CalculusBuilder
impl UnwindSafe for CalculusBuilder
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.