[GAP Forum] Re: Complex numbers (again) and Lie closure

mim_ at op.pl mim_ at op.pl
Mon Jun 30 08:29:59 BST 2008

Hello Knut,

I am using following function for commuting the set of matrices - see below function commute3. It returns two lists: first is commuted set of matrices, second is list of indexes.  List of indexes is useful for using next time to obtain basis of Lie algebra quicker.

My function is quicker than GAP "Basis" function. Here is example of usage:
     [[0,1], [1,0]]];

# Loop execute 3 times, log is printed, if more that 20-dimensional then quit.
aa:=commute3(ms, [], 2, 3, true, 20);

# If you need to commute more then do following
bb:=commute3(aa[1], aa[2], 3, 3, true, 20);

In GAP we could do it like this.
alg:=LieAlgebra(Rationals, ms);
Print("Dimension of alg is ", dim, "\n");

But sometimes this Dimension function is very slow and sometimes return error. Then you have to do first Basis(alg) and then Dimension(). But Basis() function is also slow.

This is my experience of working with Lie matrix algebras.


# Added more parameteres: a=set of matrices generators, 
#                         ind= set of indexes to show which commutators form basis
#                         start=index starting from which second base element is commuted - to save time
#                         times= how many times loop should be executed
#                         print_log=prints log while commuting
#                         max_no=quit when length of result basis is longer then max_no

# For now it doesn't work for quaternions !
commute3:=function(a, ind, start, times, print_log, max_no)
  local i,j,b,bb,x,count, out_ind, k;
  if times=0 then return [a,ind]; fi;
  out_ind := ind;
  for i in [1..count-1] do
   k:=Maximum(start, i+1);
   for j in [k..count] do
      if not IsContainedInSpan(bb,x) then   
         Add(b,x);   Add(out_ind, [i,j]);
         CloseMutableBasis(bb,x);    # This should work quicker than MutableBasis(b);
         if print_log then   Print("[",i,",",j,"]"," added - dim=",Length(b),"\n"); fi;
      if Length(b)>max_no then return [b,out_ind]; fi;
  if print_log then Print("Now length of basis b is ",Length(b),"\n");  fi;
  if times>1 then
      return commute3(b,out_ind, count+1, times-1, print_log, max_no);      
  return [b, out_ind];

More information about the Forum mailing list