pub struct Function { /* private fields */ }
Expand description
Parsed complex-valued function of a single variable.
A Function
instance can be created using FromStr
trait. A function must use z
as the (only) argument. A function may use arithmetic operations (+
, -
, *
, /
, ^
)
and/or predefined unary functions:
- General functions:
arg
,sqrt
,exp
,log
- Hyperbolic trigonometry:
sinh
,cosh
,tanh
- Inverse hyperbolic trigonometry:
asinh
,acosh
,atanh
A function may define local variable assignment(s). The assignment syntax is similar to Python
(or Rust, just without the let
keyword): variable name followed by =
and then by
the arithmetic expression. Assignments must be separated by semicolons ;
. As in Rust,
the last expression in function body is its return value.
§Examples
let function: Function = "z * z - 0.5".parse()?;
let fn_with_calls: Function = "0.8 * z + z / atanh(z ^ -4)".parse()?;
let fn_with_vars: Function = "c = -0.5 + 0.4i; z * z + c".parse()?;
Trait Implementations§
source§impl Backend<&Function> for Cpu
impl Backend<&Function> for Cpu
§type Error = Infallible
type Error = Infallible
Error that may be returned during program creation.
§type Program = CpuProgram<Function>
type Program = CpuProgram<Function>
Program output by the backend.
source§impl ComputePoint for Function
impl ComputePoint for Function
source§fn compute_point(&self, z: Complex32) -> Complex32
fn compute_point(&self, z: Complex32) -> Complex32
Available on crate feature
cpu_backend
only.Computes the function value at the specified point.
Auto Trait Implementations§
impl Freeze for Function
impl RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnwindSafe for Function
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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>
Converts
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>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
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