GiNaCRA  0.6.4
RealAlgebraicNumberFactory.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_REALALGEBRAICNUMBERFACTORY_H
00024 #define GINACRA_REALALGEBRAICNUMBERFACTORY_H
00025 
00026 #include <tr1/memory>
00027 
00028 #include "settings.h"
00029 #include "RealAlgebraicNumber.h"
00030 #include "RealAlgebraicNumberIR.h"
00031 #include "RealAlgebraicNumberNR.h"
00032 
00033 namespace GiNaCRA
00034 {
00036     // Typedefs //
00038 
00039     typedef std::map<symbol, RealAlgebraicNumberIRPtr, GiNaC::ex_is_less> evalmap;
00040 
00049     class RealAlgebraicNumberFactory
00050     {
00051         public:
00052 
00054             // Common //
00056 
00064             static bool equal( const RealAlgebraicNumberPtr& a, const RealAlgebraicNumberPtr& b );
00065 
00073             static bool less( const RealAlgebraicNumberPtr& a, const RealAlgebraicNumberPtr& b );
00074 
00079             static bool isRealAlgebraicNumberNR( const RealAlgebraicNumberPtr& a );
00080 
00085             static bool isRealAlgebraicNumberIR( const RealAlgebraicNumberPtr& a );
00086 
00088             // Real Roots //
00090 
00100             static list<RealAlgebraicNumberPtr> realRoots( const RationalUnivariatePolynomial& p,
00101                                                            RealAlgebraicNumberSettings::IsolationStrategy pivoting = RealAlgebraicNumberSettings::DEFAULT_ISOLATIONSTRATEGY );
00102 
00111             static list<RealAlgebraicNumberPtr> realRootsEval( const UnivariatePolynomial& p,
00112                                                                const evalmap& m,
00113                                                                RealAlgebraicNumberSettings::IsolationStrategy pivoting = RealAlgebraicNumberSettings::DEFAULT_ISOLATIONSTRATEGY )
00114                     throw ( invalid_argument );
00115 
00125             static list<RealAlgebraicNumberPtr> realRootsEval( const UnivariatePolynomial& p,
00126                                                                const vector<RealAlgebraicNumberIRPtr>& a,
00127                                                                const vector<symbol>& v,
00128                                                                RealAlgebraicNumberSettings::IsolationStrategy pivoting = RealAlgebraicNumberSettings::DEFAULT_ISOLATIONSTRATEGY )
00129                     throw ( invalid_argument );
00130 
00139             static list<RealAlgebraicNumberPtr> commonRealRoots( const list<RationalUnivariatePolynomial>& l );
00140 
00154             static const RealAlgebraicNumberPtr evaluateIR( const UnivariatePolynomial& p,
00155                                                             const vector<RealAlgebraicNumberIRPtr>& a,
00156                                                             const vector<symbol>& v )
00157                     throw ( invalid_argument );
00158 
00172             static const RealAlgebraicNumberPtr evaluateIR( const UnivariatePolynomial& p, const evalmap m ) throw ( invalid_argument );
00173 
00174         private:
00175 
00177             // Auxiliary Functions //
00179 
00191             static void searchRealRoots( const unsigned varMinLeft,
00192                                          const RationalUnivariatePolynomial& p,
00193                                          const list<RationalUnivariatePolynomial>& seq,
00194                                          const OpenInterval& i,
00195                                          list<RealAlgebraicNumberPtr>* roots,
00196                                          unsigned offset,
00197                                          RealAlgebraicNumberSettings::IsolationStrategy pivoting );
00198 
00199     };
00200 
00201 }    // namespace GiNaC
00202 
00203 #endif