## Libraries.Compute.MatrixTransform.LowerUpperDecomposition Documentation

This class calculates a matrix into two matrices. The first, lower, is a lower triangular matrix, which means all elements above the diagonal are zero. In the lower matrix, the diagonals are all 1s. The second matrix, Upper, has all of its lower elements as 0 and the diagonal is not guaranteed to have 1s. This type of decomposition is sometimes called, "LUDecomposition." Ultimately, this type of class is a numerical support class, where the decomposition can be used to conduct other kinds of mathematical computations. This class was adapted from the LUDecomposition class in Apache Commons. More information can be found about this kind of decomposition on wikipedia or other sources: Lower Upper Decomposition.

Example Code

``````:

use Libraries.Compute.Matrix
use Libraries.Compute.MatrixTransform.LowerUpperDecomposition

Matrix matrix
matrix:SetSize(3,3)
matrix:Set(0,0,12.0)
matrix:Set(1,0,6)
matrix:Set(2,0,-4)

matrix:Set(0,1,-51)
matrix:Set(1,1,167)
matrix:Set(2,1,24)

matrix:Set(0,2,4)
matrix:Set(1,2,-68)
matrix:Set(2,2,-41)

LowerUpperDecomposition decomp
decomp:Calculate(matrix)

Matrix value = decomp:GetResult()
output value:ToText()
``````

Inherits from: Libraries.Language.Object

## Actions Documentation

### Calculate(Libraries.Compute.Matrix matrix)

This action does the decomposition and stores the matrices as state inside of this class. Thus, the matrices can then be copied, stored, or used as desired. To obtain the results, we call GetLowerTriangular or GetUpperTriangular. In order to obtain a solution to a problem for a particular matrix once we have decomposition, we must call Solve.

#### Parameters

Example

``````:

use Libraries.Compute.Matrix
use Libraries.Compute.MatrixTransform. LowerUpperDecomposition

Matrix matrix
matrix:SetSize(3,3)
matrix:Set(0,0,12.0)
matrix:Set(1,0,6)
matrix:Set(2,0,-4)

matrix:Set(0,1,-51)
matrix:Set(1,1,167)
matrix:Set(2,1,24)

matrix:Set(0,2,4)
matrix:Set(1,2,-68)
matrix:Set(2,2,-41)

LowerUpperDecompositiondecomp
decomp:Calculate(matrix)

Matrix value = decomp: GetLowerTriangular ()
output value:ToText()
``````

### Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

#### Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

``````Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
``````

### Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

#### Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

``````use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
``````

### GetDeterminant()

This action calculates the determinant using the decomposition

number:

### GetHashCode()

This action gets the hash code for an object.

#### Return

integer: The integer hash code of the object.

Example

``````Object o
integer hash = o:GetHashCode()
``````

### GetInverse()

This action calls solve using the identity matrix as a parameter, with the size given by the Pivot.

### Solve(Libraries.Compute.Matrix matrix)

This action solves the decomposition for a particular Matrix named matrix.

#### Return

Example

``````:

use Libraries.Compute.Matrix
use Libraries.Compute.MatrixTransform. LowerUpperDecomposition

Matrix matrix
matrix:SetSize(3,3)
matrix:Set(0,0,12.0)
matrix:Set(1,0,6)
matrix:Set(2,0,-4)

matrix:Set(0,1,-51)
matrix:Set(1,1,167)
matrix:Set(2,1,24)

matrix:Set(0,2,4)
matrix:Set(1,2,-68)
matrix:Set(2,2,-41)

LowerUpperDecompositiondecomp
decomp:Calculate(matrix)

//Calls Solve for the pivot generated by the decomposition
Matrix value = decomp:GetInverse()
output value:ToText()
``````