org.apache.commons.math3.exception.MathIllegalStateException Java Examples

The following examples show how to use org.apache.commons.math3.exception.MathIllegalStateException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ValueServer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the next generated value, generated according
 * to the mode value (see MODE constants).
 *
 * @return generated value
 * @throws IOException in REPLAY_MODE if a file I/O error occurs
 * @throws MathIllegalStateException if mode is not recognized
 * @throws MathIllegalArgumentException if the underlying random generator thwrows one
 */
public double getNext() throws IOException, MathIllegalStateException, MathIllegalArgumentException {
    switch (mode) {
        case DIGEST_MODE: return getNextDigest();
        case REPLAY_MODE: return getNextReplay();
        case UNIFORM_MODE: return getNextUniform();
        case EXPONENTIAL_MODE: return getNextExponential();
        case GAUSSIAN_MODE: return getNextGaussian();
        case CONSTANT_MODE: return mu;
        default: throw new MathIllegalStateException(
                LocalizedFormats.UNKNOWN_MODE,
                mode,
                "DIGEST_MODE",   DIGEST_MODE,   "REPLAY_MODE",      REPLAY_MODE,
                "UNIFORM_MODE",  UNIFORM_MODE,  "EXPONENTIAL_MODE", EXPONENTIAL_MODE,
                "GAUSSIAN_MODE", GAUSSIAN_MODE, "CONSTANT_MODE",    CONSTANT_MODE);
    }
}
 
Example #2
Source File: RootsOfUnity.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the real part of the {@code k}-th {@code n}-th root of unity.
 *
 * @param k index of the {@code n}-th root of unity
 * @return real part of the {@code k}-th {@code n}-th root of unity
 * @throws MathIllegalStateException if no roots of unity have been
 * computed yet
 * @throws MathIllegalArgumentException if {@code k} is out of range
 */
public synchronized double getReal(int k)
        throws MathIllegalStateException, MathIllegalArgumentException {

    if (omegaCount == 0) {
        throw new MathIllegalStateException(
                LocalizedFormats.ROOTS_OF_UNITY_NOT_COMPUTED_YET);
    }
    if ((k < 0) || (k >= omegaCount)) {
        throw new OutOfRangeException(
                LocalizedFormats.OUT_OF_RANGE_ROOT_OF_UNITY_INDEX,
                Integer.valueOf(k),
                Integer.valueOf(0),
                Integer.valueOf(omegaCount - 1));
    }

    return omegaReal[k];
}
 
Example #3
Source File: DescriptiveStatistics.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generates a text report displaying univariate statistics from values
 * that have been added.  Each statistic is displayed on a separate
 * line.
 *
 * @return String with line feeds displaying statistics
 */
@Override
public String toString() {
    StringBuilder outBuffer = new StringBuilder();
    String endl = "\n";
    outBuffer.append("DescriptiveStatistics:").append(endl);
    outBuffer.append("n: ").append(getN()).append(endl);
    outBuffer.append("min: ").append(getMin()).append(endl);
    outBuffer.append("max: ").append(getMax()).append(endl);
    outBuffer.append("mean: ").append(getMean()).append(endl);
    outBuffer.append("std dev: ").append(getStandardDeviation())
        .append(endl);
    try {
        // No catch for MIAE because actual parameter is valid below
        outBuffer.append("median: ").append(getPercentile(50)).append(endl);
    } catch (MathIllegalStateException ex) {
        outBuffer.append("median: unavailable").append(endl);
    }
    outBuffer.append("skewness: ").append(getSkewness()).append(endl);
    outBuffer.append("kurtosis: ").append(getKurtosis()).append(endl);
    return outBuffer.toString();
}
 
Example #4
Source File: ValueServer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the next generated value, generated according
 * to the mode value (see MODE constants).
 *
 * @return generated value
 * @throws IOException in REPLAY_MODE if a file I/O error occurs
 */
