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

This class defines objects which represent chains as finite sequences of elements identified by integral numbers with coefficients in a given Euclidean domain. More...

#include <chains.h>

Public Member Functions

 chain ()
 The default constructor. More...
 
 chain (const chain< euclidom > &c)
 The copy constructor. More...
 
chain< euclidom > & operator= (const chain< euclidom > &c)
 The assignment operator. More...
 
 ~chain ()
 The destructor. More...
 
int_t size () const
 Returns the size of the chain, that is, the number of elements with non-zero coefficients. More...
 
bool empty () const
 Returns true if the chain is empty (zero), false otherwise. More...
 
euclidom getcoefficient (int_t n=-1) const
 Finds and returns the coefficient in front of the given element. More...
 
int_t findnumber (int_t n) const
 Find the position of an element with the given identifier. More...
 
euclidom coef (int_t i) const
 Returns the coefficient in front of the i-th element in the chain. More...
 
int_t num (int_t i) const
 Returns the number (identifier) of the i-th element in the chain. More...
 
bool contains_non_invertible () const
 Determines if the chain contains a non-invertible coefficient. More...
 
int_t findbest (chain< euclidom > *table=NULL) const
 Finds the best element in the chain for reduction, that is, the element with minimal value of delta. More...
 
chain< euclidom > & add (int_t n, euclidom e)
 Adds an element algebraically to the chain. More...
 
chain< euclidom > & remove (int_t n)
 Removes an element with the given identifier from the chain. More...
 
chain< euclidom > & add (const chain< euclidom > &other, euclidom e, int_t number=-1, chain< euclidom > *table=NULL)
 Adds one chain to another with a given coefficient. More...
 
chain< euclidom > & swap (chain< euclidom > &other, int_t number=-1, int_t othernumber=-1, chain< euclidom > *table=NULL)
 Swaps one chain with another. More...
 
chain< euclidom > & take (chain< euclidom > &c)
 Takes data from another chain. Destroys the other chain. More...
 
chain< euclidom > & multiply (euclidom e, int_t number=-1)
 Multiplies one or all the coefficients in the chain by the given number. More...
 
outputstreamshow (outputstream &out, const char *label=NULL) const
 Shows the chain to the output stream. More...
 
std::ostream & show (std::ostream &out, const char *label=NULL) const
 Shows the chain to the standard output stream. More...
 

Private Member Functions

chain< euclidom > & insertpair (int_t i, int_t n, euclidom e)
 Inserts one chain element at the given position. More...
 
chain< euclidom > & removepair (int_t i)
 Removes one chain element at the given position. More...
 
chain< euclidom > & swapnumbers (int_t number1, int_t number2)
 Swaps two numbers (identifiers) in the chain. More...
 

Private Attributes

int_t len
 The length of the list and the length of the table. More...
 
int_t_n
 Identifiers of the elements of the chain (sorted). More...
 
euclidom * _e
 Coefficients of the elements of the chain. More...
 

Detailed Description

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

This class defines objects which represent chains as finite sequences of elements identified by integral numbers with coefficients in a given Euclidean domain.

Definition at line 93 of file chains.h.

Constructor & Destructor Documentation

◆ chain() [1/2]

template<class euclidom >
chomp::homology::chain< euclidom >::chain
inline

The default constructor.

Definition at line 207 of file chains.h.

207 : len(0)
208{
209 return;
210} /* chain<euclidom>::chain */
int_t len
The length of the list and the length of the table.
Definition: chains.h:183

◆ chain() [2/2]

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

The copy constructor.

Definition at line 213 of file chains.h.

214{
215 // copy the length of the chain
216 len = c. len;
217
218 // allocate new tables and copy the data
219 if (len)
220 {
221 _n = new int_t [len];
222 _e = new euclidom [len];
223 if (!_n || !_e)
224 throw "Not enough memory to create a chain copy.";
225 }
226 for (int_t i = 0; i < len; ++ i)
227 {
228 _n [i] = c. _n [i];
229 _e [i] = c. _e [i];
230 }
231 return;
232} /* chain<euclidom>::chain */
int_t * _n
Identifiers of the elements of the chain (sorted).
Definition: chains.h:186
euclidom * _e
Coefficients of the elements of the chain.
Definition: chains.h:189
int int_t
Index type for indexing arrays, counting cubes, etc.
Definition: config.h:115

◆ ~chain()

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

The destructor.

Definition at line 270 of file chains.h.

