Magnetostriction in transversely isotropic hexagonal crystals