ParameterizedWrapper.java

  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.math4.legacy.ode;

  18. import java.util.ArrayList;
  19. import java.util.Collection;

  20. import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
  21. import org.apache.commons.math4.legacy.exception.MaxCountExceededException;

  22. /** Wrapper class enabling {@link FirstOrderDifferentialEquations basic simple}
  23.  *  ODE instances to be used when processing {@link JacobianMatrices}.
  24.  *
  25.  * @since 3.0
  26.  */
  27. class ParameterizedWrapper implements ParameterizedODE {

  28.     /** Basic FODE without parameter. */
  29.     private final FirstOrderDifferentialEquations fode;

  30.     /** Simple constructor.
  31.      * @param ode original first order differential equations
  32.      */
  33.     ParameterizedWrapper(final FirstOrderDifferentialEquations ode) {
  34.         this.fode = ode;
  35.     }

  36.     /** Get the dimension of the underlying FODE.
  37.      * @return dimension of the underlying FODE
  38.      */
  39.     public int getDimension() {
  40.         return fode.getDimension();
  41.     }

  42.     /** Get the current time derivative of the state vector of the underlying FODE.
  43.      * @param t current value of the independent <I>time</I> variable
  44.      * @param y array containing the current value of the state vector
  45.      * @param yDot placeholder array where to put the time derivative of the state vector
  46.      * @exception MaxCountExceededException if the number of functions evaluations is exceeded
  47.      * @exception DimensionMismatchException if arrays dimensions do not match equations settings
  48.      */
  49.     public void computeDerivatives(double t, double[] y, double[] yDot)
  50.         throws MaxCountExceededException, DimensionMismatchException {
  51.         fode.computeDerivatives(t, y, yDot);
  52.     }

  53.     /** {@inheritDoc} */
  54.     @Override
  55.     public Collection<String> getParametersNames() {
  56.         return new ArrayList<>();
  57.     }

  58.     /** {@inheritDoc} */
  59.     @Override
  60.     public boolean isSupported(String name) {
  61.         return false;
  62.     }

  63.     /** {@inheritDoc} */
  64.     @Override
  65.     public double getParameter(String name)
  66.         throws UnknownParameterException {
  67.         if (!isSupported(name)) {
  68.             throw new UnknownParameterException(name);
  69.         }
  70.         return Double.NaN;
  71.     }

  72.     /** {@inheritDoc} */
  73.     @Override
  74.     public void setParameter(String name, double value) {
  75.     }
  76. }