Preliminary implementation of matrix library