vector_operations 1.1.0

A collection of vector operations for Rust.
Documentation
  • Coverage
  • 80%
    4 out of 5 items documented4 out of 4 items with examples
  • Size
  • Source code size: 6.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.23 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • KaiCodesWithGithub

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]);