mathlab 0.3.4

A Powerful Math Library for Rust
Documentation

MathLab

A Powerful Math Library for Rust

Install

Run the following Cargo command in your project directory:

cargo add mathlab

or

Add the following line to your Cargo.toml file with the specified version, then run cargo build:

mathlab = "MAJOR.MINOR.PATCH"

Changelog

github

https://github.com/dr-montasir/mathlab/blob/master/CHANGELOG.md

Usage

// example

use mathlab::math;

fn main() {
    let abs = math::abs(-2.0);
    let add = math::add(0.1, 0.2);
    let add_f64 = math::add(0.1, 0.2) as f64;
    let add_f32 = math::add(0.1, 0.2) as f32;

    println!("{}", abs); // 2
    println!("{}", add); // 0.30000000000000004
    println!("{}", add_f64); // 0.30000000000000004
    println!("{}", add_f32); // 0.3

    println!(
        "{:?}",
        math::subt_vec_vec(
            &[0.1, 0.2, 0.3], &[0.3, 0.2, 0.1]
        )
    ); // [-0.19999999999999998, 0.0, 0.19999999999999998]

    println!(
        "{:?}",
        math::fround_vec(
            &math::subt_vec_vec(&[0.1, 0.2, 0.3], &[0.3, 0.2, 0.1]
        ))
    ); // [-0.2, 0.0, 0.2]

    println!(
        "{:?}",
        math::f64_to_f32_vec(
            &math::subt_vec_vec(&[0.1, 0.2, 0.3], &[0.3, 0.2, 0.1]
        ))
    ); // [-0.2, 0.0, 0.2]
}

or

// example

use mathlab::math::{
    abs, add, f64_to_f32_vec, fround_vec, subt_vec_vec
};

fn main() {
    let my_abs = abs(-2.0);
    let my_add = add(0.1, 0.2);
    let my_add_f64 = add(0.1, 0.2) as f64;
    let my_add_f32 = add(0.1, 0.2) as f32;

    println!("{}", my_abs); // 2
    println!("{}", my_add); // 0.30000000000000004
    println!("{}", my_add_f64); // 0.30000000000000004
    println!("{}", my_add_f32); // 0.3

    println!(
        "{:?}",
        subt_vec_vec(
            &[0.1, 0.2, 0.3], &[0.3, 0.2, 0.1]
        )
    ); // [-0.19999999999999998, 0.0, 0.19999999999999998]

    println!(
        "{:?}",
        fround_vec(
            &subt_vec_vec(&[0.1, 0.2, 0.3], &[0.3, 0.2, 0.1]
        ))
    ); // [-0.2, 0.0, 0.2]

    println!(
        "{:?}",
        f64_to_f32_vec(
            &subt_vec_vec(&[0.1, 0.2, 0.3], &[0.3, 0.2, 0.1]
        ))
    ); // [-0.2, 0.0, 0.2]
}

Documentation

https://docs.rs/mathlab

MathLab :

A Powerful Math Library for Rust

Modules

1. constants

constant constant constant constant
E INF_F32 INF_F64 LN2
LN10 LOG2E LOG10E NAN_F32
NAN_F64 NINF_F32 NINF_F64 PHI
PI TAU

2. functions

function function function function
monolist
function function function function
abs add ceil deg_to_rad
divi f64_to_f32 fact floor
fround gamma i64_to_f64 inv
is_inf_f32 is_inf_f64 is_nan_f32 is_nan_f64
is_ninf_f32 is_ninf_f64 mult pow
rad_to_deg round sign subt
u64_to_f64
function function function function
abs_vec ceil_vec deg_to_rad_vec f64_to_f32_vec
fact_vec floor_vec fround_vec gamma_vec
i64_to_f64_vec inv_vec rad_to_deg_vec round_vec
sign_vec u64_to_f64_vec
function function function function
add_num_vec divi_num_vec mult_num_vec pow_num_vec
subt_num_vec
function function function function
add_vec_num divi_vec_num mult_vec_num pow_vec_num
subt_vec_num
function function function function
add_vec_vec divi_vec_vec mult_vec_vec pow_vec_vec
subt_vec_vec

3. math

The math module contains all constants and functions.

All Items

crates.io

docs.rs

license

github