/// <summary> /// Perform the row operations of the simplex algorithm with the selected pivot column and row. /// </summary> /// <param name="pivotCol">the pivot column</param> /// <param name="pivotRow">the pivot row</param> public void PerformRowOperations(int pivotCol, int pivotRow) { // set the pivot element to 1 T pivotVal = GetEntry(pivotRow, pivotCol); DivideRow(pivotRow, pivotVal); // set the rest of the pivot column to 0 for (int i = 0; i < Height; i++) { if (i != pivotRow) { T multiplier = GetEntry(i, pivotCol); if (!Policy.IsZero(multiplier)) { SubtractRow(i, pivotRow, multiplier); } } } // update the basic variable mappings int previousBasicVariable = GetBasicVariable(pivotRow); basicVariables[previousBasicVariable] = -1; basicVariables[pivotCol] = pivotRow; basicRows[pivotRow] = pivotCol; }
/// <summary> /// True if numerator is zero /// </summary> /// <returns></returns> public bool IsZero() { return(Policy.IsZero(Numerator)); }