271{
272 if (len)
273 {
274 delete [] _n;
275 delete [] _e;
276 }
277 return;
278} /* chain<euclidom>::~chain */

Member Function Documentation

◆ add() [1/2]

template<class euclidom >
chain< euclidom > & chomp::homology::chain< euclidom >::add ( const chain< euclidom > &  other,
euclidom  e,
int_t  number = -1,
chain< euclidom > *  table = NULL 
)
inline

Adds one chain to another with a given coefficient.

If the chain is a row of a matrix, then its number and the table of columns must be given for proper modification. If this is a column, its number and rows(?) must be given.

Definition at line 598 of file chains.h.

600{
601 // if the coefficient is zero or the other chain is zero,
602 // then there is nothing to do
603 if ((e == 0) || !other. len)
604 return *this;
605
606 // prepare big tables for the new chain
607 int_t tablen = len + other. len;
608 int_t *bigntab = new int_t [tablen];
609 euclidom *bigetab = new euclidom [tablen];
610 if (!bigntab || !bigetab)
611 throw "Not enough memory to add chains.";
612
613 // prepare the counters of elements of the two input chains
614 // and of the output chain
615 int_t i = 0, j = 0, k = 0;
616
617 // go through both input chains and compute the output chain
618 while ((i < len) || (j < other. len))
619 {
620 // if the first chain has already been processed
621 if (i >= len)
622 {
623 bigntab [k] = other. _n [j];
624 bigetab [k] = e * other. _e [j];
625 ++ j;
626 if (table)
627 {
628 table [bigntab [k]]. add (number,
629 bigetab [k]);
630 }
631 ++ k;
632 }
633 // if an element from the first chain should be taken
634 else if ((j >= other. len) || (_n [i] < other. _n [j]))
635 {
636 bigntab [k] = _n [i];
637 bigetab [k] = _e [i];
638 ++ i;
639 ++ k;
640 }
641 // if an element from the other chain should be taken
642 else if (_n [i] > other. _n [j])
643 {
644 bigntab [k] = other. _n [j];
645 bigetab [k] = e * other. _e [j];
646 ++ j;
647 if (table)
648 {
649 table [bigntab [k]]. add (number,
650 bigetab [k]);
651 }
652 ++ k;
653 }
654 else // if (_n [i] == other. _n [j])
655 {
656 bigntab [k] = _n [i];
657 euclidom addelem = e * other. _e [j];
658 ++ j;
659 bigetab [k] = _e [i] + addelem;
660 ++ i;
661 if (!(bigetab [k] == 0))
662 {
663 if (table)
664 {
665 table [bigntab [k]]. add (number,
666 addelem);
667 }
668 ++ k;
669 }
670 else if (table)
671 {
672 table [bigntab [k]]. remove (number);
673 }
674 }
675 }
676
677 // release the old tables if they are useless now
678 if ((k != len) || (k == tablen))
679 {
680 if (len)
681 {
682 delete [] _n;
683 delete [] _e;
684 }
685 }
686
687 // use the previous tables and release the big table if beneficial
688 if ((k == len) && (k != tablen))
689 {
690 for (int_t i = 0; i < len; ++ i)
691 {
692 _n [i] = bigntab [i];
693 _e [i] = bigetab [i];
694 }
695 delete [] bigntab;
696 delete [] bigetab;
697 return *this;
698 }
699
700 // if the new chain is empty then accomodate for this
701 if (k == 0)
702 {
703 len = 0;
704 delete [] bigntab;
705 delete [] bigetab;
706 return *this;
707 }
708
709 // if the big tables cannot be used, allocate new tables
710 if (k != tablen)
711 {
712 _n = new int_t [k];
713 _e = new euclidom [k];
714 if (!_n || !_e)
715 throw "Cannot shorten a sum of chains.";
716 len = k;
717 for (int_t i = 0; i < len; ++ i)
718 {
719 _n [i] = bigntab [i];
720 _e [i] = bigetab [i];
721 }
722 delete [] bigntab;
723 delete [] bigetab;
724 }
725
726 // otherwise, simply use the big tables
727 else
728 {
729 len = k;
730 _n = bigntab;
731 _e = bigetab;
732 }
733
734 return *this;
735} /* chain<euclidom>::add */
chain< euclidom > & remove(int_t n)
Removes an element with the given identifier from the chain.
Definition: chains.h:583
chain< euclidom > & add(int_t n, euclidom e)
Adds an element algebraically to the chain.
Definition: chains.h:551

◆ add() [2/2]

