Extend SP to support N-dimensional topology

Fixes https://github.com/numenta/nupic.core/issues/121
Builds on https://github.com/numenta/nupic.core/pull/124 and https://github.com/numenta/nupic.core/pull/127