Fixed permute mat

Split permute mat into different files and fixed an error in the bounds
checking of the map.