template<class euclidom >
chain< euclidom > & chomp::homology::chain< euclidom >::add ( int_t  n,
euclidom  e 
)
inline

Adds an element algebraically to the chain.

Definition at line 551 of file chains.h.

552{
553 // if the coefficient is zero, ignore the pair
554 if (e == 0)
555 return *this;
556
557 // find the position in the table for adding this pair
558 int_t i = 0;
559 while ((i < len) && (_n [i] < n))
560 ++ i;
561
562 // if an element with this identifier was found, add the coefficients
563 if ((i < len) && (_n [i] == n))
564 {
565 // add the coefficient
566 _e [i] += e;
567
568 // if the coefficient became zero, remove this pair
569 if (_e [i] == 0)
570 return removepair (i);
571
572 // otherwise we are done
573 else
574 return *this;
575 }
576
577 // otherwise insert this pair into the chain
578 return insertpair (i, n, e);
579
580} /* chain<euclidom>::add */
chain< euclidom > & insertpair(int_t i, int_t n, euclidom e)
Inserts one chain element at the given position.
Definition: chains.h:411
chain< euclidom > & removepair(int_t i)
Removes one chain element at the given position.
Definition: chains.h:451

◆ coef()

template<class euclidom >
euclidom chomp::homology::chain< euclidom >::coef ( int_t  i) const
inline

Returns the coefficient in front of the i-th element in the chain.

The coefficient is non-zero.

Definition at line 331 of file chains.h.

332{
333 if (i >= len)
334 throw "Wrong coefficient requested from a chain.";
335 return _e [i];
336} /* chain<euclidom>::coef */

◆ contains_non_invertible()

template<class euclidom >
bool chomp::homology::chain< euclidom >::contains_non_invertible
inline

Determines if the chain contains a non-invertible coefficient.

Returns true if yes, false if not.

Definition at line 347 of file chains.h.

348{
349 for (int_t i = 0; i < len; ++ i)
350 {
351 if (_e [i]. delta () > 1)
352 return true;
353 }
354 return false;
355} /* chain<euclidom>::contains_non_invertible */

◆ empty()

template<class euclidom >
bool chomp::homology::chain< euclidom >::empty
inline

Returns true if the chain is empty (zero), false otherwise.

Definition at line 287 of file chains.h.

288{
289 return !len;
290} /* chain<euclidom>::empty */

◆ findbest()

template<class euclidom >
int_t chomp::homology::chain< euclidom >::findbest ( chain< euclidom > *  table = NULL) const
inline

Finds the best element in the chain for reduction, that is, the element with minimal value of delta.

If the given table is given, then additionally an element with the shortest chain length in the table is searched for. Returns the actual index of this element in the chain (not its identifier) or -1 if the chain is empty (zero).

Definition at line 358 of file chains.h.

359{
360 // if the chain is so short that the answer is obvious, return it
361 if (!len)
362 return -1;
363 if (len == 1)
364 return 0;
365
366 // find the number which has the smallest delta function value
367 int_t best_delta = _e [0]. delta ();
368 int_t best_i = 0;
369
370 // go through the whole table to find the first element
371 // with the lowest delta possible (1 is the smallest value)
372 for (int_t i = 1; (i < len) && (best_delta > 1); ++ i)
373 {
374 // compute the value of the function delta
375 int_t this_delta = _e [i]. delta ();
376
377 // if this delta is better, remember it
378 if (this_delta < best_delta)
379 {
380 best_delta = this_delta;
381 best_i = i;
382 }
383 }
384
385 // if no further analysis is required, return the result just now
386 if (!table)
387 return best_i;
388
389 // analyze which element has the shortest corresponding chain
390 // and update "best_i"
391 int_t best_length = table [_n [best_i]]. size ();
392 for (int_t i = best_i + 1; i < len; ++ i)
393 {
394 if (_e [i]. delta () != best_delta)
395 continue;
396 int_t this_length = table [_n [i]]. size ();
397 if (best_length > this_length)
398 {
399 best_length = this_length;
400 best_i = i;
401 }
402 }
403
404 return best_i;
405} /* chain<euclidom>::findbest */
int_t size() const
Returns the size of the chain, that is, the number of elements with non-zero coefficients.
Definition: chains.h:281

◆ findnumber()

template<class euclidom >
int_t chomp::homology::chain< euclidom >::findnumber ( int_t  n) const
inline

Find the position of an element with the given identifier.

Returns -1 if not found.

Definition at line 318 of file chains.h.

