Exemple #1
0
    void BooleanInvolutiveBasis<MonomType>::ReduceSet(bool toGroebner)
    {
        std::list<Polynom<MonomType>*> tmpPolySet;
        GBasis.sort(PointerMoreComparator<Polynom<MonomType> >());

        while (!GBasis.empty())
        {
            Polynom<MonomType>* currentPolynom = GBasis.front();
            GBasis.pop_front();
            currentPolynom = Reduce(currentPolynom, tmpPolySet, toGroebner);

            if (currentPolynom && !currentPolynom->IsZero())
            {
                const MonomType& hLm = currentPolynom->Lm();
                typename std::list<Polynom<MonomType>*>::iterator iteratorTmpPolySet = tmpPolySet.begin();
                while (iteratorTmpPolySet != tmpPolySet.end())
                {
                    if ((**iteratorTmpPolySet).Lm().IsDivisibleBy(hLm))
                    {
                        GBasis.push_back(*iteratorTmpPolySet);
                        iteratorTmpPolySet = tmpPolySet.erase(iteratorTmpPolySet);
                    }
                    else
                    {
                        ++iteratorTmpPolySet;
                    }
                }
                tmpPolySet.push_back(currentPolynom);
            }
        }

        unsigned tmpPolySetSize = static_cast<unsigned int>(tmpPolySet.size());
        for (register unsigned i = 0; i < tmpPolySetSize; ++i)
        {
            Polynom<MonomType>* currentPolynom = tmpPolySet.front();
            tmpPolySet.pop_front();
            currentPolynom = Reduce(currentPolynom, tmpPolySet, toGroebner);
            if (!currentPolynom || currentPolynom->IsZero())
            {
                tmpPolySetSize--;
            }
            else
            {
                tmpPolySet.push_back(currentPolynom);
            }
        }

        GBasis = tmpPolySet;
    }
Exemple #2
0
    void TSet<MonomType>::CollectNonMultiProlongations(typename TSet<MonomType>::Iterator& iterator, std::list<Triple<MonomType>*>& set)
    {
        if (iterator == TripleList.end() || !(*iterator))
        {
            return;
        }

        typename MonomType::Integer firstMultiVar = (**iterator).GetPolynomLm().FirstMultiVar();
        for (register typename MonomType::Integer var = 0; var < firstMultiVar; ++var)
        {
            if (!(**iterator).TestNmp(var))
            {
                Polynom<MonomType>* tmpPolynom = new Polynom<MonomType>(*(**iterator).GetPolynom());
                (*tmpPolynom) *= var;

                (**iterator).SetNmp(var);

                if (!tmpPolynom->IsZero())
                {
                    set.push_back(new Triple<MonomType>(tmpPolynom
                                                      , (**iterator).GetAncestor()
                                                      , (**iterator).GetNmp()
                                                      , (*iterator)
                                                      , var)
                                 );
                }
                delete tmpPolynom;
            }
        }
    }
Exemple #3
0
    Polynom<MonomType>* BooleanInvolutiveBasis<MonomType>::NormalForm(const Triple<MonomType>* triple) const
    {
        /* As far as currentTriple can't be 0 (checked in QSET and TSET),
         * no need to check for NULL pointer. 
         */

        const Triple<MonomType>* involutiveDivisor = 0;
        Polynom<MonomType>* originalForm = 0;
        Polynom<MonomType>* normalForm = new Polynom<MonomType>();

        if (triple->GetVariable() == -1)
        {
            originalForm = new Polynom<MonomType>(*triple->GetPolynom());
        }
        else
        {
            originalForm = new Polynom<MonomType>(*triple->GetWeakAncestor()->GetPolynom());
            (*originalForm) *= triple->GetVariable();
        }

        while (!originalForm->IsZero())
        {
            involutiveDivisor = IntermediateBasis.Find(originalForm->Lm());
            while (involutiveDivisor)
            {
                originalForm->HeadReduction(*involutiveDivisor->GetPolynom());
                if (!originalForm->IsZero())
                {
                    involutiveDivisor = IntermediateBasis.Find(originalForm->Lm());
                }
                else
                {
                    involutiveDivisor = 0;
                }
            }

            if (!originalForm->IsZero())
            {
                (*normalForm) += originalForm->Lm();
                originalForm->RidOfLm();
            }
        }

        delete originalForm;
        return normalForm;
    }
Exemple #4
0
    void BooleanInvolutiveBasis<MonomType>::ConstructInvolutiveBasis()
    {
        typename TSet<MonomType>::Iterator tit(IntermediateBasis.Begin());
        Polynom<MonomType>* newNormalForm = 0;
        Triple<MonomType>* currentTriple = 0;

        while (!ProlongationsSet.Empty())
        {
            currentTriple = ProlongationsSet.Get();
            newNormalForm = NormalForm(currentTriple);
            /* As far as currentTriple can't be 0 (checked in QSET and TSET),
             * NormalForm can't return 0.
             */

            std::set<typename MonomType::Integer> currentNmpSet;
            const Triple<MonomType>* currentAncestor = 0;
            if (!newNormalForm->IsZero() && newNormalForm->Lm() == currentTriple->GetPolynomLm())
            {
                currentNmpSet = currentTriple->GetNmp();
                currentAncestor = currentTriple->GetAncestor();
                if (currentAncestor == currentTriple) 
                {
                    currentAncestor = 0;
                }
            }
            delete currentTriple;

            if (!newNormalForm->IsZero())
            {
                std::list<Triple<MonomType>*> newProlongations;
                tit = IntermediateBasis.Begin();

                while (tit != IntermediateBasis.End())
                {
                    if ((**tit).GetPolynomLm().IsTrueDivisibleBy(newNormalForm->Lm()))
                    {
                        ProlongationsSet.DeleteDescendants(*tit);
                        newProlongations.push_back(*tit);
                        tit = IntermediateBasis.Erase(tit);
                    }
                    else
                    {
                        ++tit;
                    }
                }

                IntermediateBasis.PushBack(new Triple<MonomType>(newNormalForm, currentAncestor, currentNmpSet, 0, -1));
                if (!newNormalForm->Degree())
                {
                    return;
                }

                IntermediateBasis.CollectNonMultiProlongations(--IntermediateBasis.End(), newProlongations);
                ProlongationsSet.Insert(newProlongations);
            }
            else
            {
                delete newNormalForm;
            }
        }
    }