implemented setMatrix