Ejemplo n.º 1
0
        /// <summary>Constructs an uncertain range (centre/width).</summary>
        /// <remarks>Constructs an uncertain range (centre/width).</remarks>
        /// <TBD></TBD>
        /// <param name="centre">centre bound</param>
        /// <param name="width">size of width</param>
        /// <returns>the constructed uncertain range</returns>
        public static UncertainRange <T> CreateCentreWidth <T>(T centre, Diff <T> width)
        {
            T half = GenericMath.Half(width.Value);
            T low  = GenericMath.Diff(half, centre).Value;
            T high = GenericMath.Add(low, width);

            return(new UncertainRange <T>(low, high, centre, width, Representation.CENTRE_WIDTH));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructs an Interval using the supplied parameters.
        /// </summary>
        ///
        /// <param name="TS"> the   type of the interval</param>
        /// <param name="centre_0">the centre bound</param>
        /// <param name="width_1">the width as a Diff object</param>
        /// <returns>the constructed interval</returns>
        public static Interval <TS> CreateCentreWidth <TS>(TS centre_0, Diff <TS> width_1)
        {
            Ca.Infoway.Messagebuilder.Validate.NotNull(centre_0);
            Ca.Infoway.Messagebuilder.Validate.NotNull(width_1);
            TS half   = GenericMath.Half(width_1.Value);
            TS low_2  = GenericMath.Diff <TS>(half, centre_0).Value;
            TS high_3 = GenericMath.Add(low_2, width_1);

            return(new Interval <TS>(low_2, high_3, centre_0, width_1,
                                     Representation.CENTRE_WIDTH));
        }
Ejemplo n.º 3
0
        /// <summary>Constructs an Interval using the supplied parameters.</summary>
        /// <remarks>Constructs an Interval using the supplied parameters.</remarks>
        /// <TBD></TBD>
        /// <param name="centre">the centre bound</param>
        /// <param name="width">the width as a Diff object</param>
        /// <param name="centreNullFlavor"></param>
        /// <returns>the constructed interval</returns>
        public static Interval <T> CreateCentreWidth <T>(T centre, Diff <T> width, NullFlavor centreNullFlavor)
        {
            bool     widthNull    = (width == (Diff <T>)null);
            T        half         = GenericMath.Half(widthNull ? default(T) : width.Value);
            Diff <T> tempDiff     = GenericMath.Diff(half, centre);
            bool     tempDiffNull = (tempDiff == (Diff <T>)null);
            T        low          = tempDiffNull ? default(T) : tempDiff.Value;
            T        high         = GenericMath.Add(low, width);

            return(new Interval <T>(low, high, centre, width, Representation.CENTRE_WIDTH, null, null, centreNullFlavor));
        }