Inserted "BaseBracketedSecantSolver" into the secant-based solvers hierarchy.
Renamed "SecantBase" to "BaseSecantSolver".


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1139455 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2011-06-24 22:36:43 +00:00
parent f3f992d692
commit 06828ea9a8
11 changed files with 87 additions and 45 deletions

View File

@ -0,0 +1,71 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math.analysis.solvers;
/**
* Base class for <em>Secant</em> methods that guarantee convergence
* by maintaining a {@link BracketedSolution bracketed solution}.
*
* @since 3.0
* @version $Id$
*/
public class BaseBracketedSecantSolver extends BaseSecantSolver
implements BracketedSolution {
/**
* Construct a solver with default accuracy (1e-6).
*
* @param method Method.
*/
protected BaseBracketedSecantSolver(Method method) {
super(DEFAULT_ABSOLUTE_ACCURACY, method);
}
/**
* Construct a solver.
*
* @param absoluteAccuracy absolute accuracy
* @param method Method.
*/
protected BaseBracketedSecantSolver(final double absoluteAccuracy,
Method method) {
super(absoluteAccuracy, method);
}
/**
* Construct a solver.
*
* @param relativeAccuracy relative accuracy
* @param absoluteAccuracy absolute accuracy
* @param method Method.
*/
protected BaseBracketedSecantSolver(final double relativeAccuracy,
final double absoluteAccuracy,
Method method) {
super(relativeAccuracy, absoluteAccuracy, method);
}
/** {@inheritDoc} */
public AllowedSolutions getAllowedSolutions() {
return allowedSolutions;
}
/** {@inheritDoc} */
public void setAllowedSolutions(final AllowedSolutions allowedSolutions) {
this.allowedSolutions = allowedSolutions;
}
}

View File

