#############################################################################
##
#A  genVshow             CHEVIE library          Meinolf Geck & Frank L"ubeck
##
#Y  Copyright 1992--1993,  Lehrstuhl D f"ur Mathematik,    RWTH Aachen,   and
#Y                         IWR   der   Universit"at    Heidelberg,   Germany.
##
####################################################################
##
##  
## 
#H 1994/08/25  FL
#H Changed PrintValPhi to do something usefull with non polynomial values.
#H
#H 1994/08/05  FL
#H Mistypes in NrClasses and NrChars corrected.
#H
#H Added a function PrintValPhi 






Status:=proc(t)
   local nr;
   nr:=tablenumber(t);
   printf("\n");
   printf("Status of %a\n",t);
   printf("\n");
   printf("=======================================================\n");
## printf("Table number               : %a\n",nr);
   printf("Order                      : %a\n",t[-2,1]);
   printf("Number of character types  : %a\n",t[-2,2]);
   printf("Number of rows available   : %a\n",t[-2,3]);
   printf("Number of class types      : %a\n",t[-2,4]);
   printf("Number of columns available: %a\n",t[-2,5]);
   NULL;
end:            


####################################################################
##
##  PrintInfoTab(t)
## 
PrintInfoTab:=proc(t)
  local nr, n;
  nr:=tablenumber(t);
  n:=Information||nr;
  if n<>evaln(Information||nr) then
	#Hack to display TEXT Elements properly
    print(eval(INTERFACE_HELP(insert,topic=nr,text=eval(n),library=CHEVIEPATH)));
    print(eval(INTERFACE_HELP(display,topic=nr,library=CHEVIEPATH)));
    print(eval(INTERFACE_HELP(delete,topic=nr,library=CHEVIEPATH)));		
  else
    printf("No information available\n");
  fi;
  NULL;
end:




####################################################################
##
##  PrintVal(t,i)
##  PrintVal(t,l)
##  PrintVal(t)
## 
PrintVal:=proc(t)
   local i,ct,ll1,ll2;
   tablenumber(t);
   if nargs = 1 then 
     ll1 := [$ 1..t[-2,2]];
     ll2 := [$ 1..t[-2,4]];
   elif nargs = 2 then 
     ll1 := makelist(args[2]);
     ll2 := [$ 1..t[-2,4]];
   else 
     ll1 := makelist(args[2]);
     ll2 := makelist(args[3]);
   fi;
   for i to nops(ll1) do 
     printf("\n");
     olprint('clt',`Value of character type `,ll1[i],
                                  ` on class type clt`);
     printf("\n");
     for ct to nops(ll2) do
       olprint(ll2[ct],t[ll1[i],ll2[ct]]);
     od;
   od;
   NULL;
end:

####################################################################
##
##  PrintValPhi(t,i)
##  PrintValPhi(t,l)
##  PrintValPhi(t)
##
##  (for nicer output of tables of polynomials in q)

# List with cyclotomic polynomials:
CycPols:=proc(max)
  local erg, i, j, pol;
  erg:=array(1..max);
  for i to max do
    pol:=q^i-1;
    for j to i-1 do
      divide(pol,erg[j],'pol');
    od;
    erg[i]:=pol;
  od;
  op(erg);
end:

cycpollist:=CycPols(30):
cycpolphilist:=map(k->cycpollist[k]=phi||k, {seq(i, i=1..30)}):
k:='k':
i:='i':

# The following functions are used for non-polynomial arguments for
# PolyMitPhi
simpCharValmalfact:=proc(tt)
  global simpCharValhilf;
  local erg,ind,a;
  simpCharValhilf:=subsop(4=NULL,eval(simpCharValhilf));
  if type(tt,`*`) then
    map(simpCharValpot,convert(tt,list));
  else
    simpCharValpot(tt);
  fi;
  ind:=[indices(op(4,op(simpCharValhilf)))];
  erg:=1;
  for a in ind do 
    erg:=erg*op(a)^factor(simpCharValhilf(op(a)));
  od;
  erg;
end:
simpCharValfact:=proc(tt)
  local t;
  t:=factor(eval(tt));
  if type(t,`*`) then
    map(simpCharValfact,t);
  elif type(t,`+`) then
    map(simpCharValmalfact,t);
  else
    simpCharValmalfact(t);
  fi;
end:


PolyMitPhi:=proc(pol)
  local i, c, erg;
  if pol=0 then RETURN(`.`); fi;
  if not type(pol,polynom(algnum,q)) then
    RETURN(sort(subs(cycpolphilist,simpCharValfact(pol)),
                                                 [q,seq(phi||i, i=1..30)]));
  fi;
  c:=lcoeff(pol,q);
  erg:=factor(pol/c);
  c*sort(subs(cycpolphilist,erg),[q,seq(phi||i, i=1..30)]);
