Trait tinychain::scalar::NumberInstance[]

pub trait NumberInstance: Copy + Default + From<Boolean> + Into<Number> + Add<Self, Output = Self> + AddAssign<Self> + Sub<Self, Output = Self> + SubAssign<Self> + Mul<Self, Output = Self> + MulAssign<Self> + Div<Self, Output = Self> + DivAssign<Self> + Product<Self> + Sum<Self> + Debug + Display {
    type Abs: NumberInstance;
    type Exp: NumberInstance;
    type Class: NumberClass;
    fn class(&self) -> Self::Class;
fn into_type(
        self,
        dtype: Self::Class
    ) -> <Self::Class as NumberClass>::Instance;
fn abs(self) -> Self::Abs;
fn pow(self, exp: Self::Exp) -> Self; fn and(self, other: Self) -> Self
    where
        Boolean: CastFrom<Self>
, { ... }
fn not(self) -> Self
    where
        Boolean: CastFrom<Self>
, { ... }
fn or(self, other: Self) -> Self
    where
        Boolean: CastFrom<Self>
, { ... }
fn xor(self, other: Self) -> Self
    where
        Boolean: CastFrom<Self>
, { ... } }
Expand description

Defines common operations on numeric types supported by Number.

Associated Types

Loading content...

Required methods

fn class(&self) -> Self::Class

Expand description

Get an impl of NumberClass describing this number.

fn into_type(self, dtype: Self::Class) -> <Self::Class as NumberClass>::Instance

Expand description

Cast this number into the specified NumberClass.

fn abs(self) -> Self::Abs

Expand description

Calculate the absolute value of this number.

fn pow(self, exp: Self::Exp) -> Self

Expand description

Raise this number to the given exponent.

Loading content...

Provided methods

fn and(self, other: Self) -> Self where
    Boolean: CastFrom<Self>, 

Expand description

Return true if self and other are nonzero.

fn not(self) -> Self where
    Boolean: CastFrom<Self>, 

Expand description

Return true if this number is zero.

fn or(self, other: Self) -> Self where
    Boolean: CastFrom<Self>, 

Expand description

Return true if self or other is nonzero.

fn xor(self, other: Self) -> Self where
    Boolean: CastFrom<Self>, 

Expand description

Return true if exactly one of self and other is zero.

Loading content...

Implementors

impl NumberInstance for Complex

type Abs = Float

type Exp = Complex

type Class = ComplexType

pub fn class(&self) -> ComplexType

pub fn into_type(self, dtype: ComplexType) -> Complex

pub fn abs(self) -> Float

pub fn pow(self, exp: Complex) -> Complex

impl NumberInstance for Float

type Abs = Float

type Exp = Float

type Class = FloatType

pub fn class(&self) -> FloatType

pub fn into_type(self, dtype: FloatType) -> Float

pub fn abs(self) -> Float

pub fn pow(self, exp: Float) -> Float

impl NumberInstance for Int

type Abs = Int

type Exp = UInt

type Class = IntType

pub fn class(&self) -> IntType

pub fn into_type(self, dtype: IntType) -> Int

pub fn abs(self) -> Int

pub fn pow(self, exp: <Int as NumberInstance>::Exp) -> Int

impl NumberInstance for Number

type Abs = Number

type Exp = Number

type Class = NumberType

pub fn class(&self) -> NumberType

pub fn into_type(self, dtype: NumberType) -> Number

pub fn abs(self) -> Number

pub fn pow(self, exp: Number) -> Number

impl NumberInstance for UInt

type Abs = UInt

type Exp = UInt

type Class = UIntType

pub fn class(&self) -> UIntType

pub fn into_type(self, dtype: UIntType) -> UInt

pub fn abs(self) -> UInt

pub fn pow(self, exp: <UInt as NumberInstance>::Exp) -> UInt

impl NumberInstance for Boolean

type Abs = Boolean

type Exp = Boolean

type Class = BooleanType

pub fn class(&self) -> BooleanType

pub fn into_type(self, _dtype: BooleanType) -> Boolean

pub fn abs(self) -> Boolean

pub fn pow(self, exp: Boolean) -> Boolean

pub fn and(self, other: Boolean) -> Boolean

pub fn not(self) -> Boolean

pub fn or(self, other: Boolean) -> Boolean

pub fn xor(self, other: Boolean) -> Boolean

Loading content...