Added the implementation for matrix equality

Additionally, this commit includes the implementation of the write
method used for test implementation.