psteitz 2004/07/20 05:55:01 Modified: math/src/java/org/apache/commons/math/analysis PolynomialFunction.java PolynomialSplineFunction.java Log: javadoc. Revision Changes Path 1.12 +8 -4 jakarta-commons/math/src/java/org/apache/commons/math/analysis/PolynomialFunction.java Index: PolynomialFunction.java =================================================================== RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/analysis/PolynomialFunction.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- PolynomialFunction.java 23 Jun 2004 16:26:14 -0000 1.11 +++ PolynomialFunction.java 20 Jul 2004 12:55:01 -0000 1.12 @@ -31,13 +31,17 @@ static final long serialVersionUID = 3322454535052136809L; /** - * The coefficients of the polynomial, ordered by degree -- i.e., coefficients[0] is the constant term - * and coefficients[n] is the coefficient of x^n where n is the degree of the polynomial. + * The coefficients of the polynomial, ordered by degree -- i.e., + * coefficients[0] is the constant term and coefficients[n] is the + * coefficient of x^n where n is the degree of the polynomial. */ private double coefficients[]; /** - * Construct a polynomial with the given coefficients. + * Construct a polynomial with the given coefficients. The first element + * of the coefficients array is the constant term. Higher degree + * coefficients follow in sequence. The degree of the resulting polynomial + * is the length of the array minus 1. * <p> * The constructor makes a copy of the input array and assigns the copy to * the coefficients property. 1.8 +50 -29 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.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- PolynomialSplineFunction.java 17 Jul 2004 21:19:39 -0000 1.7 +++ PolynomialSplineFunction.java 20 Jul 2004 12:55:01 -0000 1.8 @@ -23,23 +23,32 @@ /** * Represents a polynomial spline function. * <p> - * A <strong>polynomial spline function</strong> consists of a set of <i>interpolating polynomials</i> - * and an ascending array of domain <i>knot points</i>, determining the intervals over which the - * spline function is defined by the constituent polynomials. The polynomials are assumed to have - * been computed to match the values of another function at the knot points. The value - * consistency constraints are not currently enforced by <code>PolynomialSplineFunction</code> itself, - * but are assumed to hold among the polynomials and knot points passed to the constructor. + * A <strong>polynomial spline function</strong> consists of a set of + * <i>interpolating polynomials</i> and an ascending array of domain + * <i>knot points</i>, determining the intervals over which the spline function + * is defined by the constituent polynomials. The polynomials are assumed to + * have been computed to match the values of another function at the knot + * points. The value consistency constraints are not currently enforced by + * <code>PolynomialSplineFunction</code> itself, but are assumed to hold among + * the polynomials and knot points passed to the constructor. * <p> - * N.B.: The polynomials in the <code>polynomials</code> property must be centered on the knot points - * to compute the spline function values. See below. + * N.B.: The polynomials in the <code>polynomials</code> property must be + * centered on the knot points to compute the spline function values. See below. * <p> - * The value of the polynomial spline function for an argument <code>x</code> is computed as follows: + * The domain of the polynomial spline function is + * <code>[smallest knot, largest knot)</code>. Attempts to evaluate the + * function at values outside of this range generate IllegalArgumentExceptions. + * <p> + * The value of the polynomial spline function for an argument <code>x</code> + * is computed as follows: * <ol> - * <li>The knot array is searched to find the segment to which <code>x</code> belongs. - * If <code>x</code> is less than the smallest knot point or greater than or equal to the largest one, an - * <code>IllegalArgumentException</code> is thrown.</li> - * <li> Let <code>j</code> be the index of the largest knot point that is less than or equal to <code>x</code>. - * The value returned is <br> <code>polynomials[j](x - knot[j])</code></li></ol> + * <li>The knot array is searched to find the segment to which <code>x</code> + * belongs. If <code>x</code> is less than the smallest knot point or greater + * than or equal to the largest one, an <code>IllegalArgumentException</code> + * is thrown.</li> + * <li> Let <code>j</code> be the index of the largest knot point that is less + * than or equal to <code>x</code>. The value returned is <br> + * <code>polynomials[j](x - knot[j])</code></li></ol> * * @version $Revision$ $Date$ */ @@ -52,33 +61,37 @@ private double knots[]; /** - * The polynomial functions that make up the spline. The first element determines the value of the spline - * over the first subinterval, the second over the second, etc. Spline function values are determined by - * evaluating these functions at <code>(x - knot[i])</code> where i is the knot segment to which x belongs. + * The polynomial functions that make up the spline. The first element + * determines the value of the spline over the first subinterval, the + * second over the second, etc. Spline function values are determined by + * evaluating these functions at <code>(x - knot[i])</code> where i is the + * knot segment to which x belongs. */ private PolynomialFunction polynomials[] = null; - /** Number of spline segments = number of polynomials = number of partition points - 1 */ + /** + * Number of spline segments = number of polynomials + * = number of partition points - 1 + */ private int n = 0; /** - * Construct a polynomial spline function with the given segment delimiters and interpolating - * polynomials. + * Construct a polynomial spline function with the given segment delimiters + * and interpolating polynomials. * <p> - * The constructor copies both arrays and assigns the copies to the knots and polynomials properties, - * respectively. + * The constructor copies both arrays and assigns the copies to the knots + * and polynomials properties, respectively. * * @param knots spline segment interval delimiters * @param polynomials polynomial functions that make up the spline * @throws NullPointerException if either of the input arrays is null * @throws IllegalArgumentException if knots has length less than 2, - * <code>polynomials.length != knots.length - 1 </code>, or the knots array - * is not strictly increasing. + * <code>polynomials.length != knots.length - 1 </code>, or the knots array + * is not strictly increasing. * */ public PolynomialSplineFunction(double knots[], PolynomialFunction polynomials[]) { - super(); if (knots.length < 2) { throw new IllegalArgumentException ("Not enough knot values -- spline partition must have at least 2 points."); @@ -101,12 +114,18 @@ /** * Compute the value for the function. + * <p> + * Throws FunctionEvaluationException if v is outside of the domain of the + * function. The domain is [smallest knot, largest knot). + * <p> + * See [EMAIL PROTECTED] PolynomialSplineFunction} for details on the algorithm for + * computing the value of the function. * * @param v the point for which the function value should be computed * @return the value * @throws FunctionEvaluationException if v is outside of the domain of * of the spline function (less than the smallest knot point or greater - * than the largest knot point) + * than or equal to the largest knot point) */ public double value(double v) throws FunctionEvaluationException { if (v < knots[0] || v >= knots[n]) { @@ -141,7 +160,8 @@ } /** - * Returns the number of spline segments = the number of polynomials = the number of knot points - 1. + * Returns the number of spline segments = the number of polynomials + * = the number of knot points - 1. * * @return the number of spline segments */ @@ -180,9 +200,10 @@ /** * 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. + * in a stricly increasing manner. <code>false</code>, otherwise. */ private static boolean isStrictlyIncreasing(double[] x) { for (int i = 1; i < x.length; ++i) {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]