*** empty log message ***
This commit is contained in:
		
							parent
							
								
									aa4fc240e0
								
							
						
					
					
						commit
						834437d870
					
				
							
								
								
									
										9
									
								
								permutation.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								permutation.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					template<typename T>
 | 
				
			||||||
 | 
					const NRVec<T> inversepermutation(const NRVec<T> &p, const T offset=0)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					int n=p.size();
 | 
				
			||||||
 | 
					NRVec<T> q(n);
 | 
				
			||||||
 | 
					if(!offset) for(int i=0; i<n; ++i) q[p[i]]=i;
 | 
				
			||||||
 | 
					else for(int i=0; i<n; ++i) q[p[i]-offset]=i+offset;
 | 
				
			||||||
 | 
					return q;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user