Skip to content

Commit

Permalink
Javadoc protected/public constructors and methods
Browse files Browse the repository at this point in the history
Added to avoid warnings when building on Java 21 (which fail the build).

This requires adding implicit public constructors.
  • Loading branch information
aherbert committed Jul 8, 2024
1 parent c37914a commit 17145e8
Show file tree
Hide file tree
Showing 32 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public abstract class BaseProvider
/** The fractional part of the golden ratio, phi, scaled to 32-bits and rounded to odd. */
private static final int GOLDEN_RATIO_32 = 0x9e3779b9;

/** Create an instance. */
public BaseProvider() {}

/** {@inheritDoc} */
@Override
public RandomProviderState saveState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class ComputePi extends MonteCarloIntegration {
private static final int DIMENSION = 2;

/**
* Create an instance.
*
* @param rng RNG.
*/
public ComputePi(UniformRandomProvider rng) {
Expand Down Expand Up @@ -78,6 +80,8 @@ public static void main(String[] args) {
}

/**
* Compute the value of pi.
*
* @param numPoints Number of random points to generate.
* @return the approximate value of pi.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class AhrensDieterExponentialSampler
}

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
* @param mean Mean of this distribution.
* @throws IllegalArgumentException if {@code mean <= 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class BoxMullerGaussianSampler
private final UniformRandomProvider rng;

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
* @param mean Mean of the Gaussian distribution.
* @param standardDeviation Standard deviation of the Gaussian distribution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class BoxMullerLogNormalSampler
private final ContinuousSampler sampler;

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
* @param mu Mean of the natural logarithm of the distribution values.
* @param sigma Standard deviation of the natural logarithm of the distribution values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class BoxMullerNormalizedGaussianSampler
private final UniformRandomProvider rng;

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
*/
public BoxMullerNormalizedGaussianSampler(UniformRandomProvider rng) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public SharedStateContinuousSampler withUniformRandomProvider(UniformRandomProvi
}

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
* @param lo Lower bound.
* @param hi Higher bound.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class GaussianSampler implements SharedStateContinuousSampler {
private final NormalizedGaussianSampler normalized;

/**
* Create an instance.
*
* @param normalized Generator of N(0,1) Gaussian distributed random numbers.
* @param mean Mean of the Gaussian distribution.
* @param standardDeviation Standard deviation of the Gaussian distribution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public class InverseTransformContinuousSampler
private final UniformRandomProvider rng;

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
* @param function Inverse cumulative probability function.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public class InverseTransformDiscreteSampler
private final UniformRandomProvider rng;

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
* @param function Inverse cumulative probability function.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class InverseTransformParetoSampler
private final LongToDoubleFunction nextDouble;

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
* @param scale Scale of the distribution.
* @param shape Shape of the distribution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public int sample() {


/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
* @param mean Mean.
* @throws IllegalArgumentException if {@code mean < 1} or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class LogNormalSampler implements SharedStateContinuousSampler {
private final NormalizedGaussianSampler gaussian;

/**
* Create an instance.
*
* @param gaussian N(0,1) generator.
* @param mu Mean of the natural logarithm of the distribution values.
* @param sigma Standard deviation of the natural logarithm of the distribution values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class MarsagliaNormalizedGaussianSampler
private final UniformRandomProvider rng;

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
*/
public MarsagliaNormalizedGaussianSampler(UniformRandomProvider rng) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public class PoissonSamplerCache {
private final LargeMeanPoissonSamplerState[] values;

/**
* Create an instance.
*
* @param minMean The minimum mean covered by the cache.
* @param maxMean The maximum mean covered by the cache.
* @throws IllegalArgumentException if {@code maxMean < minMean}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ public class SamplerBase {
private final UniformRandomProvider rng;

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
*/
protected SamplerBase(UniformRandomProvider rng) {
this.rng = rng;
}

/**
* Return the next {@code double} value.
*
* @return a random value from a uniform distribution in the
* interval {@code [0, 1)}.
*/
Expand All @@ -46,13 +50,17 @@ protected double nextDouble() {
}

/**
* Return the next {@code int} value.
*
* @return a random {@code int} value.
*/
protected int nextInt() {
return rng.nextInt();
}

/**
* Return the next {@code int} value.
*
* @param max Upper bound (excluded).
* @return a random {@code int} value in the interval {@code [0, max)}.
*/
Expand All @@ -61,6 +69,8 @@ protected int nextInt(int max) {
}

/**
* Return the next {@code long} value.
*
* @return a random {@code long} value.
*/
protected long nextLong() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class SmallMeanPoissonSampler
private final UniformRandomProvider rng;

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
* @param mean Mean.
* @throws IllegalArgumentException if {@code mean <= 0} or {@code Math.exp(-mean) == 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public class ZigguratNormalizedGaussianSampler
}

/**
* Create an instance.
*
* @param rng Generator of uniformly distributed random numbers.
*/
public ZigguratNormalizedGaussianSampler(UniformRandomProvider rng) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ public UnitBallSampler withUniformRandomProvider(UniformRandomProvider rng) {
}
}

/**
* Create an instance.
*/
public UnitBallSampler() {}

/**
* @return a random Cartesian coordinate within the unit n-ball.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ protected int next(int n) {
}

/**
* Serialization method.
*
* @param output Output stream.
* @throws IOException if an error occurs.
*/
Expand All @@ -115,6 +117,8 @@ private void writeObject(ObjectOutputStream output)
}

/**
* Deserialization method.
*
* @param input Input stream.
* @throws IOException if an error occurs.
* @throws ClassNotFoundException if an error occurs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* @since 1.0
*/
public class ByteArray2IntArray implements SeedConverter<byte[], int[]> {
/** Create an instance. */
public ByteArray2IntArray() {}

/** {@inheritDoc} */
@Override
public int[] convert(byte[] seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* @since 1.0
*/
public class ByteArray2LongArray implements SeedConverter<byte[], long[]> {
/** Create an instance. */
public ByteArray2LongArray() {}

/** {@inheritDoc} */
@Override
public long[] convert(byte[] seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* @since 1.0
*/
public class Int2Long implements SeedConverter<Integer, Long> {
/** Create an instance. */
public Int2Long() {}

/** {@inheritDoc} */
@Override
public Long convert(Integer seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* @since 1.0
*/
public class IntArray2Int implements SeedConverter<int[], Integer> {
/** Create an instance. */
public IntArray2Int() {}

/** {@inheritDoc} */
@Override
public Integer convert(int[] seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
* @since 1.0
*/
public class IntArray2LongArray implements SeedConverter<int[], long[]> {
/** Create an instance. */
public IntArray2LongArray() {}

/** {@inheritDoc} */
@Override
public long[] convert(int[] seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
* @since 1.0
*/
public class Long2Int implements SeedConverter<Long, Integer> {
/** Create an instance. */
public Long2Int() {}

/** {@inheritDoc} */
@SuppressWarnings("deprecation")
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class Long2IntArray implements Seed2ArrayConverter<Long, int[]> {
private final int size;

/**
* Create an instance.
*
* @param size Size of the output array.
*/
public Long2IntArray(int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class Long2LongArray implements Seed2ArrayConverter<Long, long[]> {
private final int size;

/**
* Create an instance.
*
* @param size Size of the output array.
*/
public Long2LongArray(int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
* @since 1.0
*/
public class LongArray2IntArray implements SeedConverter<long[], int[]> {
/** Create an instance. */
public LongArray2IntArray() {}

/** {@inheritDoc} */
@Override
public int[] convert(long[] seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* @since 1.0
*/
public class LongArray2Long implements SeedConverter<long[], Long> {
/** Create an instance. */
public LongArray2Long() {}

/** {@inheritDoc} */
@Override
public Long convert(long[] seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
* @since 1.0
*/
public class NoOpConverter<SEED> implements SeedConverter<SEED, SEED> {
/** Create an instance. */
public NoOpConverter() {}

/** {@inheritDoc} */
@Override
public SEED convert(SEED seed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class SeedConverterComposer<IN, TRANS, OUT> implements SeedConverter<IN,
private final SeedConverter<TRANS, OUT> second;

/**
* Create an instance.
*
* @param first First conversion.
* @param second second conversion.
*/
Expand Down

0 comments on commit 17145e8

Please sign in to comment.