public void ZeroCol(LinearEqualitiesEnvironment <Variable, Expression> env, int col, ref LinearEquations <Variable, Expression> equations) { if (sharinglist.Count == 1) { ZeroCol(matrix, col); equations = this; } else { var result = this.Unshare(env, ref equations); ZeroCol(result, col); equations = new LinearEquations <Variable, Expression>(env, result); } }
/// <summary> /// If <code>who</code>is the only one sharing this set of equations, then we simply return the set of equations /// Otherwise, we create a copy of the set of equations, we remove <code>who</code> from the sharing list of those equations, and /// we update equations /// </summary> /// <param name="equations">The new set of linear equations</param> public SparseRationalArray[] Unshare(LinearEqualitiesEnvironment <Variable, Expression> who, ref LinearEquations <Variable, Expression> equations) { Contract.Ensures(Contract.Result <SparseRationalArray[]>() != null); Contract.Ensures(Contract.Result <SparseRationalArray[]>().Length == matrix.Length); lock (sharinglist) { if (sharinglist.Count > 1) { sharinglist.Remove(who); var result = this.GetClonedEquations(); equations = new LinearEquations <Variable, Expression>(who, result); return(result); } else { // Nothing to do, we just return the previous ones equations = this; return(matrix); } } }