You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2022/05/26 23:02:01 UTC
[commons-rng] 01/04: Simplify returns.
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git
commit e674857954c2f8589392f125fe668f341da16a77
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Thu May 26 21:02:29 2022 +0200
Simplify returns.
---
.../org/apache/commons/rng/sampling/CompositeSamplers.java | 4 ++--
.../sampling/distribution/ContinuousUniformSampler.java | 14 ++++----------
2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CompositeSamplers.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CompositeSamplers.java
index b8941ee0..d46df6b6 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CompositeSamplers.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/CompositeSamplers.java
@@ -117,7 +117,7 @@ public final class CompositeSamplers {
public SharedStateDiscreteSampler create(UniformRandomProvider rng, double[] probabilities) {
return MarsagliaTsangWangDiscreteSampler.Enumerated.of(rng, probabilities);
}
- };
+ }
}
/**
@@ -262,7 +262,7 @@ public final class CompositeSamplers {
/** Instance of {@link SharedStateSampler}. */
SHARED_STATE_SAMPLER,
/** No specialisation. */
- NONE;
+ NONE
}
/**
diff --git a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSampler.java b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSampler.java
index 48732b02..02e2013e 100644
--- a/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSampler.java
+++ b/commons-rng-sampling/src/main/java/org/apache/commons/rng/sampling/distribution/ContinuousUniformSampler.java
@@ -196,17 +196,11 @@ public class ContinuousUniformSampler
// (MAX_VALUE has all bits set except the most significant sign bit.)
bitsx &= Long.MAX_VALUE;
bitsy &= Long.MAX_VALUE;
- if (lessThanUnsigned(bitsx + bitsy, MIN_ULP_OPPOSITE_SIGN)) {
- return false;
- }
- } else {
- // Same signs, subtraction will count the ULP difference.
- // This should be above 1.
- if (Math.abs(bitsx - bitsy) < MIN_ULP_SAME_SIGN) {
- return false;
- }
+ return !lessThanUnsigned(bitsx + bitsy, MIN_ULP_OPPOSITE_SIGN);
}
- return true;
+ // Same signs, subtraction will count the ULP difference.
+ // This should be above 1.
+ return Math.abs(bitsx - bitsy) >= MIN_ULP_SAME_SIGN;
}
/**