changed check of dimension to check of length
implemented energy_assignment function:
Merge pull request #1 from fgregg/master

Change dimension check