CoCoALib-0.9905 date: 23 May 2007


ReductionCog.H

Go to the documentation of this file.
00001 #ifndef CoCoA_ReductionCog_H
00002 #define CoCoA_ReductionCog_H
00003 
00004 //   Copyright (c)  2006  Anna M. Bigatti
00005 
00006 //   This file is part of the source of CoCoALib, the CoCoA Library.
00007 //   CoCoALib is free software; you can redistribute it and/or modify
00008 //   it under the terms of the GNU General Public License (version 2)
00009 //   as published by the Free Software Foundation.  A copy of the full
00010 //   licence may be found in the file COPYING in this directory.
00011 
00012 //   CoCoALib 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 CoCoA; if not, write to the Free Software
00019 //   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021 
00022 #include "CoCoA/PPMonoid.H"
00023 #include "CoCoA/SmartPtrIRC.H"
00024 
00025 #include <iosfwd>
00026 //using std::ostream;
00027 #include <cstddef>
00028 //using std::size_t;
00029 
00030 namespace CoCoA
00031 {
00032 
00033   class ConstRefRingElem; // forward declaration -- defined in ring.H
00034   //  class ConstRefPPMonoidElem; // forward declaration -- defined in PPMonoid.H
00035   class RefRingElem;      // forward declaration -- defined in ring.H
00036   class SparsePolyRing;   // forward declaration -- defined in SparsePolyRing.H
00037 
00038   class ReductionCogBase; // forward declaration for SmartPtrIRC
00039   class ReductionCog
00040   {
00041   public:
00042     explicit ReductionCog(ReductionCogBase* ptr): mySmartPtr(ptr) {}
00043     // assignment disabled because SmartPtrIRC has no assignment
00044     ReductionCogBase* operator->() { return mySmartPtr.operator->(); }  ///< Allow member fns to be called.
00045     const ReductionCogBase* operator->() const { return mySmartPtr.operator->(); }  ///< Allow const member fns to be called.
00046     bool operator==(const ReductionCog& f) const { return mySmartPtr==f.mySmartPtr; }
00047   private: // data members
00048     SmartPtrIRC<ReductionCogBase> mySmartPtr;
00049   };
00050 
00051 
00052   ConstRefPPMonoidElem ActiveLPP(const ReductionCog& F);
00053   bool IsActiveZero(const ReductionCog& F);
00054   std::ostream& operator<<(std::ostream& out, const ReductionCog& F);
00055 
00056   class ReductionCogBase: protected IntrusiveReferenceCount
00057   {
00058     friend class SmartPtrIRC<ReductionCogBase>; // morally "friend ReductionCog", so it can alter reference count
00059   protected:
00060     ReductionCogBase(): IntrusiveReferenceCount() {}
00061   public:
00062     virtual ~ReductionCogBase() {};
00063     virtual void myMoveToNextLM() =0;
00064     virtual void myReduce(ConstRefRingElem reducer, size_t RedLen=0) =0;
00065     virtual std::ostream& myOutput(std::ostream& out) const =0;
00066     virtual void myAssignReset(RefRingElem f) =0; // almost no-throw guarantee (?)
00067     virtual void myAssignReset(RefRingElem f, size_t fLen) =0; // almost no-throw guarantee (?)
00068     virtual void myRelease(RefRingElem f) =0; // almost no-throw guarantee (?)
00069 
00070     friend ConstRefPPMonoidElem ActiveLPP(const ReductionCog& F);
00071     friend bool IsActiveZero(const ReductionCog& F);
00072 
00073   protected:
00074     virtual bool IamActiveZero() const =0;
00075     virtual ConstRefPPMonoidElem myActiveLPP() const =0;
00076   };
00077 
00078 
00079   ReductionCog NewRedCogPolyField(const SparsePolyRing& P);
00080   ReductionCog NewRedCogPolyGCD(const SparsePolyRing& P);
00081   ReductionCog NewRedCogGeobucketField(const SparsePolyRing& P);
00082   ReductionCog NewRedCogGeobucketGCD(const SparsePolyRing& P);
00083 
00084   //------- inline functions ----------------------------
00085 
00086   inline ConstRefPPMonoidElem ActiveLPP(const ReductionCog& F)
00087   { return F->myActiveLPP(); }
00088 
00089   inline bool IsActiveZero(const ReductionCog& F)
00090   { return F->IamActiveZero(); }
00091 
00092 
00093 } // end of namespace CoCoA
00094 
00095 
00096 //----------------------------------------------------------------------
00097 // RCS header/log in the next few lines
00098 // $Header: /Volumes/Home/cocoa/cvs-repository/CoCoALib-0.99/include/CoCoA/ReductionCog.H,v 1.1.1.1 2007/03/09 15:16:11 abbott Exp $
00099 // $Log: ReductionCog.H,v $
00100 // Revision 1.1.1.1  2007/03/09 15:16:11  abbott
00101 // Imported files
00102 //
00103 // Revision 1.8  2007/03/08 18:42:05  cocoa
00104 // Cleaned up whitespace.
00105 //
00106 // Revision 1.7  2007/02/22 17:27:43  bigatti
00107 // -- removed useless include <memory> (auto_ptr)
00108 //
00109 // Revision 1.6  2006/12/06 17:15:26  cocoa
00110 // -- removed #include "config.H"
00111 //
00112 // Revision 1.5  2006/11/27 14:17:41  cocoa
00113 // -- just a comment
00114 //
00115 // Revision 1.4  2006/11/24 17:53:14  cocoa
00116 // -- using SmartPtrIRC for ref counting (was auto_ptr)
00117 //
00118 // Revision 1.3  2006/10/06 15:17:08  cocoa
00119 // -- myReduce now returns void instead of RingElem
00120 //
00121 // Revision 1.2  2006/10/06 14:04:15  cocoa
00122 // Corrected position of #ifndef in header files.
00123 // Separated CoCoA_ASSERT into assert.H from config.H;
00124 // many minor consequential changes (have to #include assert.H).
00125 // A little tidying of #include directives (esp. in Max's code).
00126 //
00127 // Revision 1.1.1.1  2006/05/30 11:39:37  cocoa
00128 // Imported files
00129 //
00130 // Revision 1.3  2006/04/11 14:16:29  cocoa
00131 // -- reorganization of fns between reduce,SparsePolyRing,GPoly
00132 // -- added optional "len" argument to myAssignReset in ReductionCog
00133 //
00134 // Revision 1.2  2006/04/10 13:38:06  cocoa
00135 // -- added myTmpLM field to avoid repeated creations/deletions
00136 //
00137 // Revision 1.1  2006/03/16 14:28:29  cocoa
00138 // -- first import
00139 //
00140 
00141 #endif

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