319{
320 for (int_t i = 0; i < len; ++ i)
321 {
322 if (_n [i] == n)
323 return i;
324 else if (_n [i] > n)
325 return -1;
326 }
327 return -1;
328} /* chain<euclidom>::findnumber */

◆ getcoefficient()

template<class euclidom >
euclidom chomp::homology::chain< euclidom >::getcoefficient ( int_t  n = -1) const

Finds and returns the coefficient in front of the given element.

If the identifier is negative then returns the first nonzero coefficient or 0 if none.

Definition at line 293 of file chains.h.

294{
295 if (n < 0)
296 {
297 if (len > 0)
298 return _e [0];
299 else
300 {
301 euclidom zero;
302 zero = 0;
303 return zero;
304 }
305 }
306
307 int_t i = 0;
308 while ((i < len) && (_n [i] < n))
309 ++ i;
310 if ((i < len) && (_n [i] == n))
311 return _e [i];
312 euclidom zero;
313 zero = 0;
314 return zero;
315} /* chain<euclidom>::getcoefficient */

◆ insertpair()

template<class euclidom >
chain< euclidom > & chomp::homology::chain< euclidom >::insertpair ( int_t  i,
int_t  n,
euclidom  e 
)
inlineprivate

Inserts one chain element at the given position.

The correctness of the position is not verified.

Definition at line 410 of file chains.h.

412{
413 // remember the addresses of the old tables
414 int_t *old_n = _n;
415 euclidom *old_e = _e;
416
417 // allocate new tables
418 _n = new int_t [len + 1];
419 _e = new euclidom [len + 1];
420 if (!_n || !_e)
421 throw "Cannot add an element to a chain.";
422
423 // increase the length
424 ++ len;
425
426 // copy the old data and insert the new pair
427 for (int_t j = 0; j < i; ++ j)
428 {
429 _n [j] = old_n [j];
430 _e [j] = old_e [j];
431 }
432 _n [i] = n;
433 _e [i] = e;
434 for (int_t j = i + 1; j < len; ++ j)
435 {
436 _n [j] = old_n [j - 1];
437 _e [j] = old_e [j - 1];
438 }
439
440 // release the previous tables if they were allocated
441 if (len > 1)
442 {
443 delete [] old_n;
444 delete [] old_e;
445 }
446
447 return *this;
448} /* chain<euclidom>::insertpair */

◆ multiply()

template<class euclidom >
chain< euclidom > & chomp::homology::chain< euclidom >::multiply ( euclidom  e,
int_t  number = -1 
)
inline

Multiplies one or all the coefficients in the chain by the given number.

Definition at line 801 of file chains.h.

802{
803 // if there is only one element to be multiplied, find it and do it
804 if (number >= 0)
805 {
806 for (int_t i = 0; i < len; ++ i)
807 {
808 if (_n [i] == number)
809 {
810 if (e == 0)
811 removepair (i);
812 else
813 {
814 _e [i] *= e;
815 // if (_e [i] == 0)
816 // removepair (i);
817 }
818 return *this;
819 }
820 }
821 }
822
823 // if the entire chain has to be multiplied by a non-zero number...
824 else if (!(e == 0))
825 {
826 for (int_t i = 0; i < len; ++ i)
827 {
828 _e [i] *= e;
829 // if (_e [i] == 0)
830 // removepair (i);
831 }
832 }
833
834 // otherwise, if the chain has to be made zero, clean it
835 else
836 {
837 if (len)
838 {
839 delete [] _n;
840 delete [] _e;
841 }
842 len = 0;
843 }
844
845 return *this;
846} /* chain<euclidom>::multiply */

◆ num()

template<class euclidom >
int_t chomp::homology::chain< euclidom >::num ( int_t  i) const
inline

Returns the number (identifier) of the i-th element in the chain.

Definition at line 339 of file chains.h.

340{
341 if (i >= len)
342 throw "Wrong number requested from a chain.";
343 return _n [i];
344} /* chain<euclidom>::num */

◆ operator=()

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

The assignment operator.

Definition at line 235 of file chains.h.

237{
238 // protect against self-assignment
239 if (&c == this)
240 return *this;
241
242 // make sure the lengths of the chains are the same
243 if (len != c.len)
244 {
245 if (len)
246 {
247 delete [] _n;
248 delete [] _e;
249 }
250 len = c.len;
251 if (len)
252 {
253 _n = new int_t [len];
254 _e = new euclidom [len];
255 if (!_n || !_e)
256 throw "Not enough memory to create a chain copy =.";
257 }
258 }
259
260 // copy the data
261 for (int_t i = 0; i < len; ++ i)
262 {
263 _n [i] = c. _n [i];
264 _e [i] = c. _e [i];
265 }
266 return *this;
267} /* chain<euclidom>::operator = */

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

