abstracting matrix classes to support alternate implementations