Repository: commons-math Updated Branches: refs/heads/field-ode 70e48a02d -> e55d38c43
Use MapArrays utility methods for building arrays. Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/e55d38c4 Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/e55d38c4 Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/e55d38c4 Branch: refs/heads/field-ode Commit: e55d38c43ec030403702032baa21399821e0f687 Parents: 70e48a0 Author: Luc Maisonobe <l...@apache.org> Authored: Sun Nov 15 10:31:17 2015 +0100 Committer: Luc Maisonobe <l...@apache.org> Committed: Sun Nov 15 10:31:17 2015 +0100 ---------------------------------------------------------------------- .../apache/commons/math3/ode/FieldEquationsMapper.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-math/blob/e55d38c4/src/main/java/org/apache/commons/math3/ode/FieldEquationsMapper.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math3/ode/FieldEquationsMapper.java b/src/main/java/org/apache/commons/math3/ode/FieldEquationsMapper.java index 9590984..2400fb7 100644 --- a/src/main/java/org/apache/commons/math3/ode/FieldEquationsMapper.java +++ b/src/main/java/org/apache/commons/math3/ode/FieldEquationsMapper.java @@ -18,7 +18,6 @@ package org.apache.commons.math3.ode; import java.io.Serializable; -import java.lang.reflect.Array; import org.apache.commons.math3.RealFieldElement; import org.apache.commons.math3.exception.MathIllegalArgumentException; @@ -35,7 +34,7 @@ import org.apache.commons.math3.util.MathArrays; * @param <T> the type of the field elements * @since 3.6 */ -class FieldEquationsMapper<T extends RealFieldElement<T>> implements Serializable { +public class FieldEquationsMapper<T extends RealFieldElement<T>> implements Serializable { /** Serializable UID. */ private static final long serialVersionUID = 20151114L; @@ -119,8 +118,7 @@ class FieldEquationsMapper<T extends RealFieldElement<T>> implements Serializabl if (n < 2) { return new FieldODEState<T>(t, state); } else { - @SuppressWarnings("unchecked") - final T[][] secondaryState = (T[][]) Array.newInstance(t.getField().getRuntimeClass(), n - 1); + final T[][] secondaryState = MathArrays.buildArray(t.getField(), n - 1, -1); while (++index < n) { secondaryState[index - 1] = extractEquationData(index, y); } @@ -142,10 +140,8 @@ class FieldEquationsMapper<T extends RealFieldElement<T>> implements Serializabl if (n < 2) { return new FieldODEStateAndDerivative<T>(t, state, derivative); } else { - @SuppressWarnings("unchecked") - final T[][] secondaryState = (T[][]) Array.newInstance(t.getField().getRuntimeClass(), n - 1); - @SuppressWarnings("unchecked") - final T[][] secondaryDerivative = (T[][]) Array.newInstance(t.getField().getRuntimeClass(), n - 1); + final T[][] secondaryState = MathArrays.buildArray(t.getField(), n - 1, -1); + final T[][] secondaryDerivative = MathArrays.buildArray(t.getField(), n - 1, -1); while (++index < getNumberOfEquations()) { secondaryState[index - 1] = extractEquationData(index, y); secondaryDerivative[index - 1] = extractEquationData(index, yDot);