GiNaCRA  0.6.4
Groebner.h
Go to the documentation of this file.
00001 /*
00002  * GiNaCRA - GiNaC Real Algebra package
00003  * Copyright (C) 2010-2012  Ulrich Loup, Joachim Redies, Sebastian Junges
00004  *
00005  * This file is part of GiNaCRA.
00006  *
00007  * GiNaCRA is free software: you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation, either version 3 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * GiNaCRA is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with GiNaCRA.  If not, see <http://www.gnu.org/licenses/>.
00019  *
00020  */
00021 
00022 
00023 #ifndef GROEBNER_H
00024 #define GROEBNER_H
00025 
00026 #include "MultivariatePolynomialMR.h"
00027 
00028 namespace GiNaCRA
00029 {
00037     class Groebner
00038     {
00039         public:
00040 
00041             Groebner();
00042 
00047             Groebner( const MultivariatePolynomialMR& p1 );
00048 
00054             Groebner( const MultivariatePolynomialMR& p1, const MultivariatePolynomialMR& p2 );
00055 
00062             Groebner( const MultivariatePolynomialMR& p1, const MultivariatePolynomialMR& p2, const MultivariatePolynomialMR& p3 );
00063 
00069             Groebner( std::list<MultivariatePolynomialMR>::iterator begin_generatingset,
00070                       std::list<MultivariatePolynomialMR>::iterator end_generatingset );
00071 
00072             void addPolynomial( const MultivariatePolynomialMR& p1 );
00073 
00080             void solve();
00081 
00085             void reduce();
00086 
00093             friend std::ostream& operator <<( std::ostream& os, const Groebner& rhs )
00094             {
00095                 os << "{";
00096                 for( lpol_cIt i = rhs.mGB.begin(); i != rhs.mGB.end(); ++i )
00097                 {
00098                     os << *i << std::endl;
00099                 }
00100                 return os << "}";
00101             }
00102 
00106             void print() const
00107             {
00108                 std::cout << "{" << std::endl;
00109                 for( lpol_cIt i = mGB.begin(); i != mGB.end(); ++i )
00110                 {
00111                     std::cout << i->toEx() << std::endl;
00112                 }
00113                 std::cout << "}";
00114             }
00115 
00116             std::list<MultivariatePolynomialMR> getBase()
00117             {
00118                 return mGB;
00119             }
00120 
00121             inline bool isConstant() const
00122             {
00123                 return mGB.size() == 1 && mGB.begin()->isConstant();
00124             }
00125 
00130             inline bool isEmpty() const
00131             {
00132                 return mIdeal.empty();
00133             }
00134 
00139             inline unsigned size() const
00140             {
00141                 return mGB.size();
00142             }
00143 
00144             inline bool isReduced() const
00145             {
00146                 return mIsReduced;
00147             }
00148 
00149             inline bool isSolved() const
00150             {
00151                 return pairsToBeChecked.empty();
00152             }
00153 
00154             bool hasBeenReduced() const;
00155 
00156         private:
00157             void fillB();
00158 
00159             std::list<MultivariatePolynomialMR>                         mIdeal;
00160             std::list<MultivariatePolynomialMR>                         mGB;
00161             typedef std::list<MultivariatePolynomialMR>::iterator       lpol_It;
00162             typedef std::list<MultivariatePolynomialMR>::const_iterator lpol_cIt;
00163 
00165             std::list<std::pair<lpol_cIt, lpol_cIt> > pairsToBeChecked;
00166 
00168             bool mIsSolved;
00170             bool mIsReduced;
00171     };
00172 
00173 }
00174 #endif