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

◆ gauss_reduce_row()

bool F4GB::gauss_reduce_row ( int index,
ElementArray & gauss_row )
private

Definition at line 749 of file f4.cpp.

751{
752 // returns true if the row reduces to a "new" nonzero row
753 // returns false otherwise
754 row_elem &r = mat->rows[index];
755 if (r.len == 0) return false; // could happen once we include syzygies...
756 if (is_pivot_row(index)) return false;
757
758 int pivotcol = r.comps[0];
759 int pivotrow = mat->columns[pivotcol].head;
760
761 const ElementArray& rcoeffs = get_coeffs_array(r);
763 mVectorArithmetic->fillDenseArray(gauss_row, rcoeffs, Range(r.comps, r.comps + r.len));
764
765 int firstnonzero = -1;
766 int first = r.comps[0];
767 int last = r.comps[r.len - 1];
768 do
769 {
770 pivotrow = mat->columns[first].head;
771 if (pivotrow >= 0)
772 {
773 row_elem &pivot_rowelem = mat->rows[pivotrow];
774 auto& pivot_coeffs = get_coeffs_array(pivot_rowelem);
776 mVectorArithmetic->denseCancelFromSparse(gauss_row,
777 pivot_coeffs,
778 Range(pivot_rowelem.comps,
779 pivot_rowelem.comps + pivot_rowelem.len)
780 );
781 int last1 = pivot_rowelem.comps[pivot_rowelem.len - 1];
782 if (last1 > last) last = last1;
783 }
784 else if (firstnonzero == -1)
785 firstnonzero = first;
786 first = mVectorArithmetic->denseNextNonzero(gauss_row, first+1, last);
787 }
788 while (first <= last); // end do
789
790 if (not r.coeffs.isNull())
791 mVectorArithmetic->deallocateElementArray(r.coeffs);
792 //Mem->components.deallocate(r.comps);
793 delete [] r.comps;
794 r.comps = nullptr;
795 r.len = 0;
796 //Range<int> monomRange;
797 //mVectorArithmetic->denseToSparse(gauss_row, r.coeffs, monomRange, firstnonzero, last, mComponentSpace);
798 //mVectorArithmetic->denseToSparse(gauss_row, r.coeffs, r.comps, firstnonzero, last, Mem->components);
799 mVectorArithmetic->denseToSparse(gauss_row, r.coeffs, r.comps, firstnonzero, last);
800
801 // TODO set r.comps from monomRange. Question: who has allocated this space??
802 // Maybe for now it is just the following line:
803 r.len = mVectorArithmetic->size(r.coeffs);
804 //r.len = monomRange.size();
805 //r.comps = Mem->components.allocate(r.len);
806 //std::copy(monomRange.begin(), monomRange.end(), r.comps);
807 //mComponentSpace.freeTopArray(monomRange.begin(), monomRange.end());
808 //assert(r.len == mVectorArithmetic->size(r.coeffs));
809
810 // the above line leaves gauss_row zero, and also handles the case when
811 // r.len is 0 (TODO: check this!!)
812 // it also potentially frees the old r.coeffs and r.comps (TODO: ?? r.comps??)
813 return (r.len > 0);
814}
bool isNull() const
const ElementArray & get_coeffs_array(row_elem &r)
Definition f4.cpp:591
coefficient_matrix * mat
Definition f4.hpp:186
long n_pairs_computed
Definition f4.hpp:166
bool is_pivot_row(int index) const
Definition f4.cpp:741
long n_reduction_steps
Definition f4.hpp:167
const VectorArithmetic * mVectorArithmetic
Definition f4.hpp:156
int * comps
Definition f4-types.hpp:163
ElementArray coeffs
Definition f4-types.hpp:162

References row_elem::coeffs, row_elem::comps, get_coeffs_array(), is_pivot_row(), ElementArray::isNull(), row_elem::len, mat, mVectorArithmetic, n_pairs_computed, and n_reduction_steps.

Referenced by gauss_reduce().