◆ remove()

template<class euclidom >
chain< euclidom > & chomp::homology::chain< euclidom >::remove ( int_t  n)

Removes an element with the given identifier from the chain.

Definition at line 583 of file chains.h.

584{
585 // find the element of the chain to be removed
586 int_t i = 0;
587 while ((i < len) && (_n [i] < n))
588 ++ i;
589
590 // if found, then remove it
591 if ((i < len) && (_n [i] == n))
592 return removepair (i);
593
594 return *this;
595} /* chain<euclidom>::remove */

◆ removepair()

template<class euclidom >
chain< euclidom > & chomp::homology::chain< euclidom >::removepair ( int_t  i)
inlineprivate

Removes one chain element at the given position.

The correctness of the position is not verified.

Definition at line 451 of file chains.h.

452{
453 // make sure the chain is not empty
454 if (!len)
455 throw "Trying to remove an element from an empty chain.";
456
457 // remember the addresses of the old tables
458 int_t *old_n = _n;
459 euclidom *old_e = _e;
460
461 // allocate new tables if necessary
462 if (len > 1)
463 {
464 _n = new int_t [len - 1];
465 _e = new euclidom [len - 1];
466 if (!_n || !_e)
467 throw "Cannot add an element to a chain.";
468 }
469
470 // decrease the length
471 -- len;
472
473 // copy the data form the previous tables
474 for (int_t j = 0; j < i; ++ j)
475 {
476 _n [j] = old_n [j];
477 _e [j] = old_e [j];
478 }
479 for (int_t j = i; j < len; ++ j)
480 {
481 _n [j] = old_n [j + 1];
482 _e [j] = old_e [j + 1];
483 }
484
485 // release the previous tables
486 delete [] old_n;
487 delete [] old_e;
488
489 return *this;
490} /* chain<euclidom>::removepair */

◆ show() [1/2]

template<class euclidom >
outputstream & chomp::homology::chain< euclidom >::show ( outputstream out,
const char *  label = NULL 
) const
inline

Shows the chain to the output stream.

Uses a given label for indicating identifiers of elements in the chain.

Definition at line 849 of file chains.h.

851{
852 if (len <= 0)
853 out << "0";
854 for (int_t i = 0; i < len; ++ i)
855 {
856 euclidom e = _e [i];
857 int_t n = _n [i] + 1;
858
859 if (e == 1)
860 out << (i ? " + " : "") <<
861 (label ? label : "") << n;
862 else if (-e == 1)
863 out << (i ? " - " : "-") <<
864 (label ? label : "") << n;
865 else
866 out << (i ? " + " : "") << e << " * " <<
867 (label ? label : "") << n;
868 }
869 return out;
870} /* chain<euclidom>::show */

◆ show() [2/2]

template<class euclidom >
std::ostream & chomp::homology::chain< euclidom >::show ( std::ostream &  out,
const char *  label = NULL 
) const
inline

Shows the chain to the standard output stream.

Uses a given label for indicating identifiers of elements in the chain.

Definition at line 873 of file chains.h.

874{
875 outputstream tout (out);
876 show (tout, label);
877 return out;
878} /* chain<euclidom>::show */
outputstream & show(outputstream &out, const char *label=NULL) const
Shows the chain to the output stream.
Definition: chains.h:849

◆ size()

template<class euclidom >
int_t chomp::homology::chain< euclidom >::size
inline

Returns the size of the chain, that is, the number of elements with non-zero coefficients.

Definition at line 281 of file chains.h.

282{
283 return len;
284} /* chain<euclidom>::size */

◆ swap()

template<class euclidom >
chain< euclidom > & chomp::homology::chain< euclidom >::swap ( chain< euclidom > &  other,
int_t  number = -1,
int_t  othernumber = -1,
chain< euclidom > *  table = NULL 
)
inline

Swaps one chain with another.

If the chain is a row of a matrix, then its number, the number of the other row and the table of columns must be given for proper modification; if this is a column, its number and rows(?) must be given

Definition at line 738 of file chains.h.

