コード例 #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));
 }