/** {@inheritDoc} */ @Override public RealVector mapCeilToSelf() { for (int i = 0; i < data.length; i++) { data[i] = FastMath.ceil(data[i]); } return this; }
/** {@inheritDoc} */ @Override public double value(double d) { return FastMath.ceil(d); } };
/** * 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); }
/** * 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); }
/** * 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 == MULTIPLICATIVE_MODE) { newSize = (int) FastMath.ceil(internalArray.length * expansionFactor); } else { newSize = internalArray.length + FastMath.round(expansionFactor); } double[] tempArray = new double[newSize]; // Copy and swap System.arraycopy(internalArray, 0, tempArray, 0, internalArray.length); internalArray = tempArray; }
/** * 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(this.getPopulationLimit(), this.getElitismRate()); List<Chromosome> oldChromosomes = this.getChromosomes(); Collections.sort(oldChromosomes); // index of the last "not good enough" chromosome int boundIndex = (int) FastMath.ceil((1.0 - this.getElitismRate()) * oldChromosomes.size()); for (int i=boundIndex; i<oldChromosomes.size(); i++) { nextGeneration.addChromosome(oldChromosomes.get(i)); } return nextGeneration; }
unscaled = FastMath.floor(nextAfter(unscaled, Double.NEGATIVE_INFINITY)); } else { unscaled = FastMath.ceil(nextAfter(unscaled, Double.POSITIVE_INFINITY)); case BigDecimal.ROUND_FLOOR : if (sign == -1) { unscaled = FastMath.ceil(nextAfter(unscaled, Double.POSITIVE_INFINITY)); } else { unscaled = FastMath.floor(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 n = FastMath.max(1, (int) FastMath.ceil(FastMath.abs(dt) / maxCheckInterval)); final double h = dt / n;