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

◆ tail_reduce()

void F4GB::tail_reduce ( )
private

Definition at line 817 of file f4.cpp.

818{
819 int nrows = INTSIZE(mat->rows);
820 int ncols = INTSIZE(mat->columns);
821
822 ElementArray gauss_row { mVectorArithmetic->allocateElementArray(ncols) };
823 for (int i = nrows - 1; i >= 0; i--)
824 {
825 row_elem &r = mat->rows[i];
826 if (r.len <= 1 || r.coeffs.isNull())
827 continue; // row reduced to zero, ignore it.
828 // At this point, we should have an element to reduce
829 bool anychange = false;
830 mVectorArithmetic->fillDenseArray(gauss_row, r.coeffs, Range(r.comps,
831 r.comps + r.len));
832 int firstnonzero = r.comps[0];
833 int first = (r.len == 1 ? ncols : r.comps[1]);
834 int last = r.comps[r.len - 1];
835 while (first <= last)
836 {
837 int pivotrow = mat->columns[first].head;
838 if (pivotrow >= 0)
839 {
840 anychange = true;
841 row_elem &pivot_rowelem =
842 mat->rows[pivotrow]; // pivot_rowelems.coeffs is set at this
843 mVectorArithmetic->denseCancelFromSparse(gauss_row,
844 pivot_rowelem.coeffs,
845 Range(pivot_rowelem.comps,
846 pivot_rowelem.comps + pivot_rowelem.len));
847 int last1 = pivot_rowelem.comps[pivot_rowelem.len - 1];
848 if (last1 > last) last = last1;
849 }
850 else if (firstnonzero == ncols)
851 firstnonzero = first;
852 first = mVectorArithmetic->denseNextNonzero(gauss_row, first+1, last);
853 };
854 if (anychange)
855 {
856 //Mem->components.deallocate(r.comps);
857 delete [] r.comps;
858 mVectorArithmetic->deallocateElementArray(r.coeffs);
859 r.len = 0;
860 //Range<int> monomRange;
861 //mVectorArithmetic->denseToSparse(gauss_row,
862 // r.coeffs,
863 // monomRange,
864 // firstnonzero, last,
865 // mComponentSpace);
866 // mVectorArithmetic->denseToSparse(gauss_row,
867 // r.coeffs,
868 // r.comps,
869 // firstnonzero, last,
870 // Mem->components);
871 mVectorArithmetic->denseToSparse(gauss_row,
872 r.coeffs,
873 r.comps,
874 firstnonzero, last);
875 r.len = mVectorArithmetic->size(r.coeffs);
876 //r.len = monomRange.size();
877 //r.comps = Mem->components.allocate(r.len);
878 //std::copy(monomRange.begin(), monomRange.end(), r.comps);
879 //mComponentSpace.freeTopArray(monomRange.begin(), monomRange.end());
880 assert(r.len == mVectorArithmetic->size(r.coeffs));
881 }
882 else
883 {
884 mVectorArithmetic->setZeroInRange(gauss_row, firstnonzero, last);
885 }
886 if (r.len > 0)
887 {
888 mVectorArithmetic->makeMonic(r.coeffs);
889 }
890 }
891
892 mVectorArithmetic->deallocateElementArray(gauss_row);
893}
bool isNull() const
coefficient_matrix * mat
Definition f4.hpp:186
const VectorArithmetic * mVectorArithmetic
Definition f4.hpp:156
int * comps
Definition f4-types.hpp:163
ElementArray coeffs
Definition f4-types.hpp:162
#define INTSIZE(a)
Definition style.hpp:37

References row_elem::coeffs, row_elem::comps, INTSIZE, ElementArray::isNull(), row_elem::len, mat, and mVectorArithmetic.

Referenced by gauss_reduce().