The Original CHomP Software
homology.h
Go to the documentation of this file.
1
3
16
17// This file copyright (C) 1997-2016 by Pawel Pilarczyk.
18//
19// This file is part of the "chomp" program. It is free software;
20// you can redistribute it and/or modify it under the terms of the GNU
21// General Public License as published by the Free Software Foundation,
22// either version 3 of the License, or (at your option) any later version.
23//
24// This software is distributed in the hope that it will be useful,
25// but WITHOUT ANY WARRANTY; without even the implied warranty of
26// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27// GNU General Public License for more details.
28//
29// You should have received a copy of the GNU General Public License
30// along with this software; see the file "license.txt". If not,
31// please, see <https://www.gnu.org/licenses/>.
32
33// Started on March 19, 2006. Last revision: July 27, 2007.
34
35
36#ifndef _CAPD_HOMENGIN_HOMOLOGY_H_
37#define _CAPD_HOMENGIN_HOMOLOGY_H_
38
39#include <string>
40#include <cstring>
42
43
63inline void ComputeBettiNumbers (const void *buffer, int *sizes, int dim,
64 int *result, const char *engine = 0, const int *wrapping = 0,
65 bool quiet = false)
66{
67 using namespace chomp::homology;
68 // turn off screen output if requested to
69 bool soutput = sout. show;
70 bool coutput = scon. show;
71 if (quiet)
72 {
73 sout. show = false;
74 scon. show = false;
75 fcout. turnOff ();
76 }
77 else
78 fcout. turnOn ();
79
80 // create a corresponding set of cubes
81 chomp::homengin::cubitmap X (reinterpret_cast<const char *> (buffer),
82 sizes, dim);
83
84 // set the space wrapping
85 if (wrapping)
86 X. setwrapping (wrapping, dim);
87
88 // find the best engine to use for the homology computation
90 if (!engine)
92
93 // another possibility: find the engine with the given name
94 else
96
97 // compute the homology of the set of cubes
99 e -> homology (X, hom);
100 sout << "The computed homology is " << hom << ".\n";
101
102 // fill in the resulting table of Betti numbers
103 int levels = hom. countLevels ();
104 for (int i = 0; i <= dim; ++ i)
105 result [i] = (i < levels) ? hom. getBetti (i) : 0;
106
107 // restore the message settings
108 chomp::homology::sout. show = soutput;
109 chomp::homology::scon. show = coutput;
110 return;
111} /* ComputeBettiNumbers */
112
113
114// *** temporarily ***
116
117
118#endif // _CAPD_HOMENGIN_HOMOLOGY_H_
119
121
An algebraic structure that represents a finitely generated Abelian group with gradation.
Definition: algstruct.h:68
A bitmap buffer stored in the memory, not in a file.
Definition: cubfiles.h:783
An abstract class that is inherited by all the homology engines.
Definition: engines.h:79
static const engine * find(const cubfile *X, const cubfile *Y, const engine::enginelist &elist=engine::engines)
Finds the most appropriate homology engine.
This file defines a very simple interface to manipulating a full cubical set represented as a bitmap ...
This file defines several engines for the homology computation of cubical sets.
ofstreamcout fcout
An output stream defined by M. Mrozek in the CAPD library.
void ComputeBettiNumbers(const void *buffer, int *sizes, int dim, int *result, const char *engine=0, const int *wrapping=0, bool quiet=false)
Computes the Betti numbers of the given set of full cubes encoded in a binary bitmap.
Definition: homology.h:63
This namespace contains the core of the homology computation procedures and related classes and templ...
Definition: bitmaps.h:52
outputstream sout
A replacement for standard output stream, with optional logging and other features provided by the cl...
outputstream scon
The console output stream to which one should put all the junk that spoils the log file,...