void F4Res::construct(int lev, int degree) { decltype(timer()) timeA, timeB; resetMatrix(lev, degree); timeA = timer(); makeMatrix(); timeB = timer(); mFrame.timeMakeMatrix += seconds(timeB - timeA); if (M2_gbTrace >= 2) mHashTable.dump(); if (M2_gbTrace >= 2) std::cout << " make matrix time: " << seconds(timeB - timeA) << " sec" << std::endl; #if 0 std::cout << "-- rows --" << std::endl; debugOutputReducers(); std::cout << "-- columns --" << std::endl; debugOutputColumns(); std :: cout << "-- reducer matrix --" << std::endl; if (true or lev <= 2) debugOutputMatrix(mReducers); else debugOutputMatrixSparse(mReducers); std :: cout << "-- reducer matrix --" << std::endl; debugOutputMatrix(mReducers); debugOutputMatrixSparse(mReducers); std :: cout << "-- spair matrix --" << std::endl; debugOutputMatrix(mSPairs); debugOutputMatrixSparse(mSPairs); #endif if (M2_gbTrace >= 2) std::cout << " (degree,level)=(" << (mThisDegree - mThisLevel) << "," << mThisLevel << ") #spairs=" << mSPairs.size() << " reducer= " << mReducers.size() << " x " << mReducers.size() << std::endl; if (M2_gbTrace >= 2) std::cout << " gauss reduce matrix" << std::endl; timeA = timer(); gaussReduce(); timeB = timer(); mFrame.timeGaussMatrix += seconds(timeB - timeA); if (M2_gbTrace >= 2) std::cout << " time: " << seconds(timeB - timeA) << " sec" << std::endl; // mFrame.show(-1); timeA = timer(); clearMatrix(); timeB = timer(); mFrame.timeClearMatrix += seconds(timeB - timeA); }
void F4Res::makeMatrix() { // std::cout << "entering makeMatrix()" << std::endl; auto& myframe = mFrame.level(mThisLevel); long r = 0; long comp = 0; for (auto it = myframe.begin(); it != myframe.end(); ++it) { if (it->mDegree == mThisDegree) { mSPairs.push_back(Row()); mSPairComponents.push_back(comp); Row& row = mSPairs[r]; r++; row.mLeadTerm = it->mMonom; loadRow(row); if (M2_gbTrace >= 4) if (r % 5000 == 0) std::cout << "makeMatrix sp: " << r << " #rows = " << mColumns.size() << std::endl; } comp++; } // Now we process all monomials in the columns array while (mNextReducerToProcess < mColumns.size()) { // Warning: mReducers is being appended to during 'loadRow', and // since we act on the Row directly, it might get moved on us! // (actually, it did get moved, which prompted this fix) Row thisrow; std::swap(mReducers[mNextReducerToProcess], thisrow); loadRow(thisrow); std::swap(mReducers[mNextReducerToProcess], thisrow); mNextReducerToProcess++; if (M2_gbTrace >= 4) if (mNextReducerToProcess % 5000 == 0) std::cout << "makeMatrix red: " << mNextReducerToProcess << " #rows = " << mReducers.size() << std::endl; } reorderColumns(); #if 0 debugOutputReducers(); debugOutputColumns(); std :: cout << "-- reducer matrix --" << std::endl; debugOutputMatrix(mReducers); debugOutputMatrixSparse(mReducers); std :: cout << "-- spair matrix --" << std::endl; debugOutputMatrix(mSPairs); debugOutputMatrixSparse(mSPairs); #endif }
void F4Res::debugOutputSPairMatrix() { debugOutputMatrix(mSPairs); }
void F4Res::debugOutputReducerMatrix() { debugOutputMatrix(mReducers); }