Author: erans
Date: Thu Aug 16 21:00:39 2012
New Revision: 1374054
URL: http://svn.apache.org/viewvc?rev=1374054&view=rev
Log:
Precondition check.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.java
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java?rev=1374054&r1=1374053&r2=1374054&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java
Thu Aug 16 21:00:39 2012
@@ -19,6 +19,8 @@ package org.apache.commons.math3.analysi
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 LegendreHighPrecisionRuleFa
*/
@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 },
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.java?rev=1374054&r1=1374053&r2=1374054&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/analysis/integration/gauss/LegendreRuleFactory.java
Thu Aug 16 21:00:39 2012
@@ -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
*/
@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 },