text:
# Define a pregroup by giving a list of generator names and
# a (partial) multiplication table
InstallGlobalFunction(PregroupByTableNC,
function(enams, inv, table)
    local r,e;

    r := rec( PregroupElementNames := enams
            , inv := inv
            , table := table );
    r.fam := NewFamily( "PregroupElementsFamily", IsElementOfPregroup );
    r.elt_t := NewType( r!.fam, IsElementOfPregroupRep );
    r.wfam := NewFamily( "PregroupWordFamily", IsPregroupWord );
    r.word_t := NewType( r!.wfam, IsPregroupWordListRep );
    r.elts := List( [1..Length(table)], i -> Objectify(r.elt_t, rec(parent := r, elt := i)));
    r.invs := [];
    for e in [1..Length(r.elts)] do
        r.elts[e]!.inv := r.elts[inv(e)];
    od;
    Objectify(PregroupByTableType, r);
    SetPregroupElementNames(r, enams);
    return r;
end);

InstallGlobalFunction(PregroupInversesFromTable,
function(table)
    local i,j,inv;

    inv := [];
    for i in [1..Length(table)] do
        for j in [1..Length(table[i])] do
            if table[i][j] = 1 then
                if IsBound(inv[i]) then
                    if inv[i] <> j then
                        Error("inverses not well-defined");
                    fi;
                else
                    inv[i] := j;
                fi;
            fi;
        od;
    od;
    inv := PermList(inv);
    if inv = fail then
        Error("inverses not well-defined");
    fi;
    return x -> x^inv;
end);

InstallGlobalFunction(PregroupByTable,
function(enams, table)
    local nels, inv, row, e, f, g, h;

    # We assume that the length of the list of
    # element names is the number of elements
    nels := Length(enams);

    if Length(table) <> nels then
        Error("PregroupByTable: Length of enams does not match number of rows in table");
    fi;
    for row in table do
        if Length(row) <> nels then
            Error("PregroupByTable: Multiplication table is not square");
        fi;
        for e in row do
            if (not IsInt(e)) or (e < 0) or (e > nels) then
                Error("PregroupByTable: Table entry ", e, " is invalid, needs to be an integer between 0 and ", nels);
            fi;
        od;
    od;

    inv := PregroupInversesFromTable(table);
    for e in [1..nels] do
        if inv(inv(e)) <> e then
            Error("PregroupByTable: inv needs to be an involution");
        fi;
    od;
    for e in [1..nels] do
        if (table[1][e] <> e) or (table[e][1] <> e) then
            Error("PregroupByTable: ",e,"*1 = ", e, " or 1*", e, " = ", e, " not satisfied");
        fi;
        if (table[e][inv(e)] <> 1) or (table[inv(e)][e] <> 1) then
            Error("PregroupByTable: inverses");
        fi;
    od;

    for e in [1..nels] do
        for f in [1..nels] do
            for g in [1..nels] do
                if table[e][f] > 0 and table[f][g] > 0 then
                    if (table[table[e][f]][g] = 0 and table[e][table[f][g]] > 0) or
                       (table[table[e][f]][g] > 0 and table[e][table[f][g]] = 0) then
                        Error("PregroupByTable: associativity");
                    fi;
                fi;
            od;
        od;
    od;

    for e in [1..nels] do
        for f in [1..nels] do
            if table[e][f] > 0 then
                for g in [1..nels] do
                    if table[f][g] > 0 then
                        for h in [1..nels] do
                            if table[g][h] > 0 then
                                if table[table[e][f]][g] = 0 and table[table[f][g]][h] = 0 then
                                    Error("PregroupByTable: P5 violated");
                                fi;
                            fi;
                        od;
                    fi;
                od;
            fi;
        od;
    od;
    return PregroupByTableNC(enams, inv, table);
end);

InstallMethod(\[\]
             , "for a pregroup in table rep"
             , [IsPregroupTableRep, IsInt],
function(f,a)
    return f!.elts[a];
end);

InstallMethod(Iterator
             , "for a pregroup"
             , [IsPregroupTableRep],
function(pgp)
    local r;

    r := rec( pgp := pgp
            , pos := 0
            , length := Size(pgp)
            , NextIterator := function(iter)
                if iter!.pos < iter!.length then
                    iter!.pos := iter!.pos + 1;
                    return iter!.pgp[iter!.pos];
                else
                    return fail;
                fi;
            end
            , IsDoneIterator := iter -> iter!.pos = iter!.length
            , ShallowCopy := iter -> rec( pgp := iter!.pgp, pos := iter!.pos )
            );

    return IteratorByFunctions(r);
end);

InstallMethod(PregroupElementNames
             , "for a pregroup"
             , [IsPregroupTableRep]
             , p -> p!.elementnames );

InstallMethod(SetPregroupElementNames
             , "for a pregroup"
             , [IsPregroupTableRep, IsList]
             , function(p, n)
                 p!.elementnames := n;
             end );

InstallMethod(ViewString
             , "for a pregroup in table rep"
             , [IsPregroupTableRep],
function(pg)
    return STRINGIFY("<pregroup with ", Size(pg), " elements in table rep>");
end);

InstallMethod(Size
             , "for a pregroup in table rep"
             , [IsPregroup and IsPregroupTableRep],
function(pg)
    return Length(pg!.elts);
end);

#XXX at the moment [1,x] and [x,1] intermult, but I don't think
#    this is really needed?
#XXX Intermult is only defined for elements other than 1
InstallMethod(IntermultPairs
             , "for a pregroup in table rep"
             , [IsPregroupTableRep],
function(pg)
    local i, j, k, pairs;

    pairs := [];
    for i in [2..Size(pg)] do
        for j in [2..Size(pg)] do
            if (i <> pg!.inv(j)) then
                if (pg!.table[i][j] > 0) then
                    Add(pairs, [pg[i],pg[j]]);
                else
                    for k in [2..Size(pg)] do
                        if (pg!.table[i][k] > 0) and
                           (pg!.table[pg!.inv(k)][j] > 0) then
                            Add(pairs, [pg[i],pg[j]]);
                            break;
                        fi;
                    od;
                fi;
            fi;
        od;
    od;
    return pairs;
end);

InstallMethod(IntermultPairsIDs
             , "for a pregroup in table rep"
             , [IsPregroupTableRep],
function(pg)
    local i, j, k, pairs;

    pairs := [];
    for i in [2..Size(pg)] do
        for j in [2..Size(pg)] do
            if (i <> pg!.inv(j)) then
                if (pg!.table[i][j] > 0) then
                    Add(pairs, [i,j]);
                else
                    for k in [2..Size(pg)] do
                        if (pg!.table[i][k] > 0) and
                           (pg!.table[pg!.inv(k)][j] > 0) then
                            Add(pairs, [i,j]);
                            break;
                        fi;
                    od;
                fi;
            fi;
        od;
    od;
    return pairs;
end);

InstallMethod(IntermultMapIDs
             , "for a pregroup in table rep"
             , [IsPregroupTableRep],
function(pg)
    local i, j, k, map;

    map := [];
    for i in [1..Size(pg)] do
        map[i] := [];
    od;

    for i in [2..Size(pg)] do
        for j in [2..Size(pg)] do
            if (i <> pg!.inv(j)) then
                if (pg!.table[i][j] > 0) then
                    Add(map[i], j);
                else
                    for k in [2..Size(pg)] do
                        if (pg!.table[i][k] > 0) and
                           (pg!.table[pg!.inv(k)][j] > 0) then
                            Add(map[i],j);
                            break;
                        fi;
                    od;
                fi;
            fi;
        od;
    od;
    return map;
end);

InstallMethod(IntermultMap
             , "for a pregroup in table rep"
             , [IsPregroupTableRep],
function(pg)
    return List(IntermultMapIDs(pg), x -> List(x, i -> pg[i]));
end);

InstallMethod(IntermultTable
             , "for a pregroup in table rep"
             , [IsPregroupTableRep],
function(pg)
    local i, j, k, map;

    map := [];
    for i in [1..Size(pg)] do
        map[i] := [false];
    od;

    for i in [2..Size(pg)] do
        for j in [2..Size(pg)] do
            map[i][j] := false;
            if (i <> pg!.inv(j)) then
                if (pg!.table[i][j] > 0) then
                    map[i][j] := true;
                else
                    for k in [2..Size(pg)] do
                        if (pg!.table[i][k] > 0) and
                          (pg!.table[pg!.inv(k)][j] > 0) then
                            map[i][j] := true;
                            break;
                        fi;
                    od;
                fi;
            fi;
        od;
    od;
    return map;
end);

InstallMethod(One, "for a pregroup",
              [IsPregroup],
              pg -> pg!.elts[1]);

# This is very inefficient, but I don't care at the moment
InstallMethod(MultiplicationTableIDs,
              "for a pregroup",
              [IsPregroup],
function(pg)
    local i, j, table;

    table := [];
    for i in [1..Size(pg)] do
        table[i] := [];
        for j in [1..Size(pg)] do
            table[i][j] := pg[i] * pg[j];
            if table[i][j] = fail then
                table[i][j] := 0;
            else
                table[i][j] := __ID(table[i][j]);
            fi;
        od;
    od;
    return table;
end);

InstallMethod(MultiplicationTable,
              "for a pregroup",
              [IsPregroup],
function(pg)
    local i, j, table;

    table := [];
    for i in [1..Size(pg)] do
        table[i] := [];
        for j in [1..Size(pg)] do
            table[i][j] := pg[i] * pg[j];
        od;
    od;
    return table;
end);

#
# Pregroup elements
#
InstallMethod(IntermultMap
             , "for a pregroup element"
             , [IsElementOfPregroupRep],
function(pge)
    return IntermultMap(pge!.parent)[__ID(pge)];
end);

InstallMethod(ViewString
             , "for a pregroup element"
             , [IsElementOfPregroupRep],
function(pge)
    if pge!.elt > 0 then
        return PregroupElementNames(pge!.parent)[pge!.elt];
    else
        return "undefined";
    fi;
end);

InstallMethod(String
             , "for a pregroup element"
             , [IsElementOfPregroupRep],
function(pge)
    if pge!.elt > 0 then
        return PregroupElementNames(pge!.parent)[pge!.elt];
    else
        return "undefined";
    fi;
end);

InstallMethod(InverseOp
             , "for a pregroup element"
             , [IsElementOfPregroupRep]
             , 0,
function(x)
    return PregroupInverse(x);
end);

#XXX Is fail as a result for multiplication acceptable?
InstallMethod(\*
             , "for pregroup elements"
             , IsIdenticalObj
             , [IsElementOfPregroupRep, IsElementOfPregroupRep]
             , 0,
function(x,y)
    local pg, r;

    pg := x!.parent;

    r := pg!.table[x!.elt][y!.elt];

    if r > 0 then
        return pg!.elts[r];
    else
        return fail;
    fi;
end);

InstallMethod(\=
             , "for pregroup elements"
             , IsIdenticalObj
             , [IsElementOfPregroupRep, IsElementOfPregroupRep]
             , 0,
function(x,y)
    return x!.elt = y!.elt;
end);

# Artificial ordering on pregroup to make sets work
InstallMethod(\<
             , "for pregroup elements"
             , IsIdenticalObj
             , [ IsElementOfPregroupRep, IsElementOfPregroupRep]
             , 0,
function(x,y)
    return x!.elt < y!.elt;
end);

InstallMethod(PregroupOf
             , "for pregroup elements"
             , [ IsElementOfPregroupRep ]
             , 0,
function(a)
    return a!.parent;
end);

InstallMethod(PregroupInverse
             , "for pregroup elements"
             , [ IsElementOfPregroupRep ]
             , 0,
             a -> a!.inv);

