private static float oppFloat(ref List <float> list, char opp) { Operation opperator; switch (opp) { case '+': opperator = new Operation((X, Y) => { float temps = X + Y; if (Math.Abs(temps) < Math.Abs(X / Math.Pow(10, 7)) && Math.Abs(temps) < Math.Abs(Y / Math.Pow(10, 7))) { temps = 0; } return(temps); }); break; case '*': opperator = new Operation((X, Y) => X + Y); break; default: throw new Exception("Operator " + opp + " Not Implemented"); } float result = 0; float[] listSorted = OperationFile <T> .sortedByAbsolutes(list); foreach (float element in listSorted) { result = opperator(result, element); } return(result); }
public static OperationFile <float> newOperationFileSum() { OperationFile <float> operationFile = new OperationFile <float>(); operationFile.changeOppFunction((ref List <float> aOperationFile) => OperationFile <float> .oppFloat(ref aOperationFile, '+')); return(operationFile); }
public float calcY(float X) { OperationFile <float> operationFile = OperationFile <float> .newOperationFileSum(); for (int i = 0; i < this.listFactors.Length; i++) { operationFile.Add(this.listFactors[i] * (float)Math.Pow(X, i)); } return(operationFile.doOpp()); }