Public Member Functions | Private Attributes

chomp::homology::chainmap< euclidom > Class Template Reference

This class defines a chain map between two chain complexes. More...

#include <chains.h>

List of all members.

Public Member Functions

 chainmap (const chaincomplex< euclidom > &domain, const chaincomplex< euclidom > &range)
 The default constructor of a chain map between the two given chain complexes.
 chainmap (const chainmap< euclidom > &c)
 Copy constructor.
chainmap< euclidom > & operator= (const chainmap< euclidom > &c)
 The assignment operator.
 ~chainmap ()
 The destructor.
int dim () const
 Returns the dimension of the chain map.
const mmatrix< euclidom > & operator[] (int i) const
 Returns the matrix of the chain map at the given level.
void add (int q, int m, int n, euclidom e)
 Adds a coefficient to the selected matrix of the map: M_q [m, n] += e.
void invert (void)
 Inverts the chain map.
void compose (const chainmap< euclidom > &m1, const chainmap< euclidom > &m2)
 Composes two given chain maps.
outputstreamshow (outputstream &out, const char *maplabel="f", const char *xtxt=NULL, const char *ytxt=NULL, const int *level=NULL) const
 Writes the chain map to an output stream in the text format using specified labels for the map and elements in the domain and in the codomain of the map.
std::ostream & show (std::ostream &out, const char *maplabel="f", const char *xtxt=NULL, const char *ytxt=NULL, const int *level=NULL) const
 Writes the chain map to an output stream in the text format using specified labels for the map and elements in the domain and in the codomain of the map.
void take_homology (const chainmap< euclidom > &m, const chain< euclidom > *hom_domain, const chain< euclidom > *hom_range)
 Creates a chain map that represents the map induced in homology by the chain map between the two given chain complexes which have been previously transformed to the simple form.
outputstreamshow_homology (outputstream &out, const chain< euclidom > *hom_domain, const chain< euclidom > *hom_range, const int *level=NULL, const char *xtxt=NULL, const char *ytxt=NULL) const
 Writes to an output stream the map induced in homology.
std::ostream & show_homology (std::ostream &out, const chain< euclidom > *hom_domain, const chain< euclidom > *hom_range, const int *level=NULL, const char *xtxt=NULL, const char *ytxt=NULL) const
 Writes to an output stream the map induced in homology.

Private Attributes

int len
 The number of matrices (dimension of the chain map + 1).
mmatrix< euclidom > * map
 The matrices in each dimension.

Detailed Description

template<class euclidom>
class chomp::homology::chainmap< euclidom >

This class defines a chain map between two chain complexes.

The chain complexes must exist and not change durign the existence of the chain map.

Definition at line 2950 of file chains.h.


Constructor & Destructor Documentation

template<class euclidom >
chomp::homology::chainmap< euclidom >::chainmap ( const chaincomplex< euclidom > &  domain,
const chaincomplex< euclidom > &  range 
) [inline]

The default constructor of a chain map between the two given chain complexes.

Definition at line 3036 of file chains.h.

References chomp::homology::chainmap< euclidom >::add(), chomp::homology::chainmap< euclidom >::len, and chomp::homology::chainmap< euclidom >::map.

{
        // set the dimension
        len = domain. len;
        if (range. len < domain. len)
                len = range. len;

        // allocate new matrices
        if (len)
                map = new mmatrix<euclidom> [len];
        else
                map = NULL;

        for (int i = 0; i < len; ++ i)
        {
                // define the size of the matrix (number of rows and columns)
                map [i]. define (range. getnumgen (i),
                        domain. getnumgen (i));

                // link the matrices to the ones in the chain complexes
                domain. boundary [i]. dom_dom. add (map [i]);
                range. boundary [i]. dom_img. add (map [i]);
                if (i < domain. len - 1)
                        domain. boundary [i + 1]. img_dom. add (map [i]);
                if (i < range. len - 1)
                        range. boundary [i + 1]. img_img. add (map [i]);
        }

        return;
} /* chainmap<euclidom>::chainmap */

template<class euclidom >
chomp::homology::chainmap< euclidom >::chainmap ( const chainmap< euclidom > &  c  )  [inline]

Copy constructor.

Definition at line 3069 of file chains.h.

References chomp::homology::chainmap< euclidom >::len, and chomp::homology::chainmap< euclidom >::map.

