pp from upstream
Added high performance contiguity check.
Merge pull request #381 from jlaura/weights

Weights