matrix class and basic operations