Skip to content
Complex Numbers in Rust
Rust
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
Cargo.lock
Cargo.toml
README.md

README.md

Complex numbers in Rust

on Rust (stable 1.38)

for types like Complex32, Complex64 or even Complex<i28>

Part of blog post

    extern crate complex;

    fn main() {
        let lo = complex::Complex32::new(3.0, 3.0);
        let la = complex::Complex32::new(3.0, 3.0);

        println!("ADD: {}", lo + la);
        println!("MULT: {}", lo * la);
        println!("DOT Product: ({}).({}) = {}", lo, la, lo.dot_product(la));
        println!("Conjugate: {}", lo.conjugate());
    }
    ADD: 6+6i
    MULT: 0+18i
    DOT Product: (3+3i).(3+3i) = 0
    Conjugate: 3-3i
You can’t perform that action at this time.