Skip to main content

Number

Trait Number 

Source
pub trait Number:
    CLType
    + Into<Number>
    + CastFrom<Number>
    + Default {
    type Abs: Number;

    const ZERO: Self;
    const ONE: Self;

    // Required methods
    fn abs(self) -> Self::Abs;
    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 pow(self, exp: Self) -> Self;
}
Expand description

A numeric type supported by ha-ndarray

Required Associated Constants§

Source

const ZERO: Self

The zero value of this data type.

Source

const ONE: Self

The one value of this data type.

Required Associated Types§

Source

type Abs: Number

The absolute value type of this Number.

Required Methods§

Source

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Raise this value to the power of the given exponent.

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 Number for f32

Source§

const ONE: Self = 1.

Source§

const ZERO: Self = 0.

Source§

type Abs = f32

Source§

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Source§

impl Number for f64

Source§

const ONE: Self = 1.

Source§

const ZERO: Self = 0.

Source§

type Abs = f64

Source§

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Source§

impl Number for i8

Source§

const ONE: Self = 1

Source§

const ZERO: Self = 0

Source§

type Abs = i8

Source§

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Source§

impl Number for i16

Source§

const ONE: Self = 1

Source§

const ZERO: Self = 0

Source§

type Abs = i16

Source§

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Source§

impl Number for i32

Source§

const ONE: Self = 1

Source§

const ZERO: Self = 0

Source§

type Abs = i32

Source§

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Source§

impl Number for i64

Source§

const ONE: Self = 1

Source§

const ZERO: Self = 0

Source§

type Abs = i64

Source§

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Source§

impl Number for u8

Source§

const ONE: Self = 1

Source§

const ZERO: Self = 0

Source§

type Abs = u8

Source§

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Source§

impl Number for u16

Source§

const ONE: Self = 1

Source§

const ZERO: Self = 0

Source§

type Abs = u16

Source§

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Source§

impl Number for u32

Source§

const ONE: Self = 1

Source§

const ZERO: Self = 0

Source§

type Abs = u32

Source§

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Source§

impl Number for u64

Source§

const ONE: Self = 1

Source§

const ZERO: Self = 0

Source§

type Abs = u64

Source§

fn abs(self) -> Self::Abs

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 pow(self, exp: Self) -> Self

Implementors§