replaced factors computation by precomputed values, added kernel for
binary mode
Merge pull request #2881 from mlyashko:moments_opt