Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 32610 invoked from network); 25 Jun 2003 01:29:03 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 25 Jun 2003 01:29:03 -0000 Received: (qmail 28466 invoked by uid 97); 25 Jun 2003 01:31:32 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 28459 invoked from network); 25 Jun 2003 01:31:31 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 25 Jun 2003 01:31:31 -0000 Received: (qmail 32384 invoked by uid 500); 25 Jun 2003 01:29:01 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 32373 invoked by uid 500); 25 Jun 2003 01:29:00 -0000 Received: (qmail 32369 invoked from network); 25 Jun 2003 01:29:00 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 25 Jun 2003 01:29:00 -0000 Received: (qmail 37259 invoked by uid 1674); 25 Jun 2003 01:28:59 -0000 Date: 25 Jun 2003 01:28:59 -0000 Message-ID: <20030625012859.37258.qmail@icarus.apache.org> From: mdiggory@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/math/src/test/org/apache/commons/math/analysis InterpolatorTest.java SinFunction.java QuinticFunction.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mdiggory 2003/06/24 18:28:59 Added: math/src/test/org/apache/commons/math/analysis InterpolatorTest.java Removed: math/src/test/org/apache/commons/math/analysis SinFunction.java QuinticFunction.java Log: PR: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21023 Submitted by: j3322ptm@yahoo.de HotFusionMan@Yahoo.com Revision Changes Path 1.1 jakarta-commons-sandbox/math/src/test/org/apache/commons/math/analysis/InterpolatorTest.java Index: InterpolatorTest.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.commons.math.analysis; import org.apache.commons.math.MathException; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Test the interpolation framework. * * @author pietsch at apache.org * */ public class InterpolatorTest extends TestCase { public InterpolatorTest(String name) { super(name); } public static Test suite() { TestSuite suite = new TestSuite(InterpolatorTest.class); suite.setName("UnivariateRealInterpolator Tests"); return suite; } public void testInterpolateLinearDegenerateTwoSegment() throws MathException { System.out.println(" deg 2 seg"); double xval[] = { 0.0, 0.5, 1.0 }; double yval[] = { 0.0, 0.5, 1.0 }; UnivariateRealInterpolator i = new SplineInterpolator(); UnivariateRealFunction f = i.interpolate(xval, yval); double x; x = 0.0; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 0.5; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 1 - 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); } public void testInterpolateLinearDegenerateThreeSegment() throws MathException { System.out.println(" deg 3 seg"); double xval[] = { 0.0, 0.5, 1.0, 1.5 }; double yval[] = { 0.0, 0.5, 1.0, 1.5 }; UnivariateRealInterpolator i = new SplineInterpolator(); UnivariateRealFunction f = i.interpolate(xval, yval); double x; x = 0.0; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 0.5 - 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 0.5; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 1 - 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 1; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 1.5 - 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); } public void testInterpolateLinear() throws MathException { System.out.println(" triang 2 seg"); double xval[] = { 0.0, 0.5, 1.0 }; double yval[] = { 0.0, 0.5, 0.0 }; UnivariateRealInterpolator i = new SplineInterpolator(); UnivariateRealFunction f = i.interpolate(xval, yval); double x; x = 0.0; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 0.5 - 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 0.5; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 1 - 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); } public void testInterpolateSin() throws MathException { System.out.println(" sin"); double xval[] = { 0.0, Math.PI / 6.0, Math.PI / 2.0, 5.0 * Math.PI / 6.0, Math.PI, 7.0 * Math.PI / 6.0, 3.0 * Math.PI / 2.0, 11.0 * Math.PI / 6.0, 2.0 * Math.PI }; double yval[] = { 0.0, 0.5, 1.0, 0.5, 0.0, -0.5, -1.0, -0.5, 0.0 }; System.out.println("n=" + xval.length); UnivariateRealInterpolator i = new SplineInterpolator(); UnivariateRealFunction f = i.interpolate(xval, yval); double x; x = 0.0; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = Math.PI / 6.0 - 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = Math.PI / 6.0 + 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = Math.PI / 2 - 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = Math.PI / 2 + 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = Math.PI - 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = Math.PI + 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); x = 2.0 * Math.PI - 1E-6; System.out.println( "x=" + x + " y=" + f.value(x) + " y'=" + f.firstDerivative(x) + " y''=" + f.secondDerivative(x)); //assertEquals(0.5,f.value(Math.PI/6.0),) } public void testIllegalArguments() throws MathException { // Data set arrays of different size. UnivariateRealInterpolator i = new SplineInterpolator(); try { double xval[] = { 0.0, 1.0 }; double yval[] = { 0.0, 1.0, 2.0 }; UnivariateRealFunction f = i.interpolate(xval, yval); fail("Failed to detect data set array with different sizes."); } catch (IllegalArgumentException iae) { } // X values not sorted. try { double xval[] = { 0.0, 1.0, 0.5 }; double yval[] = { 0.0, 1.0, 2.0 }; UnivariateRealFunction f = i.interpolate(xval, yval); fail("Failed to detect unsorted arguments."); } catch (IllegalArgumentException iae) { } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org