template const NRVec inversepermutation(const NRVec &p, const T offset=0) { int n=p.size(); NRVec q(n); if(!offset) for(int i=0; i