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_UTILITIES_H 00024 #define GINACRA_UTILITIES_H 00025 00034 #include <ginac/ginac.h> 00035 #include <cln/cln.h> 00036 #include <stdexcept> 00037 00038 #include "constants.h" 00039 00040 using std::invalid_argument; 00041 using std::map; 00042 using std::vector; 00043 00044 namespace GiNaC 00045 { 00050 const ex prod( const lst& l ) throw ( invalid_argument ); 00051 00057 const ex lcm( const lst& l ) throw ( invalid_argument ); 00058 00065 long lcm( long a, long b ); 00066 00073 long gcd( long a, long b ); 00074 00081 long numerator( long a, long b ); 00082 00089 long denominator( long a, long b ); 00090 00096 bool is_constant( const ex& polynomial, const vector<symbol>& symbolLst ); 00097 00104 bool is_rational_polynomial( const ex& p, const symbol& x ); 00105 00113 bool is_realalgebraic_polynomial( const ex& p, const symbol& x ); 00114 00120 bool is_realalgebraic_term( const ex& p ); 00121 00126 sign sgn( const numeric& n ); 00127 00133 const ex monpart( const ex& polynomial, const vector<symbol>& symbolLst ); 00134 00140 const ex coeffpart( const ex& polynomial, const vector<symbol>& symbolLst ); 00141 00149 void isolateByVariables( const ex& polynomial, const vector<symbol>& symbolLst, ex& coefficient, ex& monomial ); 00150 00157 const GiNaC::ex rationalize( const GiNaC::ex& p, const vector<GiNaC::symbol>& symbolLst ); 00158 00165 inline const GiNaC::ex rationalize( const GiNaC::ex& p, const GiNaC::symbol& s ); 00166 00172 inline const GiNaC::numeric rationalize( const GiNaC::numeric& n ); 00173 00177 const vector<symbol> sortVariables( const vector<symbol>& l ); 00178 00184 bool symbol_is_lesseq_lex( const symbol& a, const symbol& b ); 00185 00191 bool symbol_is_less_lex( const symbol& a, const symbol& b ); 00192 00193 // TODO make a good exception handling 00194 00207 const map<int, ex> signedSubresultants( const ex& A, const ex& B, const symbol& sym ); 00208 00222 const vector<ex> signedSubresultantsCoefficients( const ex& A, const ex& B, const symbol& sym ) throw ( invalid_argument ); 00223 00224 } // namespace GiNaC 00225 00226 namespace GiNaCRA 00227 { 00228 struct plus_second: 00229 std:: binary_function<unsigned, std::pair<unsigned, unsigned>, unsigned> 00230 { 00231 unsigned operator ()( unsigned x, const std::pair<unsigned, unsigned>& y ) const 00232 { 00233 return x + y.second; 00234 } 00235 }; 00236 00237 } 00238 00239 #endif // GINACRA_UTILITIES_H