@ -41,7 +41,7 @@ import org.apache.commons.math.exception.MathInternalError;
* @since 3.0
* @version $Id$
*/
public abstract class SecantBase extends AbstractUnivariateRealSolver {
public abstract class BaseSecantSolver extends AbstractUnivariateRealSolver {
/** Default absolute accuracy. */
protected static final double DEFAULT_ABSOLUTE_ACCURACY = 1e-6;
/** The kinds of solutions that the algorithm may accept. */
@ -55,7 +55,7 @@ public abstract class SecantBase extends AbstractUnivariateRealSolver {
* @param absoluteAccuracy absolute accuracy
* @param method <em>Secant</em>-based root-finding method to use
*/
protected SecantBase(final double absoluteAccuracy, final Method method) {
protected BaseSecantSolver(final double absoluteAccuracy, final Method method) {
super(absoluteAccuracy);
this.method = method;
}
@ -67,9 +67,9 @@ public abstract class SecantBase extends AbstractUnivariateRealSolver {
* @param absoluteAccuracy absolute accuracy
* @param method <em>Secant</em>-based root-finding method to use
*/
protected SecantBase(final double relativeAccuracy,
final double absoluteAccuracy,
final Method method) {
protected BaseSecantSolver(final double relativeAccuracy,
final double absoluteAccuracy,
final Method method) {
super(relativeAccuracy, absoluteAccuracy);
this.method = method;
}

View File

@ -38,7 +38,7 @@ package org.apache.commons.math.analysis.solvers;
* @since 3.0
* @version $Id$
*/
public class IllinoisSolver extends SecantBase implements BracketedSolution {
public class IllinoisSolver extends BaseBracketedSecantSolver {
/** Construct a solver with default accuracy (1e-6). */
public IllinoisSolver() {
super(DEFAULT_ABSOLUTE_ACCURACY, Method.ILLINOIS);
@ -63,14 +63,4 @@ public class IllinoisSolver extends SecantBase implements BracketedSolution {
final double absoluteAccuracy) {
super(relativeAccuracy, absoluteAccuracy, Method.ILLINOIS);
}
/** {@inheritDoc} */
public AllowedSolutions getAllowedSolutions() {
return allowedSolutions;
}
/** {@inheritDoc} */
public void setAllowedSolutions(final AllowedSolutions allowedSolutions) {
this.allowedSolutions = allowedSolutions;
}
}

View File

@ -40,7 +40,7 @@ package org.apache.commons.math.analysis.solvers;
* @since 3.0
* @version $Id$
*/
public class PegasusSolver extends SecantBase implements BracketedSolution {
public class PegasusSolver extends BaseBracketedSecantSolver {
/** Construct a solver with default accuracy (1e-6). */
public PegasusSolver() {
super(DEFAULT_ABSOLUTE_ACCURACY, Method.PEGASUS);
@ -65,14 +65,4 @@ public class PegasusSolver extends SecantBase implements BracketedSolution {
final double absoluteAccuracy) {
super(relativeAccuracy, absoluteAccuracy, Method.PEGASUS);
}
/** {@inheritDoc} */
public AllowedSolutions getAllowedSolutions() {
return allowedSolutions;
}
/** {@inheritDoc} */
public void setAllowedSolutions(final AllowedSolutions allowedSolutions) {
this.allowedSolutions = allowedSolutions;
}
}

View File

@ -35,7 +35,7 @@ package org.apache.commons.math.analysis.solvers;
* @since 3.0
* @version $Id$
*/
public class RegulaFalsiSolver extends SecantBase implements BracketedSolution {
public class RegulaFalsiSolver extends BaseBracketedSecantSolver {
/** Construct a solver with default accuracy (1e-6). */
public RegulaFalsiSolver() {
super(DEFAULT_ABSOLUTE_ACCURACY, Method.REGULA_FALSI);
@ -60,14 +60,4 @@ public class RegulaFalsiSolver extends SecantBase implements BracketedSolution {
final double absoluteAccuracy) {
super(relativeAccuracy, absoluteAccuracy, Method.REGULA_FALSI);
}
/** {@inheritDoc} */
public AllowedSolutions getAllowedSolutions() {
return allowedSolutions;
}
/** {@inheritDoc} */
public void setAllowedSolutions(final AllowedSolutions allowedSolutions) {
this.allowedSolutions = allowedSolutions;
}
}

View File

@ -36,7 +36,7 @@ package org.apache.commons.math.analysis.solvers;
*
* @version $Id$
*/
public class SecantSolver extends SecantBase {
public class SecantSolver extends BaseSecantSolver {
/** Construct a solver with default accuracy (1e-6). */
public SecantSolver() {
super(DEFAULT_ABSOLUTE_ACCURACY, Method.SECANT);

View File

@ -27,11 +27,12 @@ import org.junit.Assert;
import org.junit.Test;
/**
* Base class for {@link SecantBase} derived root-finding algorithms tests.
* Base class for root-finding algorithms tests derived from
* {@link BaseSecantSolver}.
*
* @version $Id$
*/
public abstract class SecantBaseTest {
public abstract class BaseSecantSolverTest {
/** Returns the solver to use to perform the tests.
* @return the solver to use to perform the tests
*/

View File

@ -22,7 +22,7 @@ package org.apache.commons.math.analysis.solvers;
*
* @version $Id$
*/
public final class IllinoisSolverTest extends SecantBaseTest {
public final class IllinoisSolverTest extends BaseSecantSolverTest {
/** {@inheritDoc} */
protected UnivariateRealSolver getSolver() {
return new IllinoisSolver();

View File

@ -22,7 +22,7 @@ package org.apache.commons.math.analysis.solvers;
*
* @version $Id$
*/
public final class PegasusSolverTest extends SecantBaseTest {
public final class PegasusSolverTest extends BaseSecantSolverTest {
/** {@inheritDoc} */
protected UnivariateRealSolver getSolver() {
return new PegasusSolver();

View File

@ -22,7 +22,7 @@ package org.apache.commons.math.analysis.solvers;
*
* @version $Id$
*/
public final class RegulaFalsiSolverTest extends SecantBaseTest {
public final class RegulaFalsiSolverTest extends BaseSecantSolverTest {
/** {@inheritDoc} */
protected UnivariateRealSolver getSolver() {
return new RegulaFalsiSolver();

View File

@ -22,7 +22,7 @@ package org.apache.commons.math.analysis.solvers;
*
* @version $Id$
*/
public final class SecantSolverTest extends SecantBaseTest {
public final class SecantSolverTest extends BaseSecantSolverTest {
/** {@inheritDoc} */
protected UnivariateRealSolver getSolver() {
return new SecantSolver();