GiNaCRA
0.6.4
|
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_UNIVARIATEPOLYNOMIALSET_H 00024 #define GINACRA_UNIVARIATEPOLYNOMIALSET_H 00025 00026 #include <unordered_set> 00027 #include <ginac/ginac.h> 00028 #include "UnivariatePolynomial.h" 00029 00030 using std::unordered_set; 00031 using std::pair; 00032 using std::cout; 00033 using std::endl; 00034 00035 namespace GiNaCRA 00036 { 00038 struct UnivariatePolynomialSetHasher 00039 { 00040 size_t operator ()( const UnivariatePolynomial& p ) const 00041 { 00042 return p.gethash(); 00043 } 00044 }; 00045 00047 struct UnivariatePolynomialSetEquals 00048 { 00049 bool operator ()( const UnivariatePolynomial& p, const UnivariatePolynomial& q ) const 00050 { 00051 return p.isEqual( q ); 00052 } 00053 }; 00054 00065 class UnivariatePolynomialSet: 00066 public std:: unordered_set<UnivariatePolynomial, UnivariatePolynomialSetHasher, UnivariatePolynomialSetEquals> 00067 { 00068 public: 00069 00071 // Con- and destructors // 00073 00077 UnivariatePolynomialSet(){} 00078 00084 template<class InputIterator> 00085 UnivariatePolynomialSet( InputIterator first, InputIterator last ): 00086 std::unordered_set<UnivariatePolynomial, UnivariatePolynomialSetHasher, UnivariatePolynomialSetEquals>( first, last ) 00087 {} 00088 00090 // Selectors // 00092 00098 const bool isConstant( symbol& x ) const; 00099 00105 const symbol variable() const; 00106 00108 // Modifiers // 00110 00117 pair<UnivariatePolynomialSet::iterator, bool> insert( const UnivariatePolynomial& x ) throw ( invalid_argument ); 00118 00126 template<class InputIterator> 00127 void insert( InputIterator first, InputIterator last ) throw ( invalid_argument ); 00128 00132 void removeNumbers(); 00133 00138 const UnivariatePolynomialSet makePrimitive(); 00139 }; 00140 00141 } // namespace GiNaC 00142 00143 #endif