public FunctionExtension clone() { SignalFunction sf = new SignalFunction(); foreach (double v in signals) { sf.addSignal(v); } sf.index = this.index; return(sf); }
static void Main(string[] args) { SignalFunction sf = new SignalFunction(); Function v = new Function("v", sf); Expression e = new Expression("v(0) + v(-1) + v(-2)", v); sf.addSignal(1); sf.addSignal(2); sf.addSignal(3); mXparser.consolePrintln(e.calculate()); sf.addSignal(4); mXparser.consolePrintln(e.calculate()); sf.addSignal(5); mXparser.consolePrintln(e.calculate()); /* now last n signals average */ Function f = new Function("f(n) = sum(i, 0, n-1, v(-i) ) / n", v); mXparser.consolePrintln(f.calculate(1)); mXparser.consolePrintln(f.calculate(2)); mXparser.consolePrintln(f.calculate(3)); mXparser.consolePrintln(f.calculate(4)); mXparser.consolePrintln(f.calculate(5)); }