Matrix class with basic operations