You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2021/06/01 19:08:34 UTC

[GitHub] [commons-math] samyBadjoudj opened a new pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

samyBadjoudj opened a new pull request #190:
URL: https://github.com/apache/commons-math/pull/190


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] amarlearning commented on a change in pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
amarlearning commented on a change in pull request #190:
URL: https://github.com/apache/commons-math/pull/190#discussion_r667349474



##########
File path: commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/quasirandom/HaltonSequenceGenerator.java
##########
@@ -151,31 +159,44 @@ public HaltonSequenceGenerator(final int dimension, final int[] bases, final int
      * @param digit the j-th digit
      * @return the scrambled digit
      */
-    protected int scramble(final int i, final int j, final int b, final int digit) {
+    protected long scramble(final int i, final int j, final int b, final long digit) {
         return weight != null ? (weight[i] * digit) % b : digit;
     }
 
     /**
-     * Skip to the i-th point in the Halton sequence.
+     * jump to the i-th point in the Halton sequence.
      * <p>
      * This operation can be performed in O(1).
      *
      * @param index the index in the sequence to skip to
-     * @return the i-th point in the Halton sequence
-     * @throws org.apache.commons.math4.legacy.exception.NotPositiveException NotPositiveException if index &lt; 0
+     * @return the copy of this sequence
+     * @throws NotPositiveException if index &lt; 0
      */
-    public double[] skipTo(final int index) {
+    @Override
+    public LowDiscrepancySequence jump(final long index) throws NotPositiveException {
+        if(index < 0) {
+            throw new NotPositiveException(index);
+        }
+        HaltonSequenceGenerator copy = this.copy();
+        copy.performJump(index);
+        return copy;
+    }
+
+    /**
+     *  Do jump at the index.
+     * @param index
+     */
+    private void performJump(long index) {
         count = index;
-        return get();
     }
 
     /**
-     * Returns the index i of the next point in the Halton sequence that will be returned
-     * by calling {@link #get()}.
-     *
-     * @return the index of the next point
+     * Private constructor avoid side effects.
+     * @return copy of HaltonSequenceGenerator
      */
-    public int getNextIndex() {
-        return count;
+    private HaltonSequenceGenerator copy() {
+        return new HaltonSequenceGenerator(this);
     }
+
+

Review comment:
       extra line




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] coveralls edited a comment on pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #190:
URL: https://github.com/apache/commons-math/pull/190#issuecomment-874527665


   
   [![Coverage Status](https://coveralls.io/builds/41399708/badge)](https://coveralls.io/builds/41399708)
   
   Coverage increased (+0.02%) to 90.46% when pulling **ac65dcabb5ff4e77c7f1aad7e2d26c57d3e395af on samyBadjoudj:feature/MATH-1597** into **dcf83c02a7a341ce40d02521a9e8d4cb863e4728 on apache:master**.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] samyBadjoudj commented on pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
samyBadjoudj commented on pull request #190:
URL: https://github.com/apache/commons-math/pull/190#issuecomment-874483891


   done


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] samyBadjoudj closed pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
samyBadjoudj closed pull request #190:
URL: https://github.com/apache/commons-math/pull/190


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] samyBadjoudj commented on pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
samyBadjoudj commented on pull request #190:
URL: https://github.com/apache/commons-math/pull/190#issuecomment-874527098


   check styles fixed


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] samyBadjoudj commented on a change in pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
samyBadjoudj commented on a change in pull request #190:
URL: https://github.com/apache/commons-math/pull/190#discussion_r664255905



##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/SobolSequenceGeneratorTest.java
##########
@@ -92,16 +92,29 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-6);
-        Assert.assertEquals(6, generator.getNextIndex());
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-6);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+
+    }
+
+
+    @Test
+    public void testFirstSupplying() {
+        LowDiscrepancySequence sequence = new SobolSequenceGenerator(3);
+        Assert.assertArrayEquals(new double[]{0.0, 0.0, 0.0}, sequence.get(),1e-6);
+

Review comment:
       done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] samyBadjoudj commented on pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
samyBadjoudj commented on pull request #190:
URL: https://github.com/apache/commons-math/pull/190#issuecomment-874483891






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] coveralls commented on pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #190:
URL: https://github.com/apache/commons-math/pull/190#issuecomment-874527665


   
   [![Coverage Status](https://coveralls.io/builds/41136546/badge)](https://coveralls.io/builds/41136546)
   
   Coverage increased (+0.009%) to 90.436% when pulling **187bd46d986d5222deaa891c0a690a5f93876815 on samyBadjoudj:feature/MATH-1597** into **7f425354fb4eed78832bbcb37b81acfd21879ab0 on apache:master**.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] samyBadjoudj commented on a change in pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
samyBadjoudj commented on a change in pull request #190:
URL: https://github.com/apache/commons-math/pull/190#discussion_r664255905



##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/SobolSequenceGeneratorTest.java
##########
@@ -92,16 +92,29 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-6);
-        Assert.assertEquals(6, generator.getNextIndex());
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-6);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+
+    }
+
+
+    @Test
+    public void testFirstSupplying() {
+        LowDiscrepancySequence sequence = new SobolSequenceGenerator(3);
+        Assert.assertArrayEquals(new double[]{0.0, 0.0, 0.0}, sequence.get(),1e-6);
+

Review comment:
       done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] amarlearning commented on a change in pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
