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.solvers; 18 19 /** 20 * Abstract factory class used to create {@link UnivariateRealSolver} instances. 21 * <p> 22 * Solvers implementing the following algorithms are supported: 23 * <ul> 24 * <li>Bisection</li> 25 * <li>Brent's method</li> 26 * <li>Secant method</li> 27 * </ul> 28 * Concrete factories extending this class also specify a default solver, instances of which 29 * are returned by <code>newDefaultSolver()</code>.</p> 30 * <p> 31 * Common usage:<pre> 32 * SolverFactory factory = UnivariateRealSolverFactory.newInstance();</p> 33 * 34 * // create a Brent solver to use 35 * BrentSolver solver = factory.newBrentSolver(); 36 * </pre> 37 * 38 * @version $Revision: 799857 $ $Date: 2009-08-01 09:07:12 -0400 (Sat, 01 Aug 2009) $ 39 */ 40 public abstract class UnivariateRealSolverFactory { 41 /** 42 * Default constructor. 43 */ 44 protected UnivariateRealSolverFactory() { 45 } 46 47 /** 48 * Create a new factory. 49 * @return a new factory. 50 */ 51 public static UnivariateRealSolverFactory newInstance() { 52 return new UnivariateRealSolverFactoryImpl(); 53 } 54 55 /** 56 * Create a new {@link UnivariateRealSolver}. The 57 * actual solver returned is determined by the underlying factory. 58 * @return the new solver. 59 */ 60 public abstract UnivariateRealSolver newDefaultSolver(); 61 62 /** 63 * Create a new {@link UnivariateRealSolver}. The 64 * solver is an implementation of the bisection method. 65 * @return the new solver. 66 */ 67 public abstract UnivariateRealSolver newBisectionSolver(); 68 69 /** 70 * Create a new {@link UnivariateRealSolver}. The 71 * solver is an implementation of the Brent method. 72 * @return the new solver. 73 */ 74 public abstract UnivariateRealSolver newBrentSolver(); 75 76 /** 77 * Create a new {@link UnivariateRealSolver}. The 78 * solver is an implementation of Newton's Method. 79 * @return the new solver. 80 */ 81 public abstract UnivariateRealSolver newNewtonSolver(); 82 83 /** 84 * Create a new {@link UnivariateRealSolver}. The 85 * solver is an implementation of the secant method. 86 * @return the new solver. 87 */ 88 public abstract UnivariateRealSolver newSecantSolver(); 89 90 }