The kinship matrix: inferring the kinship structure of a population from its demography