InstallMethod(PregroupElementId
             , "for pregroup elements"
             , [ IsElementOfPregroupRep]
             , 0,
             a -> a!.elt);

InstallMethod(__ID
             , "for pregroup elements"
             , [IsElementOfPregroup]
             , 0,
             x -> x!.elt);

InstallMethod(IsDefinedMultiplication
             , "for pregroup elements"
             , IsIdenticalObj
             , [IsElementOfPregroup, IsElementOfPregroup]
             , 0,
function(a,b)
    local pg;

    pg := PregroupOf(a);

    return pg!.table[a!.elt][b!.elt] > 0;
end);

# We could cache intermult pairs,
# or predetermine them, depending
# on the number of intermult lookups
# that could benefit runtime
InstallMethod(IsIntermultPair
             , "for pregroup elements"
             , IsIdenticalObj
             , [IsElementOfPregroup, IsElementOfPregroup]
             , 0,
function(a,b)
    local x, nontriv;

    return IntermultTable(a!.parent)[__ID(a)][__ID(b)];

    if a = PregroupInverse(b) then
        return false;
    elif IsDefinedMultiplication(a, b) then
        return true;
    else
        nontriv := List(PregroupOf(a), x -> x);
        Remove(nontriv, 1);
        for x in nontriv do
            if IsDefinedMultiplication(a,x)
               and IsDefinedMultiplication(PregroupInverse(x), b) then
                return true;
            fi;
        od;
        return false;
    fi;
    # Should not be reached
    Error("This shouldn't happen.");
end);

max_stars_repo_name: RussWoodroofe/walrus

max_issues_repo_name: RussWoodroofe/walrus

max_forks_repo_name: RussWoodroofe/walrus


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

scriptWHT := function(val1, val2, val3, val4, val5, val6)
       local opts, t, rt, srt, cs, namec, nametxt, a;

       ImportAll(paradigms.scratchpad);

       opts := ScratchX86Globals.getOpts(val1, val2, val3, val4, val5, val6);

       t := WHT(opts.size).withTags(opts.tags);

       rt := RandomRuleTree(t,opts);

       srt := SumsRuleTree(rt,opts);

       cs := CodeSums(srt,opts);

       namec := ConcatenationString("whtfile",String(val1),String(val4),String(val5),".c");
       nametxt := ConcatenationString("whtfile",String(val1),String(val4),String(val5),".txt");
       PrintTo(namec,PrintCode("sub",cs,opts));

       a := CMatrix(cs,opts);

       PrintTo(nametxt, a);
end;

scriptDFT := function(val1, val2, val3, val4, val5, val6)
       local opts, t, rt, srt, cs, namec, nametxt, a;

       ImportAll(paradigms.scratchpad);

       opts := ScratchX86Globals.getOpts(val1, val2, val3, val4, val5, val6);

       t := DFT(opts.size).withTags(opts.tags);

       rt := RandomRuleTree(t,opts);

       srt := SumsRuleTree(rt,opts);

       cs := CodeSums(srt,opts);

       namec := ConcatenationString("dftfile",String(val1),String(val4),String(val5),".c");
       nametxt := ConcatenationString("dftfile",String(val1),String(val4),String(val5),".txt");
       PrintTo(namec,PrintCode("sub",cs,opts));

       a := CMatrix(cs,opts);

       PrintTo(nametxt, a);
end;

scriptRunWHT := function(wht_size, name)
             local opts, t, rt;

             ImportAll(paradigms.scratchpad);

             i := 2;

             while (2^i) <= (2^(wht_size+1)) do
                   opts := ScratchX86Globals.getOpts(2^i,1,1,wht_size,'R',true);
                   AppendTo(name,PrintLine("--------------------"));
                   t := WHT(opts.size).withTags(opts.tags);
                   AppendTo(name,PrintLine(t));
                   rt := AllRuleTrees(t,opts);
                   L := Length(rt);
                   AppendTo(name,PrintLine(ConcatenationString("Has ", String(L), " decomposition trees")));
                   AppendTo(name,PrintLine("--------------------"));

                   i := i + 1;
             od;
end;

scriptRunDFT := function(dft_size, name)
             local opts, t, rt;

             ImportAll(paradigms.scratchpad);

             i := 2;

             while (2^i) <= (2*dft_size) do
                   opts := ScratchX86Globals.getOpts(2^i,1,1,dft_size,'C',true);
                   AppendTo(name,PrintLine("--------------------"));
                   t := DFT(opts.size).withTags(opts.tags);
                   AppendTo(name,PrintLine(t));
                   rt := AllRuleTrees(t,opts);
                   L := Length(rt);
                   AppendTo(name,PrintLine(ConcatenationString("Has ", String(L), " decomposition trees")));
                   AppendTo(name,PrintLine("--------------------"));

                   i := i + 1;
             od;
end;

scriptRun := function()
          local wht_size, dft_size, wht_file_name, dft_file_name;

          wht_file_name := "wht.txt";
          dft_file_name := "dft.txt";

          wht_size := 2;

          while wht_size <= 13 do
                scriptRunWHT(wht_size, wht_file_name);
                wht_size := wht_size + 1;
          od;

          dft_size := 4;

          while dft_size <= 8192 do
                scriptRunDFT(dft_size, dft_file_name);
                dft_size := dft_size * 2;
          od;
end;

ext: gi


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

Class(vdup, Exp, rec(
    __call__ := (self, a, n) >> WithBases(self, rec(
	    args       := [toExpArg(a), toExpArg(n)],
	    operations := ExpOps,
	)).setType(),

    computeType := self >> let(t := self.args[1].t,
	Cond(IsVecT(t),
	         ObjId(t)(t.t, t.size * self.args[2].ev()),
	     # else
	         TVect(t, self.args[2].ev())
	)),

    ev := self >> Value(self.t, Flat(Replicate(self.args[2].ev(), self.args[1].ev())))
));

# tcast(<newtype>, <exp>)
#
Class(tcast, Exp, rec(
    isLoc := true,
    __call__ := (self, t, exp) >> Checked(IsType(t), WithBases(self, rec(
	 args := [t, toExpArg(exp)],
	 t := t,
	 operations := ExpOps
    ))),

    zero := self >> self.args[1].zero(),

    computeType := self >> self.args[1]
));

# Packs n arguments into an n-way vector,
# this should be considered a pseudo-instruction
#
Class(vpack, AutoFoldExp, rec(
    ev := self >> self.t.value(List(self.args, x->x.ev())),
    computeType := self >> TVect(UnifyTypes(List(self.args, x->x.t)), Length(self.args))
));

Class(velem, nth, rec(
    __call__ := (self, loc, idx) >> Cond(
	# velem(vpack(a, b), 1) == a
	ObjId(loc)=vpack and IsInt(idx), loc.args[idx+1],
        WithBases(self, rec(loc := loc, idx := toExpArg(idx), t := loc.t.t, operations := ExpOps))),

    computeType := self >> self.loc.t.t,
    cprint := self >> Print(self.name, "(", self.loc.cprint(), ", ", self.idx.cprint(), ")"),
    print := self >> Print(self.name, "(", self.loc, ", ", self.idx, ")")
));

# tcvt(<newtype>, <exp>)
#
Class(tcvt, tcast);

# sizeof(<type>)
#
Class(sizeof, Exp, rec(
    __call__ := (self, t) >> Checked(IsType(t),
        WithBases(self, rec(args := [t], t := TInt, operations := ExpOps))),

    computeType := self >> TInt
));


text:
IsChar('a');
# true
IsString("abc");
# true
IsString('a');
# false
IsChar("a");
# false

ext: gap

max_issues_repo_name: seanwallawalla-forks/RosettaCodeData

max_forks_repo_name: seanwallawalla-forks/RosettaCodeData


text: #NGSId1	NGSId2	SuperScaffoldId	XmapGapLength	AdjustedGapLength	NGSLength1	NGSLength2

max_stars_repo_name: pavanvidem/galaxytools

max_issues_repo_name: pavanvidem/galaxytools

max_forks_repo_name: pavanvidem/galaxytools


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

# Here we define shorter print functions for common constructs.
# Loading this file will cause more compact printing of formulas,
# but the output can not be pasted back into GAP.
#

Import(formgen, code);

Diag.print := (s,i,is) >> Print("D");
Blk.print := (s,i,is) >> Print("B");

Gath._sym := true;
Scat._sym := true;
Diag._sym := true;
Blk._sym := true;

HideRTWrap := function()
   RTWrap._origprint := RTWrap.print;
   RTWrap.print := (self,i,is) >> Print(self.rt.node);
end;

ShowRTWrap := function()
   if IsBound(RTWrap._origprint)
       then RTWrap.print := RTWrap._origprint;
   fi;
end;


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

#F Printing of SPLs
#F ----------------
#F

#F SPLOps.Print( <spl> [, <indent> , <indentStep> ] )
#F   prints <spl> with <indent>. Further indenting is done
#F   in steps of size <indentStep>. The default is
#F   indent = 0, indentStep = 2.
#F
SPLOps.Print := function ( arg )
    local S, indent, indentStep;
    if Length(arg) = 1 then   S := arg[1]; indent := 0; indentStep := 2;
    elif Length(arg) = 3 then S := arg[1]; indent := arg[2]; indentStep := arg[3];
    else Error("usage: SPLOps.Print( <spl> [, <indent> , <indentStep> ] )");
    fi;
    Constraint(IsInt(indent) and indent >= 0);
    Constraint(IsInt(indentStep) and indentStep >= 0);
    if IsInt(S) then
	Print(S);
    else
	S.print(indent, indentStep);
    fi;
end;

_CompactPrintSPL := rec(
    doPrintCutoff := true,

    indentWithLines := function(indent, indentStep)
        local x, beg;
	if indent < indentStep - 2 then
	    Print(Blanks(indent));
	else
	    beg := indent mod indentStep;
	    Print(Blanks(beg));
	    x := beg+1;
	    while x < indent - indentStep do
	        Print(" |", Blanks(indentStep-2));
		x := x + indentStep;
	    od;
	    Print(" +"); x := x + 2;
	    while x < indent do
	        Print("-");
		x := x + 1;
	    od;
	fi;
    end,

    indentBlank := function(indent, indentStep)
        Print(Blanks(indent));
    end,

    print := meth(self, spl, maxDepth, indentFunc, indent, indentStep)
        local c;
	if maxDepth > 0 then
	    indentFunc(indent, indentStep);
	    if IsBound(spl.symbol) then Print(spl.symbol, " ", spl.params, "\n");
	    else Print(spl.name, "\n");
	    fi;
	    if IsBound(spl.children) then
		for c in spl.children() do
	            self.print(c, maxDepth-1, indentFunc, indent+indentStep, indentStep);
		od;
	    fi;
	elif self.doPrintCutoff then
	    indentFunc(indent, indentStep);
	    Print("...\n");
	fi;
    end
);

CompactPrintSPL := function(spl, maxDepth)
    Constraint(IsSPL(spl));
    Constraint(IsInt(maxDepth) and maxDepth >= 0);
    _CompactPrintSPL.print(spl,maxDepth, _CompactPrintSPL.indentBlank, 0,5);
end;

CompactPrintSPLTree := function(spl, maxDepth)
    Constraint(IsSPL(spl));
    Constraint(IsInt(maxDepth) and maxDepth >= 0);
    _CompactPrintSPL.print(spl,maxDepth, _CompactPrintSPL.indentWithLines, 0,5);
end;

CompactPrintSPLNode := function(spl)
    Constraint(IsSPL(spl));
    if IsBound(spl.symbol) then Print(spl.symbol, " ", spl.params);
    else Print(spl.name);
    fi;
end;


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