end:

PrintValPhi:=proc(t)
local i,ct,ll1,ll2;
    tablenumber(t);
    if nargs = 1 then ll1 := [`$`(1 .. t[-2,2])]; ll2 := [`$`(1 .. t[-2,4])]
    elif nargs = 2 then ll1 := makelist(args[2]); ll2 := [`$`(1 .. t[-2,4])]
    else ll1 := makelist(args[2]); ll2 := makelist(args[3])
    fi;
    for i to nops(ll1) do
        printf("\n");
        olprint('clt',`Value of character type `,ll1[i],` on class type clt`);
        printf("\n");
        for ct to nops(ll2) do  
            olprint(ll2[ct],PolyMitPhi(t[ll1[i],ll2[ct]])) 
        od
    od;
    NULL
end:


####################################################################
##
##  PrintInfoClass(t,i)
##  PrintInfoClass(t,l)
##  PrintInfoClass(t)
## 
PrintInfoClass:=proc(t)
  local i, ll, noinf, inf, s;
  tablenumber(t);
  if nargs = 1 then 
    ll := [$ 1..t[-2,4]]
  else 
    ll := makelist(args[2])
  fi;
  printf("\n");
  olprint('clt','Information');
  printf("\n");
  printf("======================================================\n");
  for i in ll do
    olprint(i,t[-1,i]);
  od;
  NULL;
end:


####################################################################
##
##  PrintInfoChar(t,i)
##  PrintInfoChar(t,l)
##  PrintInfoChar(t)
## 
PrintInfoChar:=proc(t)
  local i, ll, noinf, inf, s;
  tablenumber(t);
  if nargs = 1 then 
    ll := [$ 1..t[-2,2]]
  else 
    ll := makelist(args[2])
  fi;
  printf("\n");
  olprint('cht','Information');
  printf("\n");
  printf("======================================================\n");
  for i in ll do
    olprint(i,t[i,-1]);
  od;
  NULL;
end:




####################################################################
##
##  
## 
PrintCharParam:=proc(t)
   local i,ll,Exceptions,Parameter,Parameters,Substitutions,sk;
   tablenumber(t);
   if op(Char||t||Parameter) = evaln(Char||t||Parameter) then
     printf("Sorry, information not yet available.\n");
     RETURN(NULL);
   fi;
   if nargs = 1  then 
     ll := [$ 1..t[-2,2]]
   else 
     ll := makelist(args[2])
   fi;
   # Testen, ob Substitutionen vorkommen:
   sk:=false;
   for i in ll do
     if nops(Char||t||Parameter[i])=3 then
       sk:=true;
     fi;
   od;
   printf("\n");
   if sk=true then 
     olprint('cht',`Parameters`,`Exceptions`,`Substitutions`);
   else
     olprint('cht',`Parameters`,`Exceptions`);
   fi;
   printf("\n");
   printf("=======================================================\n");
   for i to nops(ll)
   do
#     xX := t[ll[i],-1][1];
#     printf("\n");
#     printf("\n");
      if nops(Char||t||Parameter[ll[i]])=3 then 
        olprint(ll[i], Char||t||Parameter[ll[i]][1],
                    Char||t||Parameter[ll[i]][2],
                    Char||t||Parameter[ll[i]][3]);
      else
        olprint(ll[i], Char||t||Parameter[ll[i]][1],
                    Char||t||Parameter[ll[i]][2]);
      fi;
   od;
   NULL;
end:


####################################################################
##
##  
## 
PrintClassParam:=proc(t)
   local i,ll,Exceptions,Parameter,Parameters,Substitutions,sk;
   tablenumber(t);
   if op(Klassen||t||Parameter) = evaln(Klassen||t||Parameter) then 
     printf("Sorry, information not yet available.\n"); 
     RETURN(NULL); 
   fi;
   if nargs = 1
       then ll := [$ 1..t[-2,4]]
       else ll := makelist(args[2])
   fi;
   # Testen, ob Substitutionen vorkommen:
   sk:=false;
   for i in ll do
     if nops(Klassen||t||Parameter[i])=3 then
       sk:=true;
     fi;
   od;
   printf("\n");
   if sk=true then 
     olprint('clt',`Parameters`,`Exceptions`,`Substitutions`);
   else
     olprint('clt',`Parameters`,`Exceptions`);
   fi;
   printf("\n");
   printf("=======================================================\n");
   for i from 1 to nops(ll)
   do 
