pub struct Function { /* private fields */ }
Available on crate features
dyn_cpu_backend
or opencl_backend
or vulkan_backend
only.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 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