Package org.ddogleg.optimization.math
Class HessianSchurComplement_Base<S extends DMatrix>
java.lang.Object
org.ddogleg.optimization.math.HessianSchurComplement_Base<S>
- All Implemented Interfaces:
HessianMath,HessianSchurComplement<S>
- Direct Known Subclasses:
HessianSchurComplement_DDRM,HessianSchurComplement_DSCC
public abstract class HessianSchurComplement_Base<S extends DMatrix>
extends Object
implements HessianSchurComplement<S>
The approximate Hessian matrix (J'*J) is assumed to have the
following block triangle form: [A B;C D]. The system being solved for
is as follows: [A B;C D] [x_1;x_2] = [b_1;b_2]. Then the following steps
are followed to solve it:
- D' = D - C*inv(A)*B and b_2' = b_2 - C*inv(A)*b_1
- D'*x_2 = b_2'
- A*x_1 = b_1 - B*x_2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LinearSolverSparse<S,DMatrixRMaj> protected LinearSolverSparse<S,DMatrixRMaj> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHessianSchurComplement_Base(LinearSolverSparse<S, DMatrixRMaj> solverA, LinearSolverSparse<S, DMatrixRMaj> solverD) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidvoidcomputeGradient(S jacLeft, S jacRight, DMatrixRMaj residuals, DMatrixRMaj gradient) Computes the gradient using Schur complementprotected abstract voiddivideRowsCols(double[] diagA, int offsetA, S B, double[] diagC, int offsetC) voiddivideRowsCols(DMatrixRMaj scaling) Applies row and column division using the scaling vector.protected abstract voidextractDiag(S input, DMatrixRMaj output) voidextractDiagonals(DMatrixRMaj diag) Extracts diagonal elements from the hessian and stores them in the vector diagvoidinit(int numParameters) Initialize Hessian to be in its initial state with the specified dimensionsbooleanInitializes the solverprotected abstract doubleinnerProduct(double[] a, int offsetA, S B, double[] c, int offsetC) doubleVector matrix inner product of Hessian in block format.protected abstract voidmult(S A, DMatrixRMaj B, DMatrixRMaj C) protected abstract voidmultTransA(S A, DMatrixRMaj B, DMatrixRMaj C) protected abstract voidmultTransA(S A, S B, S C) voidsetDiagonals(DMatrixRMaj diag) Sets the diagonal elements in the Hessian to the provided vectorbooleansolve(DMatrixRMaj gradient, DMatrixRMaj step) Solves the system step = inv(B)*YMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ddogleg.optimization.math.HessianSchurComplement
computeHessian, createMatrix
-
Field Details
-
solverA
-
solverD
-
-
Constructor Details
-
HessianSchurComplement_Base
protected HessianSchurComplement_Base(LinearSolverSparse<S, DMatrixRMaj> solverA, LinearSolverSparse<S, DMatrixRMaj> solverD)
-
-
Method Details
-
init
public void init(int numParameters) Description copied from interface:HessianMathInitialize Hessian to be in its initial state with the specified dimensions- Specified by:
initin interfaceHessianMath- Parameters:
numParameters- Number of optimization parameters. Hessian will be N by N
-
innerVectorHessian
Vector matrix inner product of Hessian in block format.[A B;C D]*[x;y] = [c;d]
A*x + B*y = c
C*x + D*y = d
[x;y]T[A B;C D]*[x;y] = [x;y]T*[c;d]
- Specified by:
innerVectorHessianin interfaceHessianMath- Parameters:
v- row vector- Returns:
- v'*H*v = v'*[A B;C D]*v
-
extractDiagonals
Description copied from interface:HessianMathExtracts diagonal elements from the hessian and stores them in the vector diag- Specified by:
extractDiagonalsin interfaceHessianMath- Parameters:
diag- vector
-
setDiagonals
Description copied from interface:HessianMathSets the diagonal elements in the Hessian to the provided vector- Specified by:
setDiagonalsin interfaceHessianMath- Parameters:
diag- vector
-
divideRowsCols
Description copied from interface:HessianMathApplies row and column division using the scaling vector. B = inv(diag(s))*B*inv(diag(s))- Specified by:
divideRowsColsin interfaceHessianMath
-
initializeSolver
public boolean initializeSolver()Description copied from interface:HessianMathInitializes the solver- Specified by:
initializeSolverin interfaceHessianMath- Returns:
- true if successful
-
solve
Description copied from interface:HessianMathSolves the system step = inv(B)*Y- Specified by:
solvein interfaceHessianMath- Parameters:
gradient- (Input) vectorstep- (output) vector
-
computeGradient
Computes the gradient using Schur complement- Specified by:
computeGradientin interfaceHessianSchurComplement<S extends DMatrix>- Parameters:
jacLeft- (Input) Left side of JacobianjacRight- (Input) Right side of Jacobianresiduals- (Input) Residualsgradient- (Output) Gradient
-
innerProduct
-
extractDiag
-
divideRowsCols
protected abstract void divideRowsCols(double[] diagA, int offsetA, S B, double[] diagC, int offsetC) -
multTransA
-
multTransA
-
add
-
mult
-