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

◆ division_in_place_monic()

TowerPolynomial DPoly::division_in_place_monic ( int level,
TowerPolynomial & f,
const TowerPolynomial g )

Definition at line 966 of file dpoly.cpp.

967{
968 // ASSUMPTION: g is MONIC, non-zero
969 if (f == nullptr) return nullptr;
970 if (f->deg < g->deg)
971 {
972 return nullptr;
973 }
974 int shift = f->deg - g->deg;
975 TowerPolynomial quot = alloc_poly_n(shift);
976
977 if (level == 0)
978 {
979 long *p = f->arr.ints;
980 long *q = g->arr.ints;
981 for (int d = f->deg; shift >= 0; d--, shift--)
982 {
983 long a = p[d];
984 if (a != 0)
985 {
986 quot->arr.ints[shift] = a;
987 ZZp_NEGATE(charac, a);
988 for (int j = 0; j <= g->deg; j++)
989 ZZp_APXY(charac, p[shift + j], a, q[j]);
990 }
991 }
993 }
994 else
995 {
996 TowerPolynomial *p = f->arr.polys;
997 TowerPolynomial *q = g->arr.polys;
998 for (int d = f->deg; shift >= 0; d--, shift--)
999 {
1000 TowerPolynomial a = p[d];
1001 if (a != nullptr)
1002 {
1003 quot->arr.polys[shift] = copy(level - 1, a);
1004 for (int j = 0; j <= g->deg; j++)
1005 {
1006 TowerPolynomial b = mult(level - 1, a, q[j], true);
1007 subtract_in_place(level - 1, p[j + shift], b);
1008 }
1009 }
1010 }
1011 reset_degree_n(level, f);
1012 }
1013 return quot;
1014}
void subtract_in_place(int level, TowerPolynomial &f, const TowerPolynomial g)
Definition dpoly.cpp:794
static TowerPolynomial alloc_poly_n(int deg, TowerPolynomial *elems=nullptr)
Definition dpoly.cpp:265
static TowerPolynomial copy(int level, const TowerPolynomial f)
Definition dpoly.cpp:483
void reset_degree_n(int level, TowerPolynomial &f)
Definition dpoly.cpp:635
long charac
Definition dpoly.hpp:115
TowerPolynomial mult(int level, const TowerPolynomial f, const TowerPolynomial g, bool reduce_by_extension)
Definition dpoly.cpp:846
void reset_degree_0(TowerPolynomial &f)
Definition dpoly.cpp:623
void ZZp_APXY(long charac, long &a, long b, long c)
Definition dpoly.cpp:49
void ZZp_NEGATE(long charac, long &a)
Definition dpoly.cpp:48
int p

References alloc_poly_n(), charac, copy(), mult(), p, reset_degree_0(), reset_degree_n(), subtract_in_place(), ZZp_APXY(), and ZZp_NEGATE().

Referenced by gcd_coefficients().