All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ojalgo.function.multiary.MultiaryFunction Maven / Gradle / Ivy

Go to download

oj! Algorithms - ojAlgo - is Open Source Java code that has to do with mathematics, linear algebra and optimisation.

There is a newer version: 55.0.1
Show newest version
/*
 * Copyright 1997-2024 Optimatika
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package org.ojalgo.function.multiary;

import org.ojalgo.ProgrammingError;
import org.ojalgo.function.BasicFunction;
import org.ojalgo.function.UnaryFunction;
import org.ojalgo.matrix.store.MatrixStore;
import org.ojalgo.matrix.store.PhysicalStore;
import org.ojalgo.structure.Access1D;

public interface MultiaryFunction> extends BasicFunction.PlainUnary, N> {

    public interface Affine> extends Linear, Constant {

    }

    public interface Constant> extends MultiaryFunction {

        N getConstant();

        void setConstant(Comparable constant);

    }

    public interface Convex> extends MultiaryFunction {

    }

    public interface Linear> extends MultiaryFunction {

        PhysicalStore linear();

    }

    public interface PureQuadratic> extends Constant {

        PhysicalStore quadratic();

    }

    public interface Quadratic> extends PureQuadratic, Linear {

    }

    /**
     * Twice (Continuously) Differentiable Multiary Function
     *
     * @author apete
     */
    public interface TwiceDifferentiable> extends MultiaryFunction {

        /**
         * 

* The gradient of a scalar field is a vector field that points in the direction of the greatest rate * of increase of the scalar field, and whose magnitude is that rate of increase. *

*

* The Jacobian is a generalization of the gradient. Gradients are only defined on scalar-valued * functions, but Jacobians are defined on vector- valued functions. When f is real-valued (i.e., f : * Rn → R) the derivative Df(x) is a 1 × n matrix, i.e., it is a row vector. Its transpose is called * the gradient of the function: ∇f(x) = Df(x)T , which is a (column) vector, i.e., in Rn. * Its components are the partial derivatives of f: *

*

* The first-order approximation of f at a point x ∈ int dom f can be expressed as (the affine * function of z) f(z) = f(x) + ∇f(x)T (z − x). *

*/ MatrixStore getGradient(Access1D point); /** *

* The Hessian matrix or Hessian is a square matrix of second-order partial derivatives of a function. * It describes the local curvature of a function of many variables. The Hessian is the Jacobian of * the gradient. *

*

* The second-order approximation of f, at or near x, is the quadratic function of z defined by f(z) = * f(x) + ∇f(x)T (z − x) + (1/2)(z − x)T ∇2f(x)(z − x) *

*/ MatrixStore getHessian(Access1D point); /** * @return The gradient at origin (0-vector), negated or not */ MatrixStore getLinearFactors(boolean negated); default MultiaryFunction.TwiceDifferentiable toFirstOrderApproximation(final Access1D arg) { return new FirstOrderApproximation<>(this, arg); } default MultiaryFunction.TwiceDifferentiable toSecondOrderApproximation(final Access1D arg) { return new SecondOrderApproximation<>(this, arg); } } default MultiaryFunction andThen(final UnaryFunction after) { ProgrammingError.throwIfNull(after); return new MultiaryFunction<>() { public int arity() { return MultiaryFunction.this.arity(); } public N invoke(final Access1D arg) { return after.invoke(MultiaryFunction.this.invoke(arg)); } }; } int arity(); N invoke(Access1D arg); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy