added square-matrix checking in cachematrix.R