Changed the implementation of moments.

Resolved the bug of moments. Optimized the kernel.(only float and double are supported).