00001 ///////////////////////////////////////////////////////////////////////////// 00002 /// 00003 /// \file 00004 /// 00005 /// A simplicial 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_AWDIAGSIM_H_ 00029 #define _CHAINCON_AWDIAGSIM_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/simplex.h" 00041 #include "chaincon/combtensor.h" 00042 00043 00044 // -------------------------------------------------- 00045 // ------------------ AW diagonal ------------------- 00046 // -------------------------------------------------- 00047 00048 /// Computes the Alexander-Whitney diagonal of a simplex. 00049 template <class VertexT> 00050 inline tCombTensor<tSimplex<VertexT> > AWdiagonal 00051 (const tSimplex<VertexT> &s) 00052 { 00053 tCombTensor<tSimplex<VertexT> > tensor; 00054 int dim = s. dim (); 00055 VertexT *left = new VertexT [dim + 1]; 00056 VertexT *right = new VertexT [dim + 1]; 00057 for (int n = 0; n <= dim; ++ n) 00058 { 00059 for (int i = 0; i <= n; ++ i) 00060 left [i] = s [i]; 00061 for (int i = n; i <= dim; ++ i) 00062 right [i - n] = s [i]; 00063 tensor. add (tSimplex<VertexT> (n, left), 00064 tSimplex<VertexT> (dim - n, right)); 00065 } 00066 delete [] right; 00067 delete [] left; 00068 return tensor; 00069 } /* AWdiagonal */ 00070 00071 00072 #endif // _CHAINCON_AWDIAGSIM_H_ 00073