pub struct Expr<'a> {
pub id: ExprId,
pub arena: &'a ExprArenaCell,
/* private fields */
}Expand description
Lightweight handle to a node in an ExprArenaCell.
Carries a borrow of the arena cell so operator overloads can push new nodes
during arithmetic. Expr is Copy, so users freely reuse a variable
handle in many constraints.
Fields§
§id: ExprId§arena: &'a ExprArenaCellImplementations§
Source§impl<'a> Expr<'a>
impl<'a> Expr<'a>
pub fn new(id: ExprId, arena: &'a ExprArenaCell) -> Self
Sourcepub const fn model_id(self) -> ModelId
pub const fn model_id(self) -> ModelId
Identity of the model/expression arena that created this handle.
pub fn constant(arena: &'a ExprArenaCell, v: f64) -> Self
pub fn from_var(arena: &'a ExprArenaCell, v: VarId) -> Self
Sourcepub fn var_id(self) -> Option<VarId>
pub fn var_id(self) -> Option<VarId>
If this handle is a bare variable, return its VarId.
None for compound expressions (sums, products, constants, …).
Sourcepub fn param_id(self) -> Option<ParamId>
pub fn param_id(self) -> Option<ParamId>
If this handle is a bare parameter, return its ParamId.
None for compound expressions.
Sourcepub fn set_param_value(self, value: f64)
pub fn set_param_value(self, value: f64)
Re-bind the parameter this handle references to value. Takes effect on
the next extraction/evaluation, which read the value straight from the
arena.
§Panics
Panics if this handle is not a bare parameter (see Self::param_id).
pub fn pow(self, exponent: Self) -> Self
pub fn powi(self, n: i32) -> Self
pub fn powf(self, n: f64) -> Self
Sourcepub fn neg(self) -> Self
pub fn neg(self) -> Self
Unary negation as an explicit expression node. The -expr operator
keeps its affine fast path. Use this method when the public
UnaryOp node is required.
pub fn abs(self) -> Self
pub fn sqrt(self) -> Self
pub fn cbrt(self) -> Self
pub fn exp(self) -> Self
pub fn exp2(self) -> Self
pub fn expm1(self) -> Self
Sourcepub fn exp_m1(self) -> Self
pub fn exp_m1(self) -> Self
Alias for Expr::expm1, matching Rust’s f64::exp_m1 spelling.
pub fn log(self) -> Self
pub fn log2(self) -> Self
pub fn log10(self) -> Self
pub fn log1p(self) -> Self
Sourcepub fn ln_1p(self) -> Self
pub fn ln_1p(self) -> Self
Alias for Expr::log1p, matching Rust’s f64::ln_1p spelling.
pub fn sin(self) -> Self
pub fn cos(self) -> Self
pub fn tan(self) -> Self
pub fn asin(self) -> Self
pub fn acos(self) -> Self
pub fn atan(self) -> Self
pub fn sinh(self) -> Self
pub fn cosh(self) -> Self
pub fn tanh(self) -> Self
pub fn asinh(self) -> Self
pub fn acosh(self) -> Self
pub fn atanh(self) -> Self
Sourcepub fn atan2(self, x: Self) -> Self
pub fn atan2(self, x: Self) -> Self
Two-argument arctangent in Rust’s y.atan2(x) argument order.