Main Content

fixed.forwardSubstitute

Solve lower-triangular system of equations through forward substitution

Since R2020b

Description

x = fixed.forwardSubstitute(R, B) performs forward substitution on upper-triangular matrix R to compute x = R'\B.

example

x = fixed.forwardSubstitute(R, B, outputType) returns x = R'\B, where the data type of output variable, x, is specified by outputType.

Examples

collapse all

This example shows how to solve the system of equations (AA)x=B using forward and backward substitution.

Specify the input variables, A and B.

rng default;
A = gallery('randsvd', [5,3], 1000);
b = [1; 1; 1; 1; 1];

Compute the upper-triangular factor, R, of A, where A=QR.

R = fixed.qlessQR(A);

Use forward and backward substitution to compute the value of X.

X = fixed.forwardSubstitute(R,b);
X(:) = fixed.backwardSubstitute(R,X)
X = 5×1
105 ×

   -0.9088
    2.7123
   -0.8958
         0
         0

This solution is equivalent to using the fixed.qlessQRMatrixSolve function.

x = fixed.qlessQRMatrixSolve(A,b) 
x = 5×1
105 ×

   -0.9088
    2.7123
   -0.8958
         0
         0

Input Arguments

collapse all

Upper triangular input, specified as a matrix.

Data Types: single | double | fi
Complex Number Support: Yes

Linear system factor, specified as a matrix.

Data Types: single | double | fi
Complex Number Support: Yes

Output data type, specified as a numerictype object or a numeric variable. If outputType is specified as a numerictype object, the output, x, will have the specified data type. If outputType is specified as a numeric variable, x will have the same data type as the numeric variable.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | fi | numerictype

Output Arguments

collapse all

Solution, returned as a matrix satisfying the equation x = R'\B.

Extended Capabilities

Version History

Introduced in R2020b