public double getNext() throws IOException {
    switch (mode) {
        case DIGEST_MODE: return getNextDigest();
        case REPLAY_MODE: return getNextReplay();
        case UNIFORM_MODE: return getNextUniform();
        case EXPONENTIAL_MODE: return getNextExponential();
        case GAUSSIAN_MODE: return getNextGaussian();
        case CONSTANT_MODE: return mu;
        default: throw new MathIllegalStateException(
                LocalizedFormats.UNKNOWN_MODE,
                mode,
                "DIGEST_MODE",   DIGEST_MODE,   "REPLAY_MODE",      REPLAY_MODE,
                "UNIFORM_MODE",  UNIFORM_MODE,  "EXPONENTIAL_MODE", EXPONENTIAL_MODE,
                "GAUSSIAN_MODE", GAUSSIAN_MODE, "CONSTANT_MODE",    CONSTANT_MODE);
    }
}
 
Example #5
Source File: AbstractLinearOptimizer.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
public PointValuePair optimize(final LinearObjectiveFunction f,
                               final Collection<LinearConstraint> constraints,
                               final GoalType goalType, final boolean restrictToNonNegative)
    throws MathIllegalStateException {

    // store linear problem characteristics
    this.function          = f;
    this.linearConstraints = constraints;
    this.goal              = goalType;
    this.nonNegative       = restrictToNonNegative;

    iterations  = 0;

    // solve the problem
    return doOptimize();

}
 
Example #6
Source File: DescriptiveStatistics.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns an estimate for the pth percentile of the stored values.
 * <p>
 * The implementation provided here follows the first estimation procedure presented
 * <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm">here.</a>
 * </p><p>
 * <strong>Preconditions</strong>:<ul>
 * <li><code>0 &lt; p &le; 100</code> (otherwise an
 * <code>MathIllegalArgumentException</code> is thrown)</li>
 * <li>at least one value must be stored (returns <code>Double.NaN
 *     </code> otherwise)</li>
 * </ul></p>
 *
 * @param p the requested percentile (scaled from 0 - 100)
 * @return An estimate for the pth percentile of the stored data
 * @throws MathIllegalStateException if percentile implementation has been
 *  overridden and the supplied implementation does not support setQuantile
 * @throws MathIllegalArgumentException if p is not a valid quantile
 */
public double getPercentile(double p) throws MathIllegalStateException, MathIllegalArgumentException {
    if (percentileImpl instanceof Percentile) {
        ((Percentile) percentileImpl).setQuantile(p);
    } else {
        try {
            percentileImpl.getClass().getMethod(SET_QUANTILE_METHOD_NAME,
                    new Class[] {Double.TYPE}).invoke(percentileImpl,
                            new Object[] {Double.valueOf(p)});
        } catch (NoSuchMethodException e1) { // Setter guard should prevent
            throw new MathIllegalStateException(
                  LocalizedFormats.PERCENTILE_IMPLEMENTATION_UNSUPPORTED_METHOD,
                  percentileImpl.getClass().getName(), SET_QUANTILE_METHOD_NAME);
        } catch (IllegalAccessException e2) {
            throw new MathIllegalStateException(
                  LocalizedFormats.PERCENTILE_IMPLEMENTATION_CANNOT_ACCESS_METHOD,
                  SET_QUANTILE_METHOD_NAME, percentileImpl.getClass().getName());
        } catch (InvocationTargetException e3) {
            throw new IllegalStateException(e3.getCause());
        }
    }
    return apply(percentileImpl);
}
 
Example #7
Source File: RootsOfUnity.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the real part of the {@code k}-th {@code n}-th root of unity.
 *
 * @param k index of the {@code n}-th root of unity
 * @return real part of the {@code k}-th {@code n}-th root of unity
 * @throws MathIllegalStateException if no roots of unity have been
 * computed yet
 * @throws MathIllegalArgumentException if {@code k} is out of range
 */
