Skip to content

Commit

Permalink
Based nextRandom on nextGaussian.
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Jan 2, 2025
1 parent 5161df4 commit ee2aa93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.meeuw.math.abstractalgebra.padic;

import lombok.EqualsAndHashCode;

import java.math.BigInteger;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

import lombok.EqualsAndHashCode;

import org.meeuw.math.IntegerUtils;
import org.meeuw.math.Randomizable;
import org.meeuw.math.abstractalgebra.Cardinality;
Expand Down Expand Up @@ -89,11 +89,11 @@ public String toString() {
@Override
public PAdicInteger nextRandom(Random r) {

int[] nonRepetitive = new int[r.nextInt(10)];
int[] nonRepetitive = new int[(int) Math.abs(r.nextGaussian(0, 10))];
for (int i = 0 ; i < nonRepetitive.length; i++) {
nonRepetitive[i] = r.nextInt(base);
}
int[] repetitive = new int[r.nextInt(base)];
int[] repetitive = new int[(int) Math.abs(r.nextGaussian(0, 10))];
for (int i = 0 ; i < repetitive.length; i++) {
repetitive[i] = r.nextInt(base);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ public void negation() {

@Test
public void random() {
PAdicInteger random = p5.nextRandom(new Random(1));
assertThat(random.toString()).isEqualTo("...1334 32344₅");
Random r = new Random(1);
PAdicInteger random = p5.nextRandom(r);
assertThat(random.toString()).isEqualTo("...33432 2344₅");
for (int i = 0; i < 200; i++) {
log.info("{}", p5.nextRandom(r));
}
}

@Test
Expand Down

0 comments on commit ee2aa93

Please sign in to comment.