From b27299f9edc6b7c5c8d067eae422ca87620496f8 Mon Sep 17 00:00:00 2001 From: Gilles Sadowski Date: Thu, 4 Nov 2010 11:21:19 +0000 Subject: [PATCH] MATH-428 Added a constructor. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1030885 13f79535-47bb-0310-9956-ffa450edef68 --- .../optimization/direct/AbstractSimplex.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/commons/math/optimization/direct/AbstractSimplex.java b/src/main/java/org/apache/commons/math/optimization/direct/AbstractSimplex.java index afbb9a62c..932603bea 100644 --- a/src/main/java/org/apache/commons/math/optimization/direct/AbstractSimplex.java +++ b/src/main/java/org/apache/commons/math/optimization/direct/AbstractSimplex.java @@ -57,13 +57,23 @@ public abstract class AbstractSimplex { private final int dimension; /** - * Default constructor. - * Build a unit hypercube. + * Build a unit hypercube simplex. * * @param n Dimension of the simplex. */ protected AbstractSimplex(int n) { - this(createUnitHypercubeSteps(n)); + this(n, 1d); + } + + /** + * Build a hypercube simplex with the given side length. + * + * @param n Dimension of the simplex. + * @param sideLength Length of the sides of the hypercube. + */ + protected AbstractSimplex(int n, + double sideLength) { + this(createHypercubeSteps(n, sideLength)); } /** @@ -328,12 +338,14 @@ public abstract class AbstractSimplex { * Create steps for a unit hypercube. * * @param n Dimension of the hypercube. - * @return unit steps. + * @param sideLength Length of the sides of the hypercube. + * @return the steps. */ - private static double[] createUnitHypercubeSteps(int n) { + private static double[] createHypercubeSteps(int n, + double sideLength) { final double[] steps = new double[n]; for (int i = 0; i < n; i++) { - steps[i] = 1; + steps[i] = sideLength; } return steps; }