Beispiel #1
0
 /// <summary>
 /// Constructs an Interval using the supplied parameters.
 /// </summary>
 ///
 /// <param name="TS"> the   type of the interval</param>
 /// <param name="low_0">the low bound</param>
 /// <param name="high_1">the high bound</param>
 /// <returns>the constructed interval</returns>
 public static Interval <TS> CreateLowHigh <TS>(TS low_0, TS high_1)
 {
     Ca.Infoway.Messagebuilder.Validate.NotNull(low_0);
     Ca.Infoway.Messagebuilder.Validate.NotNull(high_1);
     return(new Interval <TS>(low_0, high_1, GenericMath.Average(low_0, high_1),
                              GenericMath.Diff <TS>(low_0, high_1), Representation.LOW_HIGH));
 }
Beispiel #2
0
        /// <summary>Constructs an uncertain range (centre/high).</summary>
        /// <remarks>Constructs an uncertain range (centre/high).</remarks>
        /// <TBD></TBD>
        /// <param name="center">center bound</param>
        /// <param name="high">higher bound</param>
        /// <returns>the constructed uncertain range</returns>
        public static UncertainRange <T> CreateCentreHigh <T>(T center, T high)
        {
            T half = GenericMath.Diff(center, high).Value;
            T low  = GenericMath.Diff(half, center).Value;

            return(new UncertainRange <T>(low, high, center, GenericMath.Diff(low, high), Representation.CENTRE_HIGH));
        }
Beispiel #3
0
        /// <summary>Constructs an Interval using the supplied parameters.</summary>
        /// <remarks>Constructs an Interval using the supplied parameters.</remarks>
        /// <TBD></TBD>
        /// <param name="low">the low bound</param>
        /// <param name="width">the width as a Diff object</param>
        /// <param name="lowNullFlavor"></param>
        /// <returns>the constructed interval</returns>
        public static Interval <T> CreateLowWidth <T>(T low, Diff <T> width, NullFlavor lowNullFlavor)
        {
            T high = GenericMath.Add(low, width);

            return(new Interval <T>(low, high, GenericMath.Average(low, high), width, Representation.LOW_WIDTH, lowNullFlavor, null, null
                                    ));
        }
Beispiel #4
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));
        }
Beispiel #5
0
        /// <summary>Constructs an Interval using the supplied parameters.</summary>
        /// <remarks>Constructs an Interval using the supplied parameters.</remarks>
        /// <TBD></TBD>
        /// <param name="low">the low bound</param>
        /// <param name="high">the high bound</param>
        /// <param name="lowNullFlavor"></param>
        /// <param name="highNullFlavor"></param>
        /// <returns>the constructed interval</returns>
        public static Interval <T> CreateLowHigh <T>(T low, T high, NullFlavor lowNullFlavor, NullFlavor highNullFlavor)
        {
            bool     hasNullFlavor = lowNullFlavor != null || highNullFlavor != null;
            T        average       = hasNullFlavor ? default(T) : GenericMath.Average(low, high);
            Diff <T> diff          = hasNullFlavor ? null : GenericMath.Diff(low, high);

            return(new Interval <T>(low, high, average, diff, Representation.LOW_HIGH, lowNullFlavor, highNullFlavor, null));
        }
Beispiel #6
0
        /// <summary>
        /// Constructs an Interval using the supplied parameters.
        /// </summary>
        ///
        /// <param name="TS"> the   type of the interval</param>
        /// <param name="width_0">the width as a Diff object</param>
        /// <param name="high_1">the high bound</param>
        /// <returns>the constructed interval</returns>
        public static Interval <TS> CreateWidthHigh <TS>(Diff <TS> width_0, TS high_1)
        {
            Ca.Infoway.Messagebuilder.Validate.NotNull(width_0);
            Ca.Infoway.Messagebuilder.Validate.NotNull(high_1);
            TS low_2 = GenericMath.Diff <TS>(width_0.Value, high_1).Value;

            return(new Interval <TS>(low_2, high_1, GenericMath.Average(low_2, high_1),
                                     width_0, Representation.WIDTH_HIGH));
        }
Beispiel #7
0
        /// <summary>
        /// Constructs an Interval using the supplied parameters.
        /// </summary>
        ///
        /// <param name="TS"> the   type of the interval</param>
        /// <param name="low_0">the low bound</param>
        /// <param name="width_1">the width as a Diff object</param>
        /// <returns>the constructed interval</returns>
        public static Interval <TS> CreateLowWidth <TS>(TS low_0, Diff <TS> width_1)
        {
            Ca.Infoway.Messagebuilder.Validate.NotNull(low_0);
            Ca.Infoway.Messagebuilder.Validate.NotNull(width_1);
            TS high_2 = GenericMath.Add(low_0, width_1);

            return(new Interval <TS>(low_0, high_2, GenericMath.Average(low_0, high_2),
                                     width_1, Representation.LOW_WIDTH));
        }
