Example usage for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_TOO_SMALL

List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_TOO_SMALL

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_TOO_SMALL.

Prototype

LocalizedFormats NUMBER_TOO_SMALL

To view the source code for org.apache.commons.math3.exception.util LocalizedFormats NUMBER_TOO_SMALL.

Click Source Link

Usage

From source file:org.orekit.utils.GenericTimeStampedCache.java

/** Simple constructor.
 * @param neighborsSize fixed size of the arrays to be returned by {@link
 * #getNeighbors(AbsoluteDate)}, must be at least 2
 * @param maxSlots maximum number of independent cached time slots
 * @param maxSpan maximum duration span in seconds of one slot
 * (can be set to {@code Double.POSITIVE_INFINITY} if desired)
 * @param newSlotInterval time interval above which a new slot is created
 * instead of extending an existing one//from   ww  w. j a v a 2 s .  c  o m
 * @param generator generator to use for yet non-existent data
 * @param entriesClass class of the cached entries
 */
public GenericTimeStampedCache(final int neighborsSize, final int maxSlots, final double maxSpan,
        final double newSlotInterval, final TimeStampedGenerator<T> generator, final Class<T> entriesClass) {

    // safety check
    if (maxSlots < 1) {
        throw new OrekitIllegalArgumentException(LocalizedFormats.NUMBER_TOO_SMALL, maxSlots, 1);
    }
    if (neighborsSize < 2) {
        throw new OrekitIllegalArgumentException(OrekitMessages.NOT_ENOUGH_CACHED_NEIGHBORS, neighborsSize, 2);
    }

    this.reference = new AtomicReference<AbsoluteDate>();
    this.maxSlots = maxSlots;
    this.maxSpan = maxSpan;
    this.newSlotQuantumGap = FastMath.round(newSlotInterval / QUANTUM_STEP);
    this.entriesClass = entriesClass;
    this.generator = generator;
    this.neighborsSize = neighborsSize;
    this.slots = new ArrayList<Slot>(maxSlots);
    this.getNeighborsCalls = new AtomicInteger(0);
    this.generateCalls = new AtomicInteger(0);
    this.evictions = new AtomicInteger(0);
    this.lock = new ReentrantReadWriteLock();

}

From source file:org.orekit.utils.ImmutableTimeStampedCache.java

/**
 * Create a new cache with the given neighbors size and data.
 *
 * @param neighborsSize the size of the list returned from
 *        {@link #getNeighbors(AbsoluteDate)}. Must be less than or equal to
 *        {@code data.size()}.// w w w .jav  a 2s  .  c  om
 * @param data the backing data for this cache. The list will be copied to
 *        ensure immutability. To guarantee immutability the entries in
 *        {@code data} must be immutable themselves. There must be more data
 *        than {@code neighborsSize}.
 * @throws IllegalArgumentException if {@code neightborsSize > data.size()}
 *         or if {@code neighborsSize} is negative
 */
public ImmutableTimeStampedCache(final int neighborsSize, final Collection<? extends T> data) {
    // parameter check
    if (neighborsSize > data.size()) {
        throw new OrekitIllegalArgumentException(OrekitMessages.NOT_ENOUGH_CACHED_NEIGHBORS, data.size(),
                neighborsSize);
    }
    if (neighborsSize < 1) {
        throw new OrekitIllegalArgumentException(LocalizedFormats.NUMBER_TOO_SMALL, neighborsSize, 0);
    }

    // assign instance variables
    this.neighborsSize = neighborsSize;
    // sort and copy data first
    this.data = new ArrayList<T>(data);
    Collections.sort(this.data, CMP);
}

From source file:org.pmad.gmm.MyMixMNDEM.java

/**
 * Creates an object to fit a multivariate normal mixture model to data.
 *
 * @param data Data to use in fitting procedure
 * @throws NotStrictlyPositiveException if data has no rows
 * @throws DimensionMismatchException if rows of data have different numbers
 *             of columns/*w  ww  .  j a  v a 2 s . c  o m*/
 * @throws NumberIsTooSmallException if the number of columns in the data is
 *             less than 2
 */
public MyMixMNDEM(double[][] data)
        throws NotStrictlyPositiveException, DimensionMismatchException, NumberIsTooSmallException {
    if (data.length < 1) {
        throw new NotStrictlyPositiveException(data.length);
    }

    this.data = new double[data.length][data[0].length];

    for (int i = 0; i < data.length; i++) {
        if (data[i].length != data[0].length) {
            // Jagged arrays not allowed
            throw new DimensionMismatchException(data[i].length, data[0].length);
        }
        if (data[i].length < 2) {
            throw new NumberIsTooSmallException(LocalizedFormats.NUMBER_TOO_SMALL, data[i].length, 2, true);
        }
        this.data[i] = MathArrays.copyOf(data[i], data[i].length);
    }
}