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

◆ gbvector_add_to_zzp()

void GBRing::gbvector_add_to_zzp ( const FreeModule * F,
gbvector *& f,
gbvector *& g )

Definition at line 590 of file gbring.cpp.

593{
594 if (g == nullptr) return;
595 if (f == nullptr)
596 {
597 f = g;
598 g = nullptr;
599 return;
600 }
601 gbvector head;
602 gbvector *result = &head;
603 while (1)
604 {
605 int compare_result = gbvector_compare(F, f, g);
606 if (compare_result == LT)
607 {
608 result->next = g;
609 result = result->next;
610 g = g->next;
611 if (g == nullptr)
612 {
613 result->next = f;
614 f = head.next;
615 return;
616 }
617 }
618 else if (compare_result == GT)
619 {
620 result->next = f;
621 result = result->next;
622 f = f->next;
623 if (f == nullptr)
624 {
625 result->next = g;
626 f = head.next;
627 g = nullptr;
628 return;
629 }
630 }
631 else
632 {
633 gbvector *tmf = f;
634 gbvector *tmg = g;
635 f = f->next;
636 g = g->next;
637 CoefficientRingZZp::elem result_coeff;
638 zzp->init(result_coeff);
639 zzp->add(result_coeff, tmf->coeff.get_int(), tmg->coeff.get_int());
640 tmf->coeff = ring_elem(result_coeff);
641 if (zzp->is_zero(tmf->coeff.get_int()))
642 {
644 }
645 else
646 {
647 result->next = tmf;
648 result = result->next;
649 }
651 if (g == nullptr)
652 {
653 result->next = f;
654 f = head.next;
655 return;
656 }
657 if (f == nullptr)
658 {
659 result->next = g;
660 f = head.next;
661 g = nullptr;
662 return;
663 }
664 }
665 }
666}
CoefficientRingZZp * zzp
Definition gbring.hpp:141
int gbvector_compare(const FreeModule *F, const gbvector *f, const gbvector *g) const
Definition gbring.cpp:413
void gbvector_remove_term(gbvector *f)
Definition gbring.cpp:279
VALGRIND_MAKE_MEM_DEFINED & result(result)
ring_elem coeff
Definition gbring.hpp:81
gbvector * next
Definition gbring.hpp:80
const int GT
Definition style.hpp:41
const int LT
Definition style.hpp:39
int get_int() const
Definition ringelem.hpp:124

References gbvector::coeff, gbvector_compare(), gbvector_remove_term(), ring_elem::get_int(), GT, LT, gbvector::next, result(), and zzp.

Referenced by gbvector_add_to().