Ejemplo n.º 1
0
    // Generate a list of permutations taking distinguishable particles into
    // account. That is protons and electrons won't be swapped
    public List <Permutation> permutations()
    {
        // Generate List of List of indistinguishable particles
        List <List <int> > listlist = new List <List <int> >();
        List <int>         tmplist  = new List <int>();
        Particle           p        = problem.getParticles()[0];

        tmplist.Add(0);
        for (int i = 1; i < nParticles; i++)
        {
            if (problem.getParticles()[i].equals(p))
            {
                tmplist.Add(i);
            }
            else
            {
                listlist.Add(new List <int>(tmplist));
                tmplist = new List <int>();
                tmplist.Add(i);
                p = problem.getParticles()[i];
            }
            if (i == nParticles - 1)
            {
                listlist.Add(new List <int>(tmplist));
            }
        }

        // Generate List of List of permutations
        List <List <Permutation> > llp = new List <List <Permutation> >();

        foreach (List <int> list in listlist)
        {
            List <Permutation> permu = new List <Permutation>();
            permu.Add(new Permutation(list, 1, -1)); // Need to change last parameter if boson
            llp.Add(Misc.permutations(permu));
        }

        // List containing all previous permutations
        List <Permutation> lp = new List <Permutation>();

        for (int i = llp.Count - 1; i > -1; i--)
        {
            List <Permutation> tmp = new List <Permutation>();
            foreach (Permutation per in llp[i])
            {
                Permutation clone = per.Clone();
                if (lp.Count == 0)
                {
                    tmp.Add(clone);
                }
                foreach (Permutation peru in lp)
                {
                    Permutation clone2 = per.Clone();
                    clone2.Append(peru);
                    tmp.Add(clone2);
                }
            }
            lp = new List <Permutation>(tmp);
        }
        return(lp);
    }