Ab initio calculations for the elastic properties of magnesium under pressure