Added SerializeToString to matrix functions.