Trait CType

Source
pub trait CType:
    PartialEq
    + PartialOrd
    + Copy
    + Send
    + Sync
    + Display
    + Debug
    + 'static {
    type Float: Float;

    const TYPE: &'static str;
    const MAX: Self;
    const MIN: Self;
    const ZERO: Self;
    const ONE: Self;
    const IS_FLOAT: bool;
Show 14 methods // Required methods fn from_f64(float: f64) -> Self; fn from_float(float: Self::Float) -> Self; fn abs(self) -> Self; fn add(self, other: Self) -> Self; fn div(self, other: Self) -> Self; fn mul(self, other: Self) -> Self; fn sub(self, other: Self) -> Self; fn rem(self, other: Self) -> Self; fn min(l: Self, r: Self) -> Self; fn max(l: Self, r: Self) -> Self; fn pow(self, exp: Self) -> Self; fn round(self) -> Self; fn to_f64(self) -> f64; fn to_float(self) -> Self::Float;
}
Expand description

A numeric type supported by ha-ndarray

Required Associated Constants§

Source

const TYPE: &'static str

The C-language type name of this data type.

Source

const MAX: Self

The maximum value of this data type.

Source

const MIN: Self

The minimum value of this data type.

Source

const ZERO: Self

The zero value of this data type.

Source

const ONE: Self

The one value of this data type.

Source

const IS_FLOAT: bool

Whether this is a floating-point data type.

Required Associated Types§

Source

type Float: Float

The floating-point type used to represent this type in floating-point-only operations.

Required Methods§

Source

fn from_f64(float: f64) -> Self

Construct an instance of this type from a f64.

Source

fn from_float(float: Self::Float) -> Self

Construct an instance of this type from an instance of its floating-point type.

Source

fn abs(self) -> Self

Construct an instance of this type from a f64.

Source

fn add(self, other: Self) -> Self

Add two instances of this type.

Source

fn div(self, other: Self) -> Self

Divide two instances of this type.

Source

fn mul(self, other: Self) -> Self

Multiply two instances of this type.

Source

fn sub(self, other: Self) -> Self

Subtract two instances of this type.

Source

fn rem(self, other: Self) -> Self

Compute the remainder of self.div(other).

Source

fn min(l: Self, r: Self) -> Self

Return the minimum of two values of this type.

Source

fn max(l: Self, r: Self) -> Self

Return the maximum of two values of this type.

Source

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

Raise this value to the power of the given exponent.

Source

fn round(self) -> Self

Round this value to the nearest integer.

Source

fn to_f64(self) -> f64

Return the minimum of two values of this type.

Source

fn to_float(self) -> Self::Float

Convert this value to a floating-point value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl CType for f32

Source§

const TYPE: &'static str = "float"

Source§

const MAX: Self = 3.40282347E+38f32

Source§

const MIN: Self = -3.40282347E+38f32

Source§

const ZERO: Self = 0f32

Source§

const ONE: Self = 1f32

Source§

const IS_FLOAT: bool = true

Source§

type Float = f32

Source§

fn from_f64(float: f64) -> Self

Source§

fn from_float(float: Self) -> Self

Source§

fn abs(self) -> Self

Source§

fn add(self, other: Self) -> Self

Source§

fn div(self, other: Self) -> Self

Source§

fn mul(self, other: Self) -> Self

Source§

fn sub(self, other: Self) -> Self

Source§

fn rem(self, other: Self) -> Self

Source§

fn min(l: Self, r: Self) -> Self

Source§

fn max(l: Self, r: Self) -> Self

Source§

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

Source§

fn round(self) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn to_float(self) -> Self

Source§

impl CType for f64

Source§

const TYPE: &'static str = "double"

Source§

const MAX: Self = 1.7976931348623157E+308f64

Source§

const MIN: Self = -1.7976931348623157E+308f64

Source§

const ZERO: Self = 0f64

Source§

const ONE: Self = 1f64

Source§

const IS_FLOAT: bool = true

Source§

type Float = f64

Source§

fn from_f64(float: f64) -> Self

