Skip to content

A Half Matrix implementation. Like a normal matrix, but you only store half of it. Also it only contains bools.

License

Notifications You must be signed in to change notification settings

AnneKitsune/half-matrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Support an Open Source Developer! ♥️

Become a patron

Half Matrix

A Half Matrix implementation. Also called a triangular matrix. Like a normal matrix, but you only store half of it.

Used to define relations between two elements of the same set.

This can be used to represent graphs (an edge between point A and B). It can also be used to represent associations (group A should have physical collisions enabled with group A and group B).

Usage

Cargo.toml:

[dependencies]
half_matrix = "*"

Code:

// 3x3
//
//  012
// 2oxo
// 1xx
// 0o

let mut m = HalfMatrix::new(3);
m.enable(2, 0);
m.enable(2, 2);
m.enable(0, 0);

assert!(m.contains(2,0));
assert!(m.contains(2,2));
assert!(m.contains(0,0));

assert!(!m.contains(1,0));
assert!(!m.contains(1,1));
assert!(!m.contains(2,1));

About

A Half Matrix implementation. Like a normal matrix, but you only store half of it. Also it only contains bools.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages