matrix-math

Crates.iomatrix-math
lib.rsmatrix-math
version0.1.1
sourcesrc
created_at2024-05-19 19:53:46.700854
updated_at2024-05-19 19:58:59.42585
descriptionA Rust library for Mathematical matrices.
homepagehttps://github.com/1kill2steal/matrix-rs
repositoryhttps://github.com/1kill2steal/matrix-rs
max_upload_size
id1245178
size19,029
1K2S (1Kill2Steal)

documentation

README

Matrix-math

Build IconDocs IconVersion IconLicense Icon

A simple Rust library/CLI app that allows for basic work with mathematical Matrices.

Getting started

use matrix::prelude::*;

fn interactive_matrices_example() -> Result<(), Error> {
    let matrix1 = matrix(1, None, None);

    // By calling matrix2 with the length parameters of matrix1 like so. Doing the operations
    // unchecked is **SAFE**.
    let matrix2 = matrix(2, Some(matrix1.len()), Some(matrix1[0].len()));

    let sum = matrix_operation_unchecked(MatrixOperation::Addition, &matrix1, &matrix2);
    println!("Sum:\n{:#?}", sum);

    let diff = matrix_operation_unchecked(MatrixOperation::Subtraction, &matrix1, &matrix2);
    println!("Difference:\n{:#?}", diff);

    let product = matrix_operation_unchecked(MatrixOperation::Multiplication, &matrix1, &matrix2);
    println!("Product:\n{:#?}", product);

    Ok(())
}

fn main() -> Result<(), Error> {
    let args = Args::parse();

    if args.interactive {
        interactive_matrices_example()?;
    }

    Ok(())
}
Commit count: 36

cargo fmt