Optical potential method of calculating resonance energies and widths