Skip to content

It's quite funny how poorly implemented this is. Libraries that do these operations usually work in highly parallelized environments (sometimes entirely on the GPU). But the beauty of doing it manually is the learning curve. (Vec Vec double heap indirections are a crime against humanity)

License

Notifications You must be signed in to change notification settings

1Git2Clone/matrix-math-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Matrix-math

GH_Build IconBuild 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::<f32>(1, None, None);

    // By calling matrix2 with the length parameters of matrix1 like so. Doing the operations
    // unchecked is **SAFE**.
    let matrix2 = matrix::<f32>(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);

    let division = matrix_operation_unchecked(MatrixOperation::Division, &matrix1, &matrix2);
    println!("Results from division:\n{:#?}", division);

    Ok(())
}

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

    if args.interactive {
        interactive_matrices_example()?;
    }

    Ok(())
}

About

It's quite funny how poorly implemented this is. Libraries that do these operations usually work in highly parallelized environments (sometimes entirely on the GPU). But the beauty of doing it manually is the learning curve. (Vec Vec double heap indirections are a crime against humanity)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages