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

◆ vec_set_entry()

template<typename CoeffRing>
void SMat< CoeffRing >::vec_set_entry ( sparsevec *& v,
size_t r,
const elem & result ) const
private

Definition at line 347 of file smat.hpp.

350{
351 sparsevec *p;
352 bool iszero = ring().is_zero(a);
354 head.next = v;
355 for (p = &head; p->next != 0; p = p->next)
356 if (p->next->row <= r) break;
357
358 if (p->next == 0 || p->next->row < r)
359 {
360 if (iszero) return;
361 sparsevec *w = vec_new();
362 w->next = p->next;
363 w->row = r;
364 ring().init_set(w->coeff, a);
365 p->next = w;
366 }
367 else if (p->next->row == r)
368 {
369 if (iszero)
370 {
371 // delete node
372 sparsevec *tmp = p->next;
373 p->next = tmp->next;
375 }
376 else
377 ring().set(p->next->coeff, a);
378 }
379 v = head.next;
380}
const CoeffRing & ring() const
Definition smat.hpp:104
sparsevec * vec_new() const
Definition smat.hpp:281
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, SMat< ACoeffRing >::sparsevec::next, p, ring(), SMat< ACoeffRing >::sparsevec::row, vec_new(), and vec_remove_node().

Referenced by set_entry(), and vec_row_op2().