CoCoALib-0.9905 date: 23 May 2007


PPWithMask.H

Go to the documentation of this file.
00001 #ifndef CoCoA_PPWithMask_H
00002 #define CoCoA_PPWithMask_H
00003 
00004 //   Copyright (c)  2005  Anna Bigatti
00005 
00006 //   This file is part of the source of CoCoALib, the CoCoA Library.
00007 
00008 //   CoCoALib is free software; you can redistribute it and/or modify
00009 //   it under the terms of the GNU General Public License (version 2)
00010 //   as published by the Free Software Foundation.  A copy of the full
00011 //   licence may be found in the file COPYING in this directory.
00012 
00013 //   CoCoALib is distributed in the hope that it will be useful,
00014 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 //   GNU General Public License for more details.
00017 
00018 //   You should have received a copy of the GNU General Public License
00019 //   along with CoCoA; if not, write to the Free Software
00020 //   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 
00022 
00023 #include "CoCoA/PPMonoid.H"
00024 #include "CoCoA/DivMask.H"
00025 
00026 #include <iosfwd>
00027 //using std::ostream;
00028 
00029 namespace CoCoA
00030 {
00031 
00032 
00033   /*-- class PPWithMask ---------------------------------------*/
00034   /**
00035 
00036   \brief Implementation of PPMonoidElem with DivMask
00037          for fast divisibility test
00038 
00039   This type is not intended for "public use": it must be fast, so we
00040   cannot guarantee safety checks.  It does some compatibility tests
00041   with CoCoA_ASSERT.
00042 
00043   It is to be used ONLY when speed on divisibility tests is crucial
00044   (Buchberger, Toric, Hilbert).
00045 
00046   Constructor and assignment from pp might be expensive.
00047 
00048   */
00049   /*-----------------------------------------------------------------*/
00050 
00051   class PPWithMask
00052   {
00053   public:
00054     PPWithMask(const PPMonoid& PPM, const DivMaskRule& DMRule);
00055     PPWithMask(ConstRefPPMonoidElem pp, const DivMaskRule& DMRule);
00056     ~PPWithMask() {};
00057     void myAssign(ConstRefPPMonoidElem pp);
00058     friend RefPPMonoidElem PP(PPWithMask& pm) { return pm.myPP; }
00059     friend ConstRefPPMonoidElem PP(const PPWithMask& pm) { return pm.myPP; }
00060     friend const DivMaskRule& DivMaskImpl(const PPWithMask& pm) { return pm.myDivMaskRule; }
00061     friend bool IsEqualFast(const PPWithMask& pm1, const PPWithMask& pm2); ///< suffix "Fast" because it does not check compatibility
00062     friend bool IsDivisibleFast(const PPWithMask& pm1, const PPWithMask& pm2);  ///< suffix "Fast" because it does not check compatibility
00063     PPWithMask& operator=(const PPWithMask& pm);
00064     bool operator==(const PPWithMask& pm) const; ///< WARNING: it does not check compatibility
00065     bool operator!=(const PPWithMask& pm) const; ///< WARNING: it does not check compatibility
00066     friend std::ostream& operator<<(std::ostream& out, const PPWithMask& pm);
00067 //???    friend OpenMath::OutputChannel& operator<<(OpenMath::OutputChannel& OMOut, const PPWithMask& pm);
00068 
00069   private:
00070     void myUpdateDivMask(); ///< assign the correct DivMask for myPP
00071 
00072     /**@name member fields of PPWithMask  */
00073     //@{
00074   private: // data members
00075     DivMask myDivMask;  ///< the DivMask associated to PP by myDivMaskRule
00076     PPMonoidElem myPP;  ///< the PP itself
00077     const DivMaskRule myDivMaskRule; ///< the DivMask "style": this might disappear
00078     //@}
00079   };
00080 
00081 
00082   std::ostream& operator<<(std::ostream& out, const PPWithMask& pm);
00083 
00084   //----------------------------------------------------------------------
00085   // Inline functions
00086 
00087   inline PPWithMask::PPWithMask(const PPMonoid& PPM, const DivMaskRule& DMRule):
00088     myPP(PPM), myDivMaskRule(DMRule)
00089   {}
00090 
00091 
00092   inline bool IsEqualFast(const PPWithMask& pm1, const PPWithMask& pm2)
00093   {
00094     return (pm1.myDivMask == pm2.myDivMask) && (pm1.myPP == pm2.myPP);
00095   }
00096 
00097 
00098   inline bool IsDivisibleFast(const PPWithMask& pm1, const PPWithMask& pm2)
00099   {
00100     return IsSubset(pm2.myDivMask, pm1.myDivMask) && IsDivisible(pm1.myPP, pm2.myPP);
00101   }
00102 
00103 
00104   inline bool PPWithMask::operator==(const PPWithMask& pm) const
00105   {
00106     return IsEqualFast(*this, pm);
00107   }
00108 
00109 
00110   inline bool PPWithMask::operator!=(const PPWithMask& pm) const
00111   {
00112     return !IsEqualFast(*this, pm);
00113   }
00114 
00115 
00116 } // end of namespace CoCoA
00117 
00118 
00119 
00120 // RCS header/log in the next few lines
00121 // $Header: /Volumes/Home/cocoa/cvs-repository/CoCoALib-0.99/include/CoCoA/PPWithMask.H,v 1.1.1.1 2007/03/09 15:16:11 abbott Exp $
00122 // $Log: PPWithMask.H,v $
00123 // Revision 1.1.1.1  2007/03/09 15:16:11  abbott
00124 // Imported files
00125 //
00126 // Revision 1.5  2007/03/08 18:42:06  cocoa
00127 // Cleaned up whitespace.
00128 //
00129 // Revision 1.4  2006/11/27 13:45:56  cocoa
00130 // -- removed #include "config.H"
00131 //
00132 // Revision 1.3  2006/11/24 17:40:38  cocoa
00133 // -- minor reorganization
00134 //
00135 // Revision 1.2  2006/10/06 14:04:15  cocoa
00136 // Corrected position of #ifndef in header files.
00137 // Separated CoCoA_ASSERT into assert.H from config.H;
00138 // many minor consequential changes (have to #include assert.H).
00139 // A little tidying of #include directives (esp. in Max's code).
00140 //
00141 // Revision 1.1.1.1  2006/05/30 11:39:37  cocoa
00142 // Imported files
00143 //
00144 // Revision 1.7  2006/03/12 21:28:34  cocoa
00145 // Major check in after many changes
00146 //
00147 // Revision 1.6  2006/02/03 14:26:12  cocoa
00148 // -- changed "DivMaskImpl" --> "DivMaskRule"
00149 //
00150 // Revision 1.5  2006/02/01 16:56:13  cocoa
00151 // Added some missing assignment operators for (Ref)PPMonoidElems.
00152 //
00153 // Revision 1.4  2006/01/20 15:43:30  cocoa
00154 // -- fixed: use of RefPPMonoidElem and ConstRefPPMonoidElem
00155 //
00156 // Revision 1.3  2006/01/18 16:15:16  cocoa
00157 // Cleaned up DivMask considerably; everything still works,
00158 // so I'm checking in (and then going home).
00159 //
00160 // Revision 1.2  2006/01/17 10:23:08  cocoa
00161 // Updated DivMask; many consequential changes.
00162 // A few other minor fixes.
00163 //
00164 // Revision 1.1.1.1  2005/10/17 10:46:54  cocoa
00165 // Imported files
00166 //
00167 // Revision 1.1.1.1  2005/05/03 15:47:30  cocoa
00168 // Imported files
00169 //
00170 // Revision 1.2  2005/04/19 14:06:04  cocoa
00171 // Added GPL and GFDL licence stuff.
00172 //
00173 // Revision 1.1.1.1  2005/01/27 15:12:13  cocoa
00174 // Imported files
00175 //
00176 // Revision 1.2  2004/11/02 15:09:00  cocoa
00177 // -- only minor changes to documentation
00178 //
00179 // Revision 1.1  2004/10/29 15:33:23  cocoa
00180 // -- new class pairing a PPMonoidElem with a DivMask for fast
00181 //    divisibility tests
00182 //
00183 
00184 #endif

Generated on Wed May 23 13:43:35 2007 for CoCoALib by  doxygen 1.4.6