Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Range.h

Go to the documentation of this file.
00001 
00002 // MathCore = a WYSIWYG equation editor + a powerful math engine     //
00003 // Copyright (C) 2003 by Francesco Montorsi                          //
00004 //                                                                   //
00005 // This library is free software; you can redistribute it and/or     //
00006 // modify it under the terms of the GNU Lesser General Public        //
00007 // License as published by the Free Software Foundation; either      //
00008 // version 2.1 of the License, or (at your option) any later         //
00009 // version.                                                          //
00010 //                                                                   //
00011 // This library is distributed in the hope that it will be useful,   //
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of    //
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      //
00014 // GNU Lesser General Public License for more details.               //
00015 //                                                                   //
00016 // You should have received a copy of the GNU Lesser General Public  //
00017 // License along with this program; if not, write to the Free        //
00018 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,   //
00019 // MA 02111-1307, USA.                                               //
00020 //                                                                   //
00021 // For any comment, suggestion or feature request, please contact    //
00022 // the administrator of the project at frm@users.sourceforge.net     //
00023 //                                                                   //
00030 
00031 
00032 
00033 #ifndef RANGE_H
00034 #define RANGE_H
00035 
00036 // optimization for GCC compiler
00037 #ifdef __GNUG__
00038 //#pragma interface "Range.h"
00039 #endif
00040 
00041 // required includes
00042 #include "mc/Polynomial.h"
00043 
00044 
00047 class mcRange : public mcMathHelper
00048 {
00049 protected:
00050 
00052  mcPolynomial m_pUpper;
00053  
00055  mcPolynomial m_pLower;
00056  
00058  mcBoundaryMode m_nBounds;
00059  
00061  mcSet m_nSet;
00062 
00063 public:  // static public objects
00064 
00065  static mcRange *pN;  
00066  static mcRange *pZ;  
00067  static mcRange *pR;  
00068  static mcRange *pC;  
00069  
00070  static mcRange *pEmpty;  
00071  
00072 public:
00073  
00075  mcRange(const mcRealValue &l = *mcIntegerValue::pZero,
00076   const mcRealValue &u = *mcIntegerValue::pOne,
00077   mcSet s = mcSET_R,
00078   mcBoundaryMode m = mcBM_INCLUDE_BOTH)
00079  { math_Set(l, u); math_Set(s, m); }
00080 
00082  mcRange(const mcPolynomial &l,
00083   const mcPolynomial &u,
00084   mcSet s = mcSET_R,
00085   mcBoundaryMode m = mcBM_INCLUDE_BOTH)
00086  { math_Set(l, u); math_Set(s, m); }
00087  
00088  virtual ~mcRange();
00089 
00090 
00092  mcRange *data_Clone() const 
00093   { return new mcRange(m_pLower, m_pUpper, m_nSet, m_nBounds); }
00094  
00097  void math_Order();
00098 
00100  bool math_isFinite() const;
00101 
00102 
00103  void math_Set(const mcPolynomial &l = mcEmptyElement, 
00104    const mcPolynomial &u = mcEmptyElement);
00105  void math_Set(const mcRealValue &l = *mcRealValue::pNAN, 
00106    const mcRealValue &u = *mcRealValue::pNAN);
00107  void math_Set(mcSet newset, mcBoundaryMode m) 
00108   { m_nSet=newset; m_nBounds=m; }
00109 
00110  mcSet math_GetSet() const       { return m_nSet; }
00111  mcBoundaryMode math_GetBoundaryMode() const   { return m_nBounds; }
00112  const mcPolynomial &math_GetUpperLimit() const  { return m_pUpper; }
00113  const mcPolynomial &math_GetLowerLimit() const  { return m_pLower; }
00114  
00115  mcRealValue math_GetUpperLimitValue() const;
00116  mcRealValue math_GetLowerLimitValue() const;
00117 
00122  wxString io_GetInlinedExpr() const;
00123 };
00124 
00125 
00128 class mcExtRange : public mcAbstractArray
00129 {
00130 protected:
00131  void data_Delete(int n) 
00132   { delete data_GetRange(n); }
00133 
00134 public:  // static public objects
00135 
00136  static mcExtRange *pN;  
00137  static mcExtRange *pZ;  
00138  static mcExtRange *pR;  
00139  static mcExtRange *pC;  
00140  
00141  static mcExtRange *pEmpty;  
00142  
00143 public:
00144  mcExtRange() {}
00145  mcExtRange(const mcRange &r) { data_Add(r); }
00146  mcExtRange(const mcExtRange &r) { data_DeepCopy(r); }
00147  virtual ~mcExtRange() { data_Clear(); }
00148  
00149 
00150  void data_DeepCopy(const mcExtRange &r) {
00151   data_Clear();
00152   for (int i=0; i < r.data_GetCount(); i++)
00153    data_Add(*r.data_GetRange(i));
00154  }
00155 
00156  void data_Add(const mcRange &r)   
00157   { mcAbstractArray::data_Add(r.data_Clone()); }
00158 
00159  void math_Intersect(const mcRange &r);
00160  void math_Union(const mcRange &r);
00161 
00163  bool math_isFinite() const;
00164 
00165  mcExtRange *data_Clone() const
00166   { return new mcExtRange(*this); }
00167 
00168  mcRange *data_GetRange(int n)      { return (mcRange *)data_GetItem(n); }
00169  const mcRange *data_GetRange(int n) const   { return (mcRange *)data_GetItem(n); }
00170 };
00171 
00172 #endif  // RANGE_H


Documentation generated with Doxygen on Sun Feb 6 17:10:48 2005
Visit MathStudio home page for more info

[ Top ]