public void Generate_XIsFirstRootOfFirstNumberGenerator_ThrowsInvalidOperationException()
        {
            var payload = new SeriesPayLoad(-60.49590136, 1250.0);

            var generator = new SeriesGeneratorFacade();

            generator.Generate(payload, 5).ToList();
        }
예제 #2
0
        public double GetNthLargetNumber(SeriesPayLoad payLoad, int count, int index)
        {
            var series = _generator.Generate(payLoad, count);

            return index == 0
                ? series.ElementAt(count - 1)
                : series.ElementAt(count - index);
        }
        public IEnumerable<double> Generate(SeriesPayLoad payLoad, int count)
        {
            var generator = _seriesGeneratorBuilder.GetSeriesGenerator();

            var series = generator.Generate(payLoad).Take(count);

            return series.OrderBy(d => d);
        }
예제 #4
0
        public double GetClosetSpecialNumber(SeriesPayLoad payLoad, int count, double z)
        {
            var series = _generator.Generate(payLoad, count);
            var approximateNumber = GetApproximateNumber(z);

            var deltas = series.Select((d, i) => new {index = i, diff = Math.Abs(d - approximateNumber)})
                .OrderBy(d => d.diff).ThenByDescending(d => d.index);

            return series.ElementAt(deltas.ElementAt(0).index);
        }
예제 #5
0
        public IEnumerable<double> Generate(SeriesPayLoad payload)
        {
            if (Compare(payload.X, Common.MagicNumbers.X0Root01)
                || Compare(payload.X, Common.MagicNumbers.X0Root02)
                || Compare(payload.X, Common.MagicNumbers.X0Root03)
                || Compare(payload.X, Common.MagicNumbers.X0Root04))
            {
                throw new InvalidSeriesException();
            }

            return _decorated.Generate(payload);
        }
예제 #6
0
        public IEnumerable<double> Generate(SeriesPayLoad payload)
        {
            var set = new HashSet<double>();
            var enumerator = _decorated.Generate(payload).GetEnumerator();

            while (enumerator.MoveNext())
            {
                var currentValue = enumerator.Current;

                if (!set.Contains(currentValue))
                {
                    set.Add(currentValue);
                    yield return currentValue;
                }
            }
        }
예제 #7
0
        public IEnumerable<double> Generate(SeriesPayLoad payload)
        {
            var firstNumber = GetFirstNumber(payload.X);
            var growthRate = GetGrowthRate(payload.Y, firstNumber);
            var current = firstNumber;

            yield return firstNumber;

            current = firstNumber * growthRate;
            yield return current;

            while (true)
            {
                var value = current * firstNumber;
                yield return value;
                current = value;
            }
        }
 public IEnumerable<double> Generate(SeriesPayLoad payload)
 {
     return _decorated.Generate(payload).Select(RoundDecimal25);
 }
        public void Generate_XIsSecondRootOfFirstNumberGenerator_ThrowsInvalidOperationException()
        {
            var payload = new SeriesPayLoad(-58.80972058, 1250.0);

            var generator = new SeriesGeneratorFacade();

            generator.Generate(payload, 5).ToList();
        }
        public void Generate_XGeneratesLessThanOneForFirstNumber_SeriesShouldBeSorted()
        {
            var payload = new SeriesPayLoad(-59, 1250.0);

            var generator = new SeriesGeneratorFacade();

            var series = generator.Generate(payload, 5).ToList();

            DiagnoseSeries(series);
            Assert.IsTrue(series[0] < series[1]);
        }