00001 // -*- C++ -*- 00002 // 00003 // Copyright (c) 2006 by Rafael Ostertag 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 2 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 // 00020 // $Id: product.h,v 1.16 2006/12/28 19:01:25 rafi Exp $ 00021 // 00022 00032 #ifndef _PRODUCT_H 00033 #define _PRODUCT_H 00034 00035 #ifdef HAVE_CONFIG_H 00036 #include "config.h" 00037 #endif 00038 00039 #include <vector> 00040 00041 #include "castemplates.h" 00042 #include "casterm.h" 00043 #include "casgarbage.h" 00044 00060 class Product : public CASTerm { 00061 private: 00066 void GetOperandsWithoutCoefficient ( std::vector<const CASObject*>& lst ) const; 00070 const CASObject* GetCoefficient() const; 00074 CASObject* CollectEqualOperands() const; 00078 CASObject* CollectOther() const; 00082 void ExplodeSumsIP(); 00086 void GetSums ( const std::vector<const CASObject*> &in, 00087 std::vector<const CASObject*> &out ); 00092 void GetNonSums ( const std::vector<const CASObject*> &in, 00093 std::vector<const CASObject*> &out ); 00094 00095 protected: 00096 00097 public: 00101 Product(); 00105 Product ( const Product &p ); 00109 ~Product(); 00113 CASObject* Clone() const; 00122 inline CASType GetType() const { 00123 return CT_PRODUCT; 00124 }; 00128 void Get ( std::string &s ) const; 00132 void Get ( char *s, unsigned long size ) const; 00136 void Print() const; 00140 unsigned long Length() const; 00144 bool IsZero() const; 00148 bool IsOne() const; 00153 bool IsSimilar ( const CASObject *o ) const; 00158 CASObject* Absolute() const; 00162 void AbsoluteIP(); 00166 CASObject* Invert() const; 00170 void InvertIP(); 00174 CASObject* Add ( const CASObject* addend ) const; 00178 CASObject* Subtract ( const CASObject* subtrahend ) const; 00182 CASObject* Multiply ( const CASObject* factor ) const; 00186 CASObject* Divide ( const CASObject* divisor ) const; 00190 CASObject* Modulo ( const CASObject* divisor ) const; 00195 CASObject* GCD ( const CASObject* o ) const; 00199 CASObject* Evaluate() const; 00203 CASObject* Collect() const; 00207 CASObject* Expand() const; 00211 void RemoveNoOpElements(); 00215 const Product& operator= ( const Product &f ); 00216 00223 friend void resolve_parentheses<Product> ( CASObject* ); 00230 friend void evaluate_operands<Product> ( Product* ); 00237 friend void expand_operands<Product> ( Product* ); 00244 friend class CASConvert; 00245 }; 00246 00251 #endif /* _PRODUCT_H */
1.4.7