public Vec Clone() { var array = VariablesList.ToArray(); var result = new Vec(array); result.Sign = Sign; return(result); }
public Vec ReplaceVarWithVec(Vec vec, int basicVarNumber) { Vec result = new Vec(VariablesList.ToArray()); result.Sign = Sign; result = result.AddFunc(vec.Mul(result[basicVarNumber])); result[basicVarNumber] = 0; return(result); }
public Vec AddFunc(Vec vec) { Vec result = new Vec(VariablesList.ToArray()); result.Sign = Sign; for (int i = 0; i <= VariablesCount; i++) { result[i] += vec[i]; } return(result); }
public Vec Mul(double ratio) { Vec result = new Vec(VariablesList.ToArray()); result.Sign = Sign; for (int i = 0; i <= VariablesCount; i++) { result[i] *= ratio; } return(result); }
public Vec GetTagretFunc(IList <Vec> vecList, IList <int> basicVarNumbers) { if (basicVarNumbers == null) { return(null); } Vec target = new Vec(VariablesList.ToArray()); target.Sign = Sign; for (int i = 0; i < vecList.Count; i++) { var limit = vecList[i].Solve(basicVarNumbers[i]); target = target.ReplaceVarWithVec(limit, basicVarNumbers[i]); } return(target); }
public Vec Solve(int varNum) { double ratio = 1 / this[varNum]; Vec result = new Vec(VariablesList.ToArray()); result.Sign = Sign; for (int i = 0; i <= VariablesCount; i++) { if (i == varNum) { result[i] = 0; continue; } result[i] *= -ratio; } return(result); }