Class QuadraticFunction
- java.lang.Object
-
- org.hipparchus.optim.nonlinear.vector.constrained.TwiceDifferentiableFunction
-
- org.hipparchus.optim.nonlinear.vector.constrained.QuadraticFunction
-
- All Implemented Interfaces:
MultivariateFunction
public class QuadraticFunction extends TwiceDifferentiableFunction
Given P, Q, d, implements \(\frac{1}{2}x^T P X + Q^T x + d\). The gradient is P x + Q^T, and the Hessian is P- Since:
- 3.1
-
-
Constructor Summary
Constructors Constructor Description QuadraticFunction(double[][] h, double[] c, double d)
Construct quadratic function \(\frac{1}{2}x^T P X + Q^T x + d\).QuadraticFunction(RealMatrix p, RealVector q, double d)
Construct quadratic function \(\frac{1}{2}x^T P X + Q^T x + d\).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
dim()
Returns the dimensionality of the function domain.double
getD()
Get constant term.RealMatrix
getP()
Get square matrix of weights for quadratic terms.RealVector
getQ()
Get vector of weights for linear terms.RealVector
gradient(RealVector x)
Returns the gradient of this function at (x)RealMatrix
hessian(RealVector x)
The Hessian of this function at (x)double
value(RealVector x)
Returns the value of this function at (x)-
Methods inherited from class org.hipparchus.optim.nonlinear.vector.constrained.TwiceDifferentiableFunction
gradient, hessian, value
-
-
-
-
Constructor Detail
-
QuadraticFunction
public QuadraticFunction(RealMatrix p, RealVector q, double d)
Construct quadratic function \(\frac{1}{2}x^T P X + Q^T x + d\).- Parameters:
p
- square matrix of weights for quadratic terms. Typically expected to be positive definite or positive semi-definite.q
- vector of weights for linear terms.d
- constant term
-
QuadraticFunction
public QuadraticFunction(double[][] h, double[] c, double d)
Construct quadratic function \(\frac{1}{2}x^T P X + Q^T x + d\).- Parameters:
h
- square matrix of weights for quadratic terms. Typically expected to be positive definite or positive semi-definite.c
- vector of weights for linear terms.d
- constant term
-
-
Method Detail
-
getP
public RealMatrix getP()
Get square matrix of weights for quadratic terms.- Returns:
- square matrix of weights for quadratic terms
-
getQ
public RealVector getQ()
Get vector of weights for linear terms.- Returns:
- vector of weights for linear terms
-
getD
public double getD()
Get constant term.- Returns:
- constant term
-
dim
public int dim()
Returns the dimensionality of the function domain. If dim() returns (n) then this function expects an n-vector as its input.- Specified by:
dim
in classTwiceDifferentiableFunction
- Returns:
- the expected dimension of the function's domain
-
value
public double value(RealVector x)
Returns the value of this function at (x)- Specified by:
value
in classTwiceDifferentiableFunction
- Parameters:
x
- a point to evaluate this function at.- Returns:
- the value of this function at (x)
-
gradient
public RealVector gradient(RealVector x)
Returns the gradient of this function at (x)- Specified by:
gradient
in classTwiceDifferentiableFunction
- Parameters:
x
- a point to evaluate this gradient at- Returns:
- the gradient of this function at (x)
-
hessian
public RealMatrix hessian(RealVector x)
The Hessian of this function at (x)- Specified by:
hessian
in classTwiceDifferentiableFunction
- Parameters:
x
- a point to evaluate this Hessian at- Returns:
- the Hessian of this function at (x)
-
-