/*

Find the average times to compute sums of Witt vectors over
finite fields with two methods:

* precompute the formulas and then evaluate
  (disregard time to compute the formulas)

* use recursion


*/

load 'witt2_fun.m';

p:=43;
time vecS:=WittSum2Pol(p);

n:=4; F:=GF(p^n);
tms1:=[];
tms2:=[];
tms3:=[];

magma_witt:=false;

for i in [1..20] do

    v1:=[Random(F), Random(F), Random(F)]; v2:=[Random(F), Random(F), Random(F)];
    t1:=Cputime();
    tmp1:=WittSum2(v1,v2);
    Append(~tms1,Cputime(t1));

    t2:=Cputime();
    tmp2:=WittSum22(v1,v2 : vecS:=vecS);
    Append(~tms2,Cputime(t2));

    if tmp1 ne tmp2 then
        print "ERROR";
    end if;

    if magma_witt then
        W:=WittRing(F,3);
        t3:=Cputime();
        tmp3:=W!v1 + W!v2;
        Append(~tms3,Cputime(t3));
    end if;
        
end for;

print "NEW = ", (&+tms1)/20;
print "OLD = ", (&+tms2)/20;
if magma_witt then
    print "MAGMA = ", (&+tms3)/20;
end if;

print "";
print "";
