Updates to file to make it user-friendly and ability to cache matrices

I was uncomfortable with user having to create a special matrix to use
for caching, hence, put this together, where user inputs the matrix only
and the function does the rest.