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
19 import java.util.ArrayList;
20 import java.util.Collection;
21
22 import org.apache.commons.math4.legacy.exception.DimensionMismatchException;
23 import org.apache.commons.math4.legacy.exception.MaxCountExceededException;
24
25 /** Wrapper class enabling {@link FirstOrderDifferentialEquations basic simple}
26 * ODE instances to be used when processing {@link JacobianMatrices}.
27 *
28 * @since 3.0
29 */
30 class ParameterizedWrapper implements ParameterizedODE {
31
32 /** Basic FODE without parameter. */
33 private final FirstOrderDifferentialEquations fode;
34
35 /** Simple constructor.
36 * @param ode original first order differential equations
37 */
38 ParameterizedWrapper(final FirstOrderDifferentialEquations ode) {
39 this.fode = ode;
40 }
41
42 /** Get the dimension of the underlying FODE.
43 * @return dimension of the underlying FODE
44 */
45 public int getDimension() {
46 return fode.getDimension();
47 }
48
49 /** Get the current time derivative of the state vector of the underlying FODE.
50 * @param t current value of the independent <I>time</I> variable
51 * @param y array containing the current value of the state vector
52 * @param yDot placeholder array where to put the time derivative of the state vector
53 * @exception MaxCountExceededException if the number of functions evaluations is exceeded
54 * @exception DimensionMismatchException if arrays dimensions do not match equations settings
55 */
56 public void computeDerivatives(double t, double[] y, double[] yDot)
57 throws MaxCountExceededException, DimensionMismatchException {
58 fode.computeDerivatives(t, y, yDot);
59 }
60
61 /** {@inheritDoc} */
62 @Override
63 public Collection<String> getParametersNames() {
64 return new ArrayList<>();
65 }
66
67 /** {@inheritDoc} */
68 @Override
69 public boolean isSupported(String name) {
70 return false;
71 }
72
73 /** {@inheritDoc} */
74 @Override
75 public double getParameter(String name)
76 throws UnknownParameterException {
77 if (!isSupported(name)) {
78 throw new UnknownParameterException(name);
79 }
80 return Double.NaN;
81 }
82
83 /** {@inheritDoc} */
84 @Override
85 public void setParameter(String name, double value) {
86 }
87 }