Macaulay2 Engine
Loading...
Searching...
No Matches

◆ vec_sort()

void Ring::vec_sort ( vecterm *& f) const

Definition at line 674 of file ring-vecs.cpp.

675{
676 // Internal routine to place the elements back in order after
677 // an operation such as subvector.
678 // Divide f into two lists of equal length, sort each,
679 // then add them together. This allows the same monomial
680 // to appear more than once in 'f'.
681
682 if (f == nullptr || f->next == nullptr) return;
683 vecterm *f1 = nullptr;
684 vecterm *f2 = nullptr;
685 while (f != nullptr)
686 {
687 vecterm *t = f;
688 f = f->next;
689 t->next = f1;
690 f1 = t;
691
692 if (f == nullptr) break;
693 t = f;
694 f = f->next;
695 t->next = f2;
696 f2 = t;
697 }
698
699 vec_sort(f1);
700 vec_sort(f2);
701 add_vec_to(f1, f2);
702 f = f1;
703}
void vec_sort(vecterm *&f) const
void add_vec_to(vec &v, vec &w) const

References add_vec_to(), vec::next, and vec_sort().

Referenced by coeffs_of_vec(), sub_vector(), vec_diff(), and vec_sort().