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

◆ add_in_place_n()

void DPoly::add_in_place_n ( int level,
TowerPolynomial & f,
const TowerPolynomial g )
private

Definition at line 691 of file dpoly.cpp.

692{
693 int i;
694 if (g == nullptr) return;
695 if (f == nullptr)
696 {
697 f = copy(level, g);
698 return;
699 }
700 int fdeg = f->deg;
701 int gdeg = g->deg;
702
703 increase_size_n(g->deg, f);
704 for (i = 0; i <= gdeg; i++)
705 add_in_place(level - 1, f->arr.polys[i], g->arr.polys[i]);
706 if (gdeg > fdeg)
707 f->deg = gdeg;
708 else if (gdeg == fdeg)
709 {
710 // need to change the degree
711 for (int j = fdeg; j >= 0; --j)
712 if (f->arr.polys[j] != nullptr)
713 {
714 f->deg = j;
715 return;
716 }
717 // at this point, everything is 0!
718 dealloc_poly(f);
719 }
720}
static void increase_size_n(int newdeg, TowerPolynomial &f)
Definition dpoly.cpp:249
static TowerPolynomial copy(int level, const TowerPolynomial f)
Definition dpoly.cpp:483
void add_in_place(int level, TowerPolynomial &f, const TowerPolynomial g)
Definition dpoly.cpp:722
static void dealloc_poly(TowerPolynomial &f)
Definition dpoly.cpp:292

References add_in_place(), copy(), dealloc_poly(), and increase_size_n().

Referenced by add_in_place().