Resolve

Struct Resolve 

Source
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: T

Acts as the seed value.

§marker: &'static str

Acts as the variable name for the expression.

Implementations§

Source§

impl<T> Resolve<T>

Source

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);
Source

pub fn with_marker(marker: &'static str) -> Self
where 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: Clone> Clone for Resolve<T>

Source§

fn clone(&self) -> Resolve<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Combiner for Resolve<T>

Source§

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,

Combines two values into a new one via an multiplication.
Source§

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,

Combines two values into a new one via an division.
Source§

fn sin(self) -> Sin<Self>
where Self: Sized,

Calculates the sine of a value.
Source§

fn cos(self) -> Cos<Self>
where Self: Sized,

Calculates the cosine of a value.
Source§

fn tan(self) -> Tan<Self>
where Self: Sized,

Calculates the tangent of a value.
Source§

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,

Checks if the left value is greater than the right value.
Source§

fn leq<R>(self, rhs: R) -> LEq<Self, R>
where Self: Sized,

Checks if the left value is less than the right value.
Source§

fn eq<R>(self, rhs: R) -> Eq<Self, R>
where Self: Sized,

Checks if the left value is equal to the right value.
Source§

fn neg(self) -> Neg<Self>
where Self: Sized,

Negates a value.
Source§

fn exp(self) -> Exp<Self>
where Self: Sized,

Calculates the e^x of a value.
Source§

impl<T: Debug> Debug for Resolve<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Resolve<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Eval<T> for Resolve<T>

Source§

fn eval(self) -> T

Evaluates a combined (via Combiner) math operations chain to a value. Read more
Source§

impl<T> ToCLSource for Resolve<T>

Available on non-crate feature no-std only.
Source§

fn to_cl_source(&self) -> String

Evaluates a combined (via Combiner) math operations chain to a valid OpenCL C (and possibly CUDA) source string.
Source§

impl<T: Default> ToMarker<T, Resolve<T>> for &'static str

Source§

fn to_marker(self) -> Resolve<T>

Converts a &’static str to a Resolve. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Eval<T> for T
where T: Copy,

Source§

fn eval(self) -> T

Evaluates a combined (via Combiner) math operations chain to a value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToVal for T

Source§

fn to_val(self) -> Resolve<T>

Converts a value to a Resolve. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Zero for T
where T: Default,

Source§

fn zero() -> Self
where Self: Default,

Returns zero or the default. Read more
Source§

impl<T> MayToCLSource for T
where T: ToCLSource,