GiNaCRA  0.6.4
RationalUnivariatePolynomial.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 GINACRA_RATIONALUNIVARIATEPOLYNOMIAL_H
00024 #define GINACRA_RATIONALUNIVARIATEPOLYNOMIAL_H
00025 
00026 #include "UnivariatePolynomial.h"
00027 #include "OpenInterval.h"
00028 
00029 using GiNaC::ex_to;
00030 
00031 namespace GiNaCRA
00032 {
00042     class RationalUnivariatePolynomial:
00043         public UnivariatePolynomial
00044     {
00045         public:
00046 
00048             // Con- and destructors //
00050 
00054             RationalUnivariatePolynomial():
00055                 UnivariatePolynomial()
00056             {}
00057 
00063             RationalUnivariatePolynomial( const ex& p, const symbol& s ) throw ( invalid_argument );
00064 
00069             RationalUnivariatePolynomial( const UnivariatePolynomial& p ) throw ( invalid_argument );
00070 
00072             // Operations //
00074 
00079             numeric coeff( int i ) const
00080             {
00081                 return ex_to<numeric>( ex::coeff( mVariable, i ));    // cast safe because of the constructor
00082             }
00083 
00087             numeric lcoeff() const
00088             {
00089                 return ex_to<numeric>( ex::lcoeff( mVariable ));
00090             }
00091 
00095             numeric tcoeff() const
00096             {
00097                 return ex_to<numeric>( ex::tcoeff( mVariable ));
00098             }
00099 
00105             GiNaC::sign sgn( const numeric& a ) const;
00106 
00111             numeric evaluateAt( const numeric& a ) const;
00112 
00116             numeric oneNorm() const;
00117 
00121             numeric twoNorm() const;
00122 
00126             numeric maximumNorm() const;
00127 
00131             numeric cauchyBound() const;
00132 
00136             unsigned countRealRoots() const;
00137 
00145             numeric approximateRealRoot( const numeric start, const OpenInterval& i, unsigned steps = 3 ) const;
00146 
00148             // Static Methods //
00150 
00158             static list<RationalUnivariatePolynomial> standardSturmSequence( const RationalUnivariatePolynomial& a,
00159                                                                              const RationalUnivariatePolynomial& b );
00160 
00167             static unsigned signVariations( const list<RationalUnivariatePolynomial>& seq, const numeric& a );
00168 
00176             static int calculateSturmCauchyIndex( const RationalUnivariatePolynomial& p, const RationalUnivariatePolynomial& q );
00177 
00183             static unsigned countRealRoots( const list<RationalUnivariatePolynomial>& seq, const OpenInterval& i )
00184             {
00185                 // number of real roots in i, due to Sturm's theorem
00186                 return signVariations( seq, i.left() ) - signVariations( seq, i.right() );
00187             }
00188 
00194             static unsigned countRealRoots( const RationalUnivariatePolynomial& p, const OpenInterval& i )
00195             {
00196                 list<RationalUnivariatePolynomial> seq = standardSturmSequence( p, p.diff() );
00197                 return signVariations( seq, i.left() ) - signVariations( seq, i.right() );
00198             }
00199 
00207             static int calculateRemainderTarskiQuery( const RationalUnivariatePolynomial& p, const RationalUnivariatePolynomial& q );
00208 
00217             //template<class BidirectionalIterator>
00218             //static std::set<std::vector<Sign> > calculateSignDetermination(const RationalUnivariatePolynomial& z, const std::vector<RationalUnivariatePolynomial>& polynomials);
00219     };
00220 
00221 }    // namespace GiNaC
00222 
00223 #endif // GINACRA_RATIONALUNIVARIATEPOLYNOMIAL_H