Crate ancomplex

source ·
Expand description

Provides easy to use, begginer frendly and python like complex numbers

§Examples

Create complex number

use ancomplex::*;
       
fn main() {
    let c = complex(1, 2);
    //               \  \
    //                \  \
    //                 \  Imaginary Part of complex number
    //                  \
    //                   \
    //                    Real Part of complex number
}   

Math operations

use ancomplex::*;
       
fn main() {
    let c = complex(1, 2);
    let k = complex(3, 4);

    println!("Sum of two complex numbers: {}", c+k);
    println!("Product of two complex numbers: {}", c*k);
    println!("Sub of two complex numbers: {}", c-k);
    println!("Div of two complex numbers: {}", c/k);
}

More complex functions

use ancomplex::*;

fn main() {
    let c = complex(4, 5);
    let k = complex(6, 7);

    println!("Conjugate of complex number: {}", c.conj());
}

Fancy printing

use ancomplex::*;

fn main() {
    let c = complex(4, 2);

    println!("{}", c); // Output: 4+2i
}

Structs§

  • struct for Complex numbers (a+bi)

Functions§

  • Function for init float32 complex number
  • Function for init float64 complex number
  • Function to init Complex struct (Recomed way to init complex numbers)

Type Aliases§

  • type alias for Float32 Complex number
  • type alias for Float64 Complex number