CoCoALib-0.9905 date: 23 May 2007


RingHom.H

Go to the documentation of this file.
00001 #ifndef CoCoA_RingHom_H
00002 #define CoCoA_RingHom_H
00003 
00004 //   Copyright (c)  2005  John Abbott
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 // Header file for the class RingHom
00024 
00025 
00026 #include "CoCoA/ring.H"
00027 #include "CoCoA/SmartPtrIRC.H"
00028 
00029 #include <cstddef>
00030 //using std::size_t;
00031 #include <iosfwd>
00032 //using std::ostream;
00033 
00034 
00035 namespace CoCoA
00036 {
00037 
00038   class ideal; // Fwd decl for IsInKer, defined in ideal.H.
00039 
00040   /*-----------------------------------------------------------------*/
00041   /** \include RingHom.txt  */
00042   /*-----------------------------------------------------------------*/
00043   class RingHomBase: protected IntrusiveReferenceCount
00044   {
00045     friend class SmartPtrIRC<const RingHomBase>; // Morally "friend RingHom", so it can alter reference count.
00046   protected:
00047     RingHomBase(const ring& domain, const ring& codomain): myDomain(domain), myCodomain(codomain) {}
00048     virtual ~RingHomBase() {}
00049   private: // Disable copy ctor and assignment.
00050     RingHomBase(const RingHomBase&);            ///< NEVER DEFINED
00051     RingHomBase& operator=(const RingHomBase&); ///< NEVER DEFINED
00052   public:
00053     friend const ring& domain(const RingHom& phi);
00054     friend const ring& codomain(const RingHom& phi);
00055     virtual void myApply(RingElemRawPtr image, RingElemConstRawPtr arg) const = 0;
00056     void myOutputSelf(std::ostream& out) const;
00057 //???    virtual void myOutputSelf(OpenMath::OutputChannel& OMOut) const = 0;
00058   private: // Implementation details.
00059     virtual void myOutputSelfDetails(std::ostream& out) const; ///< called only by myOutputSelf
00060 
00061   protected: // const data members
00062     const ring myDomain;
00063     const ring myCodomain;
00064   };
00065 
00066 
00067 
00068   //---------------------------------------------------------------------------
00069 
00070   class RingHom
00071   {
00072   public:
00073     explicit RingHom(const RingHomBase* phi): mySmartPtr(phi) {}
00074     // Default copy ctor works fine.
00075     // Assignment disabled because SmartPtrIRC has no assignment.
00076     // Default dtor works fine.
00077     RingElem operator()(ConstRefRingElem x) const;  ///< apply hom to an element
00078     RingElem operator()(long n) const;              ///< map n into domain then apply hom
00079     RingElem operator()(const ZZ& N) const;         ///< map N into domain then apply hom
00080     RingHom operator()(const RingHom&) const;       ///< composition of two RingHoms
00081     const RingHomBase* operator->() const;
00082 //     const RingHomBase* myHomPtr() const;
00083   private: // data member
00084     const SmartPtrIRC<const RingHomBase> mySmartPtr;
00085   };
00086 
00087 
00088   const ring& domain(const RingHom& phi);    ///< inline accessor fn
00089   const ring& codomain(const RingHom& phi);  ///< inline accessor fn
00090   std::ostream& operator<<(std::ostream& out, const RingHom& phi);
00091   bool IsInKer(const ideal& I, const RingHom& phi); ///< is I in ker(phi)?
00092   RingHom IdentityHom(const ring& R);
00093 
00094 
00095   //---------------------------------------------------------------------------
00096   // Two further abstract base classes; the only change wrt RingHomBase is
00097   // the message printed out in myOutputSelfDetails.
00098 
00099   class RingHomEmbeddingBase: public RingHomBase
00100   {
00101   protected:
00102     RingHomEmbeddingBase(const ring& domain, const ring& codomain): RingHomBase(domain, codomain) {}
00103     // Copy ctor and assignment disabled in RingHomBase
00104     // Default dtor is fine.
00105   private: // Implementation details.
00106     virtual void myOutputSelfDetails(std::ostream& out) const; ///< called only by myOutputSelf
00107   };
00108 
00109 
00110   class RingHomInducedBase: public RingHomBase
00111   {
00112   protected:
00113     RingHomInducedBase(const ring& NewDomain, const RingHom& InducingHom);
00114     // Copy ctor and assignment disabled in RingHomBase
00115     // Default dtor is fine.
00116   private: // Implementation details.
00117     virtual void myOutputSelfDetails(std::ostream& out) const; ///< called only by myOutputSelf
00118   protected: // data member
00119     const RingHom myInducingHom;
00120   };
00121 
00122 
00123   //----------------------------------------------------------------------
00124   // inline functions
00125 
00126   inline const RingHomBase* RingHom::operator->() const
00127   { return mySmartPtr.operator->(); }
00128 
00129   inline const ring& domain(const RingHom& phi)
00130   { return phi->myDomain; }
00131 
00132   inline const ring& codomain(const RingHom& phi)
00133   { return phi->myCodomain; }
00134 
00135 
00136 }  // end of namespace CoCoA
00137 
00138 
00139 
00140 // RCS header/log in the next few lines
00141 // $Header: /Volumes/Home/cocoa/cvs-repository/CoCoALib-0.99/include/CoCoA/RingHom.H,v 1.1.1.1 2007/03/09 15:16:11 abbott Exp $
00142 // $Log: RingHom.H,v $
00143 // Revision 1.1.1.1  2007/03/09 15:16:11  abbott
00144 // Imported files
00145 //
00146 // Revision 1.9  2007/03/05 21:06:07  cocoa
00147 // New names for homomorphism pseudo-ctors: removed the "New" prefix.
00148 //
00149 // Revision 1.8  2007/03/03 15:24:14  cocoa
00150 // Improved a comment.
00151 //
00152 // Revision 1.7  2007/01/13 14:14:34  cocoa
00153 // Overhaul of RingHom code: it nows uses SmartPtrIRC, and printing is more logical.
00154 // Have not yet updated the documentation.
00155 //
00156 // Revision 1.6  2007/01/11 14:06:15  cocoa
00157 // -- added prefix "raw" to RawPtr arguments names
00158 //
00159 // Revision 1.5  2006/12/06 17:21:55  cocoa
00160 // -- removed #include "config.H"
00161 //
00162 // Revision 1.4  2006/11/29 16:52:07  cocoa
00163 // -- doxygen style comments
00164 //
00165 // Revision 1.3  2006/11/08 16:21:59  cocoa
00166 // Structural cleaning of RingHom; many consequential changes.
00167 //
00168 // Revision 1.2  2006/10/06 14:04:15  cocoa
00169 // Corrected position of #ifndef in header files.
00170 // Separated CoCoA_ASSERT into assert.H from config.H;
00171 // many minor consequential changes (have to #include assert.H).
00172 // A little tidying of #include directives (esp. in Max's code).
00173 //
00174 // Revision 1.1.1.1  2006/05/30 11:39:37  cocoa
00175 // Imported files
00176 //
00177 // Revision 1.4  2006/04/27 13:45:30  cocoa
00178 // Changed name of NewIdentityRingHom to NewIdentityHom.
00179 // Changed name of member functions which print out their own object
00180 // into myOutputSelf (to distinguish from "transitive" myOutput fns).
00181 //
00182 // Revision 1.3  2006/03/15 18:09:31  cocoa
00183 // Changed names of member functions which print out their object
00184 // into myOutputSelf -- hope this will appease the Intel C++ compiler.
00185 //
00186 // Revision 1.2  2006/03/12 21:28:34  cocoa
00187 // Major check in after many changes
00188 //
00189 // Revision 1.1.1.1  2005/10/17 10:46:54  cocoa
00190 // Imported files
00191 //
00192 // Revision 1.1.1.1  2005/05/03 15:47:30  cocoa
00193 // Imported files
00194 //
00195 // Revision 1.4  2005/04/20 15:40:48  cocoa
00196 // Major change: modified the standard way errors are to be signalled
00197 // (now via a macro which records filename and line number).  Updated
00198 // documentation in error.txt accordingly.
00199 //
00200 // Improved the documentation in matrix.txt (still more work to be done).
00201 //
00202 // Revision 1.3  2005/04/19 14:06:04  cocoa
00203 // Added GPL and GFDL licence stuff.
00204 //
00205 // Revision 1.2  2005/02/11 14:15:20  cocoa
00206 // New style ring elements and references to ring elements;
00207 // I hope I have finally got it right!
00208 //
00209 // Revision 1.1.1.1  2005/01/27 15:12:13  cocoa
00210 // Imported files
00211 //
00212 // Revision 1.7  2004/11/12 15:49:29  cocoa
00213 // Tidying prior to 0.90 release.
00214 // (a) documentation improved (or marked as poor)
00215 // (b) sundry minor improvements to the code
00216 //
00217 // Revision 1.6  2004/11/11 13:04:30  cocoa
00218 // -- added \include *.txt for doxygen
00219 //
00220 // Revision 1.5  2004/07/20 15:04:06  cocoa
00221 // The next step in the new "ring element" conversion process:
00222 // handling the case of creating a "const RefRingElem" object
00223 // (since C++ refuses to do this properly itself).
00224 //
00225 // Revision 1.4  2004/05/27 16:14:02  cocoa
00226 // Minor revision for new coding conventions.
00227 //
00228 // Revision 1.3  2004/05/24 15:52:13  cocoa
00229 // Major update:
00230 //   new error mechanism
00231 //   many fixes
00232 //   RingHoms almost work now
00233 //   RingFloat much improved
00234 //
00235 // Revision 1.2  2003/10/09 12:16:38  cocoa
00236 // New coding convention for rings.
00237 //
00238 // Revision 1.2  2003/06/23 16:59:19  abbott
00239 // Minor cleaning prior to public release.
00240 //
00241 // Revision 1.1  2003/05/14 17:16:35  abbott
00242 // Initial revision
00243 //
00244 
00245 #endif

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