add 'memoize' option to cache kernel computations

This tries to speed up training by caching the kernel computation for each data pair to avoid re-computation. To enable it add `memoize: true` to the training options.

I tried it on ~1000 vectors of length ~1000 and the speedup was about 10% on both linear and rbf kernels, so not a huge amount.