Class(InterpolateDFT, TaggedNonTerminal, rec(
    abbrevs := [ (dsfunc,usfunc) -> [dsfunc, usfunc] ],
    dims      := self >> [self.params[1].domain(), self.params[2].domain()],
    terminate := self >> let(n:=self.params[2].domain(), N := self.params[1].range(),
        Downsample(self.params[1]).terminate() *
        DFT(N, 1).terminate() *
        Upsample(self.params[2]).terminate() *
        Scale(1/n, DFT(n, -1).terminate())),
    isReal    := False,
    normalizedArithCost := self >> let(n:=self.params[2].domain(), N := self.params[1].range(),
        n + IntDouble(5 * n * d_log(n) / d_log(2)) + IntDouble(5 * N * d_log(N) / d_log(2))),
    TType := T_Complex(T_Real(64))
));

NewRulesFor(InterpolateDFT, rec(
    InterpolateDFT_base := rec(
        applicable := (self, nt) >> not nt.hasTags(),
        children := nt -> let(n:=nt.params[2].domain(), N := nt.params[1].range(),
            [[ Downsample(nt.params[1]), DFT(N, 1), Upsample(nt.params[2]), DFT(n, -1) ]]),
        apply := (nt, C, cnt) -> C[1] * C[2] * C[3] * Scale(1/nt.params[2].domain(), C[4])
    ),
    InterpolateDFT_PrunedDFT := rec(
        applicable := (self, nt) >> not nt.hasTags() and ObjId(nt.params[2]) = fZeroPadMiddle,
        children := nt -> let(n:=nt.params[2].domain(), N := nt.params[1].range(), us := N/n, blk := n/2,
            [[ PrunedDFT(N, 1, blk, [0, 2*us-1]), DFT(n, -1) ]]),
        apply := (nt, C, cnt) -> let(n:=nt.params[2].domain(), N := nt.params[1].range(), us := N/n, blk := n/2,
                Gath(nt.params[1]) * C[1] * Scale(1/n, C[2])
       )
    )
));


