New method for the calculation of atomic phase shifts: Application to extended x-ray absorption fine structure (EXAFS) in molecules and crystals