Cache numSegments and numSynapses for performance

Fixes https://github.com/numenta/nupic.core/issues/229.