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

◆ subtract_in_place()

void M2::ARingTower::subtract_in_place ( int level,
ARingPolynomial & f,
const ARingPolynomial g ) const
private

Definition at line 374 of file aring-tower.cpp.

375{
376 if (g == nullptr) return;
377 if (f == nullptr)
378 {
379 f = copy(level, g);
380 negate_in_place(level, f);
381 return;
382 }
383 int fdeg = f->deg;
384 int gdeg = g->deg;
385
386 increase_capacity(g->deg, f);
387 if (level == 0)
388 for (int i = 0; i <= gdeg; i++)
389 mBaseRing.subtract(f->coeffs[i], f->coeffs[i], g->coeffs[i]);
390 else
391 for (int i = 0; i <= gdeg; i++)
392 subtract_in_place(level - 1, f->polys[i], g->polys[i]);
393
394 if (gdeg > fdeg)
395 f->deg = gdeg;
396 else if (gdeg == fdeg)
397 reset_degree(f);
398}
void copy(elem &result, elem a) const
void reset_degree(ARingPolynomial &f) const
void increase_capacity(int newdeg, ARingPolynomial &f) const
void negate_in_place(int level, ARingPolynomial &f) const
const ARingZZpFFPACK & mBaseRing
void subtract_in_place(int level, ARingPolynomial &f, const ARingPolynomial g) const

References M2::ARingPolynomialStruct::coeffs, copy(), M2::ARingPolynomialStruct::deg, increase_capacity(), mBaseRing, negate_in_place(), M2::ARingPolynomialStruct::polys, reset_degree(), and subtract_in_place().

Referenced by subtract(), and subtract_in_place().