fraction.h

Go to the documentation of this file.
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: fraction.h,v 1.14 2006/12/28 19:01:25 rafi Exp $
00021 //
00022 
00032 #ifndef _FRACTION_H
00033 #define _FRACTION_H
00034 
00035 #ifdef HAVE_CONFIG_H
00036 #include "config.h"
00037 #endif
00038 
00039 #include "casexception.h"
00040 #include "cassymbolic.h"
00041 
00058 class Fraction : public CASSymbolic {
00059     private:
00065         CASObject* numerator;
00071         CASObject* denominator;
00072 
00073     protected:
00074     // Empty
00075 
00076     public:
00080         Fraction();
00084         Fraction ( const CASObject* num, const CASObject* denom );
00088         Fraction ( const CASObject* denom );
00092         Fraction ( const Fraction &f );
00096         ~Fraction();
00097 
00101         CASObject* Clone() const;
00110         inline CASType GetType() const { return CT_FRACTION; }
00111 
00116         void Get ( std::string &s ) const;
00121         void Get ( char *s, unsigned long size ) const;
00125         void Print() const;
00130         unsigned long Length() const;
00134         bool IsZero() const;
00138         bool IsOne() const;
00142         CASObject* Absolute() const;
00146         void AbsoluteIP();
00150         CASObject* Invert() const;
00154         void InvertIP();
00159         CASObject* Add ( const CASObject* addend ) const;
00164         CASObject* Subtract ( const CASObject* subtrahend ) const;
00169         CASObject* Multiply ( const CASObject* factor ) const;
00174         CASObject* Divide ( const CASObject* divisor ) const;
00178         CASObject* Power ( const CASObject* exp ) const;
00182         CASObject* Modulo ( const CASObject* divisor ) const;
00187         CASObject* GCD ( const CASObject* o ) const;
00192         bool IsEqual ( const CASObject* o ) const;
00197         bool IsLT ( const CASObject* o ) const;
00202         bool IsGT ( const CASObject* o ) const;
00207         bool IsSimilar ( const CASObject* o ) const;
00212         bool IsPureNumerical() const;
00216         CASObject* Evaluate() const;
00220         CASObject* SortWeight() const;
00224         void Sort();
00225 
00229         const Fraction& operator= ( const Fraction &f );
00233         const bool operator== ( const Fraction &f ) const;
00234 
00235         friend class CASConvert;
00236 
00237 };
00238 
00243 #endif /* _FRACTION_H */

Generated on Sun Dec 31 01:57:27 2006 for ECAS by  doxygen 1.4.7