#include <linearSystemInterface.hpp>
Public Types | |
using | InterfaceTypes = T_InterfaceTypes |
See LinearSystemInterface. | |
using | Matrix = typename InterfaceTypes::Matrix |
See LinearSystemInterfaceTypes. | |
using | MatrixIdentifier = typename InterfaceTypes::MatrixIdentifier |
See LinearSystemInterfaceTypes. | |
using | MatrixReal = typename InterfaceTypes::MatrixReal |
See LinearSystemInterfaceTypes. | |
using | Type = typename InterfaceTypes::Type |
See LinearSystemInterfaceTypes. | |
using | Vector = typename InterfaceTypes::Vector |
See LinearSystemInterfaceTypes. | |
using | VectorIdentifier = typename InterfaceTypes::VectorIdentifier |
See LinearSystemInterfaceTypes. | |
using | VectorReal = typename InterfaceTypes::VectorReal |
See LinearSystemInterfaceTypes. | |
Public Member Functions | |
Mandatory: Implementations for matrix and vector creation and deletion. | |
template<typename M > | |
MatrixReal * | createMatrixReal (M *mat) |
template<typename M > | |
MatrixIdentifier * | createMatrixIdentifier (M *mat) |
template<typename V > | |
VectorReal * | createVectorReal (V *vec) |
template<typename V > | |
VectorIdentifier * | createVectorIdentifier (V *vec) |
void | deleteMatrixReal (MatrixReal *A_v) |
Delete a real matrix. | |
void | deleteMatrixIdentifier (MatrixIdentifier *A_id) |
Delete an identifier matrix. | |
void | deleteVectorReal (VectorReal *vec_v) |
Delete a real Vector. | |
void | deleteVectorIdentifier (VectorIdentifier *vec_id) |
Delete an identifier vector. | |
Mandatory: Implementations for matrix and vector iterations. | |
template<typename Func , typename MatrixA , typename MatrixB > | |
void | iterateMatrix (Func func, MatrixA *matA, MatrixB *matB) |
Iterate over all elements in the matrices at the same time. | |
template<typename Func , typename MatrixA , typename MatrixB , typename MatrixC > | |
void | iterateMatrix (Func func, MatrixA *matA, MatrixB *matB, MatrixC *matC) |
Iterate over all elements in the matrices at the same time. | |
template<typename Func , typename VectorA , typename VectorB > | |
void | iterateVector (Func func, VectorA *vecA, VectorB *vecB) |
Iterate over all elements in the vectors at the same time. | |
template<typename Func , typename VectorA , typename VectorB , typename VectorC > | |
void | iterateVector (Func func, VectorA *vecA, VectorB *vecB, VectorC *vecC) |
Iterate over all elements in the vectors at the same time. | |
template<typename Func , typename VectorA , typename VectorB , typename VectorC , typename VectorD > | |
void | iterateVector (Func func, VectorA *vecA, VectorB *vecB, VectorC *vecC, VectorD *vecD) |
Iterate over all elements in the vectors at the same time. | |
Mandatory: Implementations for the linear system solve. | |
void | solveSystem (MatrixReal const *A, VectorReal const *b, VectorReal *x) |
Optional: Implementation for reverse mode AD. | |
template<typename Func > | |
void | iterateDyadic (Func func, MatrixIdentifier *mat_id, VectorReal *x_v, VectorReal *b_b) |
MatrixReal * | transposeMatrix (MatrixReal *A_v) |
Create a transposed matrix. | |
Optional: Implementation for forward mode AD. | |
void | subtractMultiply (VectorReal *t, VectorReal const *b_d, MatrixReal const *A_d, VectorReal const *x) |
Computes t = b_d - A_d * x. | |
Optional: Implementations for specializations of the algorithm. | |
void | solveSystemPrimal (MatrixReal const *A, VectorReal const *b, VectorReal *x) |
The interface defines all mandatory and optional functions that are required by the LinearSystemSolverHandler. Implementations need to define all mandatory functions, the optional ones either depend on the use case and on specifics of the algorithm. For more details see LinearSystemSolverHandler.
If the interface has been specialized, it can be called with:
The hints parameter is optional, but can be used to improve the runtime and memory. The set of flags that can be passed as hints is defined in LinearSystemSolverFlags.
See Example 21 - Special handling of linear system solvers for an example with the Eigen implementation.
T_InterfaceTypes | The definition of LinearSystemInterfaceTypes for the implementation. |
MatrixIdentifier * codi::LinearSystemInterface< T_InterfaceTypes >::createMatrixIdentifier | ( | M * | mat | ) |
Create an identifier matrix from an existing one. Values do not need to be copied.
M | M is either Matrix or MatrixIdentifier. |
MatrixReal * codi::LinearSystemInterface< T_InterfaceTypes >::createMatrixReal | ( | M * | mat | ) |
Create a real matrix from an existing one. Values do not need to be copied.
M | M is either Matrix or MatrixIdentifier. |
VectorIdentifier * codi::LinearSystemInterface< T_InterfaceTypes >::createVectorIdentifier | ( | V * | vec | ) |
Create an identifier vector from an existing one. Values do not need to be copied.
V | V is either Vector or VectorIdentifier. |
VectorReal * codi::LinearSystemInterface< T_InterfaceTypes >::createVectorReal | ( | V * | vec | ) |
Create a real vector from an existing one. Values do not need to be copied.
V | V is either Vector or VectorIdentifier. |
|
inline |
Iterate over all elements in mat_id
and
provide the elements in b_b
and
x_v
. For element (i,j) func needs to be called with
func
(mat_id(i,j), b_b(i), x_v(j)) . For sparse matrices, only the elements of the sparsity pattern need to be considered. Used for e.g. the computation of the dyadic product .
void codi::LinearSystemInterface< T_InterfaceTypes >::solveSystem | ( | MatrixReal const * | A, |
VectorReal const * | b, | ||
VectorReal * | x ) |
Solve the linear system with the real valued matrices and vectors. Solves Ax = b for x.
|
inline |
Solve the linear system with the real valued matrices and vectors. Implementation that is called in the primal routine. If not specialized solveSystem is called. Solves Ax = b for x.