ldlsol

Purpose

Computes the solution to a system of linear equations given a factorized matrix returned by the function ldlp() and one or more right hand sides.

Format

x = ldlsol(b, ldl_factor)
Parameters:
  • b (Nx1 vector or NxK matrix) – the right hand sides of the system of linear equations.
  • ldl_factor (Nx(N+1) matrix) – contains the a factorization returned from the function ldlp().
Returns:

x (Nx1 vector or NxK matrix) – contains the solution to LDLTx = b.

Examples

// Assign A matrix
A = { 5   9   3   4,
      9  -6   8   1,
      3   8   2   3,
      4   1   3   9 };

// Assign b matrix
b = { 1.4, 4, 0.5, 3 };

// Factorize matrix 'A'
ldl_f = ldlp(A);

// Solve system of equations
x = ldlsol(b, ldl_f);

The above code will solve the system of linear equations \(Ax = b\), assigning x to be equal to:

     0.5729
x = -0.1529
    -0.2829
     0.1900

Remarks

Matrix factorization is the most computationally intense part of solving a system of linear equations. The factorization can be saved and reused multiple times to prevent the need to repeat the matrix factorization step. ldlsol() uses the LAPACK function dsytrs to solve the system of linear equations.

See also

Functions ldlp(), lusol(), solpd()