#     xX := t[-1,ll[i]][1];
#     printf("\n");
#     printf("\n");
      if nops(Klassen||t||Parameter[ll[i]])=3 then 
        olprint(ll[i], Klassen||t||Parameter[ll[i]][1],
                    Klassen||t||Parameter[ll[i]][2],
                    Klassen||t||Parameter[ll[i]][3]);
      else
        olprint(ll[i], Klassen||t||Parameter[ll[i]][1],
                    Klassen||t||Parameter[ll[i]][2]);
      fi;
   od;
   NULL;
end:



####################################################################
##
##  The following procedures just print some usefull information
##  about classes or characters if they are called with a list
##  as argument.
##  If they are called with integer argument, they return the
##  corresponding value.


####################################################################
##
##  
## 
CentOrd:=proc(t)
  local iI, xX, yY , ll:
  tablenumber(t);
  if nargs = 1 then 
    ll := [$ 1..t[-2,4]]
  else 
    if type(args[2],integer) then
      RETURN(factor(t[-2,1]/t[0,args[2]]));
    else
      ll := makelist(args[2]);
    fi;
  fi;
  printf("\n");
  olprint('clt',`Order of centralizer(s)`);
  printf("\n");
  printf("=======================================================\n");
  for iI from 1 to nops(ll) do
#    xX := t[-1,ll[iI]][1]:
    yY := factor(t[-2,1]/t[0,ll[iI]]):
#    olprint(ll[iI], `class`, xX, `:`, yY);
    olprint(ll[iI], yY);
  od:
  NULL;
end:

####################################################################
##
##  
## 
CharDeg:=proc(t)
  local iI, xX, yY , ll:
  tablenumber(t);
  if nargs = 1 then 
    ll := [$ 1..t[-2,2]]
  else 
    if type(args[2],integer) then
      RETURN(factor(t[args[2],0]));
    else
      ll := makelist(args[2]);
    fi;
  fi;
  printf("\n");
  olprint('cht',`Degree of character(s)`);
  printf("\n");
  printf("=======================================================\n");
  for iI from 1 to nops(ll) do
#    xX := t[ll[iI],-1][1]:
    yY := factor(t[ll[iI],0]):
#    olprint(ll[iI], `character`, xX, `:`, yY);
    olprint(ll[iI], yY);
  od:
  NULL;
end:



####################################################################
##
##  
## 
NrChars:=proc(t)
  local iI, xX, yY , ll, nr, eins:
  nr:=tablenumber(t);
  eins:=[[[1,0,1]],[[1,0,1]]];
  if nargs = 1 then 
    ll := [$ 1..t[-2,2]]
  else 
    if type(args[2],integer) then
      if NurPolynom||nr=true then
        RETURN(1);
      else
        setCongruence||nr();
        iI:=args[2];
        yY:=qscew2GEW(Char||nr||Summe||iI(eins));
        unsetCongruence||nr();
        RETURN(factor(eval(yY)));
      fi;
    else
      ll := makelist(args[2]);
    fi;
  fi;
  printf("\n");
  olprint('cht',`Number of characters in this type`);
  printf("\n");
  printf("=======================================================\n");
  for iI from 1 to nops(ll) do
#    xX := t[ll[iI],-1][1]:
    yY := NrChars(t,ll[iI]):
#    olprint(ll[iI], `character`, xX, `:`, yY);
    olprint(ll[iI], yY);
  od:
  NULL;
end:



####################################################################
##
##  
## 
NrClasses:=proc(t)
  local iI, xX, yY , ll, nr, eins:
  nr:=tablenumber(t);
  eins:=[[[1,0,1]],[[1,0,1]]];
  if nargs = 1 then 
    ll := [$ 1..t[-2,4]]
  else 
    if type(args[2],integer) then
      if NurPolynom||nr=true then
        RETURN(factor(KlassentypOrd||nr[args[2]]));
      else
        setCongruence||nr();
        iI:=args[2];
        yY:=qscew2GEW(Klassen||nr||Summe||iI(eins));
        unsetCongruence||nr();
        RETURN(factor(eval(yY)));
      fi;
    else
      ll := makelist(args[2]);
    fi;
  fi;
  printf("\n");
  olprint('clt',`Number of classes in this type`);
  printf("\n");
  printf("=======================================================\n");
  for iI from 1 to nops(ll) do
#    xX := t[ll[iI],-1][1]:
    yY := NrClasses(t,ll[iI]):
#    olprint(ll[iI], `character`, xX, `:`, yY);
    olprint(ll[iI], yY);
  od:
  NULL;
end:
