rustrix

Crates.iorustrix
lib.rsrustrix
version0.2.0
sourcesrc
created_at2024-01-21 06:52:30.168222
updated_at2024-08-07 12:17:43.569006
descriptionSupports macro and basic operations for matrix.
homepage
repositoryhttps://github.com/mk0218/rustrix
max_upload_size
id1107392
size12,265
Minkyoung Kim (mk0218)

documentation

README

Rustrix

Supports macro and basic operations for matrix.

Initialization

use rustrix::*;

let m = mx![
    1, 2, 3;
    4, 5, 6;
];

let (rows, cols, init) = (2, 3, 1);
let m1 = mx!(rows, cols; init);
let m2 = mx![
    1, 1, 1;
    1, 1, 1;
];

assert_eq!(m1, m2)

Add

use rustrix::*;

let m = mx!(2, 3; 2) + mx!(2, 3; 3);

Subtract

use rustrix::*;

let m = mx!(2, 3; 4) - mx!(2, 3; 1);

Dot product

use rustrix::*;

let m1 = mx![
    1, 1;
    2, 2;
];

let m2 = mx![
    1, 1, 1, 1;
    2, 2, 2, 2;
];

let m = m1 * m2;

Transpose

use rustrix::*;

let m1 = mx![
    1, 2;
    3, 4;
    5, 6;
];

let m2 = m1.tp();
let m3 = m1.transpose();

Scalar multiplication

use rustrix::*;

let m1 = mx![
    1, 2, 3;
    4, 5, 6;
];

let m2 = m1.mul_scalar(2);
Commit count: 8

cargo fmt