added supplied code sample, made simple edits plus a way to check for matrix equality