public synchronized double getReal(int k)
        throws MathIllegalStateException, MathIllegalArgumentException {

    if (omegaCount == 0) {
        throw new MathIllegalStateException(
                LocalizedFormats.ROOTS_OF_UNITY_NOT_COMPUTED_YET);
    }
    if ((k < 0) || (k >= omegaCount)) {
        throw new OutOfRangeException(
                LocalizedFormats.OUT_OF_RANGE_ROOT_OF_UNITY_INDEX,
                Integer.valueOf(k),
                Integer.valueOf(0),
                Integer.valueOf(omegaCount - 1));
    }

    return omegaReal[k];
}
 
Example #8
Source File: RootsOfUnity.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the real part of the {@code k}-th {@code n}-th root of unity.
 *
 * @param k index of the {@code n}-th root of unity
 * @return real part of the {@code k}-th {@code n}-th root of unity
 * @throws MathIllegalStateException if no roots of unity have been
 * computed yet
 * @throws MathIllegalArgumentException if {@code k} is out of range
 */
public synchronized double getReal(int k)
        throws MathIllegalStateException, MathIllegalArgumentException {

    if (omegaCount == 0) {
        throw new MathIllegalStateException(
                LocalizedFormats.ROOTS_OF_UNITY_NOT_COMPUTED_YET);
    }
    if ((k < 0) || (k >= omegaCount)) {
        throw new OutOfRangeException(
                LocalizedFormats.OUT_OF_RANGE_ROOT_OF_UNITY_INDEX,
                Integer.valueOf(k),
                Integer.valueOf(0),
                Integer.valueOf(omegaCount - 1));
    }

    return omegaReal[k];
}
 
Example #9
Source File: EmpiricalDistribution.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generates a random value from this distribution.
 * <strong>Preconditions:</strong><ul>
 * <li>the distribution must be loaded before invoking this method</li></ul>
 * @return the random value.
 * @throws MathIllegalStateException if the distribution has not been loaded
 */
public double getNextValue() throws MathIllegalStateException {

    if (!loaded) {
        throw new MathIllegalStateException(LocalizedFormats.DISTRIBUTION_NOT_LOADED);
    }

    // Start with a uniformly distributed random number in (0,1)
    double x = randomData.nextUniform(0,1);

    // Use this to select the bin and generate a Gaussian within the bin
    for (int i = 0; i < binCount; i++) {
       if (x <= upperBounds[i]) {
           SummaryStatistics stats = binStats.get(i);
           if (stats.getN() > 0) {
               if (stats.getStandardDeviation() > 0) {  // more than one obs
                    return randomData.nextGaussian
                        (stats.getMean(),stats.getStandardDeviation());
               } else {
                   return stats.getMean(); // only one obs in bin
               }
           }
       }
    }
    throw new MathIllegalStateException(LocalizedFormats.NO_BIN_SELECTED);
}
 
Example #10
Source File: GeometricMean.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Throws MathIllegalStateException if n > 0.
 * @throws MathIllegalStateException if data has been added to this statistic
 */
private void checkEmpty() throws MathIllegalStateException {
    if (getN() > 0) {
        throw new MathIllegalStateException(
                LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC,
                getN());
    }
}
 
Example #11
Source File: NonLinearConjugateGradientOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Finds the upper bound b ensuring bracketing of a root between a and b.
 *
 * @param f function whose root must be bracketed.
 * @param a lower bound of the interval.
 * @param h initial step to try.
 * @return b such that f(a) and f(b) have opposite signs.
 * @throws MathIllegalStateException if no bracket can be found.
 */
private double findUpperBound(final UnivariateFunction f,
                              final double a, final double h) {
    final double yA = f.value(a);
    double yB = yA;
    for (double step = h; step < Double.MAX_VALUE; step *= FastMath.max(2, yA / yB)) {
        final double b = a + step;
        yB = f.value(b);
        if (yA * yB <= 0) {
            return b;
        }
    }
    throw new MathIllegalStateException(LocalizedFormats.UNABLE_TO_BRACKET_OPTIMUM_IN_LINE_SEARCH);
}
 
