Implements a few matrix algorithms