Skip to content

Commit b9104ae

Browse files
author
埃博拉酱
committed
Revert "RandomExtensions.NextBigIntegerSequence"
This reverts commit 74470f9.
1 parent 2de37bb commit b9104ae

2 files changed

Lines changed: 1 addition & 49 deletions

File tree

src/Numerics.Tests/Random/RandomExtensionTests.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
using MathNet.Numerics.Random;
3131
using NUnit.Framework;
32-
using System.Numerics;
33-
using System.Collections.Generic;
3432

3533
namespace MathNet.Numerics.UnitTests.Random
3634
{
@@ -50,22 +48,6 @@ public void CanSampleInt64()
5048
rnd.NextInt64();
5149
}
5250

53-
/// <summary>
54-
/// Can sample BigInteger
55-
/// </summary>
56-
[Test]
57-
public void CanSampleBigInteger()
58-
{
59-
var rnd = new System.Random(0);
60-
IEnumerator<BigInteger> Sequence = rnd.NextBigIntegerSequence((BigInteger)long.MinValue * 3, (BigInteger)long.MaxValue * 3).GetEnumerator();
61-
Sequence.MoveNext();
62-
System.Console.WriteLine(Sequence.Current);
63-
Sequence.MoveNext();
64-
System.Console.WriteLine(Sequence.Current);
65-
Sequence.MoveNext();
66-
System.Console.WriteLine(Sequence.Current);
67-
}
68-
6951
/// <summary>
7052
/// Can sample full range int32.
7153
/// </summary>

src/Numerics/Random/RandomExtensions.cs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
using System;
3131
using System.Collections.Generic;
32-
using System.Numerics;
33-
using System.Linq;
3432

3533
namespace MathNet.Numerics.Random
3634
{
@@ -169,7 +167,7 @@ public static void NextInt32s(this System.Random rnd, int[] values, int minInclu
169167
}
170168

171169
/// <summary>
172-
/// Returns an infinite sequence of uniform random 32-bit signed integers within the specified range.
170+
/// Returns an infinite sequence of uniform random numbers greater than or equal to 0.0 and less than 1.0.
173171
/// </summary>
174172
/// <remarks>
175173
/// This extension is thread-safe if and only if called on an random number
@@ -193,34 +191,6 @@ static IEnumerable<int> NextInt32SequenceEnumerable(System.Random rnd, int minIn
193191
}
194192
}
195193

196-
/// <summary>
197-
/// Returns an infinite sequence of uniform random <see cref="System.Numerics.BigInteger"/> within the specified range.
198-
/// </summary>
199-
/// <remarks>
200-
/// This extension is thread-safe if and only if called on an random number
201-
/// generator provided by Math.NET Numerics or derived from the RandomSource class.
202-
/// </remarks>
203-
public static IEnumerable<BigInteger> NextBigIntegerSequence(this System.Random rnd, BigInteger minInclusive, BigInteger maxExclusive)
204-
{
205-
BigInteger AbsoluteRange = maxExclusive - minInclusive;
206-
int NumBytes = (int)Math.Ceiling(BigInteger.Log(AbsoluteRange, byte.MaxValue) * 2);
207-
byte[] ByteSequence = Enumerable.Repeat(byte.MaxValue, NumBytes + 1).ToArray();
208-
ByteSequence[NumBytes] = 0;
209-
BigInteger RandomNumber = new BigInteger(ByteSequence);
210-
BigInteger ValidRange = RandomNumber - RandomNumber % AbsoluteRange;
211-
while(true)
212-
{
213-
do
214-
{
215-
rnd.NextBytes(ByteSequence);
216-
ByteSequence[NumBytes] = 0;
217-
RandomNumber = new BigInteger(ByteSequence);
218-
}
219-
while (RandomNumber >= ValidRange);
220-
yield return RandomNumber % AbsoluteRange + minInclusive;
221-
}
222-
}
223-
224194
/// <summary>
225195
/// Returns a nonnegative random number less than <see cref="Int64.MaxValue"/>.
226196
/// </summary>

0 commit comments

Comments
 (0)