vecmat

Crates.io Docs.rs Travis CI Appveyor Codecov.io License

Low-dimensional vector and matrix structures and common operations for them

Documentation

Usage

```rust extern crate vecmat;

use vecmat::vec::; use vecmat::mat::;

fn main() { // Create vectors let mut va = Vec3::::new(); // filled with zeros let vb = Vec3::::from(1.0, 2.0, 3.0); // from values println!("{}, {}", va, vb);

// Vector access
va[1] = vb[0]; // read and write 
va[0] += 3.0; // add-assign
println!("{}", va);

// Vector products
println!("{}", 2.0*vb); // scalar-by-vector
println!("{}", va*vb); // component-wise
println!("{}", va.dot(vb)); // dot
println!("{}", va.cross(vb)); // cross

// Distance between two vectors
println!("{}", (va - vb).length());

// Create matrices
let mut ma = Mat3::<f64>::one(); // identity 3x3 matrix
let mb = Mat3x2::<f64>::from( // 3x2 matrix from values
    1.0, 2.0, 0.0,
    0.0,-1.0, 1.0,
);
println!("{},\n{}", ma, mb);

// Access matrix components
ma[(1,1)] = 2.0; // access by (i,j) indices
ma[(0,2)] = -3.0;
ma[(2,0)] = -1.0;
println!("{}", ma);

// Transpose matrix
println!("{}", mb.transpose());

// Matrix-vector product
println!("{}", mb.dot(vb));
println!("{}", va.dot(ma));

// Matrix-matrix product
println!("{}", mb.dot(ma));

// Outer product of vectors
println!("{}", va.outer(vb));

// Determinant and inverse matrix
println!("{}", ma.det());
println!("{}", ma.inverse());

} ```

Structs:

Features:

Linear algebra

Complex analysis

Transformations

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.