Trait ComplexNumber

Source
pub trait ComplexNumber: ScientificNumber {
    type RealPart: RealNumber;

Show 13 methods // Required methods fn re(&self) -> Self::RealPart; fn im(&self) -> Self::RealPart; fn new(re: Self::RealPart, im: Self::RealPart) -> Self; fn conj(self) -> Self; fn abs(self) -> Self::RealPart; fn arg(self) -> Self::RealPart; fn to_polar(self) -> (Self::RealPart, Self::RealPart); fn from_polar(r: Self::RealPart, theta: Self::RealPart) -> Self; fn exp(self) -> Self; fn ln(self) -> Self; fn powc(self, exp: Self) -> Self; fn powf(self, exp: Self::RealPart) -> Self; fn sqrt(self) -> Self;
}
Expand description

A trait for complex number types

Required Associated Types§

Source

type RealPart: RealNumber

The real part of the complex number

Required Methods§

Source

fn re(&self) -> Self::RealPart

Returns the real part of the complex number

Source

fn im(&self) -> Self::RealPart

Returns the imaginary part of the complex number

Source

fn new(re: Self::RealPart, im: Self::RealPart) -> Self

Create a new complex number from real and imaginary parts

Source

fn conj(self) -> Self

Returns the complex conjugate

Source

fn abs(self) -> Self::RealPart

Returns the magnitude (absolute value)

Source

fn arg(self) -> Self::RealPart

Returns the argument (phase)

Source

fn to_polar(self) -> (Self::RealPart, Self::RealPart)

Returns the complex number in exponential form (r, theta)

Source

fn from_polar(r: Self::RealPart, theta: Self::RealPart) -> Self

Creates a complex number from polar coordinates

Source

fn exp(self) -> Self

Exponential function

Source

fn ln(self) -> Self

Natural logarithm

Source

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

Power function with complex exponent

Source

fn powf(self, exp: Self::RealPart) -> Self

Power function with real exponent

Source

fn sqrt(self) -> Self

Square root

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.

Implementors§