{
        len = c. len;
        if (len)
                map = new mmatrix<euclidom> [len];
        else
                map = 0;

        for (int i = 0; i < len; ++ i)
                map [i] = c. map [i];

        return;
} /* chainmap<euclidom>::chainmap */

template<class euclidom >
chomp::homology::chainmap< euclidom >::~chainmap (  )  [inline]

The destructor.

Definition at line 3103 of file chains.h.

References chomp::homology::chainmap< euclidom >::map.

{
        if (map)
                delete [] map;
        return;
} /* chainmap<euclidom>::~chainmap */


Member Function Documentation

template<class euclidom >
void chomp::homology::chainmap< euclidom >::add ( int  q,
int  m,
int  n,
euclidom  e 
) [inline]

Adds a coefficient to the selected matrix of the map: M_q [m, n] += e.

In other words, the image of n += e * m.

Definition at line 3125 of file chains.h.

References chomp::homology::chainmap< euclidom >::map.

Referenced by chomp::homology::chainmap< euclidom >::chainmap(), and chomp::homology::chainmap< euclidom >::take_homology().

{
        map [q]. add (m, n, e);
        return;
} /* chainmap<euclidom>::add */

template<class euclidom >
void chomp::homology::chainmap< euclidom >::compose ( const chainmap< euclidom > &  m1,
const chainmap< euclidom > &  m2 
) [inline]

Composes two given chain maps.

The chain map is replaced by the result of this composition.

Definition at line 3181 of file chains.h.

References chomp::homology::chainmap< euclidom >::len, and chomp::homology::chainmap< euclidom >::map.

{
        for (int q = 0; q < len; ++ q)
                map [q]. multiply (m1. map [q], m2. map [q]);
        return;
} /* chainmap<euclidom>::compose */

template<class euclidom >
int chomp::homology::chainmap< euclidom >::dim (  )  const [inline]

Returns the dimension of the chain map.

Definition at line 3111 of file chains.h.

References chomp::homology::chainmap< euclidom >::len.

{
        return len - 1;
} /* chainmap<euclidom>::dim */

template<class euclidom >
void chomp::homology::chainmap< euclidom >::invert ( void   )  [inline]

Inverts the chain map.

Definition at line 3173 of file chains.h.

References chomp::homology::chainmap< euclidom >::len, and chomp::homology::chainmap< euclidom >::map.

{
        for (int q = 0; q < len; ++ q)
                map [q]. invert ();
        return;
} /* chainmap<euclidom>::invert */

template<class euclidom >
chainmap< euclidom > & chomp::homology::chainmap< euclidom >::operator= ( const chainmap< euclidom > &  c  )  [inline]

The assignment operator.

Definition at line 3085 of file chains.h.

{
        if (map)
                delete [] map;

        len = c. len;
        if (len)
                map = new mmatrix<euclidom> [len];
        else
                map = 0;

        for (int i = 0; i < len; ++ i)
                map [i] = c. map [i];

        return;
} /* chainmap<euclidom>::operator = */

template<class euclidom >
const mmatrix< euclidom > & chomp::homology::chainmap< euclidom >::operator[] ( int  i  )  const [inline]

Returns the matrix of the chain map at the given level.

Definition at line 3117 of file chains.h.

References chomp::homology::chainmap< euclidom >::map.

{
//      if ((i < 0) || (i >= len))
//              throw "Chain map level out of range.";
        return map [i];
} /* chainmap<euclidom>::operator [] */

template<class euclidom >
std::ostream & chomp::homology::chainmap< euclidom >::show ( std::ostream &  out,
const char *  maplabel = "f",
const char *  xtxt = NULL,
const char *  ytxt = NULL,
const int *  level = NULL 
) const [inline]

Writes the chain map to an output stream in the text format using specified labels for the map and elements in the domain and in the codomain of the map.

Definition at line 3205 of file chains.h.

References chomp::homology::chainmap< euclidom >::show().

{
        outputstream tout (out);
        show (tout, maplabel, xtxt, ytxt, level);
        return out;
} /* chainmap<euclidom>::show */

template<class euclidom >
outputstream & chomp::homology::chainmap< euclidom >::show ( outputstream out,
const char *  maplabel = "f",
const char *  xtxt = NULL,
const char *  ytxt = NULL,
const int *  level = NULL 
) const [inline]

Writes the chain map to an output stream in the text format using specified labels for the map and elements in the domain and in the codomain of the map.

Definition at line 3190 of file chains.h.

References chomp::homology::chainmap< euclidom >::len, and chomp::homology::chainmap< euclidom >::map.

