CoCoALib-0.9905 date: 23 May 2007


EFGModule.H

Go to the documentation of this file.
00001 #ifndef CoCoA_EFGModule_H
00002 #define CoCoA_EFGModule_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 classes EFGModule and EFGModuleBase
00024 // EFG = Explicitly Finitely Generated (i.e. submodules and quotients of
00025 // free modules).
00026 
00027 
00028 #include "CoCoA/error.H"
00029 #include "CoCoA/ring.H"
00030 #include "CoCoA/module.H"
00031 
00032 #include <vector>
00033 //using std::vector;
00034 #include <cstddef>
00035 //using std::size_t;
00036 
00037 
00038 namespace CoCoA
00039 {
00040 
00041   class FreeModule; // forward declaration (just for myAmbientFreeModule)
00042 
00043   class EFGModuleBase; // forward declaration
00044   class EFGModule: public module
00045   {
00046   public:
00047     // Default copy ctor is OK.
00048     explicit EFGModule(const EFGModuleBase* MPtr);   //??? public???
00049     explicit EFGModule(const module& M); // specializing copy ctor
00050 //???    module& operator=(const module& rhs);
00051 //??? default dtor is fine???    virtual ~EFGModule();
00052 
00053     const EFGModuleBase* myModulePtr() const;
00054     const EFGModuleBase* operator->() const;  // allow const member fns to be called
00055   };
00056 
00057 
00058 
00059   class EFGModuleBase: public ModuleBase
00060   {
00061   protected:
00062 //??? default dtor is fine???    virtual ~EFGModuleBase(); // this class is abstract!!
00063 
00064   public:
00065     typedef ModuleRawPtr RawPtr;
00066     typedef const ModuleRawPtr& ConstRawPtr;
00067 
00068     virtual std::size_t myNumCompts() const = 0;
00069     virtual ConstRefRingElem myCompt(const RawPtr& v, size_t pos) const = 0;
00070     virtual const FreeModule& myAmbientFreeModule() const = 0;
00071     virtual const std::vector<ModuleElem>& myGens() const = 0;
00072     virtual const std::vector<ModuleElem>& myTidyGens() const = 0;
00073   };
00074 
00075 
00076   std::size_t NumCompts(const EFGModule& M);
00077   const std::vector<ModuleElem>& gens(const EFGModule& M);
00078   const std::vector<ModuleElem>& TidyGens(const EFGModule& M);
00079 
00080 
00081   /////////////////////////////////////////////////////////////////////////////
00082   // Inline functions
00083 
00084 
00085   inline bool IsEFGModule(const module& M)
00086   {
00087     //    return (dynamic_cast<const EFGModuleBase*>(M.myModulePtr()) != 0);
00088     return (dynamic_cast<const EFGModuleBase*>(M.myRawPtr()) != 0);
00089   }
00090 
00091 
00092   inline EFGModule AsEFGModule(const module& M)
00093   {
00094     if (!IsEFGModule(M))
00095       CoCoA_ERROR(ERR::NotEFGModule, "AsEFGModule(module)");
00096     //    return EFGModule(static_cast<const EFGModuleBase*>(M.myModulePtr()));
00097     return EFGModule(static_cast<const EFGModuleBase*>(M.myRawPtr()));
00098   }
00099 
00100 
00101   inline EFGModule::EFGModule(const EFGModuleBase* MPtr):
00102       module(MPtr)
00103   {}
00104 
00105 
00106   inline EFGModule::EFGModule(const module& copy):
00107       module(copy)
00108   {
00109     if (!IsEFGModule(copy))
00110       CoCoA_ERROR("Explicitly finitely generated module required", "EFGModule(module)");
00111   }
00112 
00113 
00114 //   inline EFGModule::~EFGModule()
00115 //   {}
00116 
00117 
00118   inline const EFGModuleBase* EFGModule::myModulePtr() const
00119   {
00120     return static_cast<const EFGModuleBase*>(myRawPtr());
00121   }
00122 
00123 
00124   inline const EFGModuleBase* EFGModule::operator->() const
00125   {
00126     return static_cast<const EFGModuleBase*>(myRawPtr());
00127   }
00128 
00129 
00130   inline std::size_t NumCompts(const EFGModule& M)
00131   {
00132     return M->myNumCompts();
00133   }
00134 
00135 
00136   inline const FreeModule& AmbientFreeModule(const EFGModule& M)
00137   {
00138     return M->myAmbientFreeModule();
00139   }
00140 
00141 
00142   inline const std::vector<ModuleElem>& gens(const EFGModule& M)
00143   {
00144     return M->myGens();
00145   }
00146 
00147 
00148   inline const std::vector<ModuleElem>& TidyGens(const EFGModule& M)
00149   {
00150     return M->myTidyGens();
00151   }
00152 
00153 } // end of namespace CoCoA
00154 
00155 
00156 
00157 // RCS header/log in the next few lines
00158 // $Header: /Volumes/Home/cocoa/cvs-repository/CoCoALib-0.99/include/CoCoA/EFGModule.H,v 1.1.1.1 2007/03/09 15:16:11 abbott Exp $
00159 // $Log: EFGModule.H,v $
00160 // Revision 1.1.1.1  2007/03/09 15:16:11  abbott
00161 // Imported files
00162 //
00163 // Revision 1.4  2006/12/06 17:11:16  cocoa
00164 // -- removed #include "config.H"
00165 //
00166 // Revision 1.3  2006/11/14 17:46:20  cocoa
00167 // -- changed: reference counting in modules now uses SmartPtrIRC
00168 //
00169 // Revision 1.2  2006/10/06 14:04:16  cocoa
00170 // Corrected position of #ifndef in header files.
00171 // Separated CoCoA_ASSERT into assert.H from config.H;
00172 // many minor consequential changes (have to #include assert.H).
00173 // A little tidying of #include directives (esp. in Max's code).
00174 //
00175 // Revision 1.1.1.1  2006/05/30 11:39:36  cocoa
00176 // Imported files
00177 //
00178 // Revision 1.6  2006/04/21 14:56:33  cocoa
00179 // Changed return type of myCompt member function: now it returns a
00180 // ConstRefRingElem instead of a RingElem (i.e. a copy).
00181 //
00182 // Revision 1.5  2006/03/27 12:21:26  cocoa
00183 // Minor silly changes to reduce number of complaints from some compiler or other.
00184 //
00185 // Revision 1.4  2005/12/31 12:22:18  cocoa
00186 // Several minor tweaks to silence the Microsoft compiler:
00187 //  - added some missing #includes and using directives
00188 //  - moved some function defns into the right namespace
00189 //  - etc.
00190 //
00191 // Revision 1.3  2005/11/29 13:04:47  cocoa
00192 // -- added "const" to myCompt argument
00193 //
00194 // Revision 1.2  2005/11/24 16:09:38  cocoa
00195 // -- added operator[] for ModuleElem
00196 //
00197 // Revision 1.1.1.1  2005/10/17 10:46:54  cocoa
00198 // Imported files
00199 //
00200 // Revision 1.2  2005/09/28 11:50:35  cocoa
00201 // -- new code for graded modules
00202 //
00203 // Revision 1.1.1.1  2005/05/03 15:47:30  cocoa
00204 // Imported files
00205 //
00206 // Revision 1.4  2005/04/20 15:40:48  cocoa
00207 // Major change: modified the standard way errors are to be signalled
00208 // (now via a macro which records filename and line number).  Updated
00209 // documentation in error.txt accordingly.
00210 //
00211 // Improved the documentation in matrix.txt (still more work to be done).
00212 //
00213 // Revision 1.3  2005/04/19 14:06:04  cocoa
00214 // Added GPL and GFDL licence stuff.
00215 //
00216 // Revision 1.2  2005/02/11 14:15:20  cocoa
00217 // New style ring elements and references to ring elements;
00218 // I hope I have finally got it right!
00219 //
00220 // Revision 1.1.1.1  2005/01/27 15:12:13  cocoa
00221 // Imported files
00222 //
00223 // Revision 1.3  2004/11/12 15:49:29  cocoa
00224 // Tidying prior to 0.90 release.
00225 // (a) documentation improved (or marked as poor)
00226 // (b) sundry minor improvements to the code
00227 //
00228 // Revision 1.2  2004/06/29 17:10:22  cocoa
00229 // Partially tidied use of "protected" and "private" in various
00230 // base classes.  Checking in at the end of the day -- it works,
00231 // and I wouldn't want it to be lost next time point's disk
00232 // misbehaves.
00233 //
00234 // Revision 1.1  2004/01/28 15:54:09  cocoa
00235 // Sundry additions.
00236 //
00237 //
00238 
00239 #endif

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