Beispiel #8
0
        /// <summary>Constructs an Interval using the supplied parameters.</summary>
        /// <remarks>Constructs an Interval using the supplied parameters.</remarks>
        /// <param name="low"></param>
        /// <param name="centre"></param>
        /// <param name="lowNullFlavor"></param>
        /// <param name="centreNullFlavor"></param>
        /// <returns>the constructed interval</returns>
        public static Interval <T> CreateLowCentre <T>(T low, T centre, NullFlavor lowNullFlavor, NullFlavor centreNullFlavor)
        {
            Diff <T> tempDiff     = GenericMath.Diff(low, centre);
            bool     tempDiffNull = (tempDiff == (Diff <T>)null);
            T        halfDiff     = tempDiffNull ? default(T) : tempDiff.Value;
            T        high         = GenericMath.Add(centre, halfDiff);
            Diff <T> width        = GenericMath.Diff(low, high);

            return(new Interval <T>(low, high, centre, width, Representation.LOW_CENTER, lowNullFlavor, null, centreNullFlavor));
        }
Beispiel #9
0
        /// <summary>Constructs an Interval using the supplied parameters.</summary>
        /// <remarks>Constructs an Interval using the supplied parameters.</remarks>
        /// <TBD></TBD>
        /// <param name="width">the width as a Diff object</param>
        /// <param name="high">the high bound</param>
        /// <param name="highNullFlavor"></param>
        /// <returns>the constructed interval</returns>
        public static Interval <T> CreateWidthHigh <T>(Diff <T> width, T high, NullFlavor highNullFlavor)
        {
            bool     widthNull    = (width == (Diff <T>)null);
            Diff <T> tempDiff     = GenericMath.Diff(widthNull ? default(T) : width.Value, high);
            bool     tempDiffNull = (tempDiff == (Diff <T>)null);
            T        low          = tempDiffNull ? default(T) : tempDiff.Value;

            return(new Interval <T>(low, high, GenericMath.Average(low, high), width, Representation.WIDTH_HIGH, null, highNullFlavor,
                                    null));
        }
Beispiel #10
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));
        }
Beispiel #11
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));
        }
Beispiel #12
0
        /// <summary>Constructs an Interval using the supplied parameters.</summary>
        /// <remarks>Constructs an Interval using the supplied parameters.</remarks>
        /// <param name="centre"></param>
        /// <param name="high"></param>
        /// <param name="centreNullFlavor"></param>
        /// <param name="highNullFlavor"></param>
        /// <returns>the constructed interval</returns>
        public static Interval <T> CreateCentreHigh <T>(T centre, T high, NullFlavor centreNullFlavor, NullFlavor highNullFlavor)
        {
            Diff <T> tempDiff      = GenericMath.Diff(centre, high);
            bool     tempDiffNull  = (tempDiff == (Diff <T>)null);
            T        halfDiff      = tempDiffNull ? default(T) : tempDiff.Value;
            Diff <T> tempDiff2     = GenericMath.Diff(halfDiff, centre);
            bool     tempDiff2Null = (tempDiff2 == (Diff <T>)null);
            T        low           = tempDiff2Null ? default(T) : tempDiff2.Value;
            Diff <T> width         = GenericMath.Diff(low, high);

            return(new Interval <T>(low, high, centre, width, Representation.CENTRE_HIGH, null, highNullFlavor, centreNullFlavor));
        }
Beispiel #13
0
        /// <summary>Constructs an uncertain range (width/high).</summary>
        /// <remarks>Constructs an uncertain range (width/high).</remarks>
        /// <TBD></TBD>
        /// <param name="width">size of width</param>
        /// <param name="high">higher bound</param>
        /// <returns>the constructed uncertain range</returns>
        public static UncertainRange <T> CreateWidthHigh <T>(Diff <T> width, T high)
        {
            T low = GenericMath.Diff(width.Value, high).Value;

            return(new UncertainRange <T>(low, high, GenericMath.Average(low, high), width, Representation.WIDTH_HIGH));
        }
Beispiel #14
0
        /// <summary>Constructs an uncertain range (low/width).</summary>
        /// <remarks>Constructs an uncertain range (low/width).</remarks>
        /// <TBD></TBD>
        /// <param name="low">lower bound</param>
        /// <param name="width">size of width</param>
        /// <returns>the constructed uncertain range</returns>
        public static UncertainRange <T> CreateLowWidth <T>(T low, Diff <T> width)
        {
            T high = GenericMath.Add(low, width);

            return(new UncertainRange <T>(low, high, GenericMath.Average(low, high), width, Representation.LOW_WIDTH));
        }
Beispiel #15
0
 /// <summary>Constructs an uncertain range (low/high).</summary>
 /// <remarks>Constructs an uncertain range (low/high).</remarks>
 /// <TBD></TBD>
 /// <param name="low">lower bound</param>
 /// <param name="high">upper bound</param>
 /// <returns>the constructed uncertain range</returns>
 public static UncertainRange <T> CreateLowHigh <T>(T low, T high)
 {
     return(new UncertainRange <T>(low, high, GenericMath.Average(low, high), GenericMath.Diff(low, high), Representation.LOW_HIGH
                                   ));
 }