private static object Calculate(string expr) { var testCell = new MathCell(expr); testCell.EvaluateFormula(); return(testCell.Value); }
public void initialize(Range mathCellSizeRange, int testLength) { testConfig = new TestConfiguration(testLength); testConfig.initializePredictionPoints(); dataFunction = RGen.gen.newRandMathCell(mathCellSizeRange, testConfig.argLength); }
//todo: to get the best possible scaler, you must also consider the negative reflected // line. How can this be dealt with? public void scaleFromLastPredictions(double[] data) { int predictionOffset = data.Length - lastPredictions.Length; double avgDifference = 0; foreach (double p in lastPredictions) { avgDifference += data[predictionOffset] - p; predictionOffset++; } avgDifference /= lastPredictions.Length; DoubleCell scaler = new DoubleCell(avgDifference); ExpressionCell scaledFunction = new ExpressionCell(OpEnum.add, new MathCell[2] {scaler, dataFunction} ); dataFunction = scaledFunction; }
public ExpressionCell(OpEnum op, MathCell[] operationArgs) { this.op = op; this.operationArgs = operationArgs; checkOperationArgs(); }
public void replaceArg(int i, MathCell newCell) { if (i > operationArgs.Length) { throw new Exception("Invalid index " + i.ToString() + " in replacing an argument in the " + op.ToString() + " operation."); } if (newCell == null) { throw new Exception("Cannot have a null argument."); } operationArgs[i] = newCell; }