added model class, fixed bugs in matrix,copy constructor in matrix