text:
    "reviewTitle": "Good place to stay for a business trip",
    "reviewText": "cleanest rooms in town.",
    "reviewerCity": "Olathe",
    "reviewerState": "KS",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-09-12T00:00:00.000Z"
    },
    "reviewTitle": "End of Day 3",
    "reviewText": "Nice Hotel just need a few things fixed, back door card reader didn't work. so long walk to car to unload. But Front Desk was very friendly and helpful. Room was clean, quite and comfortable. Bed was very good. Breakfast was good, WiFi was good.",
    "reviewerCity": "Coalinga",
    "reviewerState": "CA",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2012-08-26T00:00:00.000Z"
    },
    "reviewTitle": "End of Day 3",
    "reviewText": "check your sheets before crawling in bed here! worst hotel stay ever! yuck!",
    "reviewerCity": "Coalinga",
    "reviewerState": "CA",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2012-03-16T00:00:00.000Z"
    },
    "reviewTitle": "End of Day 3",
    "reviewText": "Cleanest rooms in town.",
    "reviewerCity": "Coalinga",
    "reviewerState": "CA",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2012-03-16T00:00:00.000Z"
    },
    "reviewTitle": "End of Day 3",
    "reviewText": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "reviewerCity": "Coalinga",
    "reviewerState": "CA",
    "reviewRating": 0
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-14T00:00:00.000Z"
    },
    "reviewTitle": "Great Choice",
    "reviewText": "Staying here for just under two weeks while working in town. At first the check in didn't go so well, they person I spoke to in the phone never reserved the rooms, after a short wait all that was taken care of by the very helpful and patient staff. Overall this place is very clean and friendly. Would stay again",
    "reviewerCity": "Coalinga",
    "reviewerState": "CA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2012-06-26T00:00:00.000Z"
    },
    "reviewTitle": "Great Choice",
    "reviewText": "don't take the elevator. i got stuck in it for 45 minutes.",
    "reviewerCity": "Coalinga",
    "reviewerState": "CA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-01-09T00:00:00.000Z"
    },
    "reviewTitle": "Clean but...",
    "reviewText": "I think it is overpriced for what you get. The rooms need updating, and oh my gosh, the mattress was horrible. Like a 30 year old box spring. My husband and I would roll to the middle and you can feel the springs. Terrible night sleep due to the mattress and the loud cars outside the window. All night long... More",
    "reviewerCity": "Bixby",
    "reviewerState": "OK",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2012-08-26T00:00:00.000Z"
    },
    "reviewTitle": "Clean but...",
    "reviewText": "Check your sheets before crawling in bed here! Worst hotel stay EVER! Yuck!",
    "reviewerCity": "Bixby",
    "reviewerState": "OK",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-03-27T00:00:00.000Z"
    },
    "reviewTitle": "Great front desk, tired rooms",
    "reviewText": "The upside: very helpful, friendly front desk staff- worked quickly to initiate a room change after cleanliness complaint, made helpful restaurant suggestions. Quick check in. Comfortable beds. Good continental breakfast: biscuits and gravy, a variety if yogurts, waffles, sausage etc The downside: it is not very clean- in fact I was sort of grossed out. Rooms were dusty, carpet soiled.... More",
    "reviewerCity": "Minneapolis",
    "reviewerState": "MN",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2012-02-22T00:00:00.000Z"
    },
    "reviewTitle": "Great front desk, tired rooms",
    "reviewText": "newly remodelled. rooms are comfortable",
    "reviewerCity": "Minneapolis",
    "reviewerState": "MN",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-12-19T00:00:00.000Z"
    },
    "reviewTitle": "Quiet clean and reasonable",
    "reviewText": "I stayed here one night as I traveled to Texas. My room was clean, bed was very comfortable and I felt very safe as I was traveling solo. Breakfast was good. Clerk gave me a recommendation for a local restaurant for supper which was excellent.",
    "reviewerCity": "Dixon",
    "reviewerState": "IL",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2012-07-01T00:00:00.000Z"
    },
    "reviewTitle": "Quiet clean and reasonable",
    "reviewText": "$80 bucks with tax!",
    "reviewerCity": "Dixon",
    "reviewerState": "IL",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-03-21T00:00:00.000Z"
    },
    "reviewTitle": "Would stay again",
    "reviewText": "Easy to get to. Friendly staff. Great amenities. Good breakfast. Clean and comfortable room. Close to many dinner options. Starbucks is next door. Decent value. A couple miles west of Joplin business area.",
    "reviewerCity": "Plano",
    "reviewerState": "TX",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-12-06T00:00:00.000Z"
    },
    "reviewTitle": "you get what you pay for",
    "reviewText": "Hotel was clean and appeared to be recently renovated. Upon arrival was told by hotel staff that there was not water due to construction project nearby that broke a water line. The room was clean but smelled very musty. Pool area was nice. Biggest complaint is that we stayed for two nights and our room was not cleaned on our... More",
    "reviewerCity": "Centerton",
    "reviewerState": "AR",
    "reviewRating": 2
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-12-29T00:00:00.000Z"
    },
    "reviewTitle": "Good place",
    "reviewText": "Nice place for the money, newer beds and seems to have been remodeled recently. Decent breakfast and above average staff. Bathrooms were clean and everything worked accordingly .ask the front desk for some local restaurant recommendations they have a list that we found helpful. Would stay here again. .",
    "reviewerCity": "Iowa City",
    "reviewerState": "IA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2012-02-22T00:00:00.000Z"
    },
    "reviewTitle": "Good place",
    "reviewText": "Newly remodelled. Rooms are comfortable",
    "reviewerCity": "Iowa City",
    "reviewerState": "IA",
    "reviewRating": 4
  }]
} {
  "_id": {
    "$oid": "5cf9dcbe433d2b44c0de410e"
  },
  "name": "Motel 6",
  "categories": ["Hotels", "Lodging", "Motels"],
  "location": {
    "country": "US",
    "state": "DC",
    "city": "Somerset",
    "postalCode": "42501",
    "address": "1532 S Highway 27",
    "coordinates": {
      "type": "Point",
      "coordinates": [-84.61848, 37.072174]
    }
  },
  "reviews": [{
    "reviewId": "",
    "reviewTitle": "",
    "reviewText": "Horrible experience never go!!!! Employees are rude and can't sleep because the beds are so hard!!!!",
    "reviewerCity": "",
    "reviewerState": "",
    "reviewRating": 1
  }, {
    "reviewId": "",
    "reviewTitle": "",
    "reviewText": "The do NOT accept there coupon that they have in the travel book. Rooms were clean but small and smelled of paint. Fresh paint is good but not until you air out the room before costomers are placed in them. Ended up costing 75 for 2 people.",
    "reviewerCity": "",
    "reviewerState": "",
    "reviewRating": 3
  }]
} {
  "_id": {
    "$oid": "5cf9dcbe433d2b44c0de410f"
  },
  "name": "Hampton Inn Dublin",
  "categories": ["Hotels"],
  "location": {
    "country": "US",
    "state": "MD",
    "city": "Dublin",
    "postalCode": "24084",
    "address": "4420 Cleburne Blvd",
    "coordinates": {
      "type": "Point",
      "coordinates": [-80.69685, 37.07256]
    }
  },
  "reviews": [{
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-03-15T00:00:00.000Z"
    },
    "reviewTitle": "Surpassed all expectations",
    "reviewText": "Great value. Newly remodeled and appointed rooms were beautiful. Clean and comfortable with a very competent and friendly staff. Excellent breakfast.",
    "reviewerCity": "",
    "reviewerState": "",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-08-19T00:00:00.000Z"
    },
    "reviewTitle": "Surpassed all expectations",
    "reviewText": "I only spent one night. It was a quite stay.",
    "reviewerCity": "",
    "reviewerState": "",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-10-10T00:00:00.000Z"
    },
    "reviewTitle": "Very nice hotel - about 10-15 mins. from RU",
    "reviewText": "Was very satisfied with the hotel. We stayed here for Radford University's parents weekend. Was the best hotel that we've stayed in so far. About a 10-15 minute ride to RU.",
    "reviewerCity": "",
    "reviewerState": "",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-09-25T00:00:00.000Z"
    },
    "reviewTitle": "Nice Hotel",
    "reviewText": "Room was very nice and bed was very comfortable. Super friendly staff.",
    "reviewerCity": "",
    "reviewerState": "",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-04-02T00:00:00.000Z"
    },
    "reviewTitle": "Dublin Hampton Inn",
    "reviewText": "The hotel was located near the highway and was a convenient stop for an overnight on our way home from vacation. The facility was a bit worn, but adequate for the night. The toilet emptied and refilled the entire time.",
    "reviewerCity": "",
    "reviewerState": "",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-12-22T00:00:00.000Z"
    },
    "reviewTitle": "Slept well, quiet location",
    "reviewText": "The beds were very comfortable and the staff friendly. This Hampton Inn is not pet friendly and the hallway had a strong smell of cigarette smoke (though not the room). There is no thermostat, just a blower with settings for low heat, high heat, etc. that I had to get up and adjust in the night. But otherwise the room... More",
    "reviewerCity": "Macon",
    "reviewerState": "",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-11-14T00:00:00.000Z"
    },
    "reviewTitle": "Great for the price!",
    "reviewText": "One of the better Hamptons I've stayed at. Clean, comfortable...would definitely stay here again.",
    "reviewerCity": "Macon",
    "reviewerState": "",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2013-11-15T00:00:00.000Z"
    },
    "reviewTitle": "Great for the price!",
    "reviewText": "One of the better Hamptons I've stayed at. Clean, comfortable...would definitely stay here again.",
    "reviewerCity": "Macon",
    "reviewerState": "",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-05-07T00:00:00.000Z"
    },
    "reviewTitle": "Great for the price!",
    "reviewText": "One of the better Hamptons I've stayed at. Clean, comfortable...would definitely stay here again.",
    "reviewerCity": "Macon",
    "reviewerState": "",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-03-08T00:00:00.000Z"
    },
    "reviewTitle": "Great for the price!",
    "reviewText": "The way we came in, it was a little off the beaten track, but would definitely stay there again, if needed. Friendly service, great breakfast, more importantly, very clean! Definitely recommend!",
    "reviewerCity": "Macon",
    "reviewerState": "",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-04-23T00:00:00.000Z"
    },
    "reviewTitle": "Great",
    "reviewText": "One of the cleanest Hamton Inns I have ever stayed in! Staff was very nice and helpful . I called for a roll away bed and it appeared in about 2 minutes. Room was exceptionally clean and bed was very comfortable.",
    "reviewerCity": "Richmond",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-13T00:00:00.000Z"
    },
    "reviewTitle": "Very nice stay",
    "reviewText": "The hotel is clean, comfortable and quiet. The staff is very friendly and helpful and the parking is easy. A perfect place to stay when I visit Blacksburg! This is my second stay in this hotel, and I anticipate there being many more.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2013-09-29T00:00:00.000Z"
    },
    "reviewTitle": "The facilities were very nice.",
    "reviewText": "The staff was very helpful and the breakfast was very good!",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-05-10T00:00:00.000Z"
    },
    "reviewTitle": "Close to Radford University",
    "reviewText": "We needed a place to stay the night as we were moving our son out of his place at Radford for the summer. It was graduation weekend and there were no decent places available close by. Although the Hampton Inn was about 15 miles from our destination, it was a clean comfortable -place to stay anfd worth driving a few extra miles.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2013-08-25T00:00:00.000Z"
    },
    "reviewTitle": "Showing Wear",
    "reviewText": "I have stayed at this Hampton Inn before because it is relatively easy on and off I-81. The property is starting to show wear and tear in the rooms.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-08-28T00:00:00.000Z"
    },
    "reviewTitle": "Convenient and Standard",
    "reviewText": "You can pretty much count on Hampton for cleanliness and a decent breakfast. Unlike a box of chocolates, you know what you'll get.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-09-26T00:00:00.000Z"
    },
    "reviewTitle": "Convenient and Standard",
    "reviewText": "You can pretty much count on Hampton for cleanliness and a decent breakfast. Unlike a box of chocolates, you know what you'll get.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-16T00:00:00.000Z"
    },
    "reviewTitle": "Nice stay",
    "reviewText": "The hotel was very clean and right off I81. I was visiting my son at Radford and it was an easy 15 mins from the campus. Breakfast was good too.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-10-13T00:00:00.000Z"
    },
    "reviewTitle": "Loved The Breakfast",
    "reviewText": "I particularly want to commend the excellent breakfast.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-06-27T00:00:00.000Z"
    },
    "reviewTitle": "Loved The Breakfast",
    "reviewText": "I particularly want to commend the excellent breakfast.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-10-17T00:00:00.000Z"
    },
    "reviewTitle": "Loved The Breakfast",
    "reviewText": "I particularly want to commend the excellent breakfast.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-07-27T00:00:00.000Z"
    },
    "reviewTitle": "Not bad for a one night stay, but not exceptional",
    "reviewText": "We had a late check-in at this hotel as we were on the road. It took a bit for us to be assisted at the front desk as the staff member was in the back somewhere, but this was understandable since it was past midnight when we arrived. Overall, the room was satisfactory. It was clean and the bed was comfortable. The TV and appliances seemed new, but the air unit was older and noisy. The tub was a little dated as well. The hotel itself is definitely a bit worn. The exterior is not as inviting as some of the surrounding hotels. Our breakfast experience was also not up to par with other hotels in this chain as the tables were dirty, the trash was overflowing, and the whole area was just very messy. After another guest pointed this out, some of the issues were fixed. I would stay here again if the price were right and I were just passing through, but would definitely check the prices of some of the newer surrounding hotels first.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-06-10T00:00:00.000Z"
    },
    "reviewTitle": "Not bad for a one night stay, but not exceptional",
    "reviewText": "Staff was great!",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-01T00:00:00.000Z"
    },
    "reviewTitle": "Nice place to stay",
    "reviewText": "Room was very clean and comfortable. Staff was incredibly friendly. Will definitely stay there again.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-05-09T00:00:00.000Z"
    },
    "reviewTitle": "Very convenient to local colleges",
    "reviewText": "We needed a room close to Radford for my sons Graduation, the staff was more than helpful, rooms were clean and the pool was great to distract my younger children from the days activities.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-07-09T00:00:00.000Z"
    },
    "reviewTitle": "Very convenient to local colleges",
    "reviewText": "Disappointing breakfast. Outof coffee several times, then coffee that must have been run through the grounds a second time. Inattentive server for a weekend crowd. I'll pass on this property next time.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-06-05T00:00:00.000Z"
    },
    "reviewTitle": "Dublin, VA wedding",
    "reviewText": "We were very happy staying at the hotel. The beds were comfy, the room and bathroom were spotless. It was nice and quiet and the hotel was quite full when we were there. Having Shoney's right next door was perfect for some meals and within a close proximity there are other eateries, shopping stores, etc. We would definitely stay again at this hotel.",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-03-16T00:00:00.000Z"
    },
    "reviewTitle": "hard to find",
    "reviewText": "after you get off 81 take second left. the hotel arrow sign is misleading",
    "reviewerCity": "Virginia Beach",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-05-06T00:00:00.000Z"
    },
    "reviewTitle": "nice, clean hotel rooms...breakfast bar was very good hot food...lots of choices",
    "reviewText": "The staff at the hotel were wonderful. We were stranded there because of car trouble and the staff at Kings Tires in Pulaski sent us to Hampton. When the van was finally fixed 2 day later, the staff at Hampton even offered to take us back to Pulaski (about 10miles away) to get the van. Food was always hot and... More",
    "reviewerCity": "Atlantic Beach",
    "reviewerState": "NC",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-07-13T00:00:00.000Z"
    },
    "reviewTitle": "nice, clean hotel rooms...breakfast bar was very good hot food...lots of choices",
    "reviewText": "This was a quick trip to Dublin VA for a funeral. They were very accommodating and got me in my room earlier so I could dress for funeral. I did not get back until late and then left early the next morning. I would stay there again if I happen to be in the area.",
    "reviewerCity": "Atlantic Beach",
    "reviewerState": "NC",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-07-30T00:00:00.000Z"
    },
    "reviewTitle": "nice, clean hotel rooms...breakfast bar was very good hot food...lots of choices",
    "reviewText": "Hotel was terrific. Hotels.com however couldn't get anything right. I made the initial reservation, and called back and asked for a change on the arrival date. After being VERY specific on what I wanted on the change, Hotels.com goofed it up. If I had not called back to the hotel to check, my stay would have been a disaster. Will have to re-assess my use of Hotels.com",
    "reviewerCity": "Atlantic Beach",
    "reviewerState": "NC",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-06-11T00:00:00.000Z"
    },
    "reviewTitle": "Comfortable Stay",
    "reviewText": "Clean rooms, spacious and comfortable",
    "reviewerCity": "Atlantic Beach",
    "reviewerState": "NC",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-03-12T00:00:00.000Z"
    },
    "reviewTitle": "Will skip next time",
    "reviewText": "Toilet was broken. Made dripping water sounds all night. Shower curtain smelled like body odor. Ventilation system was very loud. Walls were very thin and could hear everything, including when the blow dryer was off, was in, next door they the adjoining room door. Didn't sleep a wink. Front desk was curt. Good coffee and breakfast though.",
    "reviewerCity": "Atlantic Beach",
    "reviewerState": "NC",
    "reviewRating": 1
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-08-26T00:00:00.000Z"
    },
    "reviewTitle": "Great stay",
    "reviewText": "Pleasantly surprised. Loved having a fridge and the coffee in the room was great! Flavored creamers:) Bathroom amenities were really nice too. The breakfast was really good. And there was nice hot coffee in the lobby, but once there were no cups. My only complaint was the way the curtains were set up. It took three nights of bright parking lot lights in our faces to figure out that there were shades way in behind that would block the light. The curtains needed instructions!",
    "reviewerCity": "Atlantic Beach",
    "reviewerState": "NC",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-09-05T00:00:00.000Z"
    },
    "reviewTitle": "Great stay!",
    "reviewText": "Only stayed 1 night but really enjoyed the nice comfortable king-size bed.",
    "reviewerCity": "Atlantic Beach",
    "reviewerState": "NC",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-01-16T00:00:00.000Z"
    },
    "reviewTitle": "Great stay!",
    "reviewText": "Great, I enjoyed my stay af the Hampton Inn",
    "reviewerCity": "Atlantic Beach",
    "reviewerState": "NC",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-09-19T00:00:00.000Z"
    },
    "reviewTitle": "Great stay!",
    "reviewText": "Great, I enjoyed my stay af the Hampton Inn",
    "reviewerCity": "Atlantic Beach",
    "reviewerState": "NC",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-01-08T00:00:00.000Z"
    },
    "reviewTitle": "Great stay!",
    "reviewText": "Clean comfortable, friendly",
    "reviewerCity": "Atlantic Beach",
    "reviewerState": "NC",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-11-20T00:00:00.000Z"
    },
    "reviewTitle": "Good People skills",
    "reviewText": "Great service, great cookies, breakfast typical, Complintary internet work well, Just need a Jacuzzi in the pool area. The hallway on the 3rd floor smelled a little Smokey, but the room was fine no smoke smell at all.",
    "reviewerCity": "Greensboro",
    "reviewerState": "NC",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-11-01T00:00:00.000Z"
    },
    "reviewTitle": "Experience",
    "reviewText": "The hotel was typical Hampton inn quality that I have become accustomed to. The one outstanding part of my stay was I forgot my prescription sunglasses in the room. Around noon time I received a call from Kelly that they had found them and what would I like for them to do. That is outstanding customer service. Keep up the... More",
    "reviewerCity": "spencere",
    "reviewerState": "NC",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-24T00:00:00.000Z"
    },
    "reviewTitle": "Overall a nice hotel",
    "reviewText": "Overall the hotel is a nice place and the staff is friendly enough. Maybe I have seen one too many Hotel Impossible episodes, but to borrow a term from Anthony Melchiorri, nothing skeeves me out more than someone else's hair. My stay was otherwise perfect until the next morning when I stepped into the shower and opened my eyes to... More",
    "reviewerCity": "South Windsor",
    "reviewerState": "CT",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-08-23T00:00:00.000Z"
    },
    "reviewTitle": "Overall a nice hotel",
    "reviewText": "Overall the hotel is a nice place and the staff is friendly enough. Maybe I have seen one too many Hotel Impossible episodes, but to borrow a term from Anthony Melchiorri, nothing skeeves me out more than someone else's hair. My stay was otherwise perfect until the next morning when I stepped into the shower and opened my eyes to... More",
    "reviewerCity": "South Windsor",
    "reviewerState": "CT",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-08-06T00:00:00.000Z"
    },
    "reviewTitle": "Overall a nice hotel",
    "reviewText": "Overall the hotel is a nice place and the staff is friendly enough. Maybe I have seen one too many Hotel Impossible episodes, but to borrow a term from Anthony Melchiorri, nothing skeeves me out more than someone else's hair. My stay was otherwise perfect until the next morning when I stepped into the shower and opened my eyes to... More",
    "reviewerCity": "South Windsor",
    "reviewerState": "CT",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-05-03T00:00:00.000Z"
    },
    "reviewTitle": "LOVE HAMPTON",
    "reviewText": "We prefer Hampton Inn when we travel! Hotels and amenities are very consistent except for prices! Pricing is very surprising at times! We have only had one problem with Hampton Inn! The air conditioning went out but we were in a new room in minutes!",
    "reviewerCity": "Hendersonville",
    "reviewerState": "CT",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-08-26T00:00:00.000Z"
    },
    "reviewTitle": "LOVE HAMPTON",
    "reviewText": "Clean and service was great. Will stay here again!",
    "reviewerCity": "Hendersonville",
    "reviewerState": "CT",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-08-10T00:00:00.000Z"
    },
    "reviewTitle": "Very comfortable and clean",
    "reviewText": "I was very impressed with all the updates to the hotel It was very clean and comfortable. The staff was very friendly and helpful. The beds were very comfortable.",
    "reviewerCity": "Hendersonville",
    "reviewerState": "CT",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2014-09-13T00:00:00.000Z"
    },
    "reviewTitle": "Never disappointed with Hampton Inns!",
    "reviewText": "I really appreciate the dependability of Hampton Inns - they are always clean, comfortable, reasonably priced, and the staff is helpful and friendly. At the Hampton Inn Dublin, I gave a four out of five for room comfort simply because we ended up with a room that seemed a little smaller than what we usually get at a typical Hampton Inn (but it was a full hotel with the Virginia Tech home game weekend and we do have 2 adults and 3 kids in our family!) and because the bed pillows didn't seem as numerous and as comfortable as we've come to expect (firstworldproblems, right). Overall, very satisfactory! The kids had fun in the indoor pool, everyone slept well and we were on our way to our destination the next morning after coffee and a tasty little breakfast :)",
    "reviewerCity": "Hendersonville",
    "reviewerState": "CT",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-08-04T00:00:00.000Z"
    },
    "reviewTitle": "Never disappointed with Hampton Inns!",
    "reviewText": "I really appreciate the dependability of Hampton Inns - they are always clean, comfortable, reasonably priced, and the staff is helpful and friendly. At the Hampton Inn Dublin, I gave a four out of five for room comfort simply because we ended up with a room that seemed a little smaller than what we usually get at a typical Hampton Inn (but it was a full hotel with the Virginia Tech home game weekend and we do have 2 adults and 3 kids in our family!) and because the bed pillows didn't seem as numerous and as comfortable as we've come to expect (firstworldproblems, right). Overall, very satisfactory! The kids had fun in the indoor pool, everyone slept well and we were on our way to our destination the next morning after coffee and a tasty little breakfast :)",
    "reviewerCity": "Hendersonville",
    "reviewerState": "CT",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-04-26T00:00:00.000Z"
    },
    "reviewTitle": "Home Away From Home",
    "reviewText": "A BIG thank you to everyone that makes this our home away from home: Kelly Taylor (front desk), also Taylor makes great omelettes Shanna, Carlie, Diane, Jen Cathy, to name a few. Keep on the Great Work! We will definitely recommend this to our friends colleagues. Tom Kathy Stephenson (Room 223)",
    "reviewerCity": "Kernersville",
    "reviewerState": "NC",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-11-02T00:00:00.000Z"
    },
    "reviewTitle": "Watch out for things that go bump in the night !!!",
    "reviewText": "Well for starters my wife and I checked in late at night, d/t driving conditions because of the rainy weather. I was tired and exhausted and just wanted a shower and a nice clean bed to lay down.No sooner than my head hit the pillow(which you really shudnt call it a pillow) that my wife is jumping up and down... More",
    "reviewerCity": "Washington DC",
    "reviewerState": "NC",
    "reviewRating": 1
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-11-18T00:00:00.000Z"
    },
    "reviewTitle": "Smoked out.",
    "reviewText": "We only stayed one night on our way to Alabama. The room smelled so bad of smoke that I could taste it. My nose was stuffy all night. After we got to our next hotel and I opened my suitcase the pajamas I wore to bed the night I stayed there and the close I got there in still smelled like smoke. And this is coming from an ex smoker of 20 years. Pretty bad.",
    "reviewerCity": "Washington DC",
    "reviewerState": "NC",
    "reviewRating": 1
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-08-08T00:00:00.000Z"
    },
    "reviewTitle": "Perfect for our trip",
    "reviewText": "We headed to southern VA to watch minor league baseball. A couple of rainouts, but still a good long weekend. The hotel is located just off the highway with easy access. The staff could not be any nicer - truly a southern thing! Breakfast was very good with lots of choices.",
    "reviewerCity": "Washington DC",
    "reviewerState": "NC",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-07-04T00:00:00.000Z"
    },
    "reviewTitle": "Unhappy traveler",
    "reviewText": "The internet was down!!!!",
    "reviewerCity": "Washington DC",
    "reviewerState": "NC",
    "reviewRating": 2
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-04-13T00:00:00.000Z"
    },
    "reviewTitle": "Hampton Inn, Dublin, Va",
    "reviewText": "I enjoyed this hotel and would use it again. It was clean, staff courteous and helpful. I loved that it was just off I-81 with easy on/off access. The room could have been a bit larger and brighter. I was disappointed that pets were not allowed and would have opted to stay at the HI in Radford for that reason... More",
    "reviewerCity": "Fayetteville",
    "reviewerState": "NC",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-01-15T00:00:00.000Z"
    },
    "reviewTitle": "Wonderful hotel!",
    "reviewText": "We stopped at this hotel because of its convenience location. We have stayed at many Hampton Inns and this is one of the best at which we have stayed! The staff is very friendly and helpful. It was VERY clean and the breakfast was awesome! We are planning on staying here again in the near future!",
    "reviewerCity": "Sherman",
    "reviewerState": "CT",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-08-07T00:00:00.000Z"
    },
    "reviewTitle": "good stay at Hampton",
    "reviewText": "A little tricky to access, but not bad. Drive up to hotel through gas stations. Hotel staff was very welcoming and accommodating of any need we had. very comfortable bed. clean room. pool was wonderful. breakfast was nice. (sausage, waffles, french toast, fruit, oatmeal etc)",
    "reviewerCity": "Sherman",
    "reviewerState": "CT",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-17T00:00:00.000Z"
    },
    "reviewTitle": "Best Hampton Inn ever",
    "reviewText": "This Hampton Inn is amazing. So glad we found it. Convenient location to the interstate but we were most impressed because it is so nice, clean and comfortable. The service was impeccable. We will definitely return if we are ever in the area again.",
    "reviewerCity": "Chelsea",
    "reviewerState": "CT",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-17T00:00:00.000Z"
    },
    "reviewTitle": "Best Hampton Inn ever",
    "reviewText": "to share your opinion of this businesswith YP visitors across the United Statesand in your neighborhood",
    "reviewerCity": "Chelsea",
    "reviewerState": "CT",
    "reviewRating": 0
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-23T00:00:00.000Z"
    },
    "reviewTitle": "Your Basic Hampton Inn",
    "reviewText": "This is a typical Hampton Inn with the standard reception area and lobby. This particular hotel still has smoking rooms and they are on the top floor. I usually like top floor rooms as I am sensitive to noise from above and this time I had to deal with a hallway that had the stale, cloying smell of old smoke.... More",
    "reviewerCity": "Huntsville",
    "reviewerState": "AL",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-12-28T00:00:00.000Z"
    },
    "reviewTitle": "Best in the area. Excellent staff.",
    "reviewText": "I have stayed in over 1000 hotels after a long career traveling to 50 states and over 20 countries. I rate hotels on cleanliness .... comfort of rooms. ... staff responsiveness. and comparison with other hotels in the area. This is the winner in the Dublin and Pulaski area by far. Healthy or country breakfast. Your choice. Great indoor pool.... More",
    "reviewerCity": "Northern Virginia",
    "reviewerState": "AL",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-12-05T00:00:00.000Z"
    },
    "reviewTitle": "Should have been good, but it wasn't.",
    "reviewText": "There are 2 other motels to choose from in the same area, unfortunately I made the wrong choice! I arrived in the late evening after a long drive from Florida, without a reservation. Front desk clerk said there were many rooms available, but evidently gave me the worst one! She was not able to find my HHonors membership and claimed... More",
    "reviewerCity": "Montreal",
    "reviewerState": "AL",
    "reviewRating": 1
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-01-10T00:00:00.000Z"
    },
    "reviewTitle": "Transiting Southwest Virginia",
    "reviewText": "Easy access from I-81. Very clean older building that has been very nicely maintained. Suite was spotless. Everything worked and there were tons of electrical sockets conveniently located. Plentiful access around desk. Checkin/out was smooth and friendly. Nearby (200 feet) Shoney's had a seafood/beef/chicken/veggie buffet....above average, clean restaurant with friendly service.",
    "reviewerCity": "Palm Beach",
    "reviewerState": "FL",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-12T00:00:00.000Z"
    },
    "reviewTitle": "WORST HAMPTON INN EXPERIENCE EVER!!!!!!!",
    "reviewText": "We checked in around 7 P.M. after a long, demanding day and were so looking forward to a restful evening and night. When we opened the door to our room, we noticed a fairly strong smell but thought it was probably just some cleaning agent that had been used and thought that once we turned on the fan to the... More",
    "reviewerCity": "Roanoke",
    "reviewerState": "VA",
    "reviewRating": 1
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-30T00:00:00.000Z"
    },
    "reviewTitle": "Clean and VERY Nice Staff.",
    "reviewText": "The manager works as hard as the front desk and she will go out of her way to make you happy. Also, this location is quieter than I thought and they have an Indoor Pool. The Breakfast is always fresh. I just hope they will update the Climate control to a New Generation Wall Mount Digital Control.",
    "reviewerCity": "Rochester",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-10-14T00:00:00.000Z"
    },
    "reviewTitle": "Clean",
    "reviewText": "It was nice,the staff was great. I would stay there again even though it was a little pricey.",
    "reviewerCity": "Rochester",
    "reviewerState": "VA",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-10-14T00:00:00.000Z"
    },
    "reviewTitle": "Clean",
    "reviewText": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "reviewerCity": "Rochester",
    "reviewerState": "VA",
    "reviewRating": 0
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-15T00:00:00.000Z"
    },
    "reviewTitle": "Dublin VA Hampton Inn",
    "reviewText": "As always, a stay at a Hampton is always a great experience. I have been staying in Hampton Inns for many years and have always been extremely satisfied. There was only 1 exception about 4 years ago, and, I received a 100 refund because I was dissatisfied with the facility. I learned later that the hotel was sold to a... More",
    "reviewerCity": "Rochester",
    "reviewerState": "VA",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-05-05T00:00:00.000Z"
    },
    "reviewTitle": "Dublin Hampton Inn",
    "reviewText": "After spending 14 hours in a car , we were relieved that this Hampton Inn was quiet and we were able to get a very good night sleep. The breakfast we had the following morning had everything we needed for the last leg of our trip home. It was very filling and and delicious.",
    "reviewerCity": "Saratoga Springs",
    "reviewerState": "NY",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-13T00:00:00.000Z"
    },
    "reviewTitle": "Nice and Quiet hotel",
    "reviewText": "Stayed at the Hampton Inn, Dublin, VA. The hotel room was clean and the beds were extremely comfortable. The staff was nice also. One thing went wrong, my door keys didn't work. I went through four sets of keys. I think the door was the problem. Otherwise the hotel was great. I would recommend for families, couples or business trips.",
    "reviewerCity": "Ellenwood",
    "reviewerState": "NY",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-12-28T00:00:00.000Z"
    },
    "reviewTitle": "Great place is tyou enjoy smoking!",
    "reviewText": "Simply disgusting. I reserved a non smoking room on a non smoking floor. Almost seemed liked the rule was you couldn't stay at this hotel unless you smoked. It was gross. And this was on a non-smoking floor with non smoking rooms. As soon as you stepped off the elevator you gagged. Sickening. Again, unless you like smoking. Then this... More",
    "reviewerCity": "Harpers Ferry",
    "reviewerState": "NY",
    "reviewRating": 1
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2013-03-25T00:00:00.000Z"
    },
    "reviewTitle": "Great place is tyou enjoy smoking!",
    "reviewText": "the gps is wrong... follow the sign when you first get off of 81... it's right there.",
    "reviewerCity": "Harpers Ferry",
    "reviewerState": "NY",
    "reviewRating": 1
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-11-25T00:00:00.000Z"
    },
    "reviewTitle": "Only Average Compared to other Hampton Inns",
    "reviewText": "Stayed at this hotel because of it's location. Furnishings were only average, and there were no local meal discounts which I have had at other H.I.'s. On the plus side the room was very quiet. Had dinner at the local Fatz which I enjoyed",
    "reviewerCity": "Greenville",
    "reviewerState": "SC",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-04-16T00:00:00.000Z"
    },
    "reviewTitle": "Dublin Hampton Inn VA",
    "reviewText": "Enjoyed stay. Staff was very friendly but complimentary breakfast (sausage and egg omelet) was not warm but otherwise good selection of breakfast items. We appreciate getting a comfortable clean room at the last minute. We recommend this hotel.",
    "reviewerCity": "Birmingham",
    "reviewerState": "AL",
    "reviewRating": 5
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-11-17T00:00:00.000Z"
    },
    "reviewTitle": "Friendly Stay",
    "reviewText": "changed schedule and unexpectedly stayed here. Extremely friendly and helpful staff. Everything clean and fresh. Close to I-81 but no highway sound. Good restaurant next door and in close proximity. Well lit parking lot. Good value for your money.",
    "reviewerCity": "Dublin",
    "reviewerState": "AL",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-05-04T00:00:00.000Z"
    },
    "reviewTitle": "I like Hampton Inns",
    "reviewText": "This hotel is typical of Hampton Inns. I really like Hampton's beds and bedding, always clean and soft. The bathrooms are always clean, although this one had one minor maintenance problem which the front desk immediately called for repairs.",
    "reviewerCity": "Ashburn",
    "reviewerState": "AL",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-04-21T00:00:00.000Z"
    },
    "reviewTitle": "Bathroom!!!",
    "reviewText": "Place was fine for the price, however a few disappointments: Pool drained very slowly off deck Pillows sucked! No fan in the bathrooms Nasty!! Front desk charges the wrong accounts! Kids had a blast, shower was hot, had a good time- but it was good because Of the company of our friends!",
    "reviewerCity": "Kings Nympton",
    "reviewerState": "AL",
    "reviewRating": 3
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2015-10-22T00:00:00.000Z"
    },
    "reviewTitle": "Was Not Expecting...",
    "reviewText": "The hotel was great. However, I was not expecting dogs at the hotel since it is not a pet friendly hotel. A large dog was barking in the room next to me which was disturbing. I went downstairs to get coffee and saw a poodle. When I inquired about it at the front desk, they said there is only supposed... More",
    "reviewerCity": "Woodbridge",
    "reviewerState": "AL",
    "reviewRating": 4
  }, {
    "reviewId": "",
    "reviewDate": {
      "$date": "2016-04-18T00:00:00.000Z"
    },
    "reviewTitle": "Excellent staff",
    "reviewText": "This hotel is clean and the staff is both professional and friendly. They made our stay very pleasant. The room is very clean and has everything you would need for a stay away from home. We will stay at this hotel again because of the friendly staff.",
    "reviewerCity": "Staffor",
    "reviewerState": "AL",
    "reviewRating": 5
  }]
} {
  "_id": {
    "$oid": "5cf9dcbe433d2b44c0de4110"
  },

max_stars_repo_name: bigdatakid/mongodb-demos

max_issues_repo_name: bigdatakid/mongodb-demos

max_forks_repo_name: bigdatakid/mongodb-demos


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

#F standard cache params structure, it takes
#F
#F blksize (block size in bytes)
#F nsets   (number of sets)
#F assoc   (associativity eg. 2-way,4-way,etc)
#F rpolicy  (replacement policy string eg, "FIFO","LRU", etc)
#F
#F and computes a hidden value, csize (cache size)

Declare(CacheDesc);

Class(CacheDesc, rec(
    __call__ := (self, blksize, nsets, assoc, rpolicy) >>
        Checked(Is2Power(blksize),
            Is2Power(nsets),
            Is2Power(assoc),
            IsString(rpolicy),
            WithBases(self, rec(
                blksize := blksize,
                nsets := nsets,
                assoc := assoc,
                rpolicy := rpolicy,
                csize := blksize * nsets * assoc,
            ))
        ),

    operations := rec(
        Print := self >> When(ObjId(self) = CacheDesc,
            Print("CacheDesc(",
                PrintCS([
                    self.blksize,
                    self.nsets,
                    self.assoc,
                    Concat("\"", self.rpolicy, "\"")
                ]), ")"
            ),
            Print("CacheDesc(<blksize>, <nsets>, <assoc>, <rpolicy>)")
        )
    ),
));

# Cache tag. This is a generic tag, which means it takes any arguments.
# However, the correct arguments are:
#
# arg1: positive integer symbolizing cache level
# arg2: a CacheSpec()

Class(ACache, AGenericTag);

# Inplace tag. Takes one argument, maximum BB size.
#
# use this tag to specify that a transform should be computed inplace
Class(AInplace, AGenericTag);

# Right expansion tag
#
# one argument, max left kernel size
#
Class(AExpRight, AGenericTag);

# AMem tag.
#
# params are:
# 1: size
# 2: packet/block size
# 3: per use defined "fit" function
#
# what fit-function's parameters are is TBD

Class(AMem, AGenericTag, rec(
	__call__ := meth(arg)
		local self, params;
		self := arg[1];
		params := Drop(arg, 1);
		return WithBases(self,
			rec(
				params := params,
				size := (self) >> self.params[1],
				blocks := (self) >> self.params[2],
				assoc := (self) >> self.params[3],
				operations := RewritableObjectOps
			)
		);
	end,

));

#
# Basic block tag.
#
# param1 is K, size of the basic block
# param2 is mu, the block/row/whatever size
#
# we assume K >= mu
#
Class(ABB, AGenericTag);


text:
# Copyright (c) 2018-2021, Carnegie Mellon University
# See LICENSE for details

#F ArgsExp(<exp>)
#F   Collects all location leaves in an expression.
#F   This is equivalent to Collect(exp, @.cond(IsLoc)), but has less overhead.
#F
ArgsExp := exp -> Cond(
    not IsRec(exp) or not IsSymbolic(exp), [],
    IsLoc(exp), Concatenation([exp], ConcatList(exp.rChildren(), ArgsExp)),
    IsValue(exp) or not IsBound(exp.args), [],
    Concatenation(List(exp.args, ArgsExp)));

assign.op_in  := self >> ConcatList(self.loc.rChildren(), ArgsExp) :: ArgsExp(self.exp);
assign.op_out := self >> [self.loc];
assign.op_inout := self >> [];

IsCmdOp := x -> IsCommand(x) and IsBound(x.op_in) and IsBound(x.op_out) and IsBound(x.op_inout);

VarArgsExp := exp -> Cond(
    IsVar(exp), [exp],
    IsValue(exp) or not IsRec(exp), [],
    ConcatList(exp.rChildren(), VarArgsExp));

#
# Def/Succ/Pred
#

MarkDefLoc := function(loc, d)
    loc.def := d;
    if not IsBound(loc.succ) then loc.succ := Set([]); fi;
end;

MarkPredLoc := function(loc, pred)
    pred := Set(ShallowCopy(pred));
    if not IsBound(loc.pred) then loc.pred := pred;
    # NOTE: below statement crashes with "<loc.pred> is not a set" error
    #        if UniteSet(loc.pred, pred) is used. This is an indication of
    #        broken < or = operations. Union() fixes the problem, but is
    #        essentially a hack
    else loc.pred := Union(loc.pred, pred);
    fi;

    if IsBound(loc.def) then
	if not IsBound(loc.def.pred) then loc.def.pred := pred;
	else loc.def.pred := Union(loc.def.pred, pred);
	fi;
    fi;
end;

# succesors is NOT a set to allow multiplicity (2 uses from same statement, like a = b*b, succ(b)=[a, a])
# this aids compiler from preventing propagation of b in this case in CopyPropagate.propagate()
#
MarkSuccLoc := function(loc, cmd_loc)
    if IsVar(loc) then
        if not IsBound(loc.succ) then loc.succ := [cmd_loc];
        else                          Add(loc.succ, cmd_loc); fi;

        if IsBound(loc.def) then
            if not IsBound(loc.def.succ) then loc.def.succ := [cmd_loc];
            else Add(loc.def.succ, cmd_loc);
            fi;
        fi;
    fi;
end;

DefLoc   := loc -> When(IsBound(loc.def),  loc.def,  false);
PredLoc  := loc -> When(IsBound(loc.pred), loc.pred, Set([]));
SuccLoc  := loc -> When(IsBound(loc.succ), loc.succ, ([]));

PredCmd  := cmd -> When(IsBound(cmd.pred), cmd.pred, Set([]));
SuccCmd  := cmd -> When(IsBound(cmd.succ), cmd.succ, ([]));

Declare(MarkDefUse, MarkPreds, ClearDefUse);

_ChainMarkDefUse := function(code)
    local c, u, pred;
    for c in code.cmds do
        if IsCmdOp(c) then
	    DoForAll(c.op_out(), x->MarkDefLoc(x, c));
	    pred := c.op_in() :: c.op_inout();
	    DoForAll(c.op_out(), x->MarkPredLoc(x, pred));
	    for u in pred do
	        DoForAll(c.op_out(), x->MarkSuccLoc(u, x));
	    od;
	else
	    DoForAll(c.rChildren(), MarkDefUse);
	fi;
    od;
    return code;
end;

_MarkDefUse := function(code)
    if not IsCommand(code) then return;
    elif IsChain(code) then _ChainMarkDefUse(code);
    else DoForAll(code.rChildren(), _MarkDefUse);
    fi;
    return code;
end;

MarkDefUse := function(code)
    code := ClearDefUse(code);
    return _MarkDefUse(code);
end;

_ChainMarkPreds := function(code)
    local c, u, pred;
    for c in code.cmds do
        if IsAssign(c) then
	    pred := c.op_in() :: c.op_inout();
	    MarkPredLoc(c.loc, pred);
	else
	    DoForAll(c.rChildren(), MarkPreds);
	fi;
    od;
    return code;
end;

_MarkPreds := function(code)
    if not IsCommand(code) then return;
    elif IsChain(code) then _ChainMarkPreds(code);
    else DoForAll(code.rChildren(), _MarkPreds);
    fi;
    return code;
end;

MarkPreds := function(code)
    code := ClearDefUse(code);
    return _MarkPreds(code);
end;

ClearDefUseLoc := function(loc)
   if IsBound(loc.def) then
       Unbind(loc.def.pred);
       Unbind(loc.def.succ);
   fi;
   Unbind(loc.def);
   Unbind(loc.succ);
   Unbind(loc.pred);
   return loc;
end;

depthLoc := x -> When(IsBound(x.depth), x.depth, 0);
rdepthLoc := (x, max) -> When(IsBound(x.rdepth), x.rdepth, max);

ComputeDepthsChain := function(code)
    local cmd, depth, rdepth, maxdepth, succs, dd, preds, succs;
    Constraint(ObjId(code)=chain);
    for cmd in code.cmds do
        Constraint(IsAssign(cmd));
	preds := PredCmd(cmd);
	dd := List(preds, depthLoc);
        depth := When(dd=[], 0, 1 + Maximum(dd));
	cmd.allpreds := Union(Filtered(preds,x->IsVar(x) and IsBound(x.def)),
	    Union(List(preds, x->When(IsVar(x) and IsBound(x.def) and
			              IsBound(x.def.allpreds), x.def.allpreds, []))));
        cmd.earliest := depth;
	cmd.loc.depth := depth;
    od;
    maxdepth := Length(code.cmds);
    for cmd in Reversed(code.cmds) do
	succs := SuccCmd(cmd);
        dd := List(succs, s -> rdepthLoc(s, maxdepth));
        rdepth := When(dd=[], maxdepth,  -1 + Minimum(dd));
	cmd.allsuccs := Union(succs,
	    Union(List(succs, x->When(IsBound(x.def) and
			              IsBound(x.def.allsuccs), x.def.allsuccs, []))));

        cmd.latest := rdepth;
	cmd.loc.rdepth := rdepth;

    od;
end;

#F ClearDefUse(<code)> - clears attributes set by MarkDefUse
#F
ClearDefUse := code -> Chain(DoForAll(Collect(code, var), ClearDefUseLoc), code);

DFSChain := function(code)
    local c, cmds, W, next, p, added, schedule;
    cmds := code.cmds; W := []; schedule := [];
    for c in cmds do
       if not IsBound(c.loc.generated) then
       Add(schedule, c); c.loc.generated := true;
       if IsBound(c.loc.succ) then
           Append(W, c.loc.succ);
       fi;
       fi;
       while Length(W)<>0 do
           next := Last(W);
       added := false;
       if IsBound(next.pred) then
           for p in next.pred do
               if not IsBound(p.generated) then Add(W, p); added := true; fi;
           od;
       fi;
       if not added then
           if IsBound(next.def) then Add(schedule, next.def); fi;
           next.generated := true;
           RemoveLast(W, 1);
       fi;
       od;
    od;

    for c in cmds do Unbind(c.loc.generated); od;
    return chain(schedule);
end;

InputsChain := code -> List(Filtered(code.cmds, x->not ForAny(x.loc.pred,p->IsBound(p.def))),x->x.loc);
OutputsChain := code -> List(Filtered(code.cmds, x->not IsBound(x.loc.succ) or x.loc.succ=[]), x->x.loc);

_ClearRedBlue := function(v) Unbind(v.blue); Unbind(v.red); end;

ClearRedBlue := code -> DoForAll(Collect(code, var), _ClearRedBlue);

_HSplitChain := function(c,inp,out)
    local i,o,x,inpsucc,outpred, mid,done,red,blue,rcmds,bcmds;
    mid := Set([]);
    blue := Set(inp); bcmds:=List(blue, x->x.def);
    red := Set(out); rcmds:=List(red, x->x.def);

    done := (inp=[]) and (out=[]);
    while not done do
        inp := Difference(Union(List(inp, x->x.succ)),blue); # unvisited successors
    out := Difference(Union(List(out, x->x.pred)),red); # unvisited predecessors

    for x in inp do
        AddSet(blue, x);
        if not (x in red) then Add(bcmds,x.def); fi;
    od;

    for x in out do
        AddSet(red, x);
        if not (x in blue) then Add(rcmds,x.def); fi;
    od;

    inp := Difference(inp, red);
    out := Difference(out, blue);

    done := (inp=[]) and (out=[]);
    od;
    return [Intersection(red,blue), bcmds, Reversed(rcmds)];
end;

HSplitChain := function(c)
    local inp, out, mid;
    inp := Set(InputsChain(c));
    out := Set(OutputsChain(c));
    mid := _HSplitChain(c, inp, out);
    return mid;
end;

scheduled := code -> Inherit(code, rec(cmd := DFSChain(code.cmd)));


text:
# Copyright (c) 2018-2020, Carnegie Mellon University
# See LICENSE for details

@TVectSVE := @.cond(x->x.t=TVectSVE);
@ValueTVectSVE := @.cond(x->x.t=TVectSVE and ObjId(x)=Value);

Class(SVEUnparserMixin, rec(
    sve_loopn := (self, o, i, is) >> let(v := o.var.id,
        pg := self.opts.pg.id,
        lo := 0,
        hi := o.range,
        Print(Blanks(i), "int ", v, " = 0;\n",
            Blanks(i), pg, " = svwhilelt_b64(", v, ", ", hi, ");\n",
            Blanks(i), "do {\n",
            self(o.cmd, i + is, is),
            Blanks(i + is), v, " += svcntd();\n",
            Blanks(i + is), pg, " = svwhilelt_b64(", v, ", ", hi, ");\n",
            Blanks(i), "} while(svptest_any(svptrue_b64(), ", self.opts.pg.id, "));\n")
    ),

# svfloat64_t svmulx[_n_f64]_z(svbool_t pg, svfloat64_t op1, float64_t op2)

# svcntd()
    sve_svcntd := (self, o, i, is) >> Print("svcntd()"),

# svfloat64_t
    TVectSVE := (self, t, vars, i, is) >> Print(When(IsBound(self.opts.TRealSVEtype), self.opts.TRealSVEtype, "svfloat64_t"), " ", self.infix(vars, ", ", i + is)),

# svbool_t
    TBoolSVE := (self, t, vars, i, is) >> Print("svbool_t ", self.infix(vars, ", ", i + is)),

# int64_t
    TInt64SVE := (self, t, vars, i, is) >> Print("int64t ", self.infix(vars, ", ", i + is)),

# svfloat64x2_t
    TVect := (self, t, vars, i, is) >> Print(When(IsBound(self.opts.TRealSVEtype), self.opts.TRealSVEtype, "svfloat64x2_t"), " ", self.infix(vars, ", ", i + is)),

    velem := (self, o, i, is) >> Print(self(o.loc, i, is), ".v", StringInt(o.idx.v)),

## svfloat64_t svld1_gather_[u64]offset[_f64](svbool_t pg, const float64_t *base, svuint64_t offsets)
    sve_gath := (self, o, i, is) >> Print("svld1_gather_u64offset_f64(", self(o.pg, i, is), ", ", self(o.loc, i, is), ", ",
        "svindex_u64(0, (int64_t)(", self(o.stride, i, is), " * sizeof(float64_t)))",
        ")"),

# svint64_t incx_vec = svindex_s64(0, incx);
# svfloat64_t dx_vec = svld1_gather_index(pg, dx, incx_vec);
#    sve_gath := (self, o, i, is) >> Print("svld1_gather_index(", self(o.pg, i, is), ", ", self(o.loc, i, is), ", ",
#        "svindex_s64(0, (int64_t)", self(o.stride, i, is), ")",
#        ")"),

## void svst1_scatter_u64_offset_f64(svbool_t pg, svuint64_t bases, int64_t offset, svfloat64_t data)
    sve_scat := (self, o, i, is) >> Print(Blanks(i), "svst1_scatter_u64offset_f64(", self(o.pg, i, is), ", ((float64_t  *)", self(o.loc, i, is), "), ",
            "svindex_u64(0, (int64_t)(", self(o.stride, i, is), " * sizeof(float64_t)))", ", ", self(o.exp, i, is), ");\n"),

# svfloat64x2_t svld2[_f64](svbool_t pg, const float64_t *base)
    sve_ld2 := (self, o, i, is) >> Print("svld2_f64(", self(o.pg, i, is), ", ", self(o.loc, i, is), ")"),

# void svst2[_f64](svbool_t pg, float64_t *base, svfloat64x2_t data)
    sve_st2 := (self, o, i, is) >> Print(Blanks(i), "svst2_f64(", self(o.pg, i, is), ", ", self(o.loc, i, is), ", ", self(o.exp, i, is), ");\n"),

# Arithmetic
    mul := (self, o, i, is) >> let(n := Length(o.args), Cond(
        not o.t = TVectSVE,
            Print("(", self.pinfix(o.args, ")*("), ")"),
 	    n > 2 and n mod 2 <> 0,
            self(mul(o.args[1], ApplyFunc(mul, Drop(o.args, 1))), i, is),
        n > 2,
            self(mul(ApplyFunc(mul, o.args{[1..n/2]}), ApplyFunc(mul, o.args{[n/2+1..n]})), i, is),
        CondPat(o,
# svfloat64_t svmul[_n_f64]_x(svbool_t pg, svfloat64_t op1, float64_t op2)
           [mul, @ValueTVectSVE, @TVectSVE],
               self.printf("svmul_n_f64_x($1, $2, $3)", [self.opts.pg, o.args[2], o.args[1]]),
           [mul, @TVectSVE, @ValueTVectSVE],
               self.printf("svmul_n_f64_x($1, $2, $3)", [self.opts.pg, o.args[1], o.args[2]]),
           [mul, @TReal, @TVectSVE],
               self.printf("svmul_n_f64_x($1, $2, $3)", [self.opts.pg, o.args[2], o.args[1]]),
           [mul, @TVectSVE, @TReal],
               self.printf("svmul_n_f64_x($1, $2, $3)", [self.opts.pg, o.args[1], o.args[2]]),
           [mul, @TInt, @TVectSVE],
               self(mul(_toReal(o.args[1]), o.args[2]), i, is),
           [mul, @TVectSVE, @TInt],
               self(mul(o.args[1], _toReal(o.args[2])), i, is),
# svfloat64_t svmul[_f64]_x(svbool_t pg, svfloat64_t op1, float64_t op2)
           [mul, @TVectSVE, @TVectSVE],
               self.printf("svmul_f64_x($1, $2, $3)", [self.opts.pg, o.args[1], o.args[2]]),
           Error("Don't know how to unparse <o>. Unrecognized type combination")))
    ),

# -- add --
    add := (self, o, i, is) >> let(n := Length(o.args), Cond(
        not o.t = TVectSVE,
            self.pinfix(o.args, " + "),
        n > 2 and n mod 2 <> 0,
            self(add(o.args[1], ApplyFunc(add, Drop(o.args, 1))), i, is),
        n > 2,
            self(add(ApplyFunc(add, o.args{[1..n/2]}), ApplyFunc(add, o.args{[n/2+1..n]})), i, is),
        CondPat(o,
            [add, @TReal, @TVectSVE],
# svfloat64_t svadd[_n_f64]_x(svbool_t pg, svfloat64_t op1, svfloat64_t op2)
                self.printf("svadd_n_f64_x($1, $2, $3)", [self.opts.pg, o.args[2], o.args[1]]),
            [add, @TVectSVE, @TReal],
                self.printf("svadd_n_f64_x($1, $2, $3)", [self.opts.pg, o.args[1], o.args[2]]),
            [add, @TInt, @TVectSVE],
                self(add(_toReal(o.args[1]), o.args[2]), i, is),
            [add, @TVectSVE, @TInt],
                self(add(o.args[1], _toReal(o.args[2])), i, is),
# svfloat64_t svadd[_f64]_x(svbool_t pg, svfloat64_t op1, svfloat64_t op2)
            [add, @TVectSVE, @TVectSVE],
                self.printf("svadd_f64_x($1, $2, $3)", [self.opts.pg, o.args[1], o.args[2]]),
            Error("Don't know how to unparse <o>. Unrecognized type combination")))
    ),

    sub := (self, o, i, is) >> Cond(
        not o.t = TVectSVE,
            Inherited(o, i, is),
        CondPat(o,
            [sub, @TReal, @TVectSVE],
# svfloat64_t svsub[_n_f64]_x(svbool_t pg, svfloat64_t op1, float64_t op2)
                self.printf("svsubr_n_f64_x($1, $2, $3)", [self.opts.pg, o.args[2], o.args[1]]),
            [sub, @TVectSVE, @TReal],
                self.printf("svsub_n_f64_x($1, $2, $3)", [self.opts.pg, o.args[1], o.args[2]]),
            [sub, @TInt, @TVectSVE],
                self(add(_toReal(o.args[1]), o.args[2]), i, is),
            [sub, @TVectSVE, @TInt],
                self(add(o.args[1], _toReal(o.args[2])), i, is),
# svfloat64_t svadd[_f64]_x(svbool_t pg, svfloat64_t op1, svfloat64_t op2)
            [sub, @TVectSVE, @TVectSVE],
                self.printf("svsub_f64_x($1, $2, $3)", [self.opts.pg, o.args[1], o.args[2]]),
            Error("Don't know how to unparse <o>. Unrecognized type combination"))
    ),

#    neg := (self, o, i, is) >> Cond( _avxT(o.t, self.opts),
#        self(mul(neg(o.t.one()), o.args[1]), i, is),
#        Inherited(o, i, is)),
#

    fma := (self, o, i, is) >> When(
        Length(o.args) <> 3, Error("fma is strictly ternary"),
        CondPat(o,
# svfloat64_t svmla[_n_f64]_x(svbool_t pg, svfloat64_t op1, svfloat64_t op2, float64_t op3)
           [fma, @TVectSVE, @TVectSVE, @ValueTVectSVE],
                self.printf("svmla_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[2], o.args[3]]),
           [fma, @TVectSVE, @ValueTVectSVE, @TVectSVE],
                self.printf("svmla_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[3], o.args[2]]),
           [fma, @TVectSVE, @TVectSVE, @TReal],
                self.printf("svmla_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[2], o.args[3]]),
           [fma, @TVectSVE, @TReal, @TVectSVE],
                self.printf("svmla_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[3], o.args[2]]),
# svfloat64_t svmla[_f64]_x(svbool_t pg, svfloat64_t op1, svfloat64_t op2, svfloat64_t op3)
           [fma, @TVectSVE, @TVectSVE, @TVectSVE],
                self.printf("svmla_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[2], o.args[3]]),
           Error("Don't know how to unparse <o>. Unrecognized type combination")
        )),

    nfma := (self, o, i, is) >> When(
        Length(o.args) <> 3, Error("nfma is strictly ternary"),
        CondPat(o,
# svfloat64_t svnmls[_n_f64]_x(svbool_t pg, svfloat64_t op1, svfloat64_t op2, float64_t op3)
           [nfma, @TVectSVE, @TVectSVE, @ValueTVectSVE],
                self.printf("svnmls_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[2], o.args[3]]),
           [nfma, @TVectSVE, @ValueTVectSVE, @TVectSVE],
                self.printf("svnmls_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[3], o.args[2]]),
           [nfma, @TVectSVE, @TVectSVE, @TReal],
                self.printf("svnmls_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[2], o.args[3]]),
           [nfma, @TVectSVE, @TReal, @TVectSVE],
                self.printf("svnmls_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[3], o.args[2]]),
# svfloat64_t svnmls[_f64]_x(svbool_t pg, svfloat64_t op1, svfloat64_t op2, svfloat64_t op3)
           [nfma, @TVectSVE, @TVectSVE, @TVectSVE],
                self.printf("svnmls_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[2], o.args[3]]),
           Error("Don't know how to unparse <o>. Unrecognized type combination")
        )),

    fms := (self, o, i, is) >> When(
        Length(o.args) <> 3, Error("fms is strictly ternary"),
        CondPat(o,
# svfloat64_t svmls[_n_f64]_x(svbool_t pg, svfloat64_t op1, svfloat64_t op2, float64_t op3)
           [fms, @TVectSVE, @TVectSVE, @ValueTVectSVE],
                self.printf("svmls_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[2], o.args[3]]),
           [fms, @TVectSVE, @ValueTVectSVE, @TVectSVE],
                self.printf("svmls_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[3], o.args[2]]),
           [fms, @TVectSVE, @TVectSVE, @TReal],
                self.printf("svmls_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[2], o.args[3]]),
           [fms, @TVectSVE, @TReal, @TVectSVE],
                self.printf("svmls_n_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[3], o.args[2]]),
# svfloat64_t svmls[_f64]_m(svbool_t pg, svfloat64_t op1, svfloat64_t op2, svfloat64_t op3)
           [fms, @TVectSVE, @TVectSVE, @TVectSVE],
                self.printf("svmls_f64_x($1, $2, $3, $4)", [self.opts.pg, o.args[1], o.args[2], o.args[3]]),
           Error("Don't know how to unparse <o>. Unrecognized type combination")
        )),

));

Class(SVEUnparser, SVEUnparserMixin, CUnparser);

max_stars_repo_name: spiral-software/spiral-package-ffte

max_issues_repo_name: spiral-software/spiral-package-ffte

max_forks_repo_name: spiral-software/spiral-package-ffte


text:
accu := function(n)
  local f, v;
  v := n;
  f := function(a)
    v := v + a;
    return v;
  end;
  return f;
end;

a := accu(0);
# function( a ) ... end
b := accu(100);
# function( a ) ... end
a(6);
# 6
b(6);
# 106
a(1);
# 7
b(1);
# 107
# These functions also accept other types, as long as addition is meaningful
b(1/FLOAT_INT(3))
# 107.333
a(2/3);
# 23/3
a([1, 2, 3]);
# [ 26/3, 29/3, 32/3 ]

max_stars_repo_name: djgoku/RosettaCodeData

max_issues_repo_name: djgoku/RosettaCodeData

max_forks_repo_name: djgoku/RosettaCodeData


text:
##  Copyright (c) 2018-2021, Carnegie Mellon University
##  See LICENSE for details

# get “system default” as defined by SPIRAL startup scripts
LocalConfig.defaultConf();

# pick from a number of default configs
LocalConfig.supportedConfs.confGPU();
LocalConfig.supportedConfs.confMultiGPU();
LocalConfig.supportedConfs.confSclarCPU();
LocalConfig.supportedConfs.confOMPVMX();
…

# guru interface by configuring confs
LocalConfig.defaultConf(rec(useCPU := true, useGPU := false, useP9 := true, useOpenMP := true));
LocalConfig.defaultConf(rec(useCPU := false, useGPU := true, useMultiGPU := false));
LocalConfig.supportedConfs.confOMPVMX(rec(threads := 4, OMPver := “4.1.2”));

max_stars_repo_name: franzfranchetti/spiral-package-fftx

max_issues_repo_name: franzfranchetti/spiral-package-fftx

max_forks_repo_name: franzfranchetti/spiral-package-fftx


text:
Read("SchreierSims.gi");
LoadPackage( "AtlasRep" );

MicroSeconds := function()
  local t;
  t := IO_gettimeofday();
  return t.tv_sec * 1000000 + t.tv_usec;
end;

n:=11;

Groups := ["M11", "M23", "M24", "J1", "J2", "J3", "Suz", "Co2", "Fi22"];
#Groups := [120];

for group in Groups do
    counter := 0;
    time := [[],[],[],[]];
    Print("Group: ");  Print(group);
    while counter < 5 do
        G := AtlasGroup(group);
        #G := SymmetricGroup(group);
        S := Set(GeneratorsOfGroup(G)); n := LargestMovedPoint(G); B := [];
        t1 := MicroSeconds();
        BSGS := RandomSchreierSims(B, S, 10, n);
        t2 := (MicroSeconds() - t1) * 1.0 / 1000000;
        RemoveRedundantGens(BSGS, S, n);
        upper_bound := Length(BSGS[1]);
        results := [1..Length(BSGS[1])];

        ## parallelization w.r.t. base
        t1 := MicroSeconds();
        tasks := [1..Length(BSGS[1])];
        for l in [1..upper_bound] do
            tasks[l] := RunTask(SimpleVerify, BSGS, l);
        od;
        for l in [1..upper_bound] do
            results[l] := TaskResult(tasks[l]);
        od;
        if false in results then
            continue;
        fi;
        Add(time[4], t2);
        counter := counter + 1;
        Add(time[1], (MicroSeconds() - t1) * 1.0 / 1000000);

        results := [1..Length(BSGS[1])];

        ## parallelization w.r.t. base
        t1 := MicroSeconds();
        for l in Reversed([1..upper_bound]) do
            results[l] := ParallelVerify(BSGS, l);
        od;
        Add(time[2], (MicroSeconds() - t1) * 1.0 / 1000000);

        results := [1..Length(BSGS[1])];

        ## no parallelization
        t1 := MicroSeconds();
        for l in Reversed([1..upper_bound]) do
            results[l] := SimpleVerify(BSGS, l);
        od;
        Add(time[3], (MicroSeconds() - t1) * 1.0 / 1000000);
    od;
    average := [0,0,0,0];
    for i in [1..5] do
        average[1] := average[1] + time[1][i]/5;
        average[2] := average[2] + time[2][i]/5;
        average[3] := average[3] + time[3][i]/5;
        average[4] := average[4] + time[4][i]/5;
    od;
    Print(", calculation time: "); Print(average[4]); Print(", times: "); Print(average{[1..3]}); Print("\n");
od;

max_stars_repo_name: AlexanderKlemps/parallel-schreier-sims

max_issues_repo_name: AlexanderKlemps/parallel-schreier-sims

max_forks_repo_name: AlexanderKlemps/parallel-schreier-sims


text:
#
# Read("~/Workspace/Chevalley.gap/init.gi"); Read(Filename(home_dir,"load.gi")); Read(Filename(test_dir,"unicls.test.gi"));
#
# Read("~/Workspace/Chevalley.gap/init.gi"); Read(Filename(test_dir,"unicls.test.init.gi")); Read(Filename(test_dir,"unicls.test.gi"));
#
# Read(Filename(test_dir,"unicls.test.gi"));
#

sys:=AlgebraicU(ChevalleyAdj("F",4,GF(2)));
orbs:=UnipotentClasses(sys,"");
Print("Created AlgebraicU ",orbs,"\n");
Print("\t[",IsUnipotentClasses(orbs)=true,"] IsUnipotentClasses(orbs)=true\n");


text:
################################################################################
##
#W compute_cohomology.gi              GroupTheoretical Package
##
#W Paul Bruillard, Cesar Galindo, Siu-Hung Ng, Julia Plavnik, Eric Rowell,
#W Zhenghan Wang
##
## Installation file for compute_cohomology functions of the GroupTheoretical Package
##
#Y Copyright (C) 2016, Battelle Memorial Institute
##
################################################################################

################################################################################
##
#F get_cohomology(<group>,<int>). . . . a helper function for computing cocycles
##
InstallGlobalFunction(get_cohomology, function(G,k)
  local HkG, s, InitialA, a, OrderedA, A, R, C, CH, H, classes, cocycles, w;

  HkG:=GroupHomology(G,k);;
  if Size(HkG)=0 then s:=2; else s:=Lcm(HkG); fi;;
  InitialA:=CyclicGroup(s);;
  a:=MinimalGeneratingSet(InitialA)[1];;
  OrderedA:=List([1..s],x->a^x);;
  A:=TrivialGModuleAsGOuterGroup(G,InitialA);;
  R:=ResolutionFiniteGroup(G,k+1);;
  C:=HomToGModule(R,A);;
  CH:=CohomologyModule(C,k);;
  H:=ActedGroup(CH);;
  classes:=Elements(H);;
  cocycles:=List(classes,x->Mapping(CH!.representativeCocycle(x)));;
  cocycles:=List(cocycles,x->function(g,h,k) return E(s)^(Position(OrderedA,x(g,h,k))); end);;
  return [H,cocycles];;
end);

#E compute_cohomology.gi . . . . . . . . . . . . . . . . . . . . . . . ends here

max_stars_repo_name: pnnl/GroupTheoretical

max_issues_repo_name: pnnl/GroupTheoretical

max_forks_repo_name: pnnl/GroupTheoretical