1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.math.analysis;
18
19 /**
20 * A concrete {@link UnivariateRealSolverFactory}. This is the default solver factory
21 * used by commons-math.
22 * <p>
23 * The default solver returned by this factory is a {@link BrentSolver}.</p>
24 *
25 * @version $Revision: 615734 $ $Date: 2008-01-27 23:10:03 -0700 (Sun, 27 Jan 2008) $
26 */
27 public class UnivariateRealSolverFactoryImpl extends 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(UnivariateRealFunction f) {
45 return newBrentSolver(f);
46 }
47
48 /**
49 * Create a new {@link UnivariateRealSolver} for the given function. The
50 * solver is an implementation of the bisection method.
51 * @param f the function.
52 * @return the new solver.
53 */
54 public UnivariateRealSolver newBisectionSolver(UnivariateRealFunction f) {
55 return new BisectionSolver(f);
56 }
57
58 /**
59 * Create a new {@link UnivariateRealSolver} for the given function. The
60 * solver is an implementation of the Brent method.
61 * @param f the function.
62 * @return the new solver.
63 */
64 public UnivariateRealSolver newBrentSolver(UnivariateRealFunction f) {
65 return new BrentSolver(f);
66 }
67
68 /**
69 * Create a new {@link UnivariateRealSolver} for the given function. The
70 * solver is an implementation of Newton's Method.
71 * @param f the function.
72 * @return the new solver.
73 */
74 public UnivariateRealSolver newNewtonSolver(
75 DifferentiableUnivariateRealFunction f) {
76
77 return new NewtonSolver(f);
78 }
79
80 /**
81 * Create a new {@link UnivariateRealSolver} for the given function. The
82 * solver is an implementation of the secant method.
83 * @param f the function.
84 * @return the new solver.
85 */
86 public UnivariateRealSolver newSecantSolver(UnivariateRealFunction f) {
87 return new SecantSolver(f);
88 }
89 }