34#ifndef _CAPD_HOMENGIN_ALGSTRUCT_H_
35#define _CAPD_HOMENGIN_ALGSTRUCT_H_
43#include "capd/auxil/CRef.h"
44#include "capd/homologicalAlgebra/HomologySignature.h"
66template<
class eucl
idom>
81 void setBetti (
int level,
int number);
84 void addBetti (
int level,
int howmuch);
93 const euclidom &
getTorsion (
int level,
int n)
const;
99 std::ostream &
describe (std::ostream &out)
const;
102 std::ostream &
showBetti (std::ostream &out)
const;
114template <
class eucl
idom>
120template <
class eucl
idom>
128template <
class eucl
idom>
131 int nBetti = betti. size ();
132 int nTorsion = torsion. size ();
133 return (nBetti > nTorsion) ? nBetti : nTorsion;
136template <
class eucl
idom>
143 for (
int nBetti = betti. size (); nBetti < level; ++ nBetti)
144 betti. push_back (0);
145 if (
static_cast<unsigned> (level) < betti. size ())
146 betti [level] = number;
148 betti. push_back (number);
152template <
class eucl
idom>
157 if (
static_cast<unsigned> (level) < betti. size ())
158 betti [level] += howmuch;
160 setBetti (level, howmuch);
164template <
class eucl
idom>
169 if (
static_cast<unsigned> (level) < betti. size ())
170 return betti [level];
175template <
class eucl
idom>
180 std::vector<euclidom> empty;
181 for (
int nTorsion = torsion. size (); nTorsion <= level; ++ nTorsion)
182 torsion. push_back (empty);
183 torsion [level]. push_back (coef);
187template <
class eucl
idom>
193 if ((level < 0) || (n < 0))
195 if ((
static_cast<unsigned> (level) < torsion. size ()) &&
196 (
static_cast<unsigned> (n) < torsion [level]. size ()))
197 return torsion [level] [n];
202template <
class eucl
idom>
207 if (
static_cast<unsigned> (level) < torsion. size ())
208 return torsion [level]. size ();
215template <
class eucl
idom>
227template <
class eucl
idom>
230 int nBetti = betti. size ();
231 int nTorsion = torsion. size ();
232 for (
int i = 0; (i < nBetti) || (i < nTorsion); ++ i)
239 if ((i < nBetti) && (betti [i] > 0))
242 out << ringsymbol<euclidom> ();
244 out <<
'^' << betti [i];
245 if ((i < nTorsion) && (torsion [i]. size ()))
250 std::vector<euclidom> tor = torsion [i];
251 for (
unsigned j = 0; j < tor. size (); ++ j)
256 out << ringsymbol<euclidom> () <<
263 if (nBetti || nTorsion)
270template <
class eucl
idom>
274 for (std::vector<int>::const_iterator it = betti. begin ();
275 it != betti. end (); ++ it)
287template <
class eucl
idom>
291 return s. describe (out);
295template <
class eucl
idom>
299 for (
int q = 0; q <= maxlevel; ++ q)
302 for (
int i = 0; i < c. size (); ++ i)
304 const euclidom &e = c. coef (i);
305 if (e. delta () == 1)
308 h. addTorsion (q, e);
314template <
class eucl
idom>
318 int dim = (*homSignCR). topDim ();
319 for (
int i = 0; i <= dim; ++ i)
321 h. setBetti (i, (*homSignCR). bettiNumber (i));
322 FGAGrpSignature<int> &s = (*homSignCR) [i];
323 for (
int j = 0; j < s. numberOfTorsionCoefs (); ++ j)
326 e = s. torsionCoef (j);
327 h. addTorsion (i, e);
This file contains the definition of a class which can be used to parse the command line of a program...
An algebraic structure that represents a finitely generated Abelian group with gradation.
int countLevels() const
Returns the number of levels of gradation stored in the structure.
void setBetti(int level, int number)
Sets a specific Betti number.
int getBetti(int level) const
Returns a specific Betti number.
std::ostream & showBetti(std::ostream &out) const
Shows the Betti numbers as a space-sperated sequence.
std::vector< int > betti
The Betti numbers.
std::ostream & describe(std::ostream &out) const
Describes the homology group in a human-readable way.
void addBetti(int level, int howmuch)
Increases a specific Betti number.
std::vector< std::vector< euclidom > > torsion
The torsion coefficients.
~algstruct()
The destructor.
int countTorsion(int level) const
Says how many torsion coefficients exist at the given level.
void addTorsion(int level, euclidom coef)
Adds a torsion coefficient.
algstruct()
The default constructor.
const euclidom & getTorsion(int level, int n) const
Returns a torsion coefficient.
This class defines objects which represent chains as finite sequences of elements identified by integ...
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
void sign2struct(const CRef< HomologySignature< int > > &homSignCR, algstruct< euclidom > &h)
const char * ringsymbol< int >()
const char * ringsymbol()
std::ostream & operator<<(std::ostream &out, const algstruct< euclidom > &s)
Outputs the structure to the output stream in a human-readable form.
void hom2struct(const chomp::homology::chain< euclidom > *hom, int maxlevel, algstruct< euclidom > &h)
Translates the PP's homology representation to the algebraic structure.
This namespace contains the entire CHomP library interface.
This file contains some useful functions related to the text input/output procedures.
This file defines a simple data structure which can be used to measure time used by the program (or s...