fix #1440 speed up clustering by avoiding Math.pow