mirror of
				https://github.com/fjosw/pyerrors.git
				synced 2025-10-31 15:55:45 +01:00 
			
		
		
		
	refactor: calculation of permutations in correlator module simplified.
This commit is contained in:
		
					parent
					
						
							
								ffdda97c65
							
						
					
				
			
			
				commit
				
					
						0e073da5c6
					
				
			
		
					 1 changed files with 2 additions and 14 deletions
				
			
		|  | @ -1,4 +1,5 @@ | ||||||
| import warnings | import warnings | ||||||
|  | from itertools import permutations | ||||||
| import numpy as np | import numpy as np | ||||||
| import autograd.numpy as anp | import autograd.numpy as anp | ||||||
| import matplotlib.pyplot as plt | import matplotlib.pyplot as plt | ||||||
|  | @ -1057,7 +1058,7 @@ def _sort_vectors(vec_set, ts): | ||||||
|         if vec_set[t] is None: |         if vec_set[t] is None: | ||||||
|             sorted_vec_set.append(None) |             sorted_vec_set.append(None) | ||||||
|         elif not t == ts: |         elif not t == ts: | ||||||
|             perms = permutation([i for i in range(N)]) |             perms = [list(o) for o in permutations([i for i in range(N)], N)] | ||||||
|             best_score = 0 |             best_score = 0 | ||||||
|             for perm in perms: |             for perm in perms: | ||||||
|                 current_score = 1 |                 current_score = 1 | ||||||
|  | @ -1075,19 +1076,6 @@ def _sort_vectors(vec_set, ts): | ||||||
|     return sorted_vec_set |     return sorted_vec_set | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def permutation(lst):  # Shamelessly copied |  | ||||||
|     if len(lst) == 1: |  | ||||||
|         return [lst] |  | ||||||
|     ll = [] |  | ||||||
|     for i in range(len(lst)): |  | ||||||
|         m = lst[i] |  | ||||||
|         remLst = lst[:i] + lst[i + 1:] |  | ||||||
|         # Generating all permutations where m is first |  | ||||||
|         for p in permutation(remLst): |  | ||||||
|             ll.append([m] + p) |  | ||||||
|     return ll |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def _GEVP_solver(Gt, G0):  # Just so normalization an sorting does not need to be repeated. Here we could later put in some checks | def _GEVP_solver(Gt, G0):  # Just so normalization an sorting does not need to be repeated. Here we could later put in some checks | ||||||
|     sp_val, sp_vecs = scipy.linalg.eig(Gt, G0) |     sp_val, sp_vecs = scipy.linalg.eig(Gt, G0) | ||||||
|     sp_vecs = [sp_vecs[:, np.argsort(sp_val)[-i]] for i in range(1, sp_vecs.shape[0] + 1)] |     sp_vecs = [sp_vecs[:, np.argsort(sp_val)[-i]] for i in range(1, sp_vecs.shape[0] + 1)] | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue