public override RrFunction Add(RrFunction other) { var cst = other as ConstantRrFunction; if (cst != null) { return(RrFunctions.Constant(Value + cst.Value)); } var step = other as StepFunction; if (step != null) { return(StepFunction.Add(step, this)); } var spline = other as SplineInterpoler; if (spline != null) { return(SplineInterpoler.Add(spline, this)); } return(base.Add(other)); }
public WeightedStepFunction(RrFunction weight, double[] abscissae, double[] values, double leftValue) { this.weight = weight; this.abscissae = abscissae; this.values = values; this.leftValue = leftValue; stepEval = new StepFunction <double>(abscissae, values, leftValue); }
public virtual RrFunction Mult(RrFunction other) { var step = other as StepFunction; if (step != null) { return(step.Mult(this)); } return(RrFunctions.Product(this, other)); }
public override RrFunction Mult(RrFunction other) { var cst = other as ConstantRrFunction; if (cst != null) { return(ProductRrFunctions.Mult(this, cst)); } return(Create(weights, functions.Map(f => f.Mult(other)))); }
private static void AddTerm(ref IList <double> weights, ref IList <RrFunction> functions, double weight, RrFunction term) { var termIndex = functions.IndexOf(term); if (termIndex > 0) { weights[termIndex] += weight; return; } weights.Add(weight); functions.Add(term); }
public override RrFunction Add(RrFunction other) { var lc = other as LinearCombinationRrFunction; if (lc != null) { return(Add(this, lc)); } IList <double> ws = new List <double>(weights); IList <RrFunction> fs = new List <RrFunction>(functions); AddTerm(ref ws, ref fs, 1.0, other); return(new LinearCombinationRrFunction(ws.ToArray(), fs.ToArray())); }
public override RrFunction Add(RrFunction other) { var cst = other as ConstantRrFunction; if (cst != null) { return(Add(this, cst)); } var step = other as StepFunction; if (step != null) { return(Add(this, step)); } return(base.Add(other)); }
public override RrFunction Mult(RrFunction other) { var cst = other as ConstantRrFunction; if (cst != null) { return(Mult(this, cst)); } var step = other as StepFunction; if (step != null) { return(Mult(this, step)); } return(new WeightedStepFunction(other, abscissae, values, leftValue)); }
public override RrFunction Mult(RrFunction other) { var cst = other as ConstantRrFunction; if (cst != null) { return(ProductRrFunctions.Mult(this, cst)); } var exp = other as ExpRrFunction; if (exp != null) { return(ProductRrFunctions.Mult(this, exp)); } return(base.Mult(other)); }
public override RrFunction Mult(RrFunction other) { var cst = other as ConstantRrFunction; if (cst != null) { return(ProductRrFunctions.Mult(this, cst)); } var exp = other as ExpRrFunction; if (exp != null) { return(ProductRrFunctions.Mult(exp, this)); } var step = other as StepFunction; if (step != null) { return(StepFunction.Mult(step, this)); } var spline = other as SplineInterpoler; if (spline != null) { return(SplineInterpoler.Mult(spline, this)); } var lc = other as LinearCombinationRrFunction; if (lc != null) { return(ProductRrFunctions.Mult(lc, this)); } return(base.Mult(other)); }
public override RrFunction Mult(RrFunction other) { var resultWeight = weight.Mult(other); return(new WeightedStepFunction(resultWeight, abscissae, values, leftValue)); }
public virtual RrFunction Add(RrFunction other) { return(RrFunctions.Sum(this, other)); }
public static RrFunction Product(RrFunction f, RrFunction g) { return(new ProductRrFunction(1.0, f, g)); }