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

◆ set_entry()

void Ring::set_entry ( vec & v,
int i,
ring_elem r ) const

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

642{
643 vec p;
644 bool iszero = this->is_zero(a);
645 vecterm head;
646 head.next = v;
647 for (p = &head; p->next != nullptr; p = p->next)
648 if (p->next->comp <= r) break;
649
650 if (p->next == nullptr || p->next->comp < r)
651 {
652 if (iszero) return;
653 vec w = new_vec();
654 w->next = p->next;
655 w->comp = r;
656 w->coeff = a;
657 p->next = w;
658 }
659 else if (p->next->comp == r)
660 {
661 if (iszero)
662 {
663 // delete node
664 vec tmp = p->next;
665 p->next = tmp->next;
666 remove_vec_node(tmp);
667 }
668 else
669 p->next->coeff = a;
670 }
671 v = head.next;
672}
void remove_vec_node(vec n) const
Definition ring-vecs.cpp:55
virtual bool is_zero(const ring_elem f) const =0
vec new_vec() const
vector operations ////////////////////
Definition ring-vecs.cpp:54
int p
bool iszero(const mpreal &op)
Definition mpreal.h:1747

References is_zero(), new_vec(), vec::next, p, and remove_vec_node().