pub struct CalculatorComplex {
    pub re: CalculatorFloat,
    pub im: CalculatorFloat,
}
Expand description

Struct CalculatorComplex.

Fields§

§re: CalculatorFloat

CalculatorFloat value of real part of CalculatorComplex

§im: CalculatorFloat

CalculatorFloat value of imaginary part of CalculatorComplex

Implementations§

source§

impl CalculatorComplex

source

pub const ZERO: CalculatorComplex = _

Constant zero for CalculatorComplex

source

pub const ONE: CalculatorComplex = _

Constant one for CalculatorFloat

source

pub const I: CalculatorComplex = _

Constant imaginary number for CalculatorFloat

source

pub fn new<T1, T2>(re: T1, im: T2) -> Selfwhere
T1: Into<CalculatorFloat>,
T2: Into<CalculatorFloat>,

Return CalculatorComplex constructed form pair of real values.

Arguments
  • re - Real part given as type that can be converted to CalculatorFloat
  • im - Imaginary part given as type that can be converted to CalculatorFloat
source

pub fn arg(&self) -> CalculatorFloat

Return phase of complex number x: arg(x).

source

pub fn norm_sqr(&self) -> CalculatorFloat

Return square norm of complex number x: |x|^2=x.re^2+x.im^2.

source

pub fn norm(&self) -> CalculatorFloat

Return norm of complex number x: |x|=(x.re^2+x.im^2)^1/2.

source

pub fn abs(&self) -> CalculatorFloat

Return absolute value of complex number x: |x|=(x.re^2+x.im^2)^1/2.

source

pub fn conj(&self) -> CalculatorComplex

Return complex conjugate of x: x*=x.re-i*x.im.

source

pub fn isclose<T>(&self, other: T) -> boolwhere
T: Into<CalculatorComplex>,

Return true when x is close to y.

source§

impl CalculatorComplex

Implement Inverse 1/x for CalculatorFloat.

source

pub fn recip(&self) -> CalculatorComplex

Returns Inverse 1/x for CalculatorFloat.

Trait Implementations§

source§

impl<T> Add<T> for CalculatorComplexwhere
T: Into<CalculatorComplex>,

Implement + for CalculatorComplex and generic type T.

Arguments

  • other - Any type T for which CalculatorComplex::From trait is implemented
§

type Output = CalculatorComplex

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T> AddAssign<T> for CalculatorComplexwhere
T: Into<CalculatorComplex>,

Implement += for CalculatorComplex and generic type T.

Arguments

  • other - Any type T for which CalculatorComplex::From trait is implemented
source§

fn add_assign(&mut self, other: T)

Performs the += operation. Read more
source§

impl Clone for CalculatorComplex

source§

fn clone(&self) -> CalculatorComplex

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CalculatorComplex

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CalculatorComplex

Implement Default value 0 for CalculatorComplex.

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for CalculatorComplex

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for CalculatorComplex

Implement Display trait for CalculatorComplex.

Allows use of simple text formating

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Div<T> for CalculatorComplexwhere
T: Into<CalculatorComplex>,

Implement * for CalculatorComplex and generic type T.

Arguments

  • other - Any type T for which CalculatorComplex::From trait is implemented
§

type Output = CalculatorComplex

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T> DivAssign<T> for CalculatorComplexwhere
T: Into<CalculatorComplex>,

Implement *= for CalculatorComplex and generic type T.

Arguments

  • other - Any type T for which CalculatorComplex::From trait is implemented
source§

fn div_assign(&mut self, other: T)

Performs the /= operation. Read more
source§

impl<'a> From<&'a CalculatorComplex> for CalculatorComplex

Initialize CalculatorComplex from CalculatorComplex reference &CalculatorComplex.

Returns

  • CalculatorFloat
source§

fn from(item: &'a CalculatorComplex) -> Self

Converts to this type from the input type.
source§

impl<T1, T2> From<(T1, T2)> for CalculatorComplexwhere
T1: Into<CalculatorFloat>,
T2: Into<CalculatorFloat>,

I

source§

fn from(input: (T1, T2)) -> Self

Converts to this type from the input type.
source§

impl From<Complex<f64>> for CalculatorComplex

Initialize CalculatorComplex from Complex.

Returns

  • CalculatorComplex
source§

fn from(item: Complex<f64>) -> Self

Converts to this type from the input type.
source§

impl<T> From<T> for CalculatorComplexwhere
CalculatorFloat: From<T>,

Initialize CalculatorComplex from type that can be cast to CalculatorFloat.

Returns

  • CalculatorComplex
source§

fn from(item: T) -> Self

Converts to this type from the input type.
source§

impl<T> Mul<T> for CalculatorComplexwhere
T: Into<CalculatorComplex>,

Implement * for CalculatorComplex and generic type T.

Arguments

  • other - Any type T for which CalculatorComplex::From trait is implemented
§

type Output = CalculatorComplex

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T> MulAssign<T> for CalculatorComplexwhere
T: Into<CalculatorComplex>,

Implement *= for CalculatorComplex and generic type T.

Arguments

  • other - Any type T for which CalculatorComplex::From trait is implemented
source§

fn mul_assign(&mut self, other: T)

Performs the *= operation. Read more
source§

impl Neg for CalculatorComplex

Implement minus sign for CalculatorComplex.

§

type Output = CalculatorComplex

The resulting type after applying the - operator.
source§

fn neg(self) -> Self

Performs the unary - operation. Read more
source§

impl PartialEq<CalculatorComplex> for CalculatorComplex

source§

fn eq(&self, other: &CalculatorComplex) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for CalculatorComplex

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>where
S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> Sub<T> for CalculatorComplexwhere
T: Into<CalculatorComplex>,

Implement - for CalculatorComplex and generic type T.

Arguments

  • other - Any type T for which CalculatorComplex::From trait is implemented
§

type Output = CalculatorComplex

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T> SubAssign<T> for CalculatorComplexwhere
T: Into<CalculatorComplex>,

Implement -= for CalculatorComplex and generic type T.

Arguments

  • other - Any type T for which CalculatorComplex::From trait is implemented
source§

fn sub_assign(&mut self, other: T)

Performs the -= operation. Read more
source§

impl Sum<CalculatorComplex> for CalculatorComplex

Implements summing over an iterator of CalculatorComplex

Arguments

  • iter - Any iterator over CalculatorComplex items
source§

fn sum<I: Iterator<Item = CalculatorComplex>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl TryFrom<CalculatorComplex> for Complex<f64>

Try turning CalculatorComplex into Complex float.

Returns

  • f64

Panics

Panics when CalculatorFloat contains symbolic string value

§

type Error = CalculatorError

The type returned in the event of a conversion error.
source§

fn try_from(value: CalculatorComplex) -> Result<Self, CalculatorError>

Performs the conversion.
source§

impl TryFrom<CalculatorComplex> for f64

Try turning CalculatorComplex into f64 float.

Returns

  • f64

Panics

Panics when CalculatorFloat contains symbolic string value

§

type Error = CalculatorError

The type returned in the event of a conversion error.
source§

fn try_from(value: CalculatorComplex) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl StructuralPartialEq for CalculatorComplex

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere
T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere
T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,