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

chaincon/awdiagcub.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 ///
00003 /// \file
00004 ///
00005 /// A cubical version of the Alexander-Whitney diagonal.
00006 ///
00007 /////////////////////////////////////////////////////////////////////////////
00008 
00009 // Copyright (C) 2009-2011 by Pawel Pilarczyk.
00010 //
00011 // This file is part of my research software package. This is free software:
00012 // you can redistribute it and/or modify it under the terms of the GNU
00013 // General Public License as published by the Free Software Foundation,
00014 // either version 3 of the License, or (at your option) any later version.
00015 //
00016 // This software is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU General Public License
00022 // along with this software; see the file "license.txt". If not,
00023 // please, see <http://www.gnu.org/licenses/>.
00024 
00025 // Started on March 24, 2009. Last revision: March 6, 2011.
00026 
00027 
00028 #ifndef _CHAINCON_AWDIAGCUB_H_
00029 #define _CHAINCON_AWDIAGCUB_H_
00030 
00031 
00032 // include some standard C++ header files
00033 #include <istream>
00034 #include <ostream>
00035 
00036 // include selected header files from the CHomP library
00037 #include "chomp/system/config.h"
00038 
00039 // include relevant local header files
00040 #include "chaincon/cubcell.h"
00041 #include "chaincon/combtensor.h"
00042 
00043 
00044 // --------------------------------------------------
00045 // ------------------ AW diagonal -------------------
00046 // --------------------------------------------------
00047 
00048 /// Computes the Alexander-Whitney diagonal of a cubical cell
00049 /// using the formula from Serre's paper.
00050 /// Please, note that this formula has only been implemented
00051 /// for 2-dimensional cells at the moment; the general formula
00052 /// will be implemented soon.
00053 template <class CoordT>
00054 inline tCombTensor<tCubCell<CoordT> > AWdiagonal (const tCubCell<CoordT> &c)
00055 {
00056         // abort the program if the dimension is different than two
00057         if (c. dim () != 2)
00058                 throw "A-W diagonal implemented for 2-dim cubes only.";
00059 
00060         // extract the coordinates of the four vertices of the cubical cell
00061         int dim = c. spaceDim ();
00062         CoordT coord [4] [chomp::homology::MaxBasDim];
00063         int indices [2];
00064         int index = 0;
00065         for (int i = 0; i < dim; ++ i)
00066         {
00067                 coord [0] [i] = c. left (i);
00068                 coord [3] [i] = c. right (i);
00069                 if (coord [0] [i] != coord [3] [i])
00070                 {
00071                         coord [1] [i] = index ? coord [3] [i] :
00072                                 coord [0] [i];
00073                         coord [2] [i] = index ? coord [0] [i] :
00074                                 coord [3] [i];
00075                         indices [index ++] = i;
00076                 }
00077                 else
00078                 {
00079                         coord [1] [i] = coord [0] [i];
00080                         coord [2] [i] = coord [0] [i];
00081                 }
00082         }
00083 
00084         // create the products of respective cells
00085         tCombTensor<tCubCell<CoordT> > tensor;
00086         tensor. add (tCubCell<CoordT> (dim, coord [0], coord [2]),
00087                 tCubCell<CoordT> (dim, coord [2], coord [3]));
00088         tensor. add (tCubCell<CoordT> (dim, coord [0], coord [1]),
00089                 tCubCell<CoordT> (dim, coord [1], coord [3]));
00090 
00091         return tensor;
00092 } /* AWdiagonal */
00093 
00094 
00095 #endif // _CHAINCON_AWDIAGCUB_H_
00096 

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