Public Member Functions | Private Attributes

chomp::homengin::algstruct< euclidom > Class Template Reference

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

#include <algstruct.h>

List of all members.

Public Member Functions

 algstruct ()
 The default constructor.
 ~algstruct ()
 The destructor.
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.
void addBetti (int level, int howmuch)
 Increases a specific Betti number.
int getBetti (int level) const
 Returns a specific Betti number.
void addTorsion (int level, euclidom coef)
 Adds a torsion coefficient.
const euclidom & getTorsion (int level, int n) const
 Returns a torsion coefficient.
int countTorsion (int level) const
 Says how many torsion coefficients exist at the given level.
std::ostream & describe (std::ostream &out) const
 Describes the homology group in a human-readable way.
std::ostream & showBetti (std::ostream &out) const
 Shows the Betti numbers as a space-sperated sequence.

Private Attributes

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

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 68 of file algstruct.h.


Constructor & Destructor Documentation

template<class euclidom >
chomp::homengin::algstruct< euclidom >::algstruct (  )  [inline]

The default constructor.

Definition at line 116 of file algstruct.h.

{
        return;
} /* algstruct::algstruct */

template<class euclidom >
chomp::homengin::algstruct< euclidom >::~algstruct (  )  [inline]

The destructor.

Definition at line 122 of file algstruct.h.

{
        return;
} /* algstruct::~algstruct */


Member Function Documentation

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

Increases a specific Betti number.

Definition at line 154 of file algstruct.h.

References chomp::homengin::algstruct< euclidom >::betti, and chomp::homengin::algstruct< euclidom >::setBetti().

{
        if (level < 0)
                return;
        if (static_cast<unsigned> (level) < betti. size ())
                betti [level] += howmuch;
        else
                setBetti (level, howmuch);
        return;
} /* algstruct::addBetti */

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

Adds a torsion coefficient.

Definition at line 177 of file algstruct.h.

References chomp::homengin::algstruct< euclidom >::torsion.

{
        if (level < 0)
                return;
        std::vector<euclidom> empty;
        for (int nTorsion = torsion. size (); nTorsion <= level; ++ nTorsion)
                torsion. push_back (empty);
        torsion [level]. push_back (coef);
        return;
} /* algstruct::addTorsion */

template<class euclidom >
int chomp::homengin::algstruct< euclidom >::countLevels (  )  const [inline]

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

Definition at line 130 of file algstruct.h.

References chomp::homengin::algstruct< euclidom >::betti, and chomp::homengin::algstruct< euclidom >::torsion.

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

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 204 of file algstruct.h.

References chomp::homengin::algstruct< euclidom >::torsion.

{
        if (level < 0)
                return 0;
        if (static_cast<unsigned> (level) < torsion. size ())
                return torsion [level]. size ();
        return;
} /* algstruct::countTorsion */

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 229 of file algstruct.h.

References chomp::homengin::algstruct< euclidom >::betti, and chomp::homengin::algstruct< euclidom >::torsion.

{
        int nBetti = betti. size ();
        int nTorsion = torsion. size ();
        for (int i = 0; (i < nBetti) || (i < nTorsion); ++ i)
        {
                if (i)
                        out << ", ";
                else
                        out << '(';
                bool zero = true;
                if ((i < nBetti) && (betti [i] > 0))
                {
                        zero = false;
                        out << ringsymbol<euclidom> ();
                        if (betti [i] > 1)
                                out << '^' << betti [i];
                        if ((i < nTorsion) && (torsion [i]. size ()))
                                out << " + ";
                }
                if (i < nTorsion)
                {
                        std::vector<euclidom> tor = torsion [i];
                        for (unsigned j = 0; j < tor. size (); ++ j)
                        {
                                zero = false;
                                if (j)
                                        out << " + ";
                                out << ringsymbol<euclidom> () <<
                                        '_' << tor [j];
                        }
                }
                if (zero)
                        out << 0;
        }
        if (nBetti || nTorsion)
                out << ')';
        else
                out << '0';
        return out;
} /* algstruct::describe */

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

Returns a specific Betti number.

Definition at line 166 of file algstruct.h.

References chomp::homengin::algstruct< euclidom >::betti.

{
        if (level < 0)
                return 0;
        if (static_cast<unsigned> (level) < betti. size ())
                return betti [level];
        else
                return 0;
} /* algstruct::getBetti */

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

Returns a torsion coefficient.

Definition at line 189 of file algstruct.h.

References chomp::homengin::algstruct< euclidom >::torsion.

{
        static euclidom e;

        if ((level < 0) || (n < 0))
                return e;
        if ((static_cast<unsigned> (level) < torsion. size ()) &&
                (static_cast<unsigned> (n) < torsion [level]. size ()))
                return torsion [level] [n];
        else
                return e;
} /* algstruct::getTorsion */

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

Sets a specific Betti number.

Definition at line 138 of file algstruct.h.

References chomp::homengin::algstruct< euclidom >::betti.

Referenced by chomp::homengin::algstruct< euclidom >::addBetti().

{
        if (level < 0)
                return;
        if (number <= 0)
                return;
        for (int nBetti = betti. size (); nBetti < level; ++ nBetti)
                betti. push_back (0);
        if (static_cast<unsigned> (level) < betti. size ())
                betti [level] = number;
        else
                betti. push_back (number);
        return;
} /* algstruct::setBetti */

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 272 of file algstruct.h.

References chomp::homengin::algstruct< euclidom >::betti.

{
        bool first = true;
        for (std::vector<int>::const_iterator it = betti. begin ();
                it != betti. end (); ++ it)
        {
                if (first)
                        first = false;
                else
                        out << ' ';
                out << *it;
        }
        return out;
} /* algstruct::showBetti */


Member Data Documentation

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

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