Source§

fn from_float(float: Self) -> Self

Source§

fn abs(self) -> Self

Source§

fn add(self, other: Self) -> Self

Source§

fn div(self, other: Self) -> Self

Source§

fn mul(self, other: Self) -> Self

Source§

fn sub(self, other: Self) -> Self

Source§

fn rem(self, other: Self) -> Self

Source§

fn min(l: Self, r: Self) -> Self

Source§

fn max(l: Self, r: Self) -> Self

Source§

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

Source§

fn round(self) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn to_float(self) -> Self

Source§

impl CType for i8

Source§

const TYPE: &'static str = "char"

Source§

const MAX: Self = 127i8

Source§

const MIN: Self = -128i8

Source§

const ZERO: Self = 0i8

Source§

const ONE: Self = 1i8

Source§

const IS_FLOAT: bool = false

Source§

type Float = f32

Source§

fn from_f64(float: f64) -> Self

Source§

fn from_float(float: f32) -> Self

Source§

fn abs(self) -> Self

Source§

fn add(self, other: Self) -> Self

Source§

fn div(self, other: Self) -> Self

Source§

fn mul(self, other: Self) -> Self

Source§

fn sub(self, other: Self) -> Self

Source§

fn rem(self, other: Self) -> Self

Source§

fn min(l: Self, r: Self) -> Self

Source§

fn max(l: Self, r: Self) -> Self

Source§

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

Source§

fn round(self) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn to_float(self) -> f32

Source§

impl CType for i16

Source§

const TYPE: &'static str = "short"

Source§

const MAX: Self = 32_767i16

Source§

const MIN: Self = -32_768i16

Source§

const ZERO: Self = 0i16

Source§

const ONE: Self = 1i16

Source§

const IS_FLOAT: bool = false

Source§

type Float = f32

Source§

fn from_f64(float: f64) -> Self

Source§

fn from_float(float: f32) -> Self

Source§

fn abs(self) -> Self

Source§

fn add(self, other: Self) -> Self

Source§

fn div(self, other: Self) -> Self

Source§

fn mul(self, other: Self) -> Self

Source§

fn sub(self, other: Self) -> Self

Source§

fn rem(self, other: Self) -> Self

Source§

fn min(l: Self, r: Self) -> Self

Source§

fn max(l: Self, r: Self) -> Self

Source§

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

Source§

fn round(self) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn to_float(self) -> f32

Source§

impl CType for i32

Source§

const TYPE: &'static str = "int"

Source§

const MAX: Self = 2_147_483_647i32

Source§

const MIN: Self = -2_147_483_648i32

Source§

const ZERO: Self = 0i32

Source§

const ONE: Self = 1i32

Source§

const IS_FLOAT: bool = false

Source§

type Float = f32

Source§

fn from_f64(float: f64) -> Self

Source§

fn from_float(float: f32) -> Self

Source§

fn abs(self) -> Self

Source§

fn add(self, other: Self) -> Self

Source§

fn div(self, other: Self) -> Self

Source§

fn mul(self, other: Self) -> Self

Source§

fn sub(self, other: Self) -> Self

Source§

fn rem(self, other: Self) -> Self

Source§

fn min(l: Self, r: Self) -> Self

Source§

fn max(l: Self, r: Self) -> Self

Source§

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

Source§

fn round(self) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn to_float(self) -> f32

Source§

impl CType for i64

Source§

const TYPE: &'static str = "long"

Source§

const MAX: Self = 9_223_372_036_854_775_807i64

Source§

const MIN: Self = -9_223_372_036_854_775_808i64

Source§

const ZERO: Self = 0i64

Source§

const ONE: Self = 1i64

Source§

const IS_FLOAT: bool = false

Source§

type Float = f64

Source§

fn from_f64(float: f64) -> Self

Source§

fn from_float(float: f64) -> Self

Source§

fn abs(self) -> Self

Source§

fn add(self, other: Self) -> Self

Source§

fn div(self, other: Self) -> Self

Source§

fn mul(self, other: Self) -> Self

Source§

fn sub(self, other: Self) -> Self

Source§

fn rem(self, other: Self) -> Self

Source§

fn min(l: Self, r: Self) -> Self

Source§

fn max(l: Self, r: Self) -> Self

Source§

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

Source§

fn round(self) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn to_float(self) -> f64

Source§

impl CType for u8

Source§

const TYPE: &'static str = "uchar"

Source§

const MAX: Self = 255u8

Source§

const MIN: Self = 0u8

Source§

const ZERO: Self = 0u8

Source§

const ONE: Self = 1u8

Source§

const IS_FLOAT: bool = false

Source§

type Float = f32

Source§

fn from_f64(float: f64) -> Self

Source§

fn from_float(float: f32) -> Self

Source§

fn abs(self) -> Self

Source§

fn add(self, other: Self) -> Self

Source§

fn div(self, other: Self) -> Self

Source§

fn mul(self, other: Self) -> Self

Source§

fn sub(self, other: Self) -> Self

Source§

fn rem(self, other: Self) -> Self

Source§

fn min(l: Self, r: Self) -> Self

Source§

fn max(l: Self, r: Self) -> Self

Source§

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

Source§

fn round(self) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn to_float(self) -> f32

Source§

impl CType for u16

Source§

const TYPE: &'static str = "ushort"

Source§

const MAX: Self = 65_535u16

Source§

const MIN: Self = 0u16

Source§

const ZERO: Self = 0u16

Source§

const ONE: Self = 1u16

Source§

const IS_FLOAT: bool = false

Source§

type Float = f32

Source§

fn from_f64(float: f64) -> Self

Source§

fn from_float(float: f32) -> Self

Source§

fn abs(self) -> Self

Source§

fn add(self, other: Self) -> Self

Source§

fn div(self, other: Self) -> Self

Source§

fn mul(self, other: Self) -> Self

Source§

fn sub(self, other: Self) -> Self

Source§

fn rem(self, other: Self) -> Self

Source§

fn min(l: Self, r: Self) -> Self

Source§

fn max(l: Self, r: Self) -> Self

Source§

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

Source§

fn round(self) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn to_float(self) -> f32

Source§

impl CType for u32

Source§

const TYPE: &'static str = "uint"

Source§

const MAX: Self = 4_294_967_295u32

Source§

const MIN: Self = 0u32

Source§

const ZERO: Self = 0u32

Source§

const ONE: Self = 1u32

Source§

const IS_FLOAT: bool = false

Source§

type Float = f32

Source§

fn from_f64(float: f64) -> Self

Source§

fn from_float(float: f32) -> Self

Source§

fn abs(self) -> Self

Source§

fn add(self, other: Self) -> Self

Source§

fn div(self, other: Self) -> Self

Source§

fn mul(self, other: Self) -> Self

Source§

fn sub(self, other: Self) -> Self

Source§

fn rem(self, other: Self) -> Self

Source§

fn min(l: Self, r: Self) -> Self

Source§

fn max(l: Self, r: Self) -> Self

Source§

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

Source§

fn round(self) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn to_float(self) -> f32

Source§

impl CType for u64

Source§

const TYPE: &'static str = "ulong"

Source§

const MAX: Self = 18_446_744_073_709_551_615u64

Source§

const MIN: Self = 0u64

Source§

const ZERO: Self = 0u64

Source§

const ONE: Self = 1u64

Source§

const IS_FLOAT: bool = false

Source§

type Float = f64

Source§

fn from_f64(float: f64) -> Self

Source§

fn from_float(float: f64) -> Self

Source§

fn abs(self) -> Self

Source§

fn add(self, other: Self) -> Self

Source§

fn div(self, other: Self) -> Self

Source§

fn mul(self, other: Self) -> Self

Source§

fn sub(self, other: Self) -> Self

Source§

fn rem(self, other: Self) -> Self

Source§

fn min(l: Self, r: Self) -> Self

Source§

fn max(l: Self, r: Self) -> Self

Source§

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

Source§

fn round(self) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn to_float(self) -> f64

Implementors§