The Original CHomP Software
Public Member Functions | Private Attributes | List of all members
chomp::homengin::algstruct< euclidom > Class Template Reference

An algebraic structure that represents a finitely generated Abelian group with gradation. More...

#include <algstruct.h>

Public Member Functions

 algstruct ()
 The default constructor. More...
 
 ~algstruct ()
 The destructor. More...
 
int countLevels () const
 Returns the number of levels of gradation stored in the structure. More...
 
void setBetti (int level, int number)
 Sets a specific Betti number. More...
 
void addBetti (int level, int howmuch)
 Increases a specific Betti number. More...
 
int getBetti (int level) const
 Returns a specific Betti number. More...
 
void addTorsion (int level, euclidom coef)
 Adds a torsion coefficient. More...
 
const euclidom & getTorsion (int level, int n) const
 Returns a torsion coefficient. More...
 
int countTorsion (int level) const
 Says how many torsion coefficients exist at the given level. More...
 
std::ostream & describe (std::ostream &out) const
 Describes the homology group in a human-readable way. More...
 
std::ostream & showBetti (std::ostream &out) const
 Shows the Betti numbers as a space-sperated sequence. More...
 

Private Attributes

std::vector< int > betti
 The Betti numbers. More...
 
std::vector< std::vector< euclidom > > torsion
 The torsion coefficients. More...
 

Detailed Description

template<class euclidom>
class chomp::homengin::algstruct< euclidom >

An algebraic structure that represents a finitely generated Abelian group with gradation.

Definition at line 67 of file algstruct.h.

Constructor & Destructor Documentation

◆ algstruct()

template<class euclidom >
chomp::homengin::algstruct< euclidom >::algstruct
inline

The default constructor.

Definition at line 115 of file algstruct.h.

116{
117 return;
118} /* algstruct::algstruct */

◆ ~algstruct()

template<class euclidom >
chomp::homengin::algstruct< euclidom >::~algstruct
inline

The destructor.

Definition at line 121 of file algstruct.h.

122{
123 return;
124} /* algstruct::~algstruct */

Member Function Documentation

◆ addBetti()

template<class euclidom >
void chomp::homengin::algstruct< euclidom >::addBetti ( int  level,
int  howmuch 
)
inline

Increases a specific Betti number.

Definition at line 153 of file algstruct.h.

154{
155 if (level < 0)
156 return;
157 if (static_cast<unsigned> (level) < betti. size ())
158 betti [level] += howmuch;
159 else
160 setBetti (level, howmuch);
161 return;
162} /* algstruct::addBetti */
void setBetti(int level, int number)
Sets a specific Betti number.
Definition: algstruct.h:137
std::vector< int > betti
The Betti numbers.
Definition: algstruct.h:106

◆ addTorsion()

template<class euclidom >
void chomp::homengin::algstruct< euclidom >::addTorsion ( int  level,
euclidom  coef 
)
inline

Adds a torsion coefficient.

Definition at line 176 of file algstruct.h.

177{
178 if (level < 0)
179 return;
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);
184 return;
185} /* algstruct::addTorsion */
std::vector< std::vector< euclidom > > torsion
The torsion coefficients.
Definition: algstruct.h:109

◆ countLevels()

template<class euclidom >
int chomp::homengin::algstruct< euclidom >::countLevels
inline

Returns the number of levels of gradation stored in the structure.

Definition at line 129 of file algstruct.h.

130{
131 int nBetti = betti. size ();
132 int nTorsion = torsion. size ();
133 return (nBetti > nTorsion) ? nBetti : nTorsion;
134} /* algstruct::countLevels */

◆ countTorsion()

template<class euclidom >
int chomp::homengin::algstruct< euclidom >::countTorsion ( int  level) const
inline

Says how many torsion coefficients exist at the given level.

Definition at line 203 of file algstruct.h.

204{
205 if (level < 0)
206 return 0;
207 if (static_cast<unsigned> (level) < torsion. size ())
208 return torsion [level]. size ();
209 return 0;
210} /* algstruct::countTorsion */

◆ describe()

template<class euclidom >
std::ostream & chomp::homengin::algstruct< euclidom >::describe ( std::ostream &  out) const

Describes the homology group in a human-readable way.

Definition at line 228 of file algstruct.h.

229{
230 int nBetti = betti. size ();
231 int nTorsion = torsion. size ();
232 for (int i = 0; (i < nBetti) || (i < nTorsion); ++ i)
233 {
234 if (i)
235 out << ", ";
236 else
237 out << '(';
238 bool zero = true;
239 if ((i < nBetti) && (betti [i] > 0))
240 {
241 zero = false;
242 out << ringsymbol<euclidom> ();
243 if (betti [i] > 1)
244 out << '^' << betti [i];
245 if ((i < nTorsion) && (torsion [i]. size ()))
246 out << " + ";
247 }
248 if (i < nTorsion)
249 {
250 std::vector<euclidom> tor = torsion [i];
251 for (unsigned j = 0; j < tor. size (); ++ j)
252 {
253 zero = false;
254 if (j)
255 out << " + ";
256 out << ringsymbol<euclidom> () <<
257 '_' << tor [j];
258 }
259 }
260 if (zero)
261 out << 0;
262 }
263 if (nBetti || nTorsion)
264 out << ')';
265 else
266 out << '0';
267 return out;
268} /* algstruct::describe */

◆ getBetti()

template<class euclidom >
int chomp::homengin::algstruct< euclidom >::getBetti ( int  level) const
inline

Returns a specific Betti number.

Definition at line 165 of file algstruct.h.

166{
167 if (level < 0)
168 return 0;
169 if (static_cast<unsigned> (level) < betti. size ())
170 return betti [level];
171 else
172 return 0;
173} /* algstruct::getBetti */

◆ getTorsion()

template<class euclidom >
const euclidom & chomp::homengin::algstruct< euclidom >::getTorsion ( int  level,
int  n 
) const
inline

Returns a torsion coefficient.

Definition at line 188 of file algstruct.h.

190{
191 static euclidom e;
192
193 if ((level < 0) || (n < 0))
194 return e;
195 if ((static_cast<unsigned> (level) < torsion. size ()) &&
196 (static_cast<unsigned> (n) < torsion [level]. size ()))
197 return torsion [level] [n];
198 else
199 return e;
200} /* algstruct::getTorsion */

◆ setBetti()

template<class euclidom >
void chomp::homengin::algstruct< euclidom >::setBetti ( int  level,
int  number 
)
inline

Sets a specific Betti number.

Definition at line 137 of file algstruct.h.

138{
139 if (level < 0)
140 return;
141 if (number <= 0)
142 return;
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;
147 else
148 betti. push_back (number);
149 return;
150} /* algstruct::setBetti */

◆ showBetti()

template<class euclidom >
std::ostream & chomp::homengin::algstruct< euclidom >::showBetti ( std::ostream &  out) const

Shows the Betti numbers as a space-sperated sequence.

Definition at line 271 of file algstruct.h.

272{
273 bool first = true;
274 for (std::vector<int>::const_iterator it = betti. begin ();
275 it != betti. end (); ++ it)
276 {
277 if (first)
278 first = false;
279 else
280 out << ' ';
281 out << *it;
282 }
283 return out;
284} /* algstruct::showBetti */

Member Data Documentation

◆ betti

template<class euclidom >
std::vector<int> chomp::homengin::algstruct< euclidom >::betti
private

The Betti numbers.

Definition at line 106 of file algstruct.h.

◆ torsion

template<class euclidom >
std::vector<std::vector<euclidom> > chomp::homengin::algstruct< euclidom >::torsion
private

The torsion coefficients.

Definition at line 109 of file algstruct.h.


The documentation for this class was generated from the following file: