#############################################################################
##
#A  genVtestprogs        CHEVIE library                          Gunter Malle
##
#Y  Copyright 1992--1993,  Lehrstuhl D f"ur Mathematik,    RWTH Aachen,   and
#Y                         IWR   der   Universit"at    Heidelberg,   Germany.
##
# Gunters Programme zum Testen von Greenfunktionen (inoffiziell):
#
qpart:=proc(order)
local ff, i, s;
   s:=1; ff:=factor(order);
   for i from 1 to nops(ff) do if divide(op(i,ff),q) then s:= op(i,ff);
   fi: od:
   RETURN(s):
end:

gtest:=proc(table)
local M, A, i, j, k, pPart, s;
   M:=array(1..table[-2,2],1..table[-2,2]):
   pPart:= qpart(table[-2,1]):
   for i from 1 to table[-2,2] do
      for j from 1 to table[-2,2] do
         s:= 0:
         for k from 1 to table[-2,4] do
            s:= s + table[0,k]*table[i,k]*table[j,k]:
         od:
         s:= factor(s/lcoeff(table[i,0])/table[i,0]/pPart):
         M[i,j]:= s: M[j,i]:= s:
      od:
   od:
   RETURN(op(M));
end:

TestOrtho1 := proc(t)
local a0, a1, erg;
erg := array(1..t[-2,2],1..t[-2,2]);
for a0 to t[-2,2] do
for a1 to a0 do
erg[a0,a1] := Scalar(t,a0,t,a1);
od;
od;
op(erg);
end:
 
CheckUniTable:=proc(g,l)
  local nc,nct,t,i,j,k,hi,hik;
  nc:=g[-2,2];
  printf("Degrees:\n");
  for i to nc do
    for j in l do
      hi:=subs(q=j,g[i,1]);
      if not (type(hi,integer) and hi>0) then
        olprint(`Degree:`,i,j,hi);
      fi;
    od;
  od;
  printf("Norms:\n");
  for i to nc do
    hi:=Norm(g,i);
    if hi[1]<>1 then
      olprint(`Norm:`,i,hi);
    fi;
  od;
  printf("Scalars:\n");
  for i to nc do
    olprint(i);
    for j to i-1 do
      hi:=Scalar(g,i,g,j);
      if hi[1]<>0 then
        olprint(`Scalar:`,i,j,hi);
      fi;
    od;
  od;
  printf("Tensors:\n");
  Copy(g,t,[],ROWS+nc*nc);
  Tensor(g,t);
  nct:=t[-2,2];
  for j to nct do
    olprint(j);
    for i to nc do
      hi:=Scalar(g,i,t,j); 
      for k in l do
        hik:=subs(q=k,hi[1]);
        if not (type(hik,integer) and hik>=0) then
          olprint(`Tensor:`,j,i,k,hik,t[j,-1]);
        fi;
      od;
    od;
  od;
  NULL;
end:


