Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4055817AFA for ; Wed, 9 Dec 2015 16:16:56 +0000 (UTC) Received: (qmail 53647 invoked by uid 500); 9 Dec 2015 16:16:42 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 53093 invoked by uid 500); 9 Dec 2015 16:16:42 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 52644 invoked by uid 99); 9 Dec 2015 16:16:42 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Dec 2015 16:16:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 52634E0B5B; Wed, 9 Dec 2015 16:16:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: luc@apache.org To: commits@commons.apache.org Date: Wed, 09 Dec 2015 16:17:05 -0000 Message-Id: <304b214cc2144affa876b8a9204720a2@git.apache.org> In-Reply-To: <5b603929de6a4a73a78793bd0943c4a2@git.apache.org> References: <5b603929de6a4a73a78793bd0943c4a2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [25/50] [abbrv] [math] Fixed single integration step in step. Fixed single integration step in step. Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/6d8c6369 Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/6d8c6369 Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/6d8c6369 Branch: refs/heads/MATH_3_X Commit: 6d8c6369595afd421c5c487388cabe96e78c0170 Parents: dfdaea2 Author: Luc Maisonobe Authored: Fri Dec 4 11:31:26 2015 +0100 Committer: Luc Maisonobe Committed: Fri Dec 4 11:31:26 2015 +0100 ---------------------------------------------------------------------- ...ractRungeKuttaFieldStepInterpolatorTest.java | 74 +++++++++++--------- 1 file changed, 41 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/6d8c6369/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java index 43dfddf..e088434 100644 --- a/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java +++ b/src/test/java/org/apache/commons/math3/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java @@ -95,37 +95,7 @@ public abstract class AbstractRungeKuttaFieldStepInterpolatorTest { RungeKuttaFieldStepInterpolator interpolator = createInterpolator(field, t1 > t0, new FieldExpandableODE(eqn).getMapper()); // get the Butcher arrays from the field integrator - String interpolatorName = interpolator.getClass().getName(); - String integratorName = interpolatorName.replaceAll("StepInterpolator", "Integrator"); - - RungeKuttaFieldIntegrator fieldIntegrator = null; - try { - @SuppressWarnings("unchecked") - Class> clz = (Class>) Class.forName(integratorName); - try { - fieldIntegrator = clz.getConstructor(Field.class, RealFieldElement.class).newInstance(field, - field.getOne()); - } catch (NoSuchMethodException nsme) { - try { - fieldIntegrator = clz.getConstructor(Field.class, RealFieldElement.class, - RealFieldElement.class, RealFieldElement.class).newInstance(field, - field.getZero().add(0.001), - field.getOne(), - field.getOne(), - field.getOne()); - } catch (NoSuchMethodException e) { - Assert.fail(e.getLocalizedMessage()); - } - } - } catch (InvocationTargetException ite) { - Assert.fail(ite.getLocalizedMessage()); - } catch (IllegalAccessException iae) { - Assert.fail(iae.getLocalizedMessage()); - } catch (InstantiationException ie) { - Assert.fail(ie.getLocalizedMessage()); - } catch (ClassNotFoundException cnfe) { - Assert.fail(cnfe.getLocalizedMessage()); - } + RungeKuttaFieldIntegrator fieldIntegrator = createFieldIntegrator(field, interpolator); T[][] a = fieldIntegrator.getA(); T[] b = fieldIntegrator.getB(); T[] c = fieldIntegrator.getC(); @@ -146,8 +116,8 @@ public abstract class AbstractRungeKuttaFieldStepInterpolatorTest { for (int k = 0; k < a.length; ++k) { for (int i = 0; i < y0.length; ++i) { fieldY[i] = field.getZero().add(y0[i]); - for (int s = 0; s < k; ++s) { - fieldY[i] = fieldY[i].add(h.multiply(a[s][i].multiply(fieldYDotK[s][i]))); + for (int s = 0; s <= k; ++s) { + fieldY[i] = fieldY[i].add(h.multiply(a[k][s].multiply(fieldYDotK[s][i]))); } } fieldYDotK[k + 1] = eqn.computeDerivatives(h.multiply(c[k]).add(t0), fieldY); @@ -169,6 +139,44 @@ public abstract class AbstractRungeKuttaFieldStepInterpolatorTest { } + private > RungeKuttaFieldIntegrator + createFieldIntegrator(final Field field, final RungeKuttaFieldStepInterpolator interpolator) { + RungeKuttaFieldIntegrator integrator = null; + try { + String interpolatorName = interpolator.getClass().getName(); + String integratorName = interpolatorName.replaceAll("StepInterpolator", "Integrator"); + @SuppressWarnings("unchecked") + Class> clz = (Class>) Class.forName(integratorName); + try { + integrator = clz.getConstructor(Field.class, RealFieldElement.class).newInstance(field, + field.getOne()); + } catch (NoSuchMethodException nsme) { + try { + integrator = clz.getConstructor(Field.class, + RealFieldElement.class, + RealFieldElement.class, + RealFieldElement.class). + newInstance(field, field.getZero().add(0.001), + field.getOne(), field.getOne(), field.getOne()); + } catch (NoSuchMethodException e) { + Assert.fail(e.getLocalizedMessage()); + } + } + + } catch (InvocationTargetException ite) { + Assert.fail(ite.getLocalizedMessage()); + } catch (IllegalAccessException iae) { + Assert.fail(iae.getLocalizedMessage()); + } catch (InstantiationException ie) { + Assert.fail(ie.getLocalizedMessage()); + } catch (ClassNotFoundException cnfe) { + Assert.fail(cnfe.getLocalizedMessage()); + } + + return integrator; + + } + private static class SinCos> implements FieldFirstOrderDifferentialEquations { private final Field field; protected SinCos(final Field field) {