CoCoALib-0.9905 date: 23 May 2007


TmpGPair.H

Go to the documentation of this file.
00001 #ifndef CoCoA_GPair_H
00002 #define CoCoA_GPair_H
00003 
00004 //   Copyright (c)  2005  Massimo Caboara
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/TmpGPoly.H"
00024 #include "CoCoA/TmpGTypes.H"
00025 
00026 #include <iosfwd>
00027 //using std::ostream;
00028 #include <list>
00029 //using std::list;  // for GPairList
00030 #include <vector>
00031 //using std::vector;// for MGPairList
00032 #include <cstddef>
00033 //using std::size_t;
00034 
00035 
00036 namespace CoCoA
00037 {
00038 
00039   class GPair
00040   {
00041   public:
00042     //explicit GPair(const ring&, const PPMonoid&);
00043 
00044     // WARN i<j
00045     GPair(GPoly& p, unsigned int i);// special ctor
00046     GPair(GPoly& p,  GPoly& q,  unsigned int i, unsigned int j);// usualctor  
00047     GPair(const GPoly* p,  const GPoly* q,  unsigned int i, unsigned int j);// usualctor  
00048     ~GPair(){}; 
00049 
00050     void myComplete(void); ///< fills to the GPair the field myOrdPoly and myWDeg (=deg(myOrdPoly))
00051     bool operator<(const GPair& gp) const;  ///< based on (w/std)deg + IsSpecial + PPOrdering
00052 
00053     inline const GPoly& myFirstGPoly() const{return *myFirstGPolyValue;};
00054     inline const GPoly& mySecondGPoly() const{return *mySecondGPolyValue;};
00055     //  inline const GPoly* FirstGPolyPtr() const{return myFirstGPoly;};
00056     //  inline const GPoly* SecondGPolyPtr() const{return mySecondGPoly;};
00057 
00058 
00059     inline unsigned int myFirstIndex() const{return myFirstIndexValue;};
00060     inline unsigned int mySecondIndex() const{return mySecondIndexValue;};
00061     inline bool IamCoprime() const{return IamCoprimeFlag;}
00062     inline bool IsSpecial() const{return mySecondIndex()==0;}
00063     bool BCriterion_OK(const PPWithMask&)const;
00064     bool operator==(const GPair&)const;// uses the ordering on lcm_fg
00065 
00066     friend ConstRefPPMonoidElem LCM(const GPair&);
00067     friend const PPWithMask& LCMwMask(const GPair&);
00068     friend ConstRefRingElem OrdPoly(const GPair&);
00069     friend unsigned int GPairComponent(const GPair& GP){return GP.myComponent;}
00070     friend const degree& wdeg(const GPair& GP) {return GP.myWDeg;};
00071     friend std::size_t StdDeg(const GPair& GP) {return GP.myStdDeg;};
00072     friend std::size_t sugar(const GPair& GP) {return GP.mySugar;};
00073     friend degree wsugar(const GPair& GP) {return GP.myWSugar;};
00074     friend std::ostream& operator<<(std::ostream&, const GPair&);// the indexes are printed ++
00075     friend const ring& CoeffRing(const GPair& P);
00076     friend const SparsePolyRing& owner(const GPair& P);
00077     friend const GRingInfo& GetGRingInfo(const GPair& P){return P.myFirstGPoly().myGRingInfo();};
00078 
00079   private:
00080     const GPoly* myFirstGPolyValue; ///< f
00081     const GPoly* mySecondGPolyValue;///< g
00082     PPWithMask myLCMwMask; ///< lcm(lpp(f),lpp(g)), stored with DivMask
00083     RingElem myOrdPoly; ///< pairs will be ordered according to this polynomial (now = lcm)
00084     bool IamCoprimeFlag; ///< are lpp(f) and lpp(g) coprime?
00085     unsigned int myFirstIndexValue; ///< for stats purposes only
00086     unsigned int mySecondIndexValue; ///< for stats purposes only
00087     degree myWDeg; ///< degree of myLCM, hence of the pair, it being homog.
00088     unsigned int myComponent;///< LPP(f) and LPP(g) have the same component, this one
00089     std::size_t myStdDeg; ///< standard degree of myLCM.  Used only if GradingDim ==0
00090     std::size_t mySugar; ///< standard sugar of the pair.  Used only if GradingDim ==0
00091     degree myWSugar; ///< w sugar of the pair.  Used if GradingDim !=0 and the input is not homogeneous
00092   };// end GPairs class
00093 
00094   typedef std::list<GPair> GPairList;
00095 
00096 //WARN the pairs are at the moment in ORD ordering
00097   void Ordered_Insert(GPairList&,GPair);
00098   void RemoveFromGPList(GPairList&,GPair&);
00099 
00100 
00101 // This class is not used. See if it is still useful
00102   typedef std::vector<GPairList> MGPairList;
00103   class ModuleGPairList
00104   {
00105 
00106   public:
00107     ModuleGPairList();
00108     ~ModuleGPairList(){};
00109     void Insert(GPair&);
00110     friend std::ostream& operator<<(std::ostream&, const ModuleGPairList&);
00111     // if found, there is an element in this which divides P;, if !found, not.
00112     GPairList::iterator FindDivides(GPair& P,bool& found);
00113     bool IsIn(const GPair& P);
00114     GPairList::iterator FindSameLCMAndSecondInd(GPair& P,bool& found);
00115     //splice the part of degree D
00116     //   void GetPartInDegD(ModuleGPairList&, degree D);
00117     //add MGPL to this. suppose MGPL is all in a degree lesser than any in this
00118     void PushPartOfLesserDeg(ModuleGPairList&MGPL);
00119     unsigned int size() const;
00120   private:
00121     MGPairList myMGPList;
00122   };
00123 
00124   // -------------------- inline functions -------------------- //
00125 
00126   inline ConstRefPPMonoidElem LCM(const GPair& gp)
00127   {
00128     return PP(gp.myLCMwMask);
00129   }
00130 
00131 
00132   inline const PPWithMask& LCMwMask(const GPair& gp)
00133   {
00134     return gp.myLCMwMask;
00135   }
00136 
00137 
00138   inline ConstRefRingElem OrdPoly(const GPair& gp)
00139   {
00140     return gp.myOrdPoly;
00141   }
00142 
00143 }// end namespace cocoa
00144 
00145 
00146 
00147 // $Header: /Volumes/Home/cocoa/cvs-repository/CoCoALib-0.99/include/CoCoA/TmpGPair.H,v 1.1 2007/03/09 18:56:56 bigatti Exp $
00148 // $Log: TmpGPair.H,v $
00149 // Revision 1.1  2007/03/09 18:56:56  bigatti
00150 // -- added Tmp prefix to Groebner related files
00151 //
00152 // Revision 1.1.1.1  2007/03/09 15:16:11  abbott
00153 // Imported files
00154 //
00155 // Revision 1.15  2007/03/08 18:42:06  cocoa
00156 // Cleaned up whitespace.
00157 //
00158 // Revision 1.14  2007/03/07 22:24:03  bigatti
00159 // -- reintroduced TmpGTypes.H (waiting for a better solution)
00160 //
00161 // Revision 1.13  2007/03/07 17:04:31  cocoa
00162 // -- several changes by M.Caboara: more operations on ideals,
00163 //    exception cleaner, coding conventions, WSugar, dynamic
00164 //
00165 // Revision 1.12  2006/12/06 17:11:16  cocoa
00166 // -- removed #include "config.H"
00167 //
00168 // Revision 1.11  2006/12/04 13:55:54  cocoa
00169 // -- added: sugar for GradingDim > 0  (called wsugar)
00170 //
00171 // Revision 1.10  2006/11/24 17:17:58  cocoa
00172 // -- reorganized includes of header files
00173 //
00174 // Revision 1.9  2006/11/22 14:43:32  cocoa
00175 // -- minor cleaning (indicated by Intel compiler)
00176 //
00177 // Revision 1.8  2006/11/20 14:57:17  cocoa
00178 // -- added: (standard) sugar for modules
00179 // -- fixed: non-homogeneous sysygies
00180 // -- minor fixes     [M.Caboara]
00181 //
00182 // Revision 1.7  2006/10/11 13:33:06  cocoa
00183 // -- rearranged code for sugar in reduce.C
00184 // -- activated sugar in GPair.C
00185 // -- removed operator<< for GPairList (template in io)
00186 //
00187 // Revision 1.6  2006/10/06 14:04:16  cocoa
00188 // Corrected position of #ifndef in header files.
00189 // Separated CoCoA_ASSERT into assert.H from config.H;
00190 // many minor consequential changes (have to #include assert.H).
00191 // A little tidying of #include directives (esp. in Max's code).
00192 //
00193 // Revision 1.5  2006/08/17 09:24:17  cocoa
00194 // -- added: sugar
00195 // -- changed: coding conventions
00196 //
00197 // Revision 1.4  2006/06/20 17:19:45  cocoa
00198 // -- moved  GPair::operator<  into .C file
00199 //
00200 // Revision 1.3  2006/06/09 16:21:47  cocoa
00201 // -- small adjustments on StdDeg computations
00202 //
00203 // Revision 1.2  2006/06/09 16:06:04  cocoa
00204 // -- myStdDeg computed only if GradingDim==0
00205 //
00206 // Revision 1.1.1.1  2006/05/30 11:39:36  cocoa
00207 // Imported files
00208 //
00209 // Revision 1.12  2006/04/27 14:02:53  cocoa
00210 // -- tidied up include files
00211 //
00212 // Revision 1.11  2006/04/21 16:12:51  cocoa
00213 // -- just commented code
00214 //
00215 // Revision 1.10  2006/04/11 15:04:44  cocoa
00216 // -- added: StdDeg(gp)
00217 //
00218 // Revision 1.9  2006/04/11 14:54:21  cocoa
00219 // -- added: myStdDeg
00220 //
00221 // Revision 1.8  2006/04/10 17:02:47  cocoa
00222 // -- changed: BCriterion_OK now uses PPWithMask instead of ConstRefPPMonoidElem
00223 //
00224 // Revision 1.7  2006/03/17 18:28:01  cocoa
00225 // -- changed: ordering on pairs (depending on current ordering)
00226 //
00227 // Revision 1.6  2006/03/12 21:28:34  cocoa
00228 // Major check in after many changes
00229 //
00230 // Revision 1.5  2006/03/02 13:44:39  cocoa
00231 // -- just comments
00232 //
00233 // Revision 1.4  2006/02/13 13:41:22  cocoa
00234 // -- fixed: "const RingElem&" --> "ConstRefRingElem"
00235 //
00236 // Revision 1.3  2006/01/20 15:43:30  cocoa
00237 // -- fixed: use of RefPPMonoidElem and ConstRefPPMonoidElem
00238 //
00239 // Revision 1.2  2006/01/17 15:44:56  cocoa
00240 // -- chamges by Max for operations with modules
00241 //
00242 // Revision 1.1.1.1  2005/10/17 10:46:54  cocoa
00243 // Imported files
00244 //
00245 // Revision 1.3  2005/09/29 15:49:58  cocoa
00246 // -- fixed bugs in "operator<"
00247 //
00248 // Revision 1.2  2005/07/01 16:08:16  cocoa
00249 // Friday check-in.  Major change to structure under PolyRing:
00250 // now SparsePolyRing and DUPolyRing are separated (in preparation
00251 // for implementing iterators).
00252 //
00253 // A number of other relatively minor changes had to be chased through
00254 // (e.g. IndetPower).
00255 //
00256 // Revision 1.1.1.1  2005/05/03 15:47:30  cocoa
00257 // Imported files
00258 //
00259 // Revision 1.2  2005/04/19 14:06:04  cocoa
00260 // Added GPL and GFDL licence stuff.
00261 //
00262 // Revision 1.1.1.1  2005/01/27 15:12:13  cocoa
00263 // Imported files
00264 //
00265 // Revision 1.9  2004/11/19 16:15:51  cocoa
00266 // (a) Removed unused error message about degree of zero;
00267 //     replaced it by a more general message about needing a
00268 //     non-zero polynomial (for various ops such as LC, LPP).
00269 // (b) Added some missing arg checking in LC, LPP and deg
00270 //     (for elems of a PolyRing).
00271 // (c) Updated some commented out code in GPair and GPoly.
00272 //
00273 // Revision 1.8  2004/11/02 15:55:18  cocoa
00274 // -- change: "deg" now returns a const reference
00275 //
00276 // Revision 1.7  2004/10/29 15:51:37  cocoa
00277 // -- changed myLCM into myLCMwMask (PPMonoidElem --> PPWithMask)
00278 // -- function IsDivisible had wrong semantics --> swapped arguments everywhere
00279 //
00280 // Revision 1.6  2004/06/16 16:13:41  cocoa
00281 // Improved I/O facilities with knock-on changes
00282 //
00283 // Revision 1.5  2003/11/14 14:10:16  cocoa
00284 // Max - New Pair ordering
00285 //
00286 // Revision 1.4  2003/11/12 16:41:06  cocoa
00287 // CVS Test by Max
00288 //
00289 // Revision 1.3  2003/10/09 12:48:17  cocoa
00290 // New coding convention for rings.
00291 //
00292 // Revision 1.2  2003/10/01 10:35:32  cocoa
00293 // - applied "my" coding convention to PPMonoid and PPOrdering
00294 //
00295 // Revision 1.1.1.1  2003/09/24 12:55:43  cocoa
00296 // Imported files
00297 //
00298 // Revision 1.10  2003/09/22 17:20:47  bigatti
00299 // - new field myOrdPoly to order the GPairs
00300 //
00301 // Revision 1.9  2003/06/23 17:10:34  abbott
00302 // Minor cleaning prior to public release.
00303 // Improved the include directives,
00304 //
00305 // Revision 1.8  2003/05/29 16:12:33  bigatti
00306 // - fix: unsigned int --> int  for RingSpecialIndex in Component(..)
00307 //
00308 // Revision 1.7  2003/05/28 14:20:07  bigatti
00309 // - new code for modules
00310 //
00311 // Revision 1.6  2003/05/14 16:37:39  bigatti
00312 // - myDeg is now of type degree
00313 // - new ring syntax
00314 //
00315 // Revision 1.5  2002/09/19 17:21:33  bigatti
00316 // - Cleaner code based on PolyRing
00317 //
00318 // Revision 1.4  2002/04/15 17:14:58  bigatti
00319 // - Max's new code
00320 //
00321 // Revision 1.3  2002/04/09 14:08:15  bigatti
00322 // - SPoly now takes a GPair as argument
00323 //
00324 // Revision 1.2  2001/12/12 18:22:53  bigatti
00325 // - new structure of reduction
00326 //
00327 // Revision 1.1  2001/12/05 12:57:13  bigatti
00328 // Initial revision
00329 //
00330 
00331 #endif

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