The class that defines a geometric complex - a set of cells (cubes, simplices, etc). More...
#include <gcomplex.h>
Public Member Functions | |
| gcomplex () | |
| The default constructor. | |
| gcomplex (const gcomplex< cell, euclidom > &c) | |
| The copy constructor. | |
| ~gcomplex () | |
| The destructor. | |
| gcomplex & | operator= (const gcomplex< cell, euclidom > &c) |
| The assignment operator. | |
| int | dim () const |
| Returns the dimension of the complex, that is, the highest dimension of any cell contained in the complex. | |
| int_t | size () const |
| Returns the number of cells in the complex. | |
| bool | empty () const |
| Returns 'true' iff the cell complex is empty. | |
| const hashedset< cell > & | operator[] (int d) const |
| Returns the set of cells of the given dimension. | |
| const hashedset< cell > & | getcob (const cell &c) const |
| Returns the coboundary of the given cell. | |
| const hashedset< cell > & | getcob (const cell &c, int d) const |
| Returns the coboundary of the given cell. | |
| gcomplex< cell, euclidom > & | add (const cell &c) |
| Add a cell to the geometric complex. | |
| gcomplex< cell, euclidom > & | add (const hashedset< cell > &c, int d) |
| Adds a set of cells to the geometric complex. | |
| gcomplex< cell, euclidom > & | add (const hashedset< cell > &c) |
| Adds a set of cells to the geometric complex. | |
| gcomplex< cell, euclidom > & | add (const gcomplex< cell, euclidom > &c) |
| Adds all the cells from a geometric complex. | |
| gcomplex< cell, euclidom > & | remove (const cell &c) |
| Remove a cell from the geometric complex. | |
| gcomplex< cell, euclidom > & | remove (const hashedset< cell > &c, int d) |
| Removes a set of cells to the geometric complex. | |
| gcomplex< cell, euclidom > & | remove (const hashedset< cell > &c) |
| Removes a set of cells to the geometric complex. | |
| gcomplex< cell, euclidom > & | remove (const gcomplex< cell, euclidom > &c) |
| Adds all the cells from a geometric complex. | |
| gcomplex< cell, euclidom > & | removeall (int d) |
| Remove all the cells of the given dimension. | |
| bool | check (const cell &c) const |
| Check whether the given cell is in the complex. | |
| int_t | addboundaries (int d, bool addcob=false) |
| Adds boundaries of all the cells of given dimension to the geometric complex. | |
| int_t | addboundaries (bool addcob=false) |
| Adds boundaries of all the cells of all dimensions to the geometric complex. | |
| int_t | addboundaries (int d, gcomplex< cell, euclidom > ¬these, bool keepused=false) |
| Adds boundaries of all the cells of given dimension to the geometric complex, except for the cells which belong to the geometric complex "notthese". | |
| int_t | addboundaries (gcomplex< cell, euclidom > ¬these, bool keepused=false) |
| Adds boundaries of all the cells of all dimensions to the geometric complex, except for the cells which belong to the geometric complex "notthese". | |
| int_t | addboundaries (int d, chaincomplex< euclidom > &c) |
| Adds boundaries and also fills in the given chain complex. | |
| int_t | addboundaries (chaincomplex< euclidom > &c) |
| Adds boundaries and also fills in the given chain complex. | |
| int_t | addboundaries (int d, chaincomplex< euclidom > &c, gcomplex< cell, euclidom > ¬these, bool keepused=false) |
| Adds boundaries and also fills in the given chain complex. | |
| int_t | addboundaries (chaincomplex< euclidom > &c, gcomplex< cell, euclidom > ¬these, bool keepused=false) |
| Adds boundaries and also fills in the given chain complex. | |
| int_t | addboundaries (int d, chaincomplex< euclidom > *c, gcomplex< cell, euclidom > *notthese, bool dontadd, bool keepused, bool addcob) |
| The actual function that is used for all the functions for adding boundaries of a fixed dimension. | |
| int_t | addboundaries (chaincomplex< euclidom > *c, gcomplex< cell, euclidom > *notthese, bool dontadd, bool keepused, bool addcob) |
| The actual function that is used for all the functions for adding boundaries of all dimensions. | |
| int_t | collapse (int d, gcomplex< cell, euclidom > &other, const gcomplex< cell, euclidom > &keep, bool addbd, bool addcob, bool disjoint, bool quiet=false) |
| Adds boundaries of all the cells of the given dimension and then performs free face collapses. | |
| int_t | collapse (gcomplex< cell, euclidom > &other, gcomplex< cell, euclidom > &keep, bool addbd, bool addcob, bool disjoint, const int *level=NULL, bool quiet=false) |
| Adds boundaries to 'other' and 'keep', and then does the free face collapses. | |
Private Member Functions | |
| void | increasedimension (int d) |
| Increases the dimension of the complex to take this cell. | |
| void | decreasedimension () |
| Frees empty sets if there are no cells of high dimensions. | |
Private Attributes | |
| hashedset< cell > ** | tab |
| The tables with cells of dimension 0, 1, 2, etc. | |
| mvmap< cell, cell > ** | cob |
| The tables with coboundaries of cells of these dimensions. | |
| int | n |
| The number of tables. | |
The class that defines a geometric complex - a set of cells (cubes, simplices, etc).
Each cell has its dimension returned by the method "dim ()" of the cell object. Additionally, the following functions must be defined for the cell objects: "boundarylength (cell)" returns the length of the boundary of a cell (i.e., the number of lower-dimensional cells in its boundary), "boundarycell (cell, i)" returns the i-th cell in the boundary, and "boundarycoef (cell, i)" returns the i-th integer coefficient in the boundary.
Definition at line 85 of file gcomplex.h.
| chomp::homology::gcomplex< cell, euclidom >::gcomplex | ( | ) | [inline] |
The default constructor.
Definition at line 253 of file gcomplex.h.
| chomp::homology::gcomplex< cell, euclidom >::gcomplex | ( | const gcomplex< cell, euclidom > & | c | ) |
The copy constructor.
Definition at line 259 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::cob, chomp::homology::gcomplex< cell, euclidom >::n, and chomp::homology::gcomplex< cell, euclidom >::tab.
{
n = c. n;
if (n > 0)
{
tab = new hashedset<cell> *[n];
cob = new mvmap<cell,cell> *[n];
if (!tab || !cob)
throw "Cannot copy a geometric complex.";
}
else
{
tab = NULL;
cob = NULL;
}
for (int i = 0; i < n; ++ i)
{
tab [i] = new hashedset<cell> (*(c. tab [i]));
cob [i] = new mvmap<cell,cell> (*(c. cob [i]));
if (!tab [i] || !cob [i])
throw "Cannot copy part of a geometric complex.";
}
return;
} /* gcomplex<cell,euclidom>::gcomplex */
| chomp::homology::gcomplex< cell, euclidom >::~gcomplex | ( | ) |
The destructor.
Definition at line 338 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::cob, chomp::homology::gcomplex< cell, euclidom >::n, and chomp::homology::gcomplex< cell, euclidom >::tab.
| gcomplex< cell, euclidom > & chomp::homology::gcomplex< cell, euclidom >::add | ( | const cell & | c | ) | [inline] |
Add a cell to the geometric complex.
Definition at line 406 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::dim(), chomp::homology::gcomplex< cell, euclidom >::increasedimension(), chomp::homology::gcomplex< cell, euclidom >::n, and chomp::homology::gcomplex< cell, euclidom >::tab.
Referenced by chomp::homology::gcomplex< cell, euclidom >::addboundaries(), and chomp::homology::gcomplex< cell, euclidom >::collapse().
{
// get the dimension of the cell
int d = c. dim ();
if (d < 0)
throw "Negative dimension of a cell to be added.";
// if the dimension of the cell is beyond the allocated table,
// then increase the table
if (n <= d)
increasedimension (d);
// add the cell to the suitable set of cells
tab [d] -> add (c);
return *this;
} /* gcomplex<cell,euclidom>::add */
| gcomplex< cell, euclidom > & chomp::homology::gcomplex< cell, euclidom >::add | ( | const hashedset< cell > & | c, | |
| int | d | |||
| ) | [inline] |
Adds a set of cells to the geometric complex.
It is assumed that all the cells have dimension d.
Definition at line 426 of file gcomplex.h.
{
// increase the dimension of the complex if necessary
if (d > n)
increasedimension (d);
// add the set of cells to the suitable set
tab [d] -> add (c);
return *this;
} /* gcomplex<cell,euclidom>::add */
| gcomplex< cell, euclidom > & chomp::homology::gcomplex< cell, euclidom >::add | ( | const hashedset< cell > & | c | ) |
| gcomplex< cell, euclidom > & chomp::homology::gcomplex< cell, euclidom >::add | ( | const gcomplex< cell, euclidom > & | c | ) |
Adds all the cells from a geometric complex.
Definition at line 451 of file gcomplex.h.
{
// increase the dimension of the complex if necessary
if (c. n > n)
increasedimension (c. dim ());
// add the sets of cells
for (int i = 0; i < c. n; ++ i)
{
tab [i] -> add (*(c. tab [i]));
/* const hashedset<cell> &cset = *(c. tab [i]);
for (int j = 0; j < cset. size (); ++ j)
{
const cell &thecell = cset [j];
tab [i] -> add (thecell);
if (cob && c. cob)
(*(cob [i])) [thecell] =
((*(c. cob [i])) (thecell));
}
*/
}
return *this;
} /* gcomplex<cell,euclidom>::add */
| int_t chomp::homology::gcomplex< cell, euclidom >::addboundaries | ( | int | d, | |
| bool | addcob = false | |||
| ) | [inline] |
Adds boundaries of all the cells of given dimension to the geometric complex.
If requested, keeps the information about the coboundaries. Returns the number of cells added.
Definition at line 648 of file gcomplex.h.
Referenced by chomp::homology::gcomplex< cell, euclidom >::addboundaries(), and chomp::homology::gcomplex< cell, euclidom >::collapse().
{
return addboundaries (d, NULL, NULL, false, false, addcob);
} /* gcomplex<cell,euclidom>::addboundaries */
| int_t chomp::homology::gcomplex< cell, euclidom >::addboundaries | ( | chaincomplex< euclidom > * | c, | |
| gcomplex< cell, euclidom > * | notthese, | |||
| bool | dontadd, | |||
| bool | keepused, | |||
| bool | addcob | |||
| ) |
The actual function that is used for all the functions for adding boundaries of all dimensions.
Definition at line 636 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::addboundaries(), and chomp::homology::gcomplex< cell, euclidom >::n.
{
int_t countadded = 0;
for (int d = n - 1; d > 0; -- d)
countadded += addboundaries (d, c, notthese,
dontadd, keepused, addcob);
return countadded;
} /* gcomplex<cell,euclidom>::addboundaries */
| int_t chomp::homology::gcomplex< cell, euclidom >::addboundaries | ( | bool | addcob = false |
) | [inline] |
Adds boundaries of all the cells of all dimensions to the geometric complex.
If requested, keeps the information about the coboundaries. Returns the number of cells added.
Definition at line 654 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::addboundaries().
{
return addboundaries (NULL, NULL, false, false, addcob);
} /* gcomplex<cell,euclidom>::addboundaries */
| int_t chomp::homology::gcomplex< cell, euclidom >::addboundaries | ( | int | d, | |
| gcomplex< cell, euclidom > & | notthese, | |||
| bool | keepused = false | |||
| ) | [inline] |
Adds boundaries of all the cells of given dimension to the geometric complex, except for the cells which belong to the geometric complex "notthese".
If "keepused" is set to false, then cells whose boundaries have been added are removed from the geometric complex; otherwise, they are kept there. Returns the number of cells added.
Definition at line 660 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::addboundaries().
{
return addboundaries (d, NULL, ¬these, false, keepused, false);
} /* gcomplex<cell,euclidom>::addboundaries */
| int_t chomp::homology::gcomplex< cell, euclidom >::addboundaries | ( | gcomplex< cell, euclidom > & | notthese, | |
| bool | keepused = false | |||
| ) |
Adds boundaries of all the cells of all dimensions to the geometric complex, except for the cells which belong to the geometric complex "notthese".
If "keepused" is set to false, then cells whose boundaries have been added are removed from the geometric complex; otherwise, they are kept there. Returns the number of cells added.
Definition at line 668 of file gcomplex.h.
References chomp::homology::addboundaries().
{
return addboundaries (NULL, ¬these, false, keepused, false);
} /* gcomplex<cell,euclidom>::addboundaries */
| int_t chomp::homology::gcomplex< cell, euclidom >::addboundaries | ( | int | d, | |
| chaincomplex< euclidom > & | c | |||
| ) | [inline] |
Adds boundaries and also fills in the given chain complex.
Definition at line 674 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::addboundaries().
{
return addboundaries (d, &c, NULL, false, false, false);
} /* gcomplex<cell,euclidom>::addboundaries */
| int_t chomp::homology::gcomplex< cell, euclidom >::addboundaries | ( | chaincomplex< euclidom > & | c | ) | [inline] |
Adds boundaries and also fills in the given chain complex.
Definition at line 681 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::addboundaries().
{
return addboundaries (&c, NULL, false, false, false);
} /* gcomplex<cell,euclidom>::addboundaries */
| int_t chomp::homology::gcomplex< cell, euclidom >::addboundaries | ( | int | d, | |
| chaincomplex< euclidom > & | c, | |||
| gcomplex< cell, euclidom > & | notthese, | |||
| bool | keepused = false | |||
| ) | [inline] |
Adds boundaries and also fills in the given chain complex.
Definition at line 687 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::addboundaries().
{
return addboundaries (d, &c, ¬these, false, keepused, false);
} /* gcomplex<cell,euclidom>::addboundaries */
| int_t chomp::homology::gcomplex< cell, euclidom >::addboundaries | ( | chaincomplex< euclidom > & | c, | |
| gcomplex< cell, euclidom > & | notthese, | |||
| bool | keepused = false | |||
| ) | [inline] |
Adds boundaries and also fills in the given chain complex.
Definition at line 695 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::addboundaries().
{
return addboundaries (&c, ¬these, false, keepused, false);
} /* gcomplex<cell,euclidom>::addboundaries */
| int_t chomp::homology::gcomplex< cell, euclidom >::addboundaries | ( | int | d, | |
| chaincomplex< euclidom > * | c, | |||
| gcomplex< cell, euclidom > * | notthese, | |||
| bool | dontadd, | |||
| bool | keepused, | |||
| bool | addcob | |||
| ) |
The actual function that is used for all the functions for adding boundaries of a fixed dimension.
Definition at line 580 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::add(), chomp::homology::gcomplex< cell, euclidom >::addboundaries(), chomp::homology::boundarycell(), chomp::homology::boundarycoef(), chomp::homology::boundarylength(), chomp::homology::gcomplex< cell, euclidom >::check(), chomp::homology::gcomplex< cell, euclidom >::cob, chomp::homology::gcomplex< cell, euclidom >::n, chomp::homology::gcomplex< cell, euclidom >::removeall(), chomp::homology::gcomplex< cell, euclidom >::size(), and chomp::homology::gcomplex< cell, euclidom >::tab.
{
// if the dimension is inappropriate, do nothing
if ((d <= 0) || (d >= n))
return 0;
// first add boundaries to the other cell complex
if (notthese && !dontadd)
notthese -> addboundaries (d);
int_t prevsize = tab [d - 1] -> size ();
hashedset<cell> &cset = *(tab [d]);
for (int_t i = 0; i < cset. size (); ++ i)
{
const cell &thecell = cset [i];
int len = boundarylength (thecell);
for (int j = 0; j < len; ++ j)
{
// take the j-th boundary cell
cell bcell = boundarycell (thecell, j);
// add it to the cell complex unless it is unwanted
if (!notthese || !notthese -> check (bcell))
{
tab [d - 1] -> add (bcell);
if (c)
{
int icoef = boundarycoef (thecell, j);
euclidom coef;
if (icoef < 0)
{
coef = -icoef;
coef = -coef;
}
else
coef = icoef;
c -> add (d, tab [d - 1] ->
getnumber (bcell), i, coef);
}
if (addcob)
(*(cob [d - 1])) [bcell].
add (thecell);
}
}
}
// clean the used level in 'notthese'
if (notthese && !keepused)
notthese -> removeall (d);
return tab [d - 1] -> size () - prevsize;
} /* gcomplex<cell,euclidom>::addboundaries */
| bool chomp::homology::gcomplex< cell, euclidom >::check | ( | const cell & | c | ) | const |
Check whether the given cell is in the complex.
Returns true if yes, false if not.
Definition at line 563 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::dim(), chomp::homology::gcomplex< cell, euclidom >::n, and chomp::homology::gcomplex< cell, euclidom >::tab.
Referenced by chomp::homology::gcomplex< cell, euclidom >::addboundaries(), and chomp::homology::gcomplex< cell, euclidom >::collapse().
{
// get the dimension of the cell
int d = c. dim ();
if (d < 0)
throw "Negative dimension of a cell to be checked.";
// if the dimension of the cell is beyond the allocated table,
// then it is not there
if (n <= d)
return false;
// check for the existence of the cell in the suitable set of cells
return tab [d] -> check (c);
} /* gcomplex<cell,euclidom>::check */
| int_t chomp::homology::gcomplex< cell, euclidom >::collapse | ( | int | d, | |
| gcomplex< cell, euclidom > & | other, | |||
| const gcomplex< cell, euclidom > & | keep, | |||
| bool | addbd, | |||
| bool | addcob, | |||
| bool | disjoint, | |||
| bool | quiet = false | |||
| ) |
Adds boundaries of all the cells of the given dimension and then performs free face collapses.
Does not remove cells listed in 'keep'. Removes from 'other' and 'this' unnecessary d-dim cells. Returns the number of collapses performed.
Definition at line 753 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::add(), chomp::homology::boundarycell(), chomp::homology::boundarylength(), chomp::homology::gcomplex< cell, euclidom >::check(), chomp::homology::gcomplex< cell, euclidom >::cob, chomp::homology::gcomplex< cell, euclidom >::decreasedimension(), chomp::homology::gcomplex< cell, euclidom >::dim(), chomp::homology::findelem(), chomp::homology::gcomplex< cell, euclidom >::remove(), chomp::homology::gcomplex< cell, euclidom >::removeall(), chomp::homology::scon, chomp::homology::gcomplex< cell, euclidom >::size(), chomp::homology::sseq, and chomp::homology::gcomplex< cell, euclidom >::tab.
Referenced by chomp::homology::gcomplex< cell, euclidom >::collapse().
{
if ((d <= 0) || (d > dim ()))
return 0;
// prepare references to the sets of cells of interest
hashedset<cell> &cset = *(tab [d]);
hashedset<cell> &bset = *(tab [d - 1]);
hashedset<cell> empty;
hashedset<cell> &cother = (other. dim () >= d) ?
*(other. tab [d]) : empty;
hashedset<cell> &bother = (other. dim () >= d - 1) ?
*(other. tab [d - 1]) : empty;
const hashedset<cell> &ckeep = (keep. dim () >= d) ?
*(keep. tab [d]) : empty;
const hashedset<cell> &bkeep = (keep. dim () >= d - 1) ?
*(keep. tab [d - 1]) : empty;
// show the currently processed dimension
if (!quiet)
{
if (d > 9)
scon << "#\b";
else
scon << d << '\b';
}
// go through all the cells from A and generate their boundaries
if (addbd)
{
if (!quiet)
{
sseq << "\"Adding boundaries of cells in A...\"\n";
sseq << "D 0\n";
}
for (int_t i = 0; i < cother. size (); ++ i)
{
// select the given cell in 'cother'
const cell &thecell = cother [i];
// detect the length of the boundary of this cell
int blen = boundarylength (thecell);
// add to 'bother' all the cells in this boundary
for (int j = 0; j < blen; ++ j)
bother. add (boundarycell (thecell, j));
// write the boundary cells to the sequential file
if (!quiet && (sseq. show || sseq. log))
{
for (int j = 0; j < blen; ++ j)
sseq << '2' << boundarycell
(thecell, j) << '\n';
}
}
}
if (!quiet)
sseq << "D 100\n";
// if the complexes should be disjoint, remove 'bother' from 'bset'
if (disjoint)
bset. remove (bother);
// prepare tables for coboundaries of cells in X and their lengths
multitable<int> coblen;
multitable<hashedset <cell> > coboundary;
if (!bset. empty ())
coblen. fill (0, bset. size ());
// go through the list of all the cells of dimension 'd' in the set,
// add their boundaries to 'bset' and create the coboundary links;
// note: these cells may appear in the 'other' complex
if (!quiet)
sseq << "\"Adding boundaries of cells of dimension " <<
d << "\"\nD 0\n";
bool maximal = (d == dim ());
for (int_t i = 0; i < cset. size (); ++ i)
{
// select the i-th d-dimensional cell
const cell &thecell = cset [i];
// check if this cell belongs to 'cother'
bool cbelongs = cother. check (thecell);
// if this cell should be removed, do it
if (cbelongs && (disjoint || maximal))
{
// if (!quiet && (sseq. show || sseq. log))
// sseq << '0' << thecell << '\n';
cother. remove (thecell);
cset. removenum (i --);
continue;
}
// detect the length of the boundary of this cell
int blen = boundarylength (thecell);
// should this cell be kept secure from the collapses?
bool keepit = ckeep. check (thecell);
// go through all the cells in this boundary
for (int j = 0; j < blen; ++ j)
{
// take the j-th boundary cell
cell bcell = boundarycell (thecell, j);
// check if this cell belongs to the other complex
bool bbelongs = bother. check (bcell);
// if it is in 'bother', then skip it if disjoint
if (bbelongs && disjoint)
continue;
// add this cell to 'bset' or get its number
int_t prev = bset. size ();
int_t number = addbd ? bset. add (bcell) :
bset. getnumber (bcell);
// if the cell is not there, skip it
if (number < 0)
continue;
// if this is the first occurrence of the cell
if ((prev < bset. size ()) || (coblen [number] == 0))
{
// write it to the sequence if necessary
if (!quiet && !bbelongs)
sseq << '1' << bcell << '\n';
// if this cell should be kept, mark it
if (keepit || bkeep. check (bset [number]) ||
bother. check (bset [number]))
coblen [number] = 13;
else
coblen [number] = 1;
coboundary [number]. add (thecell);
}
// otherwise add the corresponding coboundary link
else
{
++ (coblen [number]);
coboundary [number]. add (thecell);
}
}
}
if (!quiet)
sseq << "D 100\n";
// show a dot
if (!quiet)
scon << "*\b";
// prepare tables for cells to be removed
hashedset<cell> cremove, bremove;
int_t nremove = 0;
// go through all the free faces
if (!quiet)
sseq << "\"Collapsing free faces...\"\n";
while (1)
{
// find a free face
int_t ncell = findelem (coblen, 1, bset. size ());
// if not found then finish
if (ncell < 0)
break;
// collapse this cell with its parent cell
const cell &parent = coboundary [ncell] [0];
int blen = boundarylength (parent);
coblen [ncell] = 0;
// remove the parent cell from coboundaries
for (int j = 0; j < blen; ++ j)
{
cell thecell = boundarycell (parent, j);
int_t number = bset. getnumber (thecell);
if ((number >= 0) && (coblen [number] > 0))
{
coboundary [number]. remove (parent);
-- (coblen [number]);
}
}
// write these cells to the sequence file
if (!quiet)
{
sseq << '0' << bset [ncell] << '\n';
sseq << '0' << parent << '\n';
}
// mark these cells for removal
cremove. add (parent);
bremove. add (bset [ncell]);
++ nremove;
// clear the coboundary, because it is no longer used
coboundary [ncell] = empty;
}
// add the computed coboundaries if required
if (addcob)
{
for (int_t i = 0; i < bset. size (); ++ i)
if (!bremove. check (bset [i]))
{
coboundary [i]. remove (cremove);
(*(cob [d - 1])) [bset [i]]. add
(coboundary [i]);
}
}
// remove cells that are scheduled for removal from 'cset'
if (nremove == cset. size ())
{
removeall (d);
other. removeall (d);
}
else
{
for (int_t i = 0; i < nremove; ++ i)
cset. remove (cremove [i]);
}
// remove from the set of boundary cells these scheduled for removal
for (int_t i = 0; i < nremove; ++ i)
bset. remove (bremove [i]);
// update the dimension of the cell complex - is this necessary?
decreasedimension ();
// show a dot
if (!quiet)
scon << '.';
return nremove;
} /* gcomplex<cell,euclidom>::collapse */
| int_t chomp::homology::gcomplex< cell, euclidom >::collapse | ( | gcomplex< cell, euclidom > & | other, | |
| gcomplex< cell, euclidom > & | keep, | |||
| bool | addbd, | |||
| bool | addcob, | |||
| bool | disjoint, | |||
| const int * | level = NULL, |
|||
| bool | quiet = false | |||
| ) |
Adds boundaries to 'other' and 'keep', and then does the free face collapses.
Does this at all levels or only the necessary ones. Remove sfrom 'other' cells that are not in the result. If 'disjoint', then removes 'other' from 'this'. Removes from 'keep' cells not contained in the result. Returns the number of collapses performed.
Definition at line 996 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::addboundaries(), chomp::homology::gcomplex< cell, euclidom >::check(), chomp::homology::gcomplex< cell, euclidom >::collapse(), chomp::homology::gcomplex< cell, euclidom >::dim(), chomp::homology::gcomplex< cell, euclidom >::empty(), chomp::homology::gcomplex< cell, euclidom >::removeall(), chomp::homology::scon, chomp::homology::gcomplex< cell, euclidom >::size(), and chomp::homology::gcomplex< cell, euclidom >::tab.
{
// determine the lower bound for the adding boundaries levels
int dmin = 0;
if (level)
{
while ((dmin < dim ()) && (!level [dmin]))
++ dmin;
if (dmin && level [dmin])
-- dmin;
}
// add boundaries to high-dimensional cells in 'keep'
while (keep. dim () > dim ())
{
keep. addboundaries (keep. dim ());
keep. removeall (keep. dim ());
}
// add boundaries to high-dimensional cells in 'other'
if (other. dim () > dim ())
{
other. addboundaries (other. dim ());
other. removeall (other. dim ());
}
// add boundaries and collapse in all the dimensions of interest
int_t counter = 0;
for (int d = dim (); d > dmin; -- d)
{
// add boundaries to the other cell complexes
keep. addboundaries (d);
// add boundaries and collapse this level
counter += collapse (d, other, keep, addbd, addcob, disjoint,
quiet);
// remove unnecessary cells from 'other'
if (disjoint)
other. removeall (d);
// remove unnecessary cells from 'keep'
keep. removeall (d);
}
// forget all the other cells of minimal dimension which are not used
if (!disjoint && (dim () >= dmin) && (other. dim () >= dmin))
{
hashedset<cell> &cset = *(tab [dmin]);
hashedset<cell> &cother = *(other. tab [dmin]);
for (int_t i = 0; i < cother. size (); ++ i)
{
if (!(cset. check (cother [i])))
cother. removenum (i --);
}
}
// remove unused cells which were supposed to be kept
if (!keep. empty ())
{
gcomplex<cell,euclidom> empty;
keep = empty;
}
if (!quiet)
scon << ' ';
return counter;
} /* gcomplex<cell,euclidom>::collapse */
| void chomp::homology::gcomplex< cell, euclidom >::decreasedimension | ( | ) | [private] |
Frees empty sets if there are no cells of high dimensions.
Definition at line 1104 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::cob, chomp::homology::gcomplex< cell, euclidom >::empty(), chomp::homology::gcomplex< cell, euclidom >::n, and chomp::homology::gcomplex< cell, euclidom >::tab.
Referenced by chomp::homology::gcomplex< cell, euclidom >::collapse(), and chomp::homology::gcomplex< cell, euclidom >::removeall().
| int chomp::homology::gcomplex< cell, euclidom >::dim | ( | ) | const [inline] |
Returns the dimension of the complex, that is, the highest dimension of any cell contained in the complex.
Definition at line 355 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::n.
Referenced by chomp::homology::gcomplex< cell, euclidom >::add(), chomp::homology::gcomplex< cell, euclidom >::check(), chomp::homology::gcomplex< cell, euclidom >::collapse(), and chomp::homology::gcomplex< cell, euclidom >::getcob().
{
return n - 1;
} /* gcomplex<cell,euclidom>::dim */
| bool chomp::homology::gcomplex< cell, euclidom >::empty | ( | ) | const |
Returns 'true' iff the cell complex is empty.
Definition at line 370 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::n, and chomp::homology::gcomplex< cell, euclidom >::tab.
Referenced by chomp::homology::gcomplex< cell, euclidom >::collapse(), and chomp::homology::gcomplex< cell, euclidom >::decreasedimension().
| const hashedset< cell > & chomp::homology::gcomplex< cell, euclidom >::getcob | ( | const cell & | c | ) | const [inline] |
Returns the coboundary of the given cell.
Definition at line 390 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::dim().
| const hashedset< cell > & chomp::homology::gcomplex< cell, euclidom >::getcob | ( | const cell & | c, | |
| int | d | |||
| ) | const [inline] |
Returns the coboundary of the given cell.
The dimension of the cell must be given.
Definition at line 397 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::cob, and chomp::homology::gcomplex< cell, euclidom >::n.
| void chomp::homology::gcomplex< cell, euclidom >::increasedimension | ( | int | d | ) | [private] |
Increases the dimension of the complex to take this cell.
Definition at line 1069 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::cob, chomp::homology::gcomplex< cell, euclidom >::n, and chomp::homology::gcomplex< cell, euclidom >::tab.
Referenced by chomp::homology::gcomplex< cell, euclidom >::add().
{
// create a new table for sets of cells
hashedset<cell> **newtab = new hashedset<cell> *[d + 1];
mvmap<cell,cell> **newcob = new mvmap<cell,cell> *[d + 1];
// copy anything that was in the old table
for (int i = 0; i < n; ++ i)
{
newtab [i] = tab [i];
newcob [i] = cob [i];
}
// delete the old table if it was allocated
if (tab)
delete [] tab;
if (cob)
delete [] cob;
// initialize the remaining portion of the new table
tab = newtab;
cob = newcob;
for (int i = n; i < d + 1; ++ i)
{
tab [i] = new hashedset<cell>;
cob [i] = new mvmap<cell,cell>;
}
// set the new dimension
n = d + 1;
return;
} /* gcomplex<cell,euclidom>::increasedimension */
| gcomplex< cell, euclidom > & chomp::homology::gcomplex< cell, euclidom >::operator= | ( | const gcomplex< cell, euclidom > & | c | ) |
The assignment operator.
Definition at line 286 of file gcomplex.h.
{
// if the sizes of the tables are not the same, re-allocate the table
// and use the copying constructor to create an identical table
if (n != c. n)
{
if (tab)
{
for (int i = 0; i < n; ++ i)
delete tab [i];
delete [] tab;
}
if (cob)
{
for (int i = 0; i < n; ++ i)
delete cob [i];
delete [] cob;
}
n = c. n;
if (n > 0)
{
tab = new hashedset<cell> *[n];
cob = new mvmap<cell,cell> *[n];
if (!tab || !cob)
throw "Cannot copy a geometric complex.";
}
else
{
tab = NULL;
cob = NULL;
}
for (int i = 0; i < n; ++ i)
{
tab [i] = new hashedset<cell> (*(c. tab [i]));
cob [i] = new mvmap<cell,cell> (*(c. cob [i]));
if (!tab [i] || !cob [i])
throw "Cannot copy part of a geom. complex.";
}
}
// otherwise copy the source table to this complex
else
{
for (int i = 0; i < n; ++ i)
{
*(tab [i]) = *(c. tab [i]);
*(cob [i]) = *(c. cob [i]);
}
}
return *this;
} /* gcomplex<cell,euclidom>::operator = */
| const hashedset< cell > & chomp::homology::gcomplex< cell, euclidom >::operator[] | ( | int | d | ) | const [inline] |
Returns the set of cells of the given dimension.
Definition at line 381 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::n, and chomp::homology::gcomplex< cell, euclidom >::tab.
| gcomplex< cell, euclidom > & chomp::homology::gcomplex< cell, euclidom >::remove | ( | const gcomplex< cell, euclidom > & | c | ) |
Adds all the cells from a geometric complex.
Definition at line 502 of file gcomplex.h.
References chomp::homology::decreasedimension().
{
// figure out the number of tables to work on
int m = c. n;
if (m > n)
m = n;
// remove the sets of cells
for (int i = 0; i < m; ++ i)
tab [i] -> remove (*(c. tab [i]));
// decrease the dimension of the complex if no highdim cells remain
decreasedimension ();
return *this;
} /* gcomplex<cell,euclidom>::remove */
| gcomplex< cell, euclidom > & chomp::homology::gcomplex< cell, euclidom >::remove | ( | const hashedset< cell > & | c, | |
| int | d | |||
| ) | [inline] |
Removes a set of cells to the geometric complex.
It is assumed that all the cells have dimension d.
Definition at line 521 of file gcomplex.h.
References chomp::homology::decreasedimension().
{
// remove the set of cells to the suitable set
tab [d] -> remove (c);
// decrease the dimension of the complex if no highdim cells remain
decreasedimension ();
return *this;
} /* gcomplex<cell,euclidom>::remove */
| gcomplex< cell, euclidom > & chomp::homology::gcomplex< cell, euclidom >::remove | ( | const hashedset< cell > & | c | ) |
| gcomplex< cell, euclidom > & chomp::homology::gcomplex< cell, euclidom >::remove | ( | const cell & | c | ) | [inline] |
Remove a cell from the geometric complex.
Definition at line 478 of file gcomplex.h.
References chomp::homology::decreasedimension().
Referenced by chomp::homology::gcomplex< cell, euclidom >::collapse().
{
// get the dimension of the cell
int d = c. dim ();
if (d < 0)
throw "Negative dimension of a cell to be removed.";
// if the dimension of the cell is beyond the allocated table,
// then ignore it
if (n <= d)
return *this;
// remove the cell from the suitable set of cells
tab [d] -> remove (c);
// decrease the dimension of the complex if no cells remain
if ((d == n - 1) && tab [d] -> empty ())
decreasedimension ();
return *this;
} /* gcomplex<cell,euclidom>::remove */
| gcomplex< cell, euclidom > & chomp::homology::gcomplex< cell, euclidom >::removeall | ( | int | d | ) |
Remove all the cells of the given dimension.
Definition at line 544 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::cob, chomp::homology::gcomplex< cell, euclidom >::decreasedimension(), chomp::homology::gcomplex< cell, euclidom >::n, and chomp::homology::gcomplex< cell, euclidom >::tab.
Referenced by chomp::homology::gcomplex< cell, euclidom >::addboundaries(), and chomp::homology::gcomplex< cell, euclidom >::collapse().
| int_t chomp::homology::gcomplex< cell, euclidom >::size | ( | ) | const |
Returns the number of cells in the complex.
Definition at line 361 of file gcomplex.h.
References chomp::homology::gcomplex< cell, euclidom >::n, and chomp::homology::gcomplex< cell, euclidom >::tab.
Referenced by chomp::homology::gcomplex< cell, euclidom >::addboundaries(), and chomp::homology::gcomplex< cell, euclidom >::collapse().
mvmap<cell,cell>** chomp::homology::gcomplex< cell, euclidom >::cob [private] |
The tables with coboundaries of cells of these dimensions.
Definition at line 237 of file gcomplex.h.
Referenced by chomp::homology::gcomplex< cell, euclidom >::addboundaries(), chomp::homology::gcomplex< cell, euclidom >::collapse(), chomp::homology::gcomplex< cell, euclidom >::decreasedimension(), chomp::homology::gcomplex< cell, euclidom >::gcomplex(), chomp::homology::gcomplex< cell, euclidom >::getcob(), chomp::homology::gcomplex< cell, euclidom >::increasedimension(), chomp::homology::gcomplex< cell, euclidom >::removeall(), and chomp::homology::gcomplex< cell, euclidom >::~gcomplex().
int chomp::homology::gcomplex< cell, euclidom >::n [private] |
The number of tables.
Definition at line 240 of file gcomplex.h.
Referenced by chomp::homology::gcomplex< cell, euclidom >::add(), chomp::homology::gcomplex< cell, euclidom >::addboundaries(), chomp::homology::gcomplex< cell, euclidom >::check(), chomp::homology::gcomplex< cell, euclidom >::decreasedimension(), chomp::homology::gcomplex< cell, euclidom >::dim(), chomp::homology::gcomplex< cell, euclidom >::empty(), chomp::homology::gcomplex< cell, euclidom >::gcomplex(), chomp::homology::gcomplex< cell, euclidom >::getcob(), chomp::homology::gcomplex< cell, euclidom >::increasedimension(), chomp::homology::gcomplex< cell, euclidom >::operator[](), chomp::homology::gcomplex< cell, euclidom >::removeall(), chomp::homology::gcomplex< cell, euclidom >::size(), and chomp::homology::gcomplex< cell, euclidom >::~gcomplex().
hashedset<cell>** chomp::homology::gcomplex< cell, euclidom >::tab [private] |
The tables with cells of dimension 0, 1, 2, etc.
Definition at line 234 of file gcomplex.h.
Referenced by chomp::homology::gcomplex< cell, euclidom >::add(), chomp::homology::gcomplex< cell, euclidom >::addboundaries(), chomp::homology::gcomplex< cell, euclidom >::check(), chomp::homology::gcomplex< cell, euclidom >::collapse(), chomp::homology::gcomplex< cell, euclidom >::decreasedimension(), chomp::homology::gcomplex< cell, euclidom >::empty(), chomp::homology::gcomplex< cell, euclidom >::gcomplex(), chomp::homology::gcomplex< cell, euclidom >::increasedimension(), chomp::homology::gcomplex< cell, euclidom >::operator[](), chomp::homology::gcomplex< cell, euclidom >::removeall(), chomp::homology::gcomplex< cell, euclidom >::size(), and chomp::homology::gcomplex< cell, euclidom >::~gcomplex().
1.7.1