|
Commons Math example source code file (ConvergingAlgorithmImpl.java)
The Commons Math ConvergingAlgorithmImpl.java source code/* * 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; /** * Provide a default implementation for several functions useful to generic * converging algorithms. * * @version $Revision: 811685 $ $Date: 2009-09-05 13:36:48 -0400 (Sat, 05 Sep 2009) $ * @since 2.0 */ public abstract class ConvergingAlgorithmImpl implements ConvergingAlgorithm{ /** Maximum absolute error. */ protected double absoluteAccuracy; /** Maximum relative error. */ protected double relativeAccuracy; /** Maximum number of iterations. */ protected int maximalIterationCount; /** Default maximum absolute error. */ protected double defaultAbsoluteAccuracy; /** Default maximum relative error. */ protected double defaultRelativeAccuracy; /** Default maximum number of iterations. */ protected int defaultMaximalIterationCount; // Mainly for test framework. /** The last iteration count. */ protected int iterationCount; /** * Construct an algorithm with given iteration count and accuracy. * * @param defaultAbsoluteAccuracy maximum absolute error * @param defaultMaximalIterationCount maximum number of iterations * @throws IllegalArgumentException if f is null or the * defaultAbsoluteAccuracy is not valid */ protected ConvergingAlgorithmImpl(final int defaultMaximalIterationCount, final double defaultAbsoluteAccuracy) { this.defaultAbsoluteAccuracy = defaultAbsoluteAccuracy; this.defaultRelativeAccuracy = 1.0e-14; this.absoluteAccuracy = defaultAbsoluteAccuracy; this.relativeAccuracy = defaultRelativeAccuracy; this.defaultMaximalIterationCount = defaultMaximalIterationCount; this.maximalIterationCount = defaultMaximalIterationCount; this.iterationCount = 0; } /** {@inheritDoc} */ public int getIterationCount() { return iterationCount; } /** {@inheritDoc} */ public void setAbsoluteAccuracy(double accuracy) { absoluteAccuracy = accuracy; } /** {@inheritDoc} */ public double getAbsoluteAccuracy() { return absoluteAccuracy; } /** {@inheritDoc} */ public void resetAbsoluteAccuracy() { absoluteAccuracy = defaultAbsoluteAccuracy; } /** {@inheritDoc} */ public void setMaximalIterationCount(int count) { maximalIterationCount = count; } /** {@inheritDoc} */ public int getMaximalIterationCount() { return maximalIterationCount; } /** {@inheritDoc} */ public void resetMaximalIterationCount() { maximalIterationCount = defaultMaximalIterationCount; } /** {@inheritDoc} */ public void setRelativeAccuracy(double accuracy) { relativeAccuracy = accuracy; } /** {@inheritDoc} */ public double getRelativeAccuracy() { return relativeAccuracy; } /** {@inheritDoc} */ public void resetRelativeAccuracy() { relativeAccuracy = defaultRelativeAccuracy; } } Other Commons Math examples (source code examples)Here is a short list of links related to this Commons Math ConvergingAlgorithmImpl.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.