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

◆ subtract_in_place_n()

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

Definition at line 762 of file dpoly.cpp.

763{
764 int i;
765 if (g == nullptr) return;
766 if (f == nullptr)
767 {
768 f = copy(level, g);
769 negate_in_place(level, f);
770 return;
771 }
772 int fdeg = f->deg;
773 int gdeg = g->deg;
774
775 increase_size_n(g->deg, f);
776 for (i = 0; i <= gdeg; i++)
777 subtract_in_place(level - 1, f->arr.polys[i], g->arr.polys[i]);
778 if (gdeg > fdeg)
779 f->deg = gdeg;
780 else if (gdeg == fdeg)
781 {
782 // need to change the degree
783 for (int j = fdeg; j >= 0; --j)
784 if (f->arr.polys[j] != nullptr)
785 {
786 f->deg = j;
787 return;
788 }
789 // at this point, everything is 0!
790 dealloc_poly(f);
791 }
792}
void subtract_in_place(int level, TowerPolynomial &f, const TowerPolynomial g)
Definition dpoly.cpp:794
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
static void dealloc_poly(TowerPolynomial &f)
Definition dpoly.cpp:292
void negate_in_place(int level, TowerPolynomial &f)
Definition dpoly.cpp:604

References copy(), dealloc_poly(), increase_size_n(), negate_in_place(), and subtract_in_place().

Referenced by subtract_in_place().