Implementation of matrix mathematics
