Prev Next Index-> contents reference index search external Up-> CppAD library LuDetAndSolve LuInvert CppAD-> Install Introduction AD ADFun preprocessor multi_thread library ipopt_solve Example speed Appendix library-> ErrorHandler NearEqual speed_test SpeedTest time_test NumericType CheckNumericType SimpleVector CheckSimpleVector nan pow_int Poly LuDetAndSolve RombergOne RombergMul Runge45 Rosen34 OdeErrControl OdeGear OdeGearControl CppAD_vector thread_alloc index_sort BenderQuad opt_val_hes LuRatio LuDetAndSolve-> LuSolve LuFactor LuInvert LuInvert-> lu_invert.cpp lu_invert.hpp Headings-> Syntax Description Include Matrix Storage ip jp LU ---..L ---..U ---..P ---..A X Example Source

Invert an LU Factored Equation
``` ```Syntax ``` # include <cppad/lu_invert.hpp>``` ``` ``` `LuInvert(ip, jp, LU, X)`

Description
Solves the matrix equation `A * X = B` using an LU factorization computed by LuFactor .

Include
The file `cppad/lu_invert.hpp` is included by `cppad/cppad.hpp` but it can also be included separately with out the rest of the `CppAD` routines.

Matrix Storage
All matrices are stored in row major order. To be specific, if ```  Y``` is a vector that contains a ```  p``` by ```  q``` matrix, the size of ```  Y``` must be equal to ```   p * q ``` and for ```  i = 0 , \ldots , p-1``` , ```  j = 0 , \ldots , q-1``` , ```  \[      Y_{i,j} = Y[ i * q + j ] \] ```

ip
The argument `ip` has prototype ```      const SizeVector &ip ``` (see description for `SizeVector` in LuFactor specifications). The size of `ip` is referred to as `n` in the specifications below. The elements of `ip` determine the order of the rows in the permuted matrix.

jp
The argument `jp` has prototype ```      const SizeVector &jp ``` (see description for `SizeVector` in LuFactor specifications). The size of `jp` must be equal to `n` . The elements of `jp` determine the order of the columns in the permuted matrix.

LU
The argument `LU` has the prototype ```      const FloatVector &LU ``` and the size of `LU` must equal ```  n * n``` (see description for `FloatVector` in LuFactor specifications).

L
We define the lower triangular matrix `L` in terms of `LU` . The matrix `L` is zero above the diagonal and the rest of the elements are defined by ```      L(i, j) = LU[ ip[i] * n + jp[j] ] ``` for ```  i = 0 , \ldots , n-1``` and ```  j = 0 , \ldots , i``` .

U
We define the upper triangular matrix `U` in terms of `LU` . The matrix `U` is zero below the diagonal, one on the diagonal, and the rest of the elements are defined by ```      U(i, j) = LU[ ip[i] * n + jp[j] ] ``` for ```  i = 0 , \ldots , n-2``` and ```  j = i+1 , \ldots , n-1``` .

P
We define the permuted matrix `P` in terms of the matrix `L` and the matrix `U` by `P = L * U` .

A
The matrix `A` , which defines the linear equations that we are solving, is given by ```      P(i, j) = A[ ip[i] * n + jp[j] ] ``` (Hence `LU` contains a permuted factorization of the matrix `A` .)

X
The argument `X` has prototype ```      FloatVector &X ``` (see description for `FloatVector` in LuFactor specifications). The matrix `X` must have the same number of rows as the matrix `A` . The input value of `X` is the matrix `B` and the output value solves the matrix equation `A * X = B` .

Example
The file lu_solve.hpp is a good example usage of `LuFactor` with `LuInvert`. The file lu_invert.cpp contains an example and test of using `LuInvert` by itself. It returns true if it succeeds and false otherwise.

Source
The file lu_invert.hpp contains the current source code that implements these specifications.