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

◆ subtract_in_place_0()

void DPoly::subtract_in_place_0 ( TowerPolynomial & f,
const TowerPolynomial g )
private

Definition at line 730 of file dpoly.cpp.

731{
732 int i;
733 if (g == nullptr) return;
734 if (f == nullptr)
735 {
736 f = copy(0, g);
737 negate_in_place(0, f);
738 return;
739 }
740 int fdeg = f->deg;
741 int gdeg = g->deg;
742
743 increase_size_0(g->deg, f);
744 for (i = 0; i <= gdeg; i++)
745 ZZp_SUBTRACT_TO(charac, f->arr.ints[i], g->arr.ints[i]);
746 if (gdeg > fdeg)
747 f->deg = gdeg;
748 else if (gdeg == fdeg)
749 {
750 // need to change the degree
751 for (int j = fdeg; j >= 0; --j)
752 if (f->arr.ints[j] != 0)
753 {
754 f->deg = j;
755 return;
756 }
757 // at this point, everything is 0!
758 dealloc_poly(f);
759 }
760}
static TowerPolynomial copy(int level, const TowerPolynomial f)
Definition dpoly.cpp:483
long charac
Definition dpoly.hpp:115
static void increase_size_0(int newdeg, TowerPolynomial &f)
Definition dpoly.cpp:233
static void dealloc_poly(TowerPolynomial &f)
Definition dpoly.cpp:292
void negate_in_place(int level, TowerPolynomial &f)
Definition dpoly.cpp:604
void ZZp_SUBTRACT_TO(long charac, long &a, long b)
Definition dpoly.cpp:58

References charac, copy(), dealloc_poly(), increase_size_0(), negate_in_place(), and ZZp_SUBTRACT_TO().

Referenced by subtract_in_place().