Implements cachematrix.R.