public static RrFunction Add(LinearCombinationRrFunction leftLc, LinearCombinationRrFunction rightLc) { IList <double> ws = new List <double>(); IList <RrFunction> fs = new List <RrFunction>(); AddTerms(leftLc.weights, leftLc.functions, ref ws, ref fs); AddTerms(rightLc.weights, rightLc.functions, ref ws, ref fs); return(new LinearCombinationRrFunction(ws.ToArray(), fs.ToArray())); }
public static RrFunction Mult(LinearCombinationRrFunction lc, ConstantRrFunction cst) { if (DoubleUtils.MachineEquality(1.0, cst.Value)) { return(lc); } if (DoubleUtils.EqualZero(cst.Value)) { return(RrFunctions.Zero); } return(LinearCombinationRrFunction.Create(lc.Weights.Map(w => w * cst.Value), lc.Functions)); }
public static RrFunction LinearCombination(double[] weights, RrFunction[] funcs) { return(LinearCombinationRrFunction.Create(weights, funcs)); }
public static RrFunction Sum(params RrFunction[] functions) { return(LinearCombinationRrFunction.Create(functions.Select(f => 1.0).ToArray(), functions)); }