def repmat(x, r, c):
if sps.issparse(x):<EOL><INDENT>row = sps.hstack([x for _ in range(c)])<EOL>return sps.vstack([row for _ in range(r)], format=x.format)<EOL><DEDENT>else: return np.matlib.repmat(x, r, c)<EOL>
repmat(x, r, c) is equivalent to numpy.matlib.repmat(x, r, c) except that it works correctly for
  sparse matrices.