Skip to content

SirEelBiscuits/matrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Matrix.h

Build Status

The purpose of matrix is to provide a generic matrix, allowing for any data type for individual elements, so long as the requisite operators are defined on those types.

Notably, types which may be multiplied resulting in a different type work with Matrix.

Author

J Thatcher - @SirEelBiscuits - [email protected]

Prerequisites

  • A C++14 compatible compiler

Usage

To use the matrix, #include "matrix.h", and create matrices as needed:

using SuperGeneric::Matrix;
auto m = Matrix<float, 2, 2> { 1, 3, 5, 2 };

individual elements may be read and written via operator() like so:

auto x = 0u, y = 1u;
m(x, y) = 3.5f;

Addition, multiplication, and scalar operations are defined where valid, invalid operations, including multiplying matrices of inapproporiate dimensions, will produce compile errors.

There are functions to get the identity and zero matrices defined statically on square matrix types:

SuperGeneric::Matrix<float, 2, 2>::Identity();
SuperGeneric::Matrix<float, 3, 3>::Zero();

One can also retrieve the inverse of 1x1 and 2x2 matrices

m.Inverse()
//or
Invert(m);

Building Tests

The included tests can be built with the included makefile. make all test will build and run the tests.

Future Work

  • Make the matrix type mutable
  • Add inverse functions for order 3 and greater matrices

About

An especially generic matrix class

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published