The Original CHomP Software
known.h
Go to the documentation of this file.
1
3
15
16// Copyright (C) 1997-2020 by Pawel Pilarczyk.
17//
18// This file is part of my research software package. This is free software:
19// you can redistribute it and/or modify it under the terms of the GNU
20// General Public License as published by the Free Software Foundation,
21// either version 3 of the License, or (at your option) any later version.
22//
23// This software is distributed in the hope that it will be useful,
24// but WITHOUT ANY WARRANTY; without even the implied warranty of
25// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26// GNU General Public License for more details.
27//
28// You should have received a copy of the GNU General Public License
29// along with this software; see the file "license.txt". If not,
30// please, see <https://www.gnu.org/licenses/>.
31
32// Started in January 2002. Last revision: June 2, 2007.
33
34
35#ifndef _CHOMP_HOMOLOGY_KNOWN_H_
36#define _CHOMP_HOMOLOGY_KNOWN_H_
37
38#include "chomp/system/config.h"
41
42namespace chomp {
43namespace homology {
44
45
46// --------------------------------------------------
47// ------------------- BitFields --------------------
48// --------------------------------------------------
49
54{
55public:
57 BitFields ();
58
61
66 void setkblimit (int limit = -1, int dim = -1);
67
69 int getkblimit (int dim = 0) const;
70
74
76 void forget (int dim = -1);
77
78private:
81
83 int len;
84
86 int *maxkb;
87
89 void extend (int n);
90
92 void allocate (int dim);
93
94}; /* class BitFields */
95
96// --------------------------------------------------
97
99{
100 tab = NULL;
101 len = 0;
102 maxkb = NULL;
103 return;
104} /* BitFields::BitFields */
105
107{
108 // make sure the dimension is positive
109 if (dim <= 0)
110 throw "Trying to get a bit field set of non-positive dim.";
111
112 // extend the tables if necessary
113 if (dim >= len)
114 extend (dim + 1);
115
116 // allocate the bit field set if necessary
117 if (!tab [dim] && maxkb [dim])
118 allocate (dim);
119
120 // return the pointer to the requested bit field set
121 return tab [dim];
122} /* BitFields::operator [] */
123
124// --------------------------------------------------
125
128extern BitFields knownbits;
129
130
131} // namespace homology
132} // namespace chomp
133
134#endif // _CHOMP_HOMOLOGY_KNOWN_H_
135
137
This file contains the definition of a bitfield class which works an array of bits.
This class defines a simple table of bit fields with very limited functionality that is used for stor...
Definition: known.h:54
~BitFields()
The destructor.
int * maxkb
The memory limit for each table (in kilobytes), -1 for none.
Definition: known.h:86
void allocate(int dim)
Allocates the specific bit field set.
int getkblimit(int dim=0) const
Returns the current limit for the given dimension.
int len
The length of the currently allocated table.
Definition: known.h:83
SetOfBitFields * operator[](int dim)
Returns the corresponding bit field set and allocates it if not used so far.
Definition: known.h:106
BitFields()
The default constructor.
Definition: known.h:98
void setkblimit(int limit=-1, int dim=-1)
Sets the limit for the number of kilobytes used for BitFields.
void forget(int dim=-1)
Forgets the given bit field set or all the sets.
SetOfBitFields ** tab
The table of bit field sets for each dimension.
Definition: known.h:80
void extend(int n)
Extends the table to the given length if necessary.
This class defines a set of bit fields of the same length which are to be stored in a contiguous piec...
Definition: bitfield.h:245
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
BitFields knownbits
The global table of BitFields which store the acyclicity information for reducing full cubical sets.
This namespace contains the entire CHomP library interface.
Definition: bitmaps.h:51
This file contains some useful functions related to the text input/output procedures.