• Main Page
  • Classes
  • Files
  • File List
  • File Members

awdiag2d.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 ///
00003 /// \file
00004 ///
00005 /// A generic procedure for the Alexander-Whithey diagonal computation
00006 /// for 2-dimensional homology generators.
00007 /// This is a complete procedure good for simplicial, cubical,
00008 /// or other complexes.
00009 ///
00010 /////////////////////////////////////////////////////////////////////////////
00011 
00012 // Copyright (C) 2009-2011 by Pawel Pilarczyk.
00013 //
00014 // This file is part of my research software package. This is free software:
00015 // you can redistribute it and/or modify it under the terms of the GNU
00016 // General Public License as published by the Free Software Foundation,
00017 // either version 3 of the License, or (at your option) any later version.
00018 //
00019 // This software is distributed in the hope that it will be useful,
00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00022 // GNU General Public License for more details.
00023 //
00024 // You should have received a copy of the GNU General Public License
00025 // along with this software; see the file "license.txt". If not,
00026 // please, see <http://www.gnu.org/licenses/>.
00027 
00028 // Started on March 24, 2009. Last revision: April 3, 2011.
00029 
00030 
00031 #ifndef _AWDIAG2D_H_
00032 #define _AWDIAG2D_H_
00033 
00034 
00035 // include selected header files from the CHomP library
00036 #include "chomp/system/config.h"
00037 #include "chomp/system/textfile.h"
00038 #include "chomp/struct/hashsets.h"
00039 
00040 // include relevant local header files
00041 #include "chaincon/awdiag.h"
00042 #include "chaincon/combchain.h"
00043 #include "chaincon/combtensor.h"
00044 #include "chaincon/comblinmap.h"
00045 
00046 
00047 // --------------------------------------------------
00048 // ---------------- compute homology ----------------
00049 // --------------------------------------------------
00050 
00051 /// Computes the Alexander-Whithey diagonal for 2-dimensional
00052 /// homology generators.
00053 /// Uses the projection and inclusion maps computed previously
00054 /// as parts of a chain contraction of a cell complex.
00055 template <class CellT>
00056 void computeAWdiagonal (const chomp::homology::hashedset<CellT> &H,
00057         const tCombLinMap<CellT, CellT> &pi,
00058         const tCombLinMap<CellT, CellT> &incl,
00059         bool displayDiag, bool verify)
00060 {
00061         using chomp::homology::sout;
00062 
00063         // compute the AW decomposition of each 2D homology generator
00064         int_t Hsize = H. size ();
00065         for (int_t i = 0; i < Hsize; ++ i)
00066         {
00067                 if (H [i]. dim () != 2)
00068                         continue;
00069                 tCombChain<CellT> homGen = incl (H [i]);
00070                 tCombTensor<CellT> diag (AWdiagonal (homGen));
00071                 if (displayDiag)
00072                 {
00073                         sout << "A-W diagonal of the cycle "
00074                                 "corresponding to " << H [i] << ":\n";
00075                         int_t size = homGen. size ();
00076                         for (int_t j = 0; j < size; ++ j)
00077                         {
00078                                 tCombTensor<CellT> diagGen (AWdiagonal
00079                                         (tCombChain<CellT> (homGen [j])));
00080                                 sout << homGen [j] << " -> " <<
00081                                         diagGen << "\n";
00082                         }
00083                 //      sout << "which reduces to:\n" << diag << "\n";
00084                 }
00085                 int_t n = diag. size ();
00086                 tCombTensor<CellT> diag1dim;
00087                 for (int_t j = 0; j < n; ++ j)
00088                 {
00089                         if (diag. left (j). dim () != 1)
00090                                 continue;
00091                         if (diag. right (j). dim () != 1)
00092                                 continue;
00093                         diag1dim. add (diag. left (j), diag. right (j));
00094                 }
00095                 tCombTensor<CellT> diagBoundary;
00096                 if (verify)
00097                         computeBoundary (diag1dim, diagBoundary);
00098                 if (displayDiag)
00099                 {
00100                         sout << "restricted to 1-dim:\n" << diag1dim << "\n";
00101                         if (verify)
00102                         {
00103                                 sout << "its boundary: " <<
00104                                         diagBoundary << "\n";
00105                         }
00106                 }
00107                 if (verify)
00108                 {
00109                         if (diagBoundary. empty ())
00110                                 sout << "Verified: bd AW " << H [i] <<
00111                                         " = 0.\n";
00112                         else
00113                                 sout << "Failed to verify that bd AW " <<
00114                                         H [i] << " = 0.\n";
00115                 }
00116                 tCombTensor<CellT> diagHom (pi (diag1dim));
00117                 sout << "A-W decomp of " << H [i] << ": " << diagHom << "\n";
00118         }
00119 
00120         return;
00121 } /* computeAWdiagonal */
00122 
00123 
00124 #endif // _AWDIAG2D_H_
00125 

Generated on Tue Apr 5 2011 00:06:31 for Chain Contraction Software by  doxygen 1.7.2