Precondition check.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1374054 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7994d3ee9d
commit
b1741d1b46
|
@ -19,6 +19,8 @@ package org.apache.commons.math3.analysis.integration.gauss;
|
|||
import java.math.MathContext;
|
||||
import java.math.BigDecimal;
|
||||
import org.apache.commons.math3.util.Pair;
|
||||
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
|
||||
/**
|
||||
* Factory that creates Gauss-type quadrature rule using Legendre polynomials.
|
||||
|
@ -63,6 +65,11 @@ public class LegendreHighPrecisionRuleFactory extends BaseRuleFactory<BigDecimal
|
|||
*/
|
||||
@Override
|
||||
protected Pair<BigDecimal[], BigDecimal[]> computeRule(int numberOfPoints) {
|
||||
if (numberOfPoints <= 0) {
|
||||
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_POINTS,
|
||||
numberOfPoints);
|
||||
}
|
||||
|
||||
if (numberOfPoints == 1) {
|
||||
// Break recursion.
|
||||
return new Pair<BigDecimal[], BigDecimal[]>(new BigDecimal[] { BigDecimal.ZERO },
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
package org.apache.commons.math3.analysis.integration.gauss;
|
||||
|
||||
import org.apache.commons.math3.util.Pair;
|
||||
import org.apache.commons.math3.exception.NotStrictlyPositiveException;
|
||||
import org.apache.commons.math3.exception.util.LocalizedFormats;
|
||||
|
||||
/**
|
||||
* Factory that creates Gauss-type quadrature rule using Legendre polynomials.
|
||||
|
@ -35,6 +37,11 @@ public class LegendreRuleFactory extends BaseRuleFactory<Double> {
|
|||
*/
|
||||
@Override
|
||||
protected Pair<Double[], Double[]> computeRule(int numberOfPoints) {
|
||||
if (numberOfPoints <= 0) {
|
||||
throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_POINTS,
|
||||
numberOfPoints);
|
||||
}
|
||||
|
||||
if (numberOfPoints == 1) {
|
||||
// Break recursion.
|
||||
return new Pair<Double[], Double[]>(new Double[] { 0d },
|
||||
|
|
Loading…
Reference in New Issue