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

◆ vec_dot_product()

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

Definition at line 721 of file smat.hpp.

724{
725 Element a(ring());
726 ring().set_zero(a);
727 ring().set_zero(result);
728 while (true)
729 {
730 if (v == 0 || w == 0) break;
731 if (v->row > w->row)
732 v = v->next;
733 else if (v->row < w->row)
734 w = w->next;
735 else
736 {
737 ring().mult(a, v->coeff, w->coeff);
738 ring().add(result, result, a);
739 v = v->next;
740 w = w->next;
741 }
742 }
743}
const CoeffRing & ring() const
Definition smat.hpp:104
CoeffRing::Element Element
Definition smat.hpp:52
Definition smat.hpp:43

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

Referenced by dot_product().