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

◆ vec_add_to()

template<typename CoeffRing>
void SMat< CoeffRing >::vec_add_to ( sparsevec *& v,
sparsevec *& w ) const
private

Definition at line 542 of file smat.hpp.

544{
545 if (w == 0) return;
546 if (v == 0)
547 {
548 v = w;
549 w = 0;
550 return;
551 }
554 while (true)
555 if (v->row < w->row)
556 {
557 result->next = w;
558 result = result->next;
559 w = w->next;
560 if (w == 0)
561 {
562 result->next = v;
563 v = head.next;
564 return;
565 }
566 }
567 else if (v->row > w->row)
568 {
569 result->next = v;
570 result = result->next;
571 v = v->next;
572 if (v == 0)
573 {
574 result->next = w;
575 v = head.next;
576 w = 0;
577 return;
578 }
579 }
580 else
581 {
582 sparsevec *tmv = v;
583 sparsevec *tmw = w;
584 v = v->next;
585 w = w->next;
586 ring().add(tmv->coeff, tmv->coeff, tmw->coeff);
587 if (ring().is_zero(tmv->coeff))
588 {
590 }
591 else
592 {
593 result->next = tmv;
594 result = result->next;
595 }
597 if (w == 0)
598 {
599 result->next = v;
600 v = head.next;
601 return;
602 }
603 if (v == 0)
604 {
605 result->next = w;
606 v = head.next;
607 w = 0;
608 return;
609 }
610 }
611}
const CoeffRing & ring() const
Definition smat.hpp:104
bool is_zero() const
Definition smat.hpp:1107
void vec_remove_node(sparsevec *&v) const
Definition smat.hpp:287
Definition smat.hpp:43

References SMat< ACoeffRing >::sparsevec::coeff, is_zero(), SMat< ACoeffRing >::sparsevec::next, result(), ring(), and vec_remove_node().

Referenced by addInPlace(), column2by2(), subtractInPlace(), vec_column_op(), and vec_sort().