740{
741 // swap the data of the chains
742 swapelements (_n, other. _n);
743 swapelements (_e, other. _e);
744 swapelements (len, other. len);
745
746 if (!table)
747 return *this;
748
749 // change the numbers in every relevant entry of the table
750 int_t i = 0;
751 int_t j = 0;
752 while ((i < len) || (j < other. len))
753 {
754 // determine which table entry should be modified
755 int_t n;
756 if (i >= len)
757 n = other. _n [j ++];
758 else if (j >= other. len)
759 n = _n [i ++];
760 else if (_n [i] < other. _n [j])
761 n = _n [i ++];
762 else if (other. _n [j] < _n [i])
763 n = other. _n [j ++];
764 else
765 {
766 n = _n [i ++];
767 ++ j;
768 // ++ i;
769 // ++ j;
770 // continue;
771 }
772
773 // swap numbers in that table entry
774 table [n]. swapnumbers (othernumber, number);
775 }
776
777 return *this;
778} /* chain<euclidom>::swap */
chain< euclidom > & swapnumbers(int_t number1, int_t number2)
Swaps two numbers (identifiers) in the chain.
Definition: chains.h:493
void swapelements(type &x, type &y)
A simple template for swapping two elements with the use of a temporary variable of the same type and...
Definition: textfile.h:329

References chomp::homology::swapelements().

◆ swapnumbers()

template<class euclidom >
chain< euclidom > & chomp::homology::chain< euclidom >::swapnumbers ( int_t  number1,
int_t  number2 
)
inlineprivate

Swaps two numbers (identifiers) in the chain.

Definition at line 493 of file chains.h.

495{
496 // if the numbers are the same, do nothing
497 if (number1 == number2)
498 return *this;
499
500 // force the first number be less than the second number
501 if (number1 > number2)
502 std::swap (number1, number2);
503
504 // find both numbers or the positions they should be at
505 int_t i1 = 0;
506 while ((i1 < len) && (_n [i1] < number1))
507 ++ i1;
508 int_t i2 = i1;
509 while ((i2 < len) && (_n [i2] < number2))
510 ++ i2;
511
512 // if the first number was found...
513 if ((i1 < len) && (_n [i1] == number1))
514 {
515 // if both numbers were found, exchange their coefficients
516 if ((i2 < len) && (_n [i2] == number2))
517 swapelements (_e [i1], _e [i2]);
518 // if only the first was found, move it to the new position
519 else
520 {
521 euclidom temp = _e [i1];
522 for (int_t i = i1 + 1; i < i2; ++ i)
523 {
524 _n [i - 1] = _n [i];
525 _e [i - 1] = _e [i];
526 }
527 _n [i2 - 1] = number2;
528 _e [i2 - 1] = temp;
529 }
530 }
531
532 // otherwise if the second number only was found, move it to its pos.
533 else if ((i2 < len) && (_n [i2] == number2))
534 {
535 euclidom temp = _e [i2];
536 for (int_t i = i2; i > i1; -- i)
537 {
538 _n [i] = _n [i - 1];
539 _e [i] = _e [i - 1];
540 }
541 _n [i1] = number1;
542 _e [i1] = temp;
543 }
544
545 return *this;
546} /* chain<euclidom>::swapnumbers */
void swap(mwWorkerData &data1, mwWorkerData &data2)
Definition: mwcoord.h:108

References chomp::multiwork::swap(), and chomp::homology::swapelements().

◆ take()

template<class euclidom >
chain< euclidom > & chomp::homology::chain< euclidom >::take ( chain< euclidom > &  c)
inline

Takes data from another chain. Destroys the other chain.

Definition at line 781 of file chains.h.

782{
783 // release the current tables if they were allocated
784 if (len)
785 {
786 delete [] _n;
787 delete [] _e;
788 }
789
790 _n = c. _n;
791 _e = c. _e;
792
793 // copy the length and reset the other length
794 len = c. len;
795 c. len = 0;
796
797 return *this;
798} /* chain<euclidom>::take */

Member Data Documentation

◆ _e

template<class euclidom >
euclidom* chomp::homology::chain< euclidom >::_e
private

Coefficients of the elements of the chain.

Definition at line 189 of file chains.h.

◆ _n

template<class euclidom >
int_t* chomp::homology::chain< euclidom >::_n
private

Identifiers of the elements of the chain (sorted).

Definition at line 186 of file chains.h.

◆ len

template<class euclidom >
int_t chomp::homology::chain< euclidom >::len
private

The length of the list and the length of the table.

Definition at line 183 of file chains.h.

Referenced by chomp::homology::chain< euclidom >::operator=().


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