# 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:
1. D' = D - C*inv(A)*B and b_2' = b_2 - C*inv(A)*b_1
2. D'*x_2 = b_2'
3. A*x_1 = b_1 - B*x_2
 Triggs, Bill, et al. "Bundle adjustment—a modern synthesis." International workshop on vision algorithms. Springer, Berlin, Heidelberg, 1999.
• ## Field Summary

Fields
Modifier and Type
Field
Description
`protected LinearSolverSparse<S,DMatrixRMaj>`
`solverA`

`protected LinearSolverSparse<S,DMatrixRMaj>`
`solverD`

• ## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected `
```HessianSchurComplement_Base(LinearSolverSparse<S,DMatrixRMaj> solverA, LinearSolverSparse<S,DMatrixRMaj> solverD)```

• ## Method Summary

Modifier and Type
Method
Description
`protected abstract void`
```add(double alpha, S A, double beta, S B, S C)```

`void`
```computeGradient(S jacLeft, S jacRight, DMatrixRMaj residuals, DMatrixRMaj gradient)```
Computes the gradient using Schur complement
`protected abstract void`
```divideRowsCols(double[] diagA, int offsetA, S B, double[] diagC, int offsetC)```

`void`
`divideRowsCols(DMatrixRMaj scaling)`
Applies row and column division using the scaling vector.
`protected abstract void`
```extractDiag(S input, DMatrixRMaj output)```

`void`
`extractDiagonals(DMatrixRMaj diag)`
Extracts diagonal elements from the hessian and stores them in the vector diag
`void`
`init(int numParameters)`
Initialize Hessian to be in its initial state with the specified dimensions
`boolean`
`initializeSolver()`
Initializes the solver
`protected abstract double`
```innerProduct(double[] a, int offsetA, S B, double[] c, int offsetC)```

`double`
`innerVectorHessian(DMatrixRMaj v)`
Vector matrix inner product of Hessian in block format.
`protected abstract void`
```mult(S A, DMatrixRMaj B, DMatrixRMaj C)```

`protected abstract void`
```multTransA(S A, DMatrixRMaj B, DMatrixRMaj C)```

`protected abstract void`
```multTransA(S A, S B, S C)```

`void`
`setDiagonals(DMatrixRMaj diag)`
Sets the diagonal elements in the Hessian to the provided vector
`boolean`
```solve(DMatrixRMaj gradient, DMatrixRMaj step)```
Solves the system step = inv(B)*Y

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.ddogleg.optimization.math.HessianSchurComplement

`computeHessian, createMatrix`

• ## Method Details

• ### init

public void init(int numParameters)
Description copied from interface: `HessianMath`
Initialize Hessian to be in its initial state with the specified dimensions
Specified by:
`init` in interface `HessianMath`
Parameters:
`numParameters` - Number of optimization parameters. Hessian will be N by N
• ### innerVectorHessian

public double innerVectorHessian(DMatrixRMaj v)
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:
`innerVectorHessian` in interface `HessianMath`
Parameters:
`v` - row vector
Returns:
v'*H*v = v'*[A B;C D]*v
• ### extractDiagonals

public void extractDiagonals(DMatrixRMaj diag)
Description copied from interface: `HessianMath`
Extracts diagonal elements from the hessian and stores them in the vector diag
Specified by:
`extractDiagonals` in interface `HessianMath`
Parameters:
`diag` - vector
• ### setDiagonals

public void setDiagonals(DMatrixRMaj diag)
Description copied from interface: `HessianMath`
Sets the diagonal elements in the Hessian to the provided vector
Specified by:
`setDiagonals` in interface `HessianMath`
Parameters:
`diag` - vector
• ### divideRowsCols

public void divideRowsCols(DMatrixRMaj scaling)
Description copied from interface: `HessianMath`
Applies row and column division using the scaling vector. B = inv(diag(s))*B*inv(diag(s))
Specified by:
`divideRowsCols` in interface `HessianMath`
• ### initializeSolver

public boolean initializeSolver()
Description copied from interface: `HessianMath`
Initializes the solver
Specified by:
`initializeSolver` in interface `HessianMath`
Returns:
true if successful
• ### solve

public boolean solve(DMatrixRMaj gradient, DMatrixRMaj step)
Description copied from interface: `HessianMath`
Solves the system step = inv(B)*Y
Specified by:
`solve` in interface `HessianMath`
Parameters:
`gradient` - (Input) vector
`step` - (output) vector

Computes the gradient using Schur complement
Specified by:
`computeGradient` in interface `HessianSchurComplement<S extends DMatrix>`
Parameters:
`jacLeft` - (Input) Left side of Jacobian
`jacRight` - (Input) Right side of Jacobian
`residuals` - (Input) Residuals
`gradient` - (Output) Gradient
• ### innerProduct

protected abstract double innerProduct(double[] a, int offsetA, S B, double[] c, int offsetC)
• ### extractDiag

protected abstract void extractDiag(S input, DMatrixRMaj output)
• ### divideRowsCols

protected abstract void divideRowsCols(double[] diagA, int offsetA, S B, double[] diagC, int offsetC)
• ### multTransA

protected abstract void multTransA(S A, S B, S C)
• ### multTransA

protected abstract void multTransA(S A, DMatrixRMaj B, DMatrixRMaj C)