vector_operations

Crates.iovector_operations
lib.rsvector_operations
version1.1.0
sourcesrc
created_at2024-11-07 11:24:59.74376
updated_at2024-11-07 12:18:12.743413
descriptionA collection of vector operations for Rust.
homepage
repositoryhttps://github.com/Kai-Smith/vector_operations
max_upload_size
id1439685
size7,029
Kai Smith (KaiCodesWithGithub)

documentation

README

Vector Operations

This is a collection of vector operations for Rust.

Usage

To use this crate, add the following to your Cargo.toml file:

[dependencies]
vector_operations = "0.1.0"

Then, add this to your crate root:

use vector_operations::*;

Examples

Addition

let a = vec![1, 2, 3];
let b = vec![4, 5, 6];

let c = add(a, b);

assert_eq!(c, vec![5, 7, 9]);

Subtraction

let a = vec![1, 2, 3];
let b = vec![4, 5, 6];

let c = sub(a, b);

assert_eq!(c, vec![-3, -3, -3]);

Scaling

let a = vec![1, 2, 3];
let b = 2;

let c = scale(a, b);

assert_eq!(c, vec![2, 4, 6]);

Matrix-Vector Multiplication

let a = vec![
    vec![1, 2, 3],
    vec![4, 5, 6],
    vec![7, 8, 9],
];
let b = vec![1, 2, 3];

let c = mat_vec_mul(a, b);

assert_eq!(c, vec![30, 36, 42]);
Commit count: 0

cargo fmt