01: /*
02: * Copyright 2003-2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.commons.math.analysis;
17:
18: /**
19: * A concrete {@link UnivariateRealSolverFactory}. This is the default solver factory
20: * used by commons-math.
21: * <p>
22: * The default solver returned by this factory is a {@link BrentSolver}.
23: *
24: * @version $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $
25: */
26: public class UnivariateRealSolverFactoryImpl extends
27: UnivariateRealSolverFactory {
28:
29: /**
30: * Default constructor.
31: */
32: public UnivariateRealSolverFactoryImpl() {
33: }
34:
35: /**
36: * Create a new {@link UnivariateRealSolver} for the given function. The
37: * actual solver returned is determined by the underlying factory.
38: *
39: * This factory returns a {@link BrentSolver} instance.
40: *
41: * @param f the function.
42: * @return the new solver.
43: */
44: public UnivariateRealSolver newDefaultSolver(
45: UnivariateRealFunction f) {
46: return newBrentSolver(f);
47: }
48:
49: /**
50: * Create a new {@link UnivariateRealSolver} for the given function. The
51: * solver is an implementation of the bisection method.
52: * @param f the function.
53: * @return the new solver.
54: */
55: public UnivariateRealSolver newBisectionSolver(
56: UnivariateRealFunction f) {
57: return new BisectionSolver(f);
58: }
59:
60: /**
61: * Create a new {@link UnivariateRealSolver} for the given function. The
62: * solver is an implementation of the Brent method.
63: * @param f the function.
64: * @return the new solver.
65: */
66: public UnivariateRealSolver newBrentSolver(UnivariateRealFunction f) {
67: return new BrentSolver(f);
68: }
69:
70: /**
71: * Create a new {@link UnivariateRealSolver} for the given function. The
72: * solver is an implementation of Newton's Method.
73: * @param f the function.
74: * @return the new solver.
75: */
76: public UnivariateRealSolver newNewtonSolver(
77: DifferentiableUnivariateRealFunction f) {
78:
79: return new NewtonSolver(f);
80: }
81:
82: /**
83: * Create a new {@link UnivariateRealSolver} for the given function. The
84: * solver is an implementation of the secant method.
85: * @param f the function.
86: * @return the new solver.
87: */
88: public UnivariateRealSolver newSecantSolver(UnivariateRealFunction f) {
89: return new SecantSolver(f);
90: }
91: }
|