amarlearning commented on a change in pull request #190:
URL: https://github.com/apache/commons-math/pull/190#discussion_r664038668



##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/HaltonSequenceGeneratorTest.java
##########
@@ -119,16 +118,32 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-3);
-        Assert.assertEquals(6, generator.getNextIndex());
+
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-3);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+
+    }
+
+
+
+    @Test
+    public void testFirstSupplying() {
+        LowDiscrepancySequence sequence = new HaltonSequenceGenerator(3);
+        Assert.assertArrayEquals(new double[]{0.0, 0.0, 0.0}, sequence.get(),1e-6);
+

Review comment:
       Please remove this newline

##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/SobolSequenceGeneratorTest.java
##########
@@ -92,16 +92,29 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-6);
-        Assert.assertEquals(6, generator.getNextIndex());
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-6);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+

Review comment:
       Please remove this newline

##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/HaltonSequenceGeneratorTest.java
##########
@@ -119,16 +118,32 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-3);
-        Assert.assertEquals(6, generator.getNextIndex());
+
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-3);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+

Review comment:
       Please remove this newline

##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/SobolSequenceGeneratorTest.java
##########
@@ -92,16 +92,29 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-6);
-        Assert.assertEquals(6, generator.getNextIndex());
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-6);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+
+    }
+
+
+    @Test
+    public void testFirstSupplying() {
+        LowDiscrepancySequence sequence = new SobolSequenceGenerator(3);
+        Assert.assertArrayEquals(new double[]{0.0, 0.0, 0.0}, sequence.get(),1e-6);
+

Review comment:
       Please remove this newline




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] coveralls commented on pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #190:
URL: https://github.com/apache/commons-math/pull/190#issuecomment-874527665


   
   [![Coverage Status](https://coveralls.io/builds/41136546/badge)](https://coveralls.io/builds/41136546)
   
   Coverage increased (+0.009%) to 90.436% when pulling **187bd46d986d5222deaa891c0a690a5f93876815 on samyBadjoudj:feature/MATH-1597** into **7f425354fb4eed78832bbcb37b81acfd21879ab0 on apache:master**.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] amarlearning commented on a change in pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
amarlearning commented on a change in pull request #190:
URL: https://github.com/apache/commons-math/pull/190#discussion_r664038668



##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/HaltonSequenceGeneratorTest.java
##########
@@ -119,16 +118,32 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-3);
-        Assert.assertEquals(6, generator.getNextIndex());
+
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-3);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+
+    }
+
+
+
+    @Test
+    public void testFirstSupplying() {
+        LowDiscrepancySequence sequence = new HaltonSequenceGenerator(3);
+        Assert.assertArrayEquals(new double[]{0.0, 0.0, 0.0}, sequence.get(),1e-6);
+

Review comment:
       Please remove this newline

##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/SobolSequenceGeneratorTest.java
##########
@@ -92,16 +92,29 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-6);
-        Assert.assertEquals(6, generator.getNextIndex());
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-6);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+

Review comment:
       Please remove this newline

##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/HaltonSequenceGeneratorTest.java
##########
@@ -119,16 +118,32 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-3);
-        Assert.assertEquals(6, generator.getNextIndex());
+
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-3);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+

Review comment:
       Please remove this newline

