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_MULTIVARIATETERMMR_H 00024 #define GINACRA_MULTIVARIATETERMMR_H 00025 00026 // #define GINACRA_MULTIVARIATEPOLYNOMIAL_DEBUG 00027 00028 #include <ginac/ginac.h> 00029 #include <stdexcept> 00030 #include <utility> 00031 00032 #include "MultivariateMonomialMR.h" 00033 #include "MultivariateCoefficientMR.h" 00034 #include "utilities.h" 00035 00036 namespace GiNaCRA 00037 { 00047 class MultivariateTermMR: 00048 public MultivariateMonomialMR 00049 { 00050 public: 00051 00055 MultivariateTermMR(): 00056 mCoeff() 00057 {} 00058 00063 MultivariateTermMR( unsigned size ): 00064 MultivariateMonomialMR( size ), 00065 mCoeff( 1 ) 00066 {} 00067 00072 MultivariateTermMR( GiNaC::ex coeff ): 00073 MultivariateMonomialMR(), 00074 mCoeff( coeff ) 00075 {} 00076 00082 MultivariateTermMR( const MultivariateMonomialMR& m1, const GiNaC::ex& coeff ): 00083 MultivariateMonomialMR( m1 ), 00084 mCoeff( coeff ) 00085 {} 00086 00092 MultivariateTermMR( const MultivariateMonomialMR& m1, const MultivariateCoefficientMR& coeff ): 00093 MultivariateMonomialMR( m1 ), 00094 mCoeff( coeff ) 00095 {} 00096 00101 MultivariateTermMR( const MultivariateMonomialMR& m1 ): 00102 MultivariateMonomialMR( m1 ), 00103 mCoeff( 1 ) 00104 {} 00105 00106 friend bool operator ==( const MultivariateTermMR& t1, const MultivariateTermMR& t2 ); 00107 friend const MultivariateTermMR operator *( const MultivariateTermMR& t1, const MultivariateTermMR& t2 ); 00108 friend const MultivariateTermMR operator *( const MultivariateTermMR& t1, const MultivariateMonomialMR& m1 ); 00109 friend const MultivariateTermMR operator *( const MultivariateMonomialMR& m1, const MultivariateTermMR& t1 ); 00110 00116 inline bool hasEqualExponents( const MultivariateTermMR& m2 ) const 00117 { 00118 if( mTotDeg != m2.mTotDeg || mExponents.size() != m2.mExponents.size() ) 00119 return false; 00120 return std::equal( mExponents.begin(), mExponents.end(), m2.mExponents.begin() ); 00121 } 00122 00127 inline GiNaC::ex toEx() const 00128 { 00129 return getCoeffExpr() * super::toEx(); 00130 } 00131 00136 inline GiNaC::ex getCoeffExpr() const 00137 { 00138 return mCoeff.getExpression(); 00139 } 00140 00145 inline MultivariateCoefficientMR getCoeff() const 00146 { 00147 return mCoeff; 00148 } 00149 00154 inline MultivariateTermMR negate() const 00155 { 00156 return MultivariateTermMR( *this, -mCoeff ); 00157 } 00158 00159 /* 00160 * Part of the SPolynomial calculation. 00161 * @param m1 00162 * @return lcm(mon(this),m1) divided by t1 00163 */ 00164 const MultivariateTermMR lcmdivt( const MultivariateMonomialMR& m1 ) const; 00165 00171 bool dividable( const MultivariateTermMR& denom ) const; 00172 00178 std::pair<MultivariateTermMR, bool> divby( const MultivariateTermMR& denom ) const; 00179 00185 MultivariateTermMR divide( const ex& c ) const 00186 { 00187 return MultivariateTermMR( *this, mCoeff.getExpression() / c ); 00188 } 00189 00195 friend std::ostream& operator <<( std::ostream& os, const MultivariateTermMR& rhs ); 00196 00197 protected: 00198 MultivariateCoefficientMR mCoeff; 00199 00200 private: 00201 typedef MultivariateMonomialMR super; 00202 }; 00203 00204 } 00205 00206 /* 00207 namespace std { 00208 00209 template<typename t1, typename t2> 00210 pair<const GiNaCRA::MultivariateTermMR, bool>& pair<const GiNaCRA::MultivariateTermMR, bool>::operator=(const pair<const GiNaCRA::MultivariateTermMR, bool>& input); 00211 00212 }*/ 00213 00214 #endif