Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1307

Create a base class for all RNGs

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • None
    • None
    • None

    Description

      I proposed to create a base class which the existing abstract classes AbstractRandomGenerator and BitsStreamGenerator will extend.

      This would allow to define nextBytes(byte[]) at the base class level.

      The code for that method is almost identical in the two hierarchies: they only differ in a call to either nextInt() or next(32) respectively; the latter is however the same as the former, in disguise, and is not subject to change given the type of return value.

      As a corollary, the new base class can be the unique place where to add utilities such as the one proposed in MATH-1306.

      Update: AbstractRandomGenerator and BitsStreamGenerator are both obsoleted by the class proposed in this report.

      Attachments

        1. BaseRandomGeneratorFloatGenerationPerformanceTest.java
          4 kB
          Otmar Ertl
        2. BaseRandomGenerator.java
          9 kB
          Gilles Sadowski

        Issue Links

          Activity

            People

              erans Gilles Sadowski
              erans Gilles Sadowski
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: