Matrix representations of semigroups