pub struct Context {
pub zero_precision: f64,
/* private fields */
}
Fields§
§zero_precision: f64
Implementations§
source§impl Context
impl Context
sourcepub fn get_reserved_names(&self) -> Vec<&str>
pub fn get_reserved_names(&self) -> Vec<&str>
Get an iterator over the reserved names for this context You should only call this function once and cache its result But you can call it multiples times
sourcepub fn get_binding(&self, name: &str) -> Result<&Complex64, CalcError>
pub fn get_binding(&self, name: &str) -> Result<&Complex64, CalcError>
Errors
Return an error if the requested binding isn’t found in this context
sourcepub fn get_binding_mut(
&mut self,
name: &str
) -> Result<&mut Complex64, CalcError>
pub fn get_binding_mut(
&mut self,
name: &str
) -> Result<&mut Complex64, CalcError>
Errors
Return an error if the requested binding isn’t found in this context
sourcepub fn get_func(
&self,
name: &str
) -> Result<&Arc<dyn Func + Send + Sync>, CalcError>
pub fn get_func(
&self,
name: &str
) -> Result<&Arc<dyn Func + Send + Sync>, CalcError>
Errors
Return an error if the requested function isn’t found in this context
sourcepub fn insert_func(
&mut self,
name: Cow<'static, str>,
func: Arc<dyn Func + Send + Sync>
)
pub fn insert_func(
&mut self,
name: Cow<'static, str>,
func: Arc<dyn Func + Send + Sync>
)
Insert the given function into the context, overwriting if the function already existed
sourcepub fn insert_binding(&mut self, name: Cow<'static, str>, binding: Complex64)
pub fn insert_binding(&mut self, name: Cow<'static, str>, binding: Complex64)
Insert the given binding into the context, overwriting if the binding already existed
sourcepub fn eval<'expr: 'arena, 'arena>(
&self,
expr: &'expr Expr<'arena>
) -> Result<Complex64, CalcError>
pub fn eval<'expr: 'arena, 'arena>(
&self,
expr: &'expr Expr<'arena>
) -> Result<Complex64, CalcError>
Evaluate an AST in the current Context
Errors
This will return an error if any of the operation return an error
sourcepub fn eval_rpn<'expr: 'arena, 'arena>(
&self,
rpn: &'expr RpnExpr<'arena>
) -> Result<Complex64, CalcError>
pub fn eval_rpn<'expr: 'arena, 'arena>(
&self,
rpn: &'expr RpnExpr<'arena>
) -> Result<Complex64, CalcError>
Evaluate an RPN sequence in the current context
Errors
This will return an error on three separate instances: - A User-Function has returned an error - A bindings is missing in the current context - A User-Function is missing in the current context
sourcepub fn is_zero(&self, f: f64) -> bool
pub fn is_zero(&self, f: f64) -> bool
Check that the given f64
can be considered equal to zero
It uses the field zero_precision
to get a range of values (-zero_precision, +zero_precision)
this considered equal to zero
sourcepub fn is_complex_zero(&self, c: Complex64) -> bool
pub fn is_complex_zero(&self, c: Complex64) -> bool
Check that the given Complex
number is close enough to zero to
be considered equal to zero
sourcepub fn is_near(&self, f: f64, to: f64) -> bool
pub fn is_near(&self, f: f64, to: f64) -> bool
Check if a f64
is close enough to another one to be considered equal
sourcepub fn is_complex_near(&self, c: Complex64, to: Complex64) -> bool
pub fn is_complex_near(&self, c: Complex64, to: Complex64) -> bool
Check if a complex number is near enough to another one to be considered equal