(defun spectra-compare (s1 s2 &optional (eps 1e-2)) "Compare spectrum multisets S1 and S2 by using convolution and return its largest multiplicity and corresponding element." (let ((diffs (make-hash-table))) (dolist (x s1) (dolist (y s2) (let ((d (truncate (/ (- x y) eps)))) (incf (gethash d diffs 0))))) (loop with best-d = 0 with best-m = 0 for d being each hash-key of diffs using (hash-value m) when (> m best-m) do (setf best-d d best-m m) finally (return (values best-m (* best-d eps))))))