Implement the kernel polynomial method (KPM).