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

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

#include <chains.h>

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. More...
 
 chainmap (const chainmap< euclidom > &c)
 Copy constructor. More...
 
chainmap< euclidom > & operator= (const chainmap< euclidom > &c)
 The assignment operator. More...
 
 ~chainmap ()
 The destructor. More...
 
int dim () const
 Returns the dimension of the chain map. More...
 
const mmatrix< euclidom > & operator[] (int i) const
 Returns the matrix of the chain map at the given level. More...
 
void add (int q, int_t m, int_t n, euclidom e)
 Adds a coefficient to the selected matrix of the map: M_q [m, n] += e. More...
 
void invert (void)
 Inverts the chain map. More...
 
void compose (const chainmap< euclidom > &m1, const chainmap< euclidom > &m2)
 Composes two given chain maps. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Private Attributes

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

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 3242 of file chains.h.

Constructor & Destructor Documentation

◆ chainmap() [1/2]

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 3328 of file chains.h.

3330{
3331 // set the dimension
3332 len = domain. len;
3333 if (range. len < domain. len)
3334 len = range. len;
3335
3336 // allocate new matrices
3337 if (len)
3338 map = new mmatrix<euclidom> [len];
3339 else
3340 map = NULL;
3341
3342 for (int i = 0; i < len; ++ i)
3343 {
3344 // define the size of the matrix (number of rows and columns)
3345 map [i]. define (range. getnumgen (i),
3346 domain. getnumgen (i));
3347
3348 // link the matrices to the ones in the chain complexes
3349 domain. boundary [i]. dom_dom. add (map [i]);
3350 range. boundary [i]. dom_img. add (map [i]);
3351 if (i < domain. len - 1)
3352 domain. boundary [i + 1]. img_dom. add (map [i]);
3353 if (i < range. len - 1)
3354 range. boundary [i + 1]. img_img. add (map [i]);
3355 }
3356
3357 return;
3358} /* chainmap<euclidom>::chainmap */
int len
The number of matrices (dimension of the chain map + 1).
Definition: chains.h:3318
void add(int q, int_t m, int_t n, euclidom e)
Adds a coefficient to the selected matrix of the map: M_q [m, n] += e.
Definition: chains.h:3417
mmatrix< euclidom > * map
The matrices in each dimension.
Definition: chains.h:3321

◆ chainmap() [2/2]

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

Copy constructor.

Definition at line 3361 of file chains.h.

3362{
3363 len = c. len;
3364 if (len)
3365 map = new mmatrix<euclidom> [len];
3366 else
3367 map = 0;
3368
3369 for (int i = 0; i < len; ++ i)
3370 map [i] = c. map [i];
3371
3372 return;
3373} /* chainmap<euclidom>::chainmap */

◆ ~chainmap()

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

The destructor.

Definition at line 3395 of file chains.h.

3396{
3397 if (map)
3398 delete [] map;
3399 return;
3400} /* chainmap<euclidom>::~chainmap */

Member Function Documentation

◆ add()

