pub struct Resolve<T> {
pub val: T,
pub marker: &'static str,
}Expand description
Resolves to either a mathematical expression as string or a computed value.
This is used to create generic kernels / operations over OpenCL, CUDA and CPU.
§Example
use custos::{Resolve, Eval, Combiner, ToCLSource};
let val = Resolve::with_val(1.5);
let out = val.mul(val).add(2.);
assert_eq!(out.eval(), 4.25);
let mark = Resolve::<f32>::with_marker("x");
let out = mark.mul(mark).add(2.);
assert_eq!(out.to_cl_source(), "((x * x) + 2)");Fields§
§val: TActs as the seed value.
marker: &'static strActs as the variable name for the expression.
Implementations§
Source§impl<T> Resolve<T>
impl<T> Resolve<T>
Sourcepub fn with_val(val: T) -> Self
pub fn with_val(val: T) -> Self
Creates a Resolve with a value.
§Example
use custos::{Resolve, Eval, Combiner};
let val = Resolve::with_val(1.5);
let out = val.mul(val).add(2.);
assert_eq!(out.eval(), 4.25);Sourcepub fn with_marker(marker: &'static str) -> Selfwhere
T: Default,
pub fn with_marker(marker: &'static str) -> Selfwhere
T: Default,
Creates a Resolve with a marker.
§Example
use custos::{Resolve, Eval, Combiner, ToCLSource};
let mark = Resolve::<f32>::with_marker("x");
let out = mark.add(mark).mul(2.);
assert_eq!(out.to_cl_source(), "((x + x) * 2)");Trait Implementations§
Source§impl<T> Combiner for Resolve<T>
impl<T> Combiner for Resolve<T>
Source§fn add<R>(self, rhs: R) -> Add<Self, R>where
Self: Sized,
fn add<R>(self, rhs: R) -> Add<Self, R>where
Self: Sized,
Combines two values into a new one via an addition.
Source§fn mul<R>(self, rhs: R) -> Mul<Self, R>where
Self: Sized,
fn mul<R>(self, rhs: R) -> Mul<Self, R>where
Self: Sized,
Combines two values into a new one via an multiplication.
Source§fn sub<R>(self, rhs: R) -> Sub<Self, R>where
Self: Sized,
fn sub<R>(self, rhs: R) -> Sub<Self, R>where
Self: Sized,
Combines two values into a new one via an subtraction.
Source§fn div<R>(self, rhs: R) -> Div<Self, R>where
Self: Sized,
fn div<R>(self, rhs: R) -> Div<Self, R>where
Self: Sized,
Combines two values into a new one via an division.
Source§fn pow<R>(self, rhs: R) -> Pow<Self, R>where
Self: Sized,
fn pow<R>(self, rhs: R) -> Pow<Self, R>where
Self: Sized,
Combined two values into a new one via exponentiation.
Source§fn geq<R>(self, rhs: R) -> GEq<Self, R>where
Self: Sized,
fn geq<R>(self, rhs: R) -> GEq<Self, R>where
Self: Sized,
Checks if the left value is greater than the right value.
Source§fn leq<R>(self, rhs: R) -> LEq<Self, R>where
Self: Sized,
fn leq<R>(self, rhs: R) -> LEq<Self, R>where
Self: Sized,
Checks if the left value is less than the right value.
Source§impl<T> ToCLSource for Resolve<T>
Available on non-crate feature no-std only.
impl<T> ToCLSource for Resolve<T>
Available on non-crate feature
no-std only.Source§fn to_cl_source(&self) -> String
fn to_cl_source(&self) -> String
Evaluates a combined (via
Combiner) math operations chain to a valid OpenCL C (and possibly CUDA) source string.impl<T: Copy> Copy for Resolve<T>
Auto Trait Implementations§
impl<T> Freeze for Resolve<T>where
T: Freeze,
impl<T> RefUnwindSafe for Resolve<T>where
T: RefUnwindSafe,
impl<T> Send for Resolve<T>where
T: Send,
impl<T> Sync for Resolve<T>where
T: Sync,
impl<T> Unpin for Resolve<T>where
T: Unpin,
impl<T> UnwindSafe for Resolve<T>where
T: UnwindSafe,
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