Example #12
Source File: EdgesBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Get the edge that should naturally follow another one.
 * @param previous edge to be continued
 * @return other edge, starting where the previous one ends (they
 * have not been connected yet)
 * @exception MathIllegalStateException if there is not a single other edge
 */
private Edge getFollowingEdge(final Edge previous)
    throws MathIllegalStateException {

    // get the candidate nodes
    final S2Point point = previous.getEnd().getLocation();
    final List<BSPTree<Sphere2D>> candidates = root.getCloseCuts(point, tolerance);

    // the following edge we are looking for must start from one of the candidates nodes
    double closest = tolerance;
    Edge following = null;
    for (final BSPTree<Sphere2D> node : candidates) {
        for (final Edge edge : nodeToEdgesList.get(node)) {
            if (edge != previous && edge.getStart().getIncoming() == null) {
                final Vector3D edgeStart = edge.getStart().getLocation().getVector();
                final double gap         = Vector3D.angle(point.getVector(), edgeStart);
                if (gap <= closest) {
                    closest   = gap;
                    following = edge;
                }
            }
        }
    }

    if (following == null) {
        final Vector3D previousStart = previous.getStart().getLocation().getVector();
        if (Vector3D.angle(point.getVector(), previousStart) <= tolerance) {
            // the edge connects back to itself
            return previous;
        }

        // this should never happen
        throw new MathIllegalStateException(LocalizedFormats.OUTLINE_BOUNDARY_LOOP_OPEN);

    }

    return following;

}
 
Example #13
Source File: Math_6_NonLinearConjugateGradientOptimizer_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Finds the upper bound b ensuring bracketing of a root between a and b.
 *
 * @param f function whose root must be bracketed.
 * @param a lower bound of the interval.
 * @param h initial step to try.
 * @return b such that f(a) and f(b) have opposite signs.
 * @throws MathIllegalStateException if no bracket can be found.
 */
private double findUpperBound(final UnivariateFunction f,
                              final double a, final double h) {
    final double yA = f.value(a);
    double yB = yA;
    for (double step = h; step < Double.MAX_VALUE; step *= FastMath.max(2, yA / yB)) {
        final double b = a + step;
        yB = f.value(b);
        if (yA * yB <= 0) {
            return b;
        }
    }
    throw new MathIllegalStateException(LocalizedFormats.UNABLE_TO_BRACKET_OPTIMUM_IN_LINE_SEARCH);
}
 
Example #14
Source File: MultivariateSummaryStatistics.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Throws MathIllegalStateException if the statistic is not empty.
 * @throws MathIllegalStateException if n > 0.
 */
private void checkEmpty() throws MathIllegalStateException {
    if (n > 0) {
        throw new MathIllegalStateException(
                LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC, n);
    }
}
 
Example #15
Source File: Array2DRowFieldMatrix.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void setSubMatrix(final T[][] subMatrix, final int row,
                         final int column)
    throws OutOfRangeException, NullArgumentException, NoDataException,
    DimensionMismatchException {
    if (data == null) {
        if (row > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
        }
        if (column > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
        }
        final int nRows = subMatrix.length;
        if (nRows == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }

        final int nCols = subMatrix[0].length;
        if (nCols == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }
        data = MathArrays.buildArray(getField(), subMatrix.length, nCols);
        for (int i = 0; i < data.length; ++i) {
            if (subMatrix[i].length != nCols) {
                throw new DimensionMismatchException(nCols, subMatrix[i].length);
            }
            System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
        }
    } else {
        super.setSubMatrix(subMatrix, row, column);
    }

}
 
Example #16
Source File: GeometricMean.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Throws MathIllegalStateException if n > 0.
 * @throws MathIllegalStateException if data has been added to this statistic
 */
private void checkEmpty() throws MathIllegalStateException {
    if (getN() > 0) {
        throw new MathIllegalStateException(
                LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC,
                getN());
    }
}
 
