commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brentwor...@apache.org
Subject cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/analysis PolynomialSplineFunction.java
Date Fri, 23 Apr 2004 18:16:06 GMT
brentworden    2004/04/23 11:16:06

  Modified:    math/src/java/org/apache/commons/math/analysis
                        PolynomialSplineFunction.java
  Log:
  Fixed a TODO by addid a isStrictlyIncreasing method.  This can be refactored later into
a more reusable location.
  
  Revision  Changes    Path
  1.3       +20 -3     jakarta-commons/math/src/java/org/apache/commons/math/analysis/PolynomialSplineFunction.java
  
  Index: PolynomialSplineFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/analysis/PolynomialSplineFunction.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PolynomialSplineFunction.java	3 Apr 2004 03:05:33 -0000	1.2
  +++ PolynomialSplineFunction.java	23 Apr 2004 18:16:06 -0000	1.3
  @@ -86,8 +86,10 @@
               throw new IllegalArgumentException 
               ("Number of polynomial interpolants must match the number of segments.");
           }
  -        
  -        // TODO: check that knots is increasing
  +        if (!isStrictlyIncreasing(knots)) {
  +            throw new IllegalArgumentException 
  +                ("Knot values must be strictly increasing.");
  +        }
           
           this.n = knots.length -1;
           this.knots = new double[n + 1];
  @@ -174,4 +176,19 @@
           return out;  
       }
   
  +    /**
  +     * Determines if the given array is ordered in a strictly increasing
  +     * fashion.
  +     * @param x the array to examine.
  +     * @return <code>true</code> if the elements in <code>x</code>
are ordered
  +     *         in a stricly increasing manner.  <code>false</code>, otherwise.
  +     */
  +    private static boolean isStrictlyIncreasing(double[] x) {
  +        for (int i = 1; i < x.length; ++i) {
  +            if (x[i - 1] >= x[i]) {
  +                return false;
  +            }
  +        }
  +        return true;
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message