Populate "throws" clause.


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1382197 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2012-09-07 22:35:01 +00:00
parent ac597cc172
commit b8f2fb815f
3 changed files with 20 additions and 12 deletions

View File

@ -20,6 +20,7 @@ import java.util.Map;
import java.util.TreeMap;
import org.apache.commons.math3.util.Pair;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
/**
* Base class for rules that determines the integration nodes and their
@ -41,12 +42,15 @@ public abstract class BaseRuleFactory<T extends Number> {
= new TreeMap<Integer, Pair<double[], double[]>>();
/**
* Gets a copy of the quadrature rule with given number of integration points.
* Gets a copy of the quadrature rule with the given number of integration
* points.
*
* @param numberOfPoints Number of integration points.
* @return a copy of the integration rule.
* @throws NotStrictlyPositiveException if {@code numberOfPoints < 1}.
*/
public Pair<double[], double[]> getRule(int numberOfPoints) {
public Pair<double[], double[]> getRule(int numberOfPoints)
throws NotStrictlyPositiveException {
// Try to obtain the rule from the cache.
Pair<double[], double[]> cached = pointsAndWeightsDouble.get(numberOfPoints);
@ -74,8 +78,10 @@ public abstract class BaseRuleFactory<T extends Number> {
*
* @param numberOfPoints Order of the rule to be retrieved.
* @return the points and weights corresponding to the given order.
* @throws NotStrictlyPositiveException if {@code numberOfPoints < 1}.
*/
protected synchronized Pair<T[], T[]> getRuleInternal(int numberOfPoints) {
protected synchronized Pair<T[], T[]> getRuleInternal(int numberOfPoints)
throws NotStrictlyPositiveException {
final Pair<T[], T[]> rule = pointsAndWeights.get(numberOfPoints);
if (rule == null) {
addRule(computeRule(numberOfPoints));

View File

@ -18,6 +18,7 @@ package org.apache.commons.math3.analysis.integration.gauss;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.exception.DimensionMismatchException;
import org.apache.commons.math3.exception.NonMonotonicSequenceException;
import org.apache.commons.math3.util.MathArrays;
import org.apache.commons.math3.util.Pair;
@ -42,11 +43,12 @@ public class GaussIntegrator {
*
* @param points Integration points.
* @param weights Weights of the corresponding integration nodes.
* @throws org.apache.commons.math3.exception.NonMonotonicSequenceException
* if the {@code points} are not sorted in increasing order.
* @throws NonMonotonicSequenceException if the {@code points} are not
* sorted in increasing order.
*/
public GaussIntegrator(double[] points,
double[] weights) {
double[] weights)
throws NonMonotonicSequenceException {
if (points.length != weights.length) {
throw new DimensionMismatchException(points.length,
weights.length);
@ -63,12 +65,13 @@ public class GaussIntegrator {
* the pair) and weights (second element of the pair.
*
* @param pointsAndWeights Integration points and corresponding weights.
* @throws org.apache.commons.math3.exception.NonMonotonicSequenceException
* if the {@code points} are not sorted in increasing order.
* @throws NonMonotonicSequenceException if the {@code points} are not
* sorted in increasing order.
*
* @see #GaussIntegrator(double[], double[])
*/
public GaussIntegrator(Pair<double[], double[]> pointsAndWeights) {
public GaussIntegrator(Pair<double[], double[]> pointsAndWeights)
throws NonMonotonicSequenceException {
this(pointsAndWeights.getFirst(), pointsAndWeights.getSecond());
}

View File

@ -34,11 +34,10 @@ import org.apache.commons.math3.exception.util.LocalizedFormats;
public class LegendreRuleFactory extends BaseRuleFactory<Double> {
/**
* {@inheritDoc}
*
* @throws NotStrictlyPositiveException if {@code numberOfPoints < 1}.
*/
@Override
protected Pair<Double[], Double[]> computeRule(int numberOfPoints) {
protected Pair<Double[], Double[]> computeRule(int numberOfPoints)
throws NotStrictlyPositiveException {
if (numberOfPoints <= 0) {
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_POINTS,
numberOfPoints);