예제 #1
0
        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));
        }
예제 #2
0
 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);
 }
예제 #3
0
        public virtual RrFunction Mult(RrFunction other)
        {
            var step = other as StepFunction;

            if (step != null)
            {
                return(step.Mult(this));
            }

            return(RrFunctions.Product(this, other));
        }
예제 #4
0
        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))));
        }
예제 #5
0
        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);
        }
예제 #6
0
        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()));
        }
예제 #7
0
        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));
        }
예제 #8
0
        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));
        }
예제 #9
0
        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));
        }
예제 #10
0
        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));
        }
예제 #11
0
        public override RrFunction Mult(RrFunction other)
        {
            var resultWeight = weight.Mult(other);

            return(new WeightedStepFunction(resultWeight, abscissae, values, leftValue));
        }
예제 #12
0
 public virtual RrFunction Add(RrFunction other)
 {
     return(RrFunctions.Sum(this, other));
 }
예제 #13
0
 public static RrFunction Product(RrFunction f, RrFunction g)
 {
     return(new ProductRrFunction(1.0, f, g));
 }