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

◆ gaussReduceRow()

void F4Res::gaussReduceRow ( int index,
ElementArray & dense,
bool onlyConstantMaps,
const std::vector< bool > & track )
private

Definition at line 465 of file res-f4.cpp.

469{
470 int i = index;
471
472#ifdef DEBUG_GAUSS
473 std::cout << "reducing row " << i << std::endl;
474#endif
475
476 // Reduce spair #i
477 // fill in dense row with this element.
478
479 ResPolynomialConstructor result(mRing);
480
481 Row& r = mSPairs[i]; // row to be reduced.
482 long comp = mSPairComponents[i];
483 result.appendMonicTerm(mFrame.level(mThisLevel)[comp].mMonom);
484
485 auto& syz = mFrame.level(mThisLevel)[comp].mSyzygy; // this is the element we will fill out
486
487 // Note: in the polynomial ring case, the row r is non-zero.
488 // BUT: for skew commuting variables, it can happen that r is zero
489 // (e.g. a.(acd<0>) = 0). In this case we have nothing to reduce.
490 if (!r.mComponents.empty())
491 {
492 ComponentIndex firstcol = r.mComponents[0];
493 ComponentIndex lastcol = static_cast<ComponentIndex>(mColumns.size() - 1); // maybe: r.mComponents[r.mComponents.size()-1];
494
495#ifdef DEBUG_GAUSS
496 std::cout << "about to fill from sparse " << i << std::endl;
497#endif
498
499 mRing.vectorArithmetic().fillDenseArray(gauss_row,
500 r.mCoeffs,
501 Range(&r.mComponents[0],
502 &r.mComponents[0] + static_cast<ComponentIndex>(r.mComponents.size())));
503
504 while (firstcol <= lastcol)
505 {
506#ifdef DEBUG_GAUSS
507 std::cout << "about to reduce with col " << firstcol << std::endl;
508 std::cout << "gauss_row: "
509 << (gauss_row.isNull() ? "null" : "not-null")
510 << std::endl;
511 std::cout << "mReducers[" << firstcol << "]: "
512 << (mReducers[firstcol].mCoeffs.isNull() ? "null"
513 : "not-null")
514 << std::endl;
515 std::cout << "result: " << (result.coefficientInserter().isNull()
516 ? "null"
517 : "not-null")
518 << std::endl;
519 std::cout << " dense: ";
520 mRing.vectorArithmetic().displayElementArray(std::cout, gauss_row)
521 << std::endl;
522 mRing.vectorArithmetic().displayElementArray(std::cout,
523 mReducers[firstcol].mCoeffs);
524 std::cout << std::endl;
525 mRing.vectorArithmetic().displayElementArray(std::cout,
526 result.coefficientInserter());
527 std::cout << std::endl;
528#endif
529
530 if (onlyConstantMaps and not track[firstcol])
531 {
532 mRing.vectorArithmetic().denseCancelFromSparse(gauss_row,
533 mReducers[firstcol].mCoeffs,
534 Range(mReducers[firstcol].mComponents.data(),
535 mReducers[firstcol].mComponents.data() +
536 mRing.vectorArithmetic().size(mReducers[firstcol].mCoeffs)));
537 }
538 else
539 {
540 mRing.vectorArithmetic().denseCancelFromSparse(gauss_row,
541 mReducers[firstcol].mCoeffs,
542 Range(mReducers[firstcol].mComponents.data(),
543 mReducers[firstcol].mComponents.data() +
544 mRing.vectorArithmetic().size(mReducers[firstcol].mCoeffs)),
545 result.coefficientInserter());
546
547#ifdef DEBUG_GAUSS
548 std::cout << " done with sparseCancel" << std::endl;
549 mRing.vectorArithmetic().displayElementArray(std::cout, gauss_row)
550 << std::endl;
551 mRing.vectorArithmetic().displayElementArray(std::cout,
552 mReducers[firstcol].mCoeffs)
553 << std::endl;
554 mRing.vectorArithmetic().displayElementArray(std::cout,
555 result.coefficientInserter())
556 << std::endl;
557 std::cout << " about to push back term" << std::endl;
558#endif
559
560 result.pushBackTerm(mReducers[firstcol].mLeadTerm);
561
562#ifdef DEBUG_GAUSS
563 std::cout << "done with col " << firstcol << std::endl;
564#endif
565 }
566 firstcol = mRing.vectorArithmetic().denseNextNonzero(gauss_row, firstcol + 1, lastcol);
567 }
568 }
569
570#ifdef DEBUG_GAUSS
571 std::cout << "about to set syz" << std::endl;
572#endif
573 result.setPoly(syz);
574#ifdef DEBUG_GAUSS
575 std::cout << "just set syz" << std::endl;
576#endif
577}
int mThisLevel
Definition res-f4.hpp:164
std::vector< res_packed_monomial > mColumns
Definition res-f4.hpp:184
std::vector< Row > mReducers
Definition res-f4.hpp:179
SchreyerFrame & mFrame
Definition res-f4.hpp:159
const ResPolyRing & mRing
Definition res-f4.hpp:161
std::vector< long > mSPairComponents
Definition res-f4.hpp:182
std::vector< Row > mSPairs
Definition res-f4.hpp:181
VALGRIND_MAKE_MEM_DEFINED & result(result)
int ComponentIndex
One row of the Macaulay matrix built by F4Res::construct.
Definition res-f4.hpp:119

References ElementArray::isNull(), F4Res::Row::mCoeffs, mColumns, F4Res::Row::mComponents, mFrame, mReducers, mRing, mSPairComponents, mSPairs, mThisLevel, and result().

Referenced by gaussReduce().