24 Test Basic Combinatorial Species

 24.1 Test EmptySetSpecies
 24.2 Test CharacteristicSetSpecies
 24.3 Test SetSpecies
 24.4 Test Subset
 24.5 Test Partition
 24.6 Test LinearOrder
 24.7 Test Cycle
 24.8 Test Permutation
 24.9 Test Two-Element Subsets
 24.10 Test Constructors
 24.11 Test Recursive Structures
 24.12 Test Composition
 24.13 Test Functorial Composition

In this file we test src/species.as.nw.

626* 13+   613  660
-------------------------------------------------------------------
----
---- Combinat
---- Copyright (C) Ralf Hemmecke <ralf@hemmecke.de>
---- Copyright (C) Martin Rubey <martin.rubey@univie.ac.at>
---- svn co svn://svn.risc.uni-linz.ac.at/hemmecke/combinat/
----
-------------------------------------------------------------------

#assert DontNeedLibraryTestCases
#include "testcases"

TestCombinatorialSpecies: TestCaseType with {
#include "species.signatures.as"
} == add {
        import from TestCaseTools;
        macro {
                V == CycleIndexVariable;
                NonNegativeMachineInteger == I;
                T == SparseIndexedPowerProduct(V, NonNegativeMachineInteger);
                P == SparseDistributedPolynomial(Q, V, T);
                SPECIES == (L: LabelType) -> CombinatorialSpecies L;
        }
        import from I, Z, Q, Array Z, V, T, P, Array P;
        local x(i: I): P == power(i :: V, 1) :: P;
        local y(i: I): P == power(1 :: V, i) :: P;
        local x(i: I, e: I): P == power(i :: V, e) :: P;
        local bracket(t: Tuple Z): Array P == {
                a: Array P := new(length t);
                for i:I in 0..prev length t repeat {
                        a.i := element(t, next i)::Q * y.i;
                }
                a;
        }
        auxiliary 628
        test EmptySetSpecies 629
        test CharacteristicSpecies 630a
        test SetSpecies 632
        test Subset 633a
        test Partition 634
        test LinearOrder 635
        test Cycle 637
        test Permutation 639
        test TwoElement Subset 640
        test Constructor 641a
        test Recursive 643
        test Compose 649
        test Functorial Compose 655
        test CompilerBug 657
        --<<test SpeciesCollection>>
}

Defines:
TestCombinatorialSpecies, never used.

Uses Array 599, CombinatorialSpecies 71, CycleIndexVariable 329, I 47, LabelType 62, Q 47, SparseDistributedPolynomial 526, SparseIndexedPowerProduct 506, SPECIES 55, and Z 47.
628auxiliary 628  (626 660 669 728)  661a
check(
    S: SPECIES,
    expExpected: Array Integer,
    ordExpected: Array Integer,
    cisExpected: Array P
): () == {
        import from I, List Z, S Z, List S Z;

        egs: ExponentialGeneratingSeries == generatingSeries;
        computed: Array Integer := [
            count(egs, n) for n in 0 .. prev #expExpected
        ];
        assertEquals(Array Integer, expExpected, computed);

        ogs: OrdinaryGeneratingSeries == isomorphismTypeGeneratingSeries;
        computed := [
            coefficient(ogs, n) for n in 0 .. prev #ordExpected
        ];
        assertEquals(Array Integer, ordExpected, computed);

        cis: CycleIndexSeries == cycleIndexSeries;
        computedP := [
            coefficient(cis, n) for n in 0 .. prev #cisExpected
        ];
        assertEquals(Array P, cisExpected, computedP);

-- Test whether there are as many structures generated as the
-- generating series says.
        for n:I in 0..9 while count(egs, n) < 20 repeat {
                labels: SetSpecies Z := set [z::Z for z in 1..n];
                assertEquals(Z, count(egs, n), (#[structures labels])::Z);
        }

-- Test whether there are as many isomorphim types generated as the
-- generating series says.
        for n:I in 0..9 while count(ogs, n) < 20 repeat {
                labels: SetSpecies Z := set [z::Z for z in 1..n];
                assertEquals(Z, count(ogs, n),(#[isomorphismTypes labels])::Z);
        }
}

Uses Array 599, CycleIndexSeries 330, ExponentialGeneratingSeries 316, I 47, Integer 66, OrdinaryGeneratingSeries 311, SetSpecies 117, SPECIES 55, and Z 47.