template<class euclidom >
void chomp::homology::chainmap< euclidom >::add ( int  q,
int_t  m,
int_t  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 3417 of file chains.h.

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

◆ compose()

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 3473 of file chains.h.

3475{
3476 if ((m1. len < len) || (m2. len < len))
3477 throw "Trying to compose chain maps with too few levels.";
3478 for (int q = 0; q < len; ++ q)
3479 map [q]. multiply (m1. map [q], m2. map [q]);
3480 return;
3481} /* chainmap<euclidom>::compose */

◆ dim()

template<class euclidom >
int chomp::homology::chainmap< euclidom >::dim
inline

Returns the dimension of the chain map.

Definition at line 3403 of file chains.h.

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

◆ invert()

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

Inverts the chain map.

Definition at line 3465 of file chains.h.

3466{
3467 for (int q = 0; q < len; ++ q)
3468 map [q]. invert ();
3469 return;
3470} /* chainmap<euclidom>::invert */
void invert(void)
Inverts the chain map.
Definition: chains.h:3465

◆ operator=()

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

The assignment operator.

Definition at line 3376 of file chains.h.

3378{
3379 if (map)
3380 delete [] map;
3381
3382 len = c. len;
3383 if (len)
3384 map = new mmatrix<euclidom> [len];
3385 else
3386 map = 0;
3387
3388 for (int i = 0; i < len; ++ i)
3389 map [i] = c. map [i];
3390
3391 return *this;
3392} /* chainmap<euclidom>::operator = */

◆ 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 3409 of file chains.h.

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

◆ show() [1/2]

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 3484 of file chains.h.

3487{
3488 for (int q = 0; q < len; ++ q)
3489 {
3490 if (level && !level [q])
3491 continue;
3492 out << "Dim " << q << ":";
3493 map [q]. showmap (out, maplabel, xtxt, ytxt);
3494 }
3495 return out;
3496} /* chainmap<euclidom>::show */

◆ show() [2/2]

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 3499 of file chains.h.

3502{
3503 outputstream tout (out);
3504 show (tout, maplabel, xtxt, ytxt, level);
3505 return out;
3506} /* chainmap<euclidom>::show */
outputstream & show(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 el...
Definition: chains.h:3484

◆ show_homology() [1/2]

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 3509 of file chains.h.

3513{
3514 int max_len = len - 1;
3515 while ((max_len >= 0) && !hom_domain [max_len]. size ())
3516 -- max_len;
3517 ++ max_len;
3518 for (int q = 0; q < max_len; ++ q)
3519 {
3520 if (!level || level [q])
3521 {
3522 out << "Dim " << q << ":";
3523 int hlen = hom_domain [q]. size ();
3524 if (!hlen)
3525 out << "\t0" << '\n';
3526 for (int i = 0; i < hlen; ++ i)
3527 {
3528 out << "\tf (";
3529 if (xtxt)
3530 out << xtxt;
3531 out << (i + 1) << ") = ";
3532 map [q]. show_hom_col (out,
3533 hom_domain [q]. num (i),
3534 hom_range [q], ytxt);
3535 out << '\n';
3536 }
3537 }
3538 }
3539 return out;
3540} /* chainmap<euclidom>::show_homology */

◆ show_homology() [2/2]

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 3543 of file chains.h.

3547{
3548 outputstream tout (out);
3549 show_homology (tout, hom_domain, hom_range, level, xtxt, ytxt);
3550 return out;
3551} /* chainmap<euclidom>::show_homology */
outputstream & 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
Writes to an output stream the map induced in homology.
Definition: chains.h:3509

References chomp::homology::show_homology().

◆ take_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 3424 of file chains.h.

3426{
3427 if (!hom_domain || !hom_range)
3428 return;
3429
3430 for (int q = 0; q < len; ++ q)
3431 {
3432 int_t dlen = hom_domain [q]. size ();
3433 const chain<euclidom> &r = hom_range [q];
3434 int_t rlen = r. size ();
3435 map [q]. define (rlen, dlen);
3436 // go through the homology generators in the domain
3437 for (int_t i = 0; i < dlen; ++ i)
3438 {
3439 // retrieve the real number of the homology generator
3440 int_t x = hom_domain [q]. num (i);
3441
3442 // get the image of this element by the chain map
3443 const chain<euclidom> &img = m [q]. getcol (x);
3444
3445 // transform numbers in this image to hom. generators
3446 int_t j = 0;
3447 for (int_t k = 0; k < img. size (); ++ k)
3448 {
3449 // find the current element in the range
3450 while ((j < rlen) &&
3451 (r. num (j) < img. num (k)))
3452 ++ j;
3453
3454 // if found in the range, add it
3455 if ((j < rlen) &&
3456 (r. num (j) == img. num (k)))
3457 map [q]. add (j, i, img. coef (k));
3458 }
3459 }
3460 }
3461 return;
3462} /* chainmap<euclidom>::take_homology */
int int_t
Index type for indexing arrays, counting cubes, etc.
Definition: config.h:115

Member Data Documentation

◆ len

template<class euclidom >
int chomp::homology::chainmap< euclidom >::len
private

The number of matrices (dimension of the chain map + 1).

Definition at line 3318 of file chains.h.

◆ map

template<class euclidom >
mmatrix<euclidom>* chomp::homology::chainmap< euclidom >::map
private

The matrices in each dimension.

Definition at line 3321 of file chains.h.


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