001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.math4.legacy.fitting.leastsquares; 018 019import org.apache.commons.math4.legacy.linear.RealVector; 020import org.apache.commons.math4.legacy.optim.ConvergenceChecker; 021import org.apache.commons.math4.legacy.core.IntegerSequence; 022 023/** 024 * An adapter that delegates to another implementation of {@link LeastSquaresProblem}. 025 * 026 * @since 3.3 027 */ 028public class LeastSquaresAdapter implements LeastSquaresProblem { 029 030 /** the delegate problem. */ 031 private final LeastSquaresProblem problem; 032 033 /** 034 * Delegate the {@link LeastSquaresProblem} interface to the given implementation. 035 * 036 * @param problem the delegate 037 */ 038 public LeastSquaresAdapter(final LeastSquaresProblem problem) { 039 this.problem = problem; 040 } 041 042 /** {@inheritDoc} */ 043 @Override 044 public RealVector getStart() { 045 return problem.getStart(); 046 } 047 048 /** {@inheritDoc} */ 049 @Override 050 public int getObservationSize() { 051 return problem.getObservationSize(); 052 } 053 054 /** {@inheritDoc} */ 055 @Override 056 public int getParameterSize() { 057 return problem.getParameterSize(); 058 } 059 060 /** {@inheritDoc} 061 */ 062 @Override 063 public Evaluation evaluate(final RealVector point) { 064 return problem.evaluate(point); 065 } 066 067 /** {@inheritDoc} */ 068 @Override 069 public IntegerSequence.Incrementor getEvaluationCounter() { 070 return problem.getEvaluationCounter(); 071 } 072 073 /** {@inheritDoc} */ 074 @Override 075 public IntegerSequence.Incrementor getIterationCounter() { 076 return problem.getIterationCounter(); 077 } 078 079 /** {@inheritDoc} */ 080 @Override 081 public ConvergenceChecker<Evaluation> getConvergenceChecker() { 082 return problem.getConvergenceChecker(); 083 } 084}