Referenced by chomp::homology::chainmap< euclidom >::show().

{
        for (int q = 0; q < len; ++ q)
        {
                if (level && !level [q])
                        continue;
                out << "Dim " << q << ":";
                map [q]. showmap (out, maplabel, xtxt, ytxt);
        }
        return out;
} /* chainmap<euclidom>::show */

template<class euclidom >
std::ostream & chomp::homology::chainmap< euclidom >::show_homology ( std::ostream &  out,
const chain< euclidom > *  hom_domain,
const chain< euclidom > *  hom_range,
const int *  level = NULL,
const char *  xtxt = NULL,
const char *  ytxt = NULL 
) const [inline]

Writes to an output stream the map induced in homology.

If the array of levels is provided, only these homology levels are displayed for which the array has a nonzero entry.

Definition at line 3249 of file chains.h.

References chomp::homology::chainmap< euclidom >::show_homology().

{
        outputstream tout (out);
        show_homology (tout, hom_domain, hom_range, level, xtxt, ytxt);
        return out;
} /* chainmap<euclidom>::show_homology */

template<class euclidom >
outputstream & chomp::homology::chainmap< euclidom >::show_homology ( outputstream out,
const chain< euclidom > *  hom_domain,
const chain< euclidom > *  hom_range,
const int *  level = NULL,
const char *  xtxt = NULL,
const char *  ytxt = NULL 
) const [inline]

Writes to an output stream the map induced in homology.

If the array of levels is provided, only these homology levels are displayed for which the array has a nonzero entry.

Definition at line 3215 of file chains.h.

References chomp::homology::chainmap< euclidom >::len, and chomp::homology::chainmap< euclidom >::map.

Referenced by chomp::homology::chainmap< euclidom >::show_homology().

{
        int max_len = len - 1;
        while ((max_len >= 0) && !hom_domain [max_len]. size ())
                -- max_len;
        ++ max_len;
        for (int q = 0; q < max_len; ++ q)
        {
                if (!level || level [q])
                {
                        out << "Dim " << q << ":";
                        int hlen = hom_domain [q]. size ();
                        if (!hlen)
                                out << "\t0" << '\n';
                        for (int i = 0; i < hlen; ++ i)
                        {
                                out << "\tf (";
                                if (xtxt)
                                        out << xtxt;
                                out << (i + 1) << ") = ";
                                map [q]. show_hom_col (out,
                                        hom_domain [q]. num (i),
                                        hom_range [q], ytxt);
                                out << '\n';
                        }
                }
        }
        return out;
} /* chainmap<euclidom>::show_homology */

template<class euclidom >
void chomp::homology::chainmap< euclidom >::take_homology ( const chainmap< euclidom > &  m,
const chain< euclidom > *  hom_domain,
const chain< euclidom > *  hom_range 
) [inline]

Creates a chain map that represents the map induced in homology by the chain map between the two given chain complexes which have been previously transformed to the simple form.

Definition at line 3132 of file chains.h.

References chomp::homology::chainmap< euclidom >::add(), chomp::homology::chainmap< euclidom >::len, and chomp::homology::chainmap< euclidom >::map.

{
        if (!hom_domain || !hom_range)
                return;

        for (int q = 0; q < len; ++ q)
        {
                int dlen = hom_domain [q]. size ();
                const chain<euclidom> &r = hom_range [q];
                int rlen = r. size ();
                map [q]. define (rlen, dlen);
                // go through the homology generators in the domain
                for (int i = 0; i < dlen; ++ i)
                {
                        // retrieve the real number of the homology generator
                        int x = hom_domain [q]. num (i);

                        // get the image of this element by the chain map
                        const chain<euclidom> &img = m [q]. getcol (x);

                        // transform numbers in this image to hom. generators
                        int j = 0;
                        for (int k = 0; k < img. size (); ++ k)
                        {
                                // find the current element in the range
                                while ((j < rlen) &&
                                        (r. num (j) < img. num (k)))
                                        ++ j;

                                // if found in the range, add it
                                if ((j < rlen) &&
                                        (r. num (j) == img. num (k)))
                                        map [q]. add (j, i, img. coef (k));
                        }
                }
        }
        return;
} /* chainmap<euclidom>::take_homology */


Member Data Documentation

template<class euclidom>
int chomp::homology::chainmap< euclidom >::len [private]
template<class euclidom>
mmatrix<euclidom>* chomp::homology::chainmap< euclidom >::map [private]

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