Any dimension

This pull request allows the method to calculate to any dimension.