Completed implementing coarse integration of perm in c++