Implemented matrix calcs