Class for matrix algebra