##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/SobolSequenceGeneratorTest.java
##########
@@ -92,16 +92,29 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-6);
-        Assert.assertEquals(6, generator.getNextIndex());
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-6);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+
+    }
+
+
+    @Test
+    public void testFirstSupplying() {
+        LowDiscrepancySequence sequence = new SobolSequenceGenerator(3);
+        Assert.assertArrayEquals(new double[]{0.0, 0.0, 0.0}, sequence.get(),1e-6);
+

Review comment:
       Please remove this newline




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [commons-math] amarlearning commented on a change in pull request #190: MATH-1597: LowDiscrepancySequence supplier/jump for Halton and Sobol

Posted by GitBox <gi...@apache.org>.
amarlearning commented on a change in pull request #190:
URL: https://github.com/apache/commons-math/pull/190#discussion_r667349534



##########
File path: commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/quasirandom/HaltonSequenceGenerator.java
##########
@@ -151,31 +159,44 @@ public HaltonSequenceGenerator(final int dimension, final int[] bases, final int
      * @param digit the j-th digit
      * @return the scrambled digit
      */
-    protected int scramble(final int i, final int j, final int b, final int digit) {
+    protected long scramble(final int i, final int j, final int b, final long digit) {
         return weight != null ? (weight[i] * digit) % b : digit;
     }
 
     /**
-     * Skip to the i-th point in the Halton sequence.
+     * jump to the i-th point in the Halton sequence.
      * <p>
      * This operation can be performed in O(1).
      *
      * @param index the index in the sequence to skip to
-     * @return the i-th point in the Halton sequence
-     * @throws org.apache.commons.math4.legacy.exception.NotPositiveException NotPositiveException if index &lt; 0
+     * @return the copy of this sequence
+     * @throws NotPositiveException if index &lt; 0

Review comment:
       We can give the reference to the exception class as well `org.apache.commons.math4.legacy.exception.NotPositiveException`

##########
File path: commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/quasirandom/HaltonSequenceGeneratorTest.java
##########
@@ -119,16 +118,30 @@ public void testConstructor2() throws Exception{
     }
 
     @Test
-    public void testSkip() {
-        double[] result = generator.skipTo(5);
+    public void testJump() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(5);
+        double[] result = copyOfSeq.get();
         Assert.assertArrayEquals(referenceValues[5], result, 1e-3);
-        Assert.assertEquals(6, generator.getNextIndex());
+
 
         for (int i = 6; i < referenceValues.length; i++) {
-            result = generator.get();
+            result = copyOfSeq.get();
             Assert.assertArrayEquals(referenceValues[i], result, 1e-3);
-            Assert.assertEquals(i + 1, generator.getNextIndex());
         }
     }
 
+
+    @Test(expected = NotPositiveException.class)
+    public void testJumpNegativeIndex() {
+        LowDiscrepancySequence copyOfSeq = generator.jump(-5);
+    }
+
+
+
+    @Test

Review comment:
       Can you please remove these 2 extra lines as well

##########
File path: commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/quasirandom/HaltonSequenceGenerator.java
##########
@@ -151,31 +159,44 @@ public HaltonSequenceGenerator(final int dimension, final int[] bases, final int
      * @param digit the j-th digit
      * @return the scrambled digit
      */
-    protected int scramble(final int i, final int j, final int b, final int digit) {
+    protected long scramble(final int i, final int j, final int b, final long digit) {
         return weight != null ? (weight[i] * digit) % b : digit;
     }
 
     /**
-     * Skip to the i-th point in the Halton sequence.
+     * jump to the i-th point in the Halton sequence.

Review comment:
       Make the `J` capital

##########
File path: commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/quasirandom/HaltonSequenceGenerator.java
##########
@@ -151,31 +159,44 @@ public HaltonSequenceGenerator(final int dimension, final int[] bases, final int
      * @param digit the j-th digit
      * @return the scrambled digit
      */
-    protected int scramble(final int i, final int j, final int b, final int digit) {
+    protected long scramble(final int i, final int j, final int b, final long digit) {
         return weight != null ? (weight[i] * digit) % b : digit;
     }
 
     /**
-     * Skip to the i-th point in the Halton sequence.
+     * jump to the i-th point in the Halton sequence.
      * <p>
      * This operation can be performed in O(1).
      *
      * @param index the index in the sequence to skip to
-     * @return the i-th point in the Halton sequence
-     * @throws org.apache.commons.math4.legacy.exception.NotPositiveException NotPositiveException if index &lt; 0
+     * @return the copy of this sequence
+     * @throws NotPositiveException if index &lt; 0
      */
-    public double[] skipTo(final int index) {
+    @Override
+    public LowDiscrepancySequence jump(final long index) throws NotPositiveException {
+        if(index < 0) {
+            throw new NotPositiveException(index);
+        }
+        HaltonSequenceGenerator copy = this.copy();
+        copy.performJump(index);
+        return copy;
+    }
+
+    /**
+     *  Do jump at the index.
+     * @param index
+     */
+    private void performJump(long index) {
         count = index;
-        return get();
     }
 
     /**
-     * Returns the index i of the next point in the Halton sequence that will be returned
-     * by calling {@link #get()}.
-     *
-     * @return the index of the next point
+     * Private constructor avoid side effects.
+     * @return copy of HaltonSequenceGenerator
      */
-    public int getNextIndex() {
-        return count;
+    private HaltonSequenceGenerator copy() {
+        return new HaltonSequenceGenerator(this);
     }
+
+

Review comment:
       extra space




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org