# HG changeset patch
# User Dan Christensen <jdc@uwo.ca>
# Date 1240969172 14400
# Node ID 9c4fea38b4c35b8fff068eddc544734a09539211
# Parent 5c0961ff033d04c42cc1d920b97d191b5ab44c0e
Greatly speed up sage.combinat.symmetric_group_algebra.e
The old code essentially reimplemented the multiplication in
the group algebra. The new code accumulates the symmetrizers
and antisymmetrizers separately, and then does one multiply
at the end. This probably results in the same number of
operations, but it avoids creating many intermediate objects,
so it is about 10x faster.
diff r 5c0961ff033d r 9c4fea38b4c3 sage/combinat/symmetric_group_algebra.py
a

b


428  428  permutation_options['mult'] = 'l2r' 
429  429  
430  430  if t in e_cache: 
431   res = e_cache[t] 
 431  res = e_cache[t] 
432  432  else: 
433  433  rs = t.row_stabilizer() 
434  434  cs = t.column_stabilizer() 
… 
… 

436  436  
437  437  QSn = SymmetricGroupAlgebra(QQ, n) 
438  438  
439   res = 0 
 439  sym = 0 
440  440  for h in rs: 
441   for v in cs: 
442   res += v.sign() * QSn( (h*v).list() ) 
 441  sym += QSn(h.list()) 
 442  antisym = 0 
 443  for v in cs: 
 444  antisym += v.sign() * QSn(v.list()) 
 445  res = antisym*sym 
443  446  e_cache[t] = res 
444  447  
445  448  permutation_options['mult'] = mult 