Example #17
Source File: MultiStartUnivariateOptimizerTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test(expected=MathIllegalStateException.class)
public void testMissingMaxEval() {
    UnivariateOptimizer underlying = new BrentOptimizer(1e-10, 1e-14);
    JDKRandomGenerator g = new JDKRandomGenerator();
    g.setSeed(44428400075l);
    MultiStartUnivariateOptimizer optimizer = new MultiStartUnivariateOptimizer(underlying, 10, g);
    optimizer.optimize(new UnivariateObjectiveFunction(new Sin()),
                       GoalType.MINIMIZE,
                       new SearchInterval(-1, 1));
}
 
Example #18
Source File: Kurtosis.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void increment(final double d) {
    if (incMoment) {
        moment.increment(d);
    }  else  {
        throw new MathIllegalStateException(LocalizedFormats.CANNOT_INCREMENT_STATISTIC_CONSTRUCTED_FROM_EXTERNAL_MOMENTS);
    }
}
 
Example #19
Source File: EdgesBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Get the boundary edges.
 * @return boundary edges
 * @exception MathIllegalStateException if there is not a single other edge
 */
public List<Edge> getEdges() throws MathIllegalStateException {

    // connect the edges
    for (final Edge previous : edgeToNode.keySet()) {
        previous.setNextEdge(getFollowingEdge(previous));
    }

    return new ArrayList<Edge>(edgeToNode.keySet());

}
 
Example #20
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Substitutes <code>value</code> for the most recently added value.
 * Returns the value that has been replaced. If the array is empty (i.e.
 * if {@link #numElements} is zero), an IllegalStateException is thrown.
 *
 * @param value New value to substitute for the most recently added value
 * @return the value that has been replaced in the array.
 * @throws MathIllegalStateException if the array is empty
 * @since 2.0
 */
public synchronized double substituteMostRecentElement(double value)
    throws MathIllegalStateException {
    if (numElements < 1) {
        throw new MathIllegalStateException(
                LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
    }

    final int substIndex = startIndex + (numElements - 1);
    final double discarded = internalArray[substIndex];

    internalArray[substIndex] = value;

    return discarded;
}
 
Example #21
Source File: DescriptiveStatistics.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Removes the most recent value from the dataset.
 *
 * @throws MathIllegalStateException if there are no elements stored
 */
public void removeMostRecentValue() throws MathIllegalStateException {
    try {
        eDA.discardMostRecentElements(1);
    } catch (MathIllegalArgumentException ex) {
        throw new MathIllegalStateException(LocalizedFormats.NO_DATA);
    }
}
 
Example #22
Source File: NonLinearConjugateGradientOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find the upper bound b ensuring bracketing of a root between a and b.
 *
 * @param f function whose root must be bracketed.
 * @param a lower bound of the interval.
 * @param h initial step to try.
 * @return b such that f(a) and f(b) have opposite signs.
 * @throws MathIllegalStateException if no bracket can be found.
 */
private double findUpperBound(final UnivariateFunction f,
                              final double a, final double h) {
    final double yA = f.value(a);
    double yB = yA;
    for (double step = h; step < Double.MAX_VALUE; step *= FastMath.max(2, yA / yB)) {
        final double b = a + step;
        yB = f.value(b);
        if (yA * yB <= 0) {
            return b;
        }
    }
    throw new MathIllegalStateException(LocalizedFormats.UNABLE_TO_BRACKET_OPTIMUM_IN_LINE_SEARCH);
}
 
Example #23
Source File: PolynomialSplineFunctionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
*  Do linear search to find largest knot point less than or equal to x.
*  Implementation does binary search.
*/
protected int findKnot(double[] knots, double x) {
    if (x < knots[0] || x >= knots[knots.length -1]) {
        throw new OutOfRangeException(x, knots[0], knots[knots.length -1]);
    }
    for (int i = 0; i < knots.length; i++) {
        if (knots[i] > x) {
            return i - 1;
        }
    }
    throw new MathIllegalStateException();
}
 
Example #24
Source File: NonLinearConjugateGradientOptimizer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find the upper bound b ensuring bracketing of a root between a and b.
 *
 * @param f function whose root must be bracketed.
 * @param a lower bound of the interval.
 * @param h initial step to try.
 * @return b such that f(a) and f(b) have opposite signs.
 * @throws MathIllegalStateException if no bracket can be found.
 */
private double findUpperBound(final UnivariateFunction f,
                              final double a, final double h) {
    final double yA = f.value(a);
    double yB = yA;
    for (double step = h; step < Double.MAX_VALUE; step *= FastMath.max(2, yA / yB)) {
        final double b = a + step;
        yB = f.value(b);
        if (yA * yB <= 0) {
            return b;
        }
    }
    throw new MathIllegalStateException(LocalizedFormats.UNABLE_TO_BRACKET_OPTIMUM_IN_LINE_SEARCH);
}
 
Example #25
Source File: GeometricMean.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Throws IllegalStateException if n > 0.
 */
private void checkEmpty() {
    if (getN() > 0) {
        throw new MathIllegalStateException(
                LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC,
                getN());
    }
}
 
Example #26
Source File: ResizableDoubleArray.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Substitutes <code>value</code> for the most recently added value.
 * Returns the value that has been replaced. If the array is empty (i.e.
 * if {@link #numElements} is zero), an IllegalStateException is thrown.
 *
 * @param value new value to substitute for the most recently added value
 * @return value that has been replaced in the array
 * @throws MathIllegalStateException if the array is empty
 * @since 2.0
 */
public synchronized double substituteMostRecentElement(double value) throws MathIllegalStateException {
    if (numElements < 1) {
        throw new MathIllegalStateException(
                LocalizedFormats.CANNOT_SUBSTITUTE_ELEMENT_FROM_EMPTY_ARRAY);
    }

    double discarded = internalArray[startIndex + (numElements - 1)];

    internalArray[startIndex + (numElements - 1)] = value;

    return discarded;
}
 
Example #27
Source File: Array2DRowRealMatrix.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void setSubMatrix(final double[][] subMatrix, final int row,
                         final int column)
    throws NoDataException, OutOfRangeException,
    DimensionMismatchException, NullArgumentException {
    if (data == null) {
        if (row > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_ROWS_NOT_INITIALIZED_YET, row);
        }
        if (column > 0) {
            throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
        }
        MathUtils.checkNotNull(subMatrix);
        final int nRows = subMatrix.length;
        if (nRows == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }

        final int nCols = subMatrix[0].length;
        if (nCols == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }
        data = new double[subMatrix.length][nCols];
        for (int i = 0; i < data.length; ++i) {
            if (subMatrix[i].length != nCols) {
                throw new DimensionMismatchException(subMatrix[i].length, nCols);
            }
            System.arraycopy(subMatrix[i], 0, data[i + row], column, nCols);
        }
    } else {
        super.setSubMatrix(subMatrix, row, column);
    }

}
 
Example #28
Source File: GeometricMean.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Throws MathIllegalStateException if n > 0.
 * @throws MathIllegalStateException if data has been added to this statistic
 */
private void checkEmpty() throws MathIllegalStateException {
    if (getN() > 0) {
        throw new MathIllegalStateException(
                LocalizedFormats.VALUES_ADDED_BEFORE_CONFIGURING_STATISTIC,
                getN());
    }
}
 
Example #29
Source File: SynchronizedSummaryStatistics.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public synchronized void setMeanImpl(StorelessUnivariateStatistic meanImpl)
throws MathIllegalStateException {
    super.setMeanImpl(meanImpl);
}
 
Example #30
Source File: SynchronizedSummaryStatistics.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public synchronized void setMeanImpl(StorelessUnivariateStatistic meanImpl)
throws MathIllegalStateException {
    super.setMeanImpl(meanImpl);
}