#complex-numbers #arithmetic-operations #real-number #rust

complexible

A minimal and user-friendly Rust library complex-number operations, bringing the joy of complex mathematics to Rustaceans everywhere!

3 releases

0.2.4 Apr 24, 2023
0.2.3 Apr 23, 2023
0.2.2 Apr 22, 2023
0.2.1 Apr 22, 2023
0.2.0 Apr 22, 2023

#1674 in Math

Download history 1/week @ 2024-07-21 10/week @ 2024-07-28 2/week @ 2024-10-13 51/week @ 2024-11-03

53 downloads per month

MIT license

32KB
246 lines

Complexible: A Rust Library for Complex-Number Operations

Complexible is a minimal and user-friendly Rust library for complex-number operations, bringing the joy of complex mathematics to Rustaceans everywhere! Designed with simplicity and ease-of-use in mind, Complexible offers a range of functionality to help you work with complex numbers in your Rust projects.

Features 🎁

  • Complex numbers support:
    • Representation of complex numbers in Cartesian (CartesianComplexNumber) and polar (PolarComplexNumber) forms
    • Conversion between Cartesian and polar forms
    • Creation of complex numbers from real numbers
  • Angle representation:
    • Angle representation using Angle, Radian, and Degree structs
  • Basic arithmetic operations on complex numbers:
    • Addition
    • Subtraction
    • Multiplication (complex and scalar)
    • Division
  • Complex number properties and operations:
    • Real part
    • Imaginary part
    • Magnitude (absolute value)
    • Angle (argument) in radians and degrees
    • Natural logarithm (ln)
    • Logarithm with arbitrary base
    • Logarithm base 10
    • Power (exponentiation)
    • Nth root

Installation 🪄

cargo add complexible

Usage 💡

Here's a quick example to get you started:

use complexible::complex_numbers::*;

fn main() {
    let a = ComplexNumber::from_cartesian(3.0, 4.0);

    let angle = Angle::from_radians(0.927); 
    let b = ComplexNumber::from_polar(5.0, angle);

    let sum = a.add(&b);
    let product = a.mul(&b); 

    println!("Sum: {}", sum);
    println!("Product: {}", product);
}

For more examples and detailed documentation, please refer to the API documentation.

Quick Tour 🚀

To get a quick tour of complex numbers and the functions of this library, you can refer to this section of DSP for All library.

Contributing ✍🏻

We welcome contributions! If you'd like to help improve Complexible, feel free to submit a pull request on GitHub. Please make sure to follow the existing coding style and add tests for any new features or bug fixes.

License 📜

Complexible is released under the MIT license.

No runtime deps