Trait tea_dtype::Number

source ·
pub trait Number:
    Copy
    + Send
    + Sync
    + IsNone
    + Sized
    + Default
    + Num
    + AddAssign
    + SubAssign
    + MulAssign
    + DivAssign
    + PartialOrd
    + MulAdd
    + Cast<f64>
    + Cast<f32>
    + Cast<usize>
    + Cast<i32>
    + Cast<i64>
    + 'static {
Show 17 methods // Required methods fn min_() -> Self; fn max_() -> Self; fn abs(self) -> Self; // Provided methods fn ceil(self) -> Self { ... } fn floor(self) -> Self { ... } fn min_with(self, other: Self) -> Self { ... } fn max_with(self, other: Self) -> Self { ... } fn f32(self) -> f32 { ... } fn f64(self) -> f64 { ... } fn i32(self) -> i32 { ... } fn i64(self) -> i64 { ... } fn usize(self) -> usize { ... } fn fromas<U>(v: U) -> Self where U: Number + Cast<Self>, Self: 'static { ... } fn to<T: Number>(self) -> T where Self: Cast<T> { ... } fn kh_sum(self, v: Self, c: &mut Self) -> Self { ... } fn n_add(self, other: Self, n: &mut usize) -> Self { ... } fn n_prod(self, other: Self, n: &mut usize) -> Self { ... }
}
Expand description

A trait representing numeric types with various operations and conversions.

This trait combines several other traits and provides additional functionality for numeric types. It includes operations for arithmetic, comparison, conversion, and special numeric functions.

§Type Constraints

The type implementing this trait must satisfy the following constraints:

  • Copy: The type can be copied bit-for-bit.
  • Send: The type can be safely transferred across thread boundaries.
  • Sync: The type can be safely shared between threads.
  • IsNone: The type has a concept of a “none” value.
  • Sized: The type has a known size at compile-time.
  • Default: The type has a default value.
  • Num: The type supports basic numeric operations.
  • AddAssign, SubAssign, MulAssign, DivAssign: The type supports compound assignment operations.
  • PartialOrd: The type can be partially ordered.
  • MulAdd: The type supports fused multiply-add operations.
  • Cast<f64>, Cast<f32>, Cast<usize>, Cast<i32>, Cast<i64>: The type can be cast to these numeric types.
  • 'static: The type has a static lifetime.

Required Methods§

source

fn min_() -> Self

Returns the minimum value of the data type.

source

fn max_() -> Self

Returns the maximum value of the data type.

source

fn abs(self) -> Self

Computes the absolute value of the number.

Provided Methods§

source

fn ceil(self) -> Self

Computes the ceiling of the number.

For integer types, this is typically the identity function.

source

fn floor(self) -> Self

Computes the floor of the number.

For integer types, this is typically the identity function.

source

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

Returns the minimum of self and other.

source

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

Returns the maximum of self and other.

source

fn f32(self) -> f32

Casts the number to f32.

source

fn f64(self) -> f64

Casts the number to f64.

source

fn i32(self) -> i32

Casts the number to i32.

source

fn i64(self) -> i64

Casts the number to i64.

source

fn usize(self) -> usize

Casts the number to usize.

source

fn fromas<U>(v: U) -> Self
where U: Number + Cast<Self>, Self: 'static,

Creates a value of type Self using a value of type U using Cast.

source

fn to<T: Number>(self) -> T
where Self: Cast<T>,

Casts self to another type T using Cast.

source

fn kh_sum(self, v: Self, c: &mut Self) -> Self

Performs Kahan summation.

This method implements the Kahan summation algorithm, which helps reduce numerical error in the sum of a sequence of floating point numbers.

source

fn n_add(self, other: Self, n: &mut usize) -> Self

Conditionally adds other to self and increments n.

If other is not none, it adds other to self and increments n. Otherwise, it returns self unchanged.

source

fn n_prod(self, other: Self, n: &mut usize) -> Self

Conditionally multiplies self by other and increments n.

If other is not none, it multiplies self by other and increments n. Otherwise, it returns self unchanged.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Number for f32

source§

fn min_() -> f32

source§

fn max_() -> f32

source§

fn ceil(self) -> Self

source§

fn floor(self) -> Self

source§

fn abs(self) -> Self

source§

impl Number for f64

source§

fn min_() -> f64

source§

fn max_() -> f64

source§

fn ceil(self) -> Self

source§

fn floor(self) -> Self

source§

fn abs(self) -> Self

source§

impl Number for i32

source§

fn min_() -> i32

source§

fn max_() -> i32

source§

fn abs(self) -> Self

source§

impl Number for i64

source§

fn min_() -> i64

source§

fn max_() -> i64

source§

fn abs(self) -> Self

source§

impl Number for u64

source§

fn min_() -> u64

source§

fn max_() -> u64

source§

fn abs(self) -> Self

source§

impl Number for usize

source§

fn min_() -> usize

source§

fn max_() -> usize

source§

fn abs(self) -> Self

Implementors§