ComplexScalarConstructors

Trait ComplexScalarConstructors 

Source
pub trait ComplexScalarConstructors: FpScalar<InnerType = Self::RawComplex> {
    type RawComplex: RawComplexTrait<RawReal = <Self::RealType as RealScalar>::RawReal>;

    // Required method
    fn try_new_complex(
        real: <Self::RawComplex as RawComplexTrait>::RawReal,
        imag: <Self::RawComplex as RawComplexTrait>::RawReal,
    ) -> Result<Self, <Self::RawComplex as RawScalarTrait>::ValidationErrors>;

    // Provided methods
    fn new_complex(real: Self::RealType, imag: Self::RealType) -> Self { ... }
    fn try_new_pure_real(
        real_part: <Self::RawComplex as RawComplexTrait>::RawReal,
    ) -> Result<Self, <Self::RawComplex as RawScalarTrait>::ValidationErrors> { ... }
    fn try_new_pure_imaginary(
        imag_part: <Self::RawComplex as RawComplexTrait>::RawReal,
    ) -> Result<Self, <Self::RawComplex as RawScalarTrait>::ValidationErrors> { ... }
    fn new_pure_real(real_part: Self::RealType) -> Self { ... }
    fn new_pure_imaginary(imag_part: Self::RealType) -> Self { ... }
}
Expand description

Trait for constructing complex scalar types from their raw components.

This trait provides methods for creating complex numbers from raw real and imaginary parts, as well as specialized constructors for purely real or purely imaginary numbers.

§Examples

use num_valid::ComplexNative64StrictFinite;
use num_valid::functions::ComplexScalarConstructors;

// Create a complex number from raw f64 values
let z = ComplexNative64StrictFinite::try_new_complex(3.0, 4.0).unwrap();

// Create a purely real number (imaginary part is zero)
let real_only = ComplexNative64StrictFinite::try_new_pure_real(5.0).unwrap();

// Create a purely imaginary number (real part is zero)
let imag_only = ComplexNative64StrictFinite::try_new_pure_imaginary(7.0).unwrap();

Required Associated Types§

Source

type RawComplex: RawComplexTrait<RawReal = <Self::RealType as RealScalar>::RawReal>

The raw underlying complex type (e.g., num::Complex<f64> or rug::Complex).

Required Methods§

Source

fn try_new_complex( real: <Self::RawComplex as RawComplexTrait>::RawReal, imag: <Self::RawComplex as RawComplexTrait>::RawReal, ) -> Result<Self, <Self::RawComplex as RawScalarTrait>::ValidationErrors>

Tries to create a new complex scalar from its raw real and imaginary parts.

Returns an error if either component fails validation (e.g., NaN, Infinity).

Provided Methods§

Source

fn new_complex(real: Self::RealType, imag: Self::RealType) -> Self

Creates a new complex scalar from its (validated) real and imaginary parts.

Source

fn try_new_pure_real( real_part: <Self::RawComplex as RawComplexTrait>::RawReal, ) -> Result<Self, <Self::RawComplex as RawScalarTrait>::ValidationErrors>

Tries to create a new complex scalar from a raw real part, with a zero imaginary part.

Source

fn try_new_pure_imaginary( imag_part: <Self::RawComplex as RawComplexTrait>::RawReal, ) -> Result<Self, <Self::RawComplex as RawScalarTrait>::ValidationErrors>

Tries to create a new complex scalar from a raw imaginary part, with a zero real part.

Source

fn new_pure_real(real_part: Self::RealType) -> Self

Source

fn new_pure_imaginary(imag_part: Self::RealType) -> Self

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 ComplexScalarConstructors for Complex<f64>

Implementors§