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));
        }
Beispiel #2
0
        public override RrFunction Integral(double basePoint)
        {
            var zeroBaseIntegrals = Enumerable.Range(0, abscissae.Length)
                                    .Map(i => i == 0 ? 0.0 : values[i - 1] * (abscissae[i] - abscissae[i - 1]))
                                    .Scan(0.0, (sum, current) => sum + current);
            var zeroBasedIntegral = RrFunctions.LinearInterpolation(abscissae, zeroBaseIntegrals,
                                                                    leftValue, values[values.Length - 1]);

            return(zeroBasedIntegral - zeroBasedIntegral.Eval(basePoint));
        }
Beispiel #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));
        }
        public override RrFunction Integral(double basePoint)
        {
            if (DoubleUtils.EqualZero(slope))
            {
                return(RrFunctions.Constant(weight).Integral(basePoint));
            }

            var zeroBaseIntegral = Create(weight / slope, slope);

            return(zeroBaseIntegral - zeroBaseIntegral.Eval(basePoint));
        }
        public static RrFunction Create(double weight, double slope)
        {
            if (DoubleUtils.EqualZero(weight))
            {
                return(RrFunctions.Zero);
            }

            if (DoubleUtils.EqualZero(slope))
            {
                return(RrFunctions.Constant(weight));
            }

            return(new ExpRrFunction(weight, slope));
        }
Beispiel #6
0
 public virtual RrFunction Add(RrFunction other)
 {
     return(RrFunctions.Sum(this, other));
 }
 public override RrFunction Inverse()
 {
     return(RrFunctions.Constant(1.0 / Value));
 }
 public override RrFunction Integral(double basePoint)
 {
     return(RrFunctions.LinearInterpolation(new[] { basePoint }, new[] { 0.0 }, Value, Value));
 }
 public static RrFunction Mult(ConstantRrFunction left, ConstantRrFunction right)
 {
     return(RrFunctions.Constant(left.Value * right.Value));
 }