[][src]Trait mathru::algebra::abstr::Sign

pub trait Sign: Sized + Neg<Output = Self> {
    fn sign(&self) -> Self;
fn abs(&self) -> Self;
fn is_positive(&self) -> bool;
fn is_negative(&self) -> bool; }

Sign trait

Required methods

fn sign(&self) -> Self

Returns the sign of a number

Param

Return

-1 if self < 0 0 if self = 0 1 if self > 0

fn abs(&self) -> Self

fn is_positive(&self) -> bool

fn is_negative(&self) -> bool

Loading content...

Implementations on Foreign Types

impl Sign for i8[src]

impl Sign for i16[src]

impl Sign for i32[src]

impl Sign for i64[src]

impl Sign for i128[src]

impl Sign for f32[src]

impl Sign for f64[src]

Loading content...

Implementors

impl<T> Sign for Vector<T> where
    T: Field + Scalar
[src]

impl<T> Sign for Complex<T> where
    T: Real
[src]

fn abs(&self) -> Self[src]

Absolute value of the complex number

Example

use mathru::{
    algebra::abstr::{cast::ToPrimitive, Sign},
    num::Complex,
};

let a: Complex<f64> = Complex::new(1.0, 2.0);
let refer: f64 = (5.0_f64).sqrt();
assert_eq!(refer, a.abs().to_f64());
Loading content...