1 /* 2 * Licensed to the Hipparchus project 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 Hipparchus project 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 * https://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.hipparchus.optim.nonlinear.vector.constrained; 18 19 20 21 import org.hipparchus.analysis.MultivariateVectorFunction; 22 import org.hipparchus.linear.ArrayRealVector; 23 import org.hipparchus.linear.RealMatrix; 24 import org.hipparchus.linear.RealVector; 25 26 /** A MultivariateFunction that also has a defined gradient and Hessian. 27 * @since 3.1 28 */ 29 public interface VectorDifferentiableFunction extends MultivariateVectorFunction { 30 31 /** 32 * Returns the dimensionality of the function domain. 33 * If dim() returns (n) then this function expects an n-vector as its input. 34 * @return the expected dimension of the function's domain 35 */ 36 int dim(); 37 38 /** 39 * Returns the dimensionality of the function eval. 40 * 41 * @return the expected dimension of the function's eval 42 */ 43 int dimY(); 44 45 /** 46 * Returns the value of this function at (x) 47 * 48 * @param x a point to evaluate this function at. 49 * @return the value of this function at (x) 50 */ 51 RealVector value(RealVector x); 52 53 /** 54 * Returns the value of this function at (x) 55 * 56 * @param x a point to evaluate this function at. 57 * @return the value of this function at (x) 58 */ 59 @Override 60 default double[] value(final double[] x) { 61 return value(new ArrayRealVector(x, false)).toArray(); 62 } 63 64 /** 65 * Returns the gradient of this function at (x) 66 * 67 * @param x a point to evaluate this gradient at 68 * @return the gradient of this function at (x) 69 */ 70 RealMatrix jacobian(RealVector x); 71 72 /** 73 * Returns the gradient of this function at (x) 74 * 75 * @param x a point to evaluate this gradient at 76 * @return the gradient of this function at (x) 77 */ 78 default RealMatrix gradient(final double[] x) { 79 return jacobian(new ArrayRealVector(x, false)); 80 } 81 82 }