/** {@inheritDoc} */ public double value(double x) { return FastMath.ceil(x); } }
/** {@inheritDoc} * @since 3.2 */ public Decimal64 ceil() { return new Decimal64(FastMath.ceil(value)); }
/** * {@inheritDoc}This method in particular for R_1 uses ceil(pos-0.5) */ @Override protected double estimate(final double[] values, final int[] pivotsHeap, final double pos, final int length, final KthSelector selector) { return super.estimate(values, pivotsHeap, FastMath.ceil(pos - 0.5), length, selector); }
/** {@inheritDoc} */ public SparseGradient ceil() { return createConstant(FastMath.ceil(value)); }
/** * Compute the capacity needed for a given size. * @param expectedSize expected size of the map * @return capacity to use for the specified size */ private static int computeCapacity(final int expectedSize) { if (expectedSize == 0) { return 1; } final int capacity = (int) FastMath.ceil(expectedSize / LOAD_FACTOR); final int powerOfTwo = Integer.highestOneBit(capacity); if (powerOfTwo == capacity) { return capacity; } return nextPowerOfTwo(capacity); }
/** * Compute the capacity needed for a given size. * @param expectedSize expected size of the map * @return capacity to use for the specified size */ private static int computeCapacity(final int expectedSize) { if (expectedSize == 0) { return 1; } final int capacity = (int) FastMath.ceil(expectedSize / LOAD_FACTOR); final int powerOfTwo = Integer.highestOneBit(capacity); if (powerOfTwo == capacity) { return capacity; } return nextPowerOfTwo(capacity); }
/** * Given a d-statistic in the range [0, 1] and the two sample sizes n and m, * an integral d-statistic in the range [0, n*m] is calculated, that can be used for * comparison with other integral d-statistics. Depending whether {@code strict} is * {@code true} or not, the returned value divided by (n*m) is greater than * (resp greater than or equal to) the given d value (allowing some tolerance). * * @param d a d-statistic in the range [0, 1] * @param n first sample size * @param m second sample size * @param strict whether the returned value divided by (n*m) is allowed to be equal to d * @return the integral d-statistic in the range [0, n*m] */ private static long calculateIntegralD(double d, int n, int m, boolean strict) { final double tol = 1e-12; // d-values within tol of one another are considered equal long nm = n * (long)m; long upperBound = (long)FastMath.ceil((d - tol) * nm); long lowerBound = (long)FastMath.floor((d + tol) * nm); if (strict && lowerBound == upperBound) { return upperBound + 1l; } else { return upperBound; } }
/** * Expands the internal storage array using the expansion factor. * <p> * if <code>expansionMode</code> is set to MULTIPLICATIVE_MODE, * the new array size will be <code>internalArray.length * expansionFactor.</code> * If <code>expansionMode</code> is set to ADDITIVE_MODE, the length * after expansion will be <code>internalArray.length + expansionFactor</code> * </p> */ protected synchronized void expand() { // notice the use of FastMath.ceil(), this guarantees that we will always // have an array of at least currentSize + 1. Assume that the // current initial capacity is 1 and the expansion factor // is 1.000000000000000001. The newly calculated size will be // rounded up to 2 after the multiplication is performed. int newSize = 0; if (expansionMode == ExpansionMode.MULTIPLICATIVE) { newSize = (int) FastMath.ceil(internalArray.length * expansionFactor); } else { newSize = (int) (internalArray.length + FastMath.round(expansionFactor)); } final double[] tempArray = new double[newSize]; // Copy and swap System.arraycopy(internalArray, 0, tempArray, 0, internalArray.length); internalArray = tempArray; }
/** * Returns the index of the bin to which the given value belongs * * @param value the value whose bin we are trying to find * @return the index of the bin containing the value */ private int findBin(double value) { return FastMath.min( FastMath.max((int) FastMath.ceil((value - min) / delta) - 1, 0), binCount - 1); }
/** * Return the ceiling value of the given complex number * * @param num the number to getScalar the absolute value for * @return the absolute value of this complex number */ public static IComplexNumber ceil(IComplexNumber num) { Complex c = new Complex(FastMath.ceil(num.realComponent().doubleValue()), FastMath.ceil(num.imaginaryComponent().doubleValue())); return Nd4j.createDouble(c.getReal(), c.getImaginary()); }
/** {@inheritDoc} * @since 3.2 */ public DerivativeStructure ceil() { return new DerivativeStructure(compiler.getFreeParameters(), compiler.getOrder(), FastMath.ceil(data[0])); }
/** * {@inheritDoc}This method in particular for R_2 averages the * values at ceil(p+0.5) and floor(p-0.5). */ @Override protected double estimate(final double[] values, final int[] pivotsHeap, final double pos, final int length, final KthSelector selector) { final double low = super.estimate(values, pivotsHeap, FastMath.ceil(pos - 0.5), length, selector); final double high = super.estimate(values, pivotsHeap,FastMath.floor(pos + 0.5), length, selector); return (low + high) / 2; }
/** * Start the population for the next generation. The <code>{@link #elitismRate}</code> * percents of the best chromosomes are directly copied to the next generation. * * @return the beginnings of the next generation. */ public Population nextGeneration() { // initialize a new generation with the same parameters ElitisticListPopulation nextGeneration = new ElitisticListPopulation(getPopulationLimit(), getElitismRate()); final List<Chromosome> oldChromosomes = getChromosomeList(); Collections.sort(oldChromosomes); // index of the last "not good enough" chromosome int boundIndex = (int) FastMath.ceil((1.0 - getElitismRate()) * oldChromosomes.size()); for (int i = boundIndex; i < oldChromosomes.size(); i++) { nextGeneration.addChromosome(oldChromosomes.get(i)); } return nextGeneration; }
/** * Calculates the exact value of {@code P(D_n < d)} using method described * in [1] and {@link org.apache.commons.math3.fraction.BigFraction} (see * above). * * @param d statistic * @return the two-sided probability of {@code P(D_n < d)} * @throws MathArithmeticException if algorithm fails to convert {@code h} * to a {@link org.apache.commons.math3.fraction.BigFraction} in expressing * {@code d} as {@code (k - h) / m} for integer {@code k, m} and * {@code 0 <= h < 1}. */ private double exactK(double d) throws MathArithmeticException { final int k = (int) FastMath.ceil(n * d); final FieldMatrix<BigFraction> H = this.createH(d); final FieldMatrix<BigFraction> Hpower = H.power(n); BigFraction pFrac = Hpower.getEntry(k - 1, k - 1); for (int i = 1; i <= n; ++i) { pFrac = pFrac.multiply(i).divide(n); } /* * BigFraction.doubleValue converts numerator to double and the * denominator to double and divides afterwards. That gives NaN quite * easy. This does not (scale is the number of digits): */ return pFrac.bigDecimalValue(20, BigDecimal.ROUND_HALF_UP).doubleValue(); }
unscaled = FastMath.floor(FastMath.nextAfter(unscaled, Double.NEGATIVE_INFINITY)); } else { unscaled = FastMath.ceil(FastMath.nextAfter(unscaled, Double.POSITIVE_INFINITY)); case BigDecimal.ROUND_FLOOR : if (sign == -1) { unscaled = FastMath.ceil(FastMath.nextAfter(unscaled, Double.POSITIVE_INFINITY)); } else { unscaled = FastMath.floor(FastMath.nextAfter(unscaled, Double.NEGATIVE_INFINITY)); double fraction = unscaled - FastMath.floor(unscaled); if (fraction > 0.5) { unscaled = FastMath.ceil(unscaled); } else { unscaled = FastMath.floor(unscaled); double fraction = unscaled - FastMath.floor(unscaled); if (fraction > 0.5) { unscaled = FastMath.ceil(unscaled); } else if (fraction < 0.5) { unscaled = FastMath.floor(unscaled); unscaled = FastMath.floor(unscaled); } else { // odd unscaled = FastMath.ceil(unscaled); double fraction = unscaled - FastMath.floor(unscaled); if (fraction >= 0.5) { unscaled = FastMath.ceil(unscaled);
final int k = (int) FastMath.ceil(n * d); final FieldMatrix<BigFraction> HBigFraction = this.createH(d); final int m = HBigFraction.getRowDimension();
throws NumberIsTooLargeException, FractionConversionException { int k = (int) FastMath.ceil(n * d);
final int n = FastMath.max(1, (int) FastMath.ceil(FastMath.abs(dt.getReal()) / maxCheckInterval)); final T h = dt.divide(n);