001/*
002*   VectorFunction  -- Defines an n-Dimensional vector function y[]=fn(x[]).
003*
004*   Copyright (C) 2010-2025, by Joseph A. Huwaldt. All rights reserved.
005*   
006*   This library is free software; you can redistribute it and/or
007*   modify it under the terms of the GNU Lesser General Public
008*   License as published by the Free Software Foundation; either
009*   version 2 of the License, or (at your option) any later version.
010*   
011*   This library is distributed in the hope that it will be useful,
012*   but WITHOUT ANY WARRANTY; without even the implied warranty of
013*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014*   Lesser General Public License for more details.
015*
016*   You should have received a copy of the GNU Lesser General Public License
017*   along with this program; if not, write to the Free Software
018*   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019*   Or visit:  http://www.gnu.org/licenses/lgpl.html
020 */
021package jahuwaldt.tools.math;
022
023/**
024 * A class that defines an n-Dimensional vector function y[] = fn(x[]) (named "function")
025 * that can be called by math tools such as root finders. Also defines the derivative of
026 * the function. dy[]/dx = d fn(x[])/dx (oddly enough, named "derivative").
027 *
028 * <p> Modified by: Joseph A. Huwaldt  </p>
029 *
030 * @author Joseph A. Huwaldt Date: July 4, 2010
031 * @version February 23, 2025
032 */
033public interface VectorFunction {
034
035    /**
036     * User supplied method that calculates the function y[] = fn(x[]).
037     *
038     * @param n The number of variables in the x & y arrays.
039     * @param x Independent parameters to the function, passed in as input.
040     * @param y An existing array that is filled in with the outputs of the function
041     * @throws RootException if there is a problem computing the function.
042     */
043    public void function(int n, double x[], double[] y) throws RootException;
044
045    /**
046     * User supplied method that calculates the Jacobian of the function.
047     *
048     * @param n   The number of rows and columns in the Jacobian.
049     * @param x   Independent parameters to the function, passed in as input.
050     * @param jac The Jacobian array.
051     * @return <code>true</code> if the Jacobian was computed by this method,
052     * <code>false</code> if it was not.
053     * @throws RootException if there is a problem computing the Jacobian.
054     */
055    public boolean jacobian(int n, double[] x, double[][] jac);
056
057}