Represents a range with minimum and maximum values, which are single precision numbers (floats).

The class represents a single precision range with inclusive limits - both minimum and maximum values of the range are included into it. Mathematical notation of such range is [min, max].

Sample usage:

// create [0.25, 1.5] range Range range1 = new Range( 0.25f, 1.5f ); // create [1.00, 2.25] range Range range2 = new Range( 1.00f, 2.25f ); // check if values is inside of the first range if ( range1.IsInside( 0.75f ) ) { // ... } // check if the second range is inside of the first range if ( range1.IsInside( range2 ) ) { // ... } // check if two ranges overlap if ( range1.IsOverlapping( range2 ) ) { // ... }
Esempio n. 1
0
        public void IsOverlappingTest( float min1, float max1, float min2, float max2, bool expectedResult )
        {
            Range range1 = new Range( min1, max1 );
            Range range2 = new Range( min2, max2 );

            Assert.AreEqual<bool>( expectedResult, range1.IsOverlapping( range2 ) );
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UniformGenerator"/> class.
        /// </summary>
        /// 
        /// <param name="range">Random numbers range.</param>
        /// <param name="seed">Seed value to initialize random numbers generator.</param>
        /// 
        public UniformGenerator( Range range, int seed )
        {
            rand = new UniformOneGenerator( seed );

            min     = range.Min;
            length  = range.Length;
        }
Esempio n. 3
0
        public void ToRangeTest( float fMin, float fMax, int iMin, int iMax, bool innerRange )
        {
            Range range = new Range( fMin, fMax );
            IntRange iRange = range.ToIntRange( innerRange );

            Assert.AreEqual<int>( iMin, iRange.Min );
            Assert.AreEqual<int>( iMax, iRange.Max );
        }
Esempio n. 4
0
        public void EqualityOperatorTest( float min1, float max1, float min2, float max2, bool areEqual )
        {
            Range range1 = new Range( min1, max1 );
            Range range2 = new Range( min2, max2 );

            Assert.AreEqual( range1.Equals( range2 ), areEqual );
            Assert.AreEqual( range1 == range2, areEqual );
            Assert.AreEqual( range1 != range2, !areEqual );
        }
Esempio n. 5
0
        /// <summary>
        ///   Constructs a new Nguyen-Widrow Weight initialization.
        /// </summary>
        /// 
        /// <param name="network">The activation network whose weights will be initialized.</param>
        /// 
        public NguyenWidrow(ActivationNetwork network)
        {
            this.network = network;

            int hiddenNodes = network.Layers[0].Neurons.Length;
            int inputNodes = network.Layers[0].InputsCount;

            randRange = new Range(-0.5f, 0.5f);
            beta = 0.7 * Math.Pow(hiddenNodes, 1.0 / inputNodes);
        }
Esempio n. 6
0
        /// <summary>
        /// Update Y range.
        /// </summary>
        private void UpdateYRange()
        {
            float minY = float.MaxValue;
            float maxY = float.MinValue;

            // walk through all data series
            foreach (KeyValuePair <string, DataSeries> kvp in seriesTable)
            {
                DataSeries series = kvp.Value;
                // get data of the series
                double[,] data = series.data;

                if ((series.updateYRange) && (data != null))
                {
                    for (int i = 0, n = data.GetLength(0); i < n; i++)
                    {
                        if (rangeX.IsInside((float)data[i, 0]))
                        {
                            float v = (float)data[i, 1];

                            // check for max
                            if (v > maxY)
                            {
                                maxY = v;
                            }
                            // check for min
                            if (v < minY)
                            {
                                minY = v;
                            }
                        }
                    }
                }
            }

            // update Y range, if there are any data
            if ((minY != double.MaxValue) || (maxY != double.MinValue))
            {
                rangeY = new Range(minY, maxY);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HSLFiltering"/> class.
 /// </summary>
 /// 
 /// <param name="hue">Range of hue component.</param>
 /// <param name="saturation">Range of saturation component.</param>
 /// <param name="luminance">Range of luminance component.</param>
 /// 
 public HSLFiltering( IntRange hue, Range saturation, Range luminance ) :
     this( )
 {
     this.hue = hue;
     this.saturation = saturation;
     this.luminance = luminance;
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="YCbCrFiltering"/> class.
 /// </summary>
 /// 
 /// <param name="yRange">Range of Y component.</param>
 /// <param name="cbRange">Range of Cb component.</param>
 /// <param name="crRange">Range of Cr component.</param>
 /// 
 public YCbCrFiltering( Range yRange, Range cbRange, Range crRange ) :
     this( )
 {
     this.yRange  = yRange;
     this.cbRange = cbRange;
     this.crRange = crRange;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OptimizationFunction2D"/> class.
 /// </summary>
 ///
 /// <param name="rangeX">Specifies X variable's range.</param>
 /// <param name="rangeY">Specifies Y variable's range.</param>
 ///
 public OptimizationFunction2D( Range rangeX, Range rangeY )
 {
     this.rangeX = rangeX;
     this.rangeY = rangeY;
 }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UniformGenerator"/> class.
 /// </summary>
 /// 
 /// <param name="range">Random numbers range.</param>
 /// 
 /// <remarks>Initializes random numbers generator with zero seed.</remarks>
 /// 
 public UniformGenerator( Range range ) :
     this( range, 0 )
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OptimizationFunction1D"/> class.
 /// </summary>
 ///
 /// <param name="range">Specifies range for optimization.</param>
 ///
 public OptimizationFunction1D( Range range )
 {
     this.range = range;
 }
Esempio n. 12
0
 /// <summary>
 /// Check if the specified range overlaps with the range.
 /// </summary>
 /// 
 /// <param name="range">Range to check for overlapping.</param>
 /// 
 /// <returns><b>True</b> if the specified range overlaps with the range or
 /// <b>false</b> otherwise.</returns>
 /// 
 public bool IsOverlapping( Range range )
 {
     return ( ( IsInside( range.min ) ) || ( IsInside( range.max ) ) ||
              ( range.IsInside( min ) ) || ( range.IsInside( max ) ) );
 }
Esempio n. 13
0
 /// <summary>
 /// Check if the specified range is inside of the range.
 /// </summary>
 /// 
 /// <param name="range">Range to check.</param>
 /// 
 /// <returns><b>True</b> if the specified range is inside of the range or
 /// <b>false</b> otherwise.</returns>
 /// 
 public bool IsInside( Range range )
 {
     return ( ( IsInside( range.min ) ) && ( IsInside( range.max ) ) );
 }
Esempio n. 14
0
        /// <summary>
        /// Update Y range.
        /// </summary>
        private void UpdateYRange()
        {
            float minY = float.MaxValue;
            float maxY = float.MinValue;

            // walk through all data series
            foreach (KeyValuePair<string, DataSeries> kvp in seriesTable)
            {
                DataSeries series = kvp.Value;
                // get data of the series
                double[,] data = series.data;

                if ((series.updateYRange) && (data != null))
                {
                    for (int i = 0, n = data.GetLength(0); i < n; i++)
                    {
                        if (rangeX.IsInside((float)data[i, 0]))
                        {
                            float v = (float)data[i, 1];

                            // check for max
                            if (v > maxY)
                                maxY = v;
                            // check for min
                            if (v < minY)
                                minY = v;
                        }
                    }
                }
            }

            // update Y range, if there are any data
            if ((minY != double.MaxValue) || (maxY != double.MinValue))
            {
                rangeY = new Range(minY, maxY);
            }
        }
Esempio n. 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OptimizationFunction2D"/> class.
 /// </summary>
 ///
 /// <param name="rangeX">Specifies X variable's range.</param>
 /// <param name="rangeY">Specifies Y variable's range.</param>
 ///
 public OptimizationFunction2D(Range rangeX, Range rangeY)
 {
     this.rangeX = rangeX;
     this.rangeY = rangeY;
 }
Esempio n. 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OptimizationFunction1D"/> class.
 /// </summary>
 ///
 /// <param name="range">Specifies range for optimization.</param>
 ///
 public OptimizationFunction1D(Range range)
 {
     this.range = range;
 }