예제 #1
0
        public void NextDouble()
        {
            // no params
            int count = 30, minVal = 0, maxVal = 1;
            var nums = new List <double>(ArrayBuilder.repeat(() => GlobalRandom.NextDouble(), count));

            foreach (var num in nums)
            {
                Assert.IsTrue(num >= minVal && num < maxVal);
            }

            // count
            nums = new List <double>(GlobalRandom.NextDoubleArr(count));
            Assert.IsTrue(nums.Count == count);
            foreach (var num in nums)
            {
                Assert.IsTrue(num >= minVal && num < maxVal);
            }

            // count, min, max
            minVal = -2; maxVal = 2;
            nums   = new List <double>(GlobalRandom.NextDoubleArr(count, minVal, maxVal));
            Assert.IsTrue(nums.Count == count);
            foreach (var num in nums)
            {
                Assert.IsTrue(num >= minVal && num < maxVal);
            }
        }
예제 #2
0
 public MultiMatrix random(int[] sizes, double minVal, double maxVal)
 => this.useData(GlobalRandom.NextDoubleArr(sizes.product(), minVal, maxVal), sizes);
예제 #3
0
 public MultiMatrix random(int[] sizes)
 => this.useData(GlobalRandom.NextDoubleArr(sizes.product()), sizes);