Porting matrix class.