Generalized spectral decomposition method applied to infrared, ultraviolet, and atomic emission spectrometry