Q-less QR decomposition
Solve a System of Equations Using Forward and Backward Substitution
This example shows how to solve the system of equations using forward and backward substitution.
Specify the input variables,
rng default; A = gallery('randsvd', [5,3], 1000); b = [1; 1; 1; 1; 1];
Compute the upper-triangular factor,
A, where .
R = fixed.qlessQR(A);
Use forward and backward substitution to compute the value of
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
x = fixed.qlessQRMatrixSolve(A,b)
x = 5×1 105 × -0.9088 2.7123 -0.8958 0 0
Compute Upper-Triangular Matrix Factor Using Forgetting Factor
Using a forgetting factor with the
fixed.qlessQR function is roughly equivalent to the Complex- and Real Partial-Systolic Q-less QR with Forgetting Factor blocks. These blocks process one row of the input matrix at a time and apply the forgetting factor before each row is processed. The
fixed.qlessQR function takes in all rows of A at once, but carries out the computation in the same way as the blocks. The forgetting factor is applied before each row is processed.
Specifying a forgetting factor is useful when you want to stream an indefinite number of rows continuously, such as reading values from a sensor array continuously, without accumulating the data without bound.
Without using a forgetting factor, the accumulation is the square root of the number of rows, so 10000 rows would accumulate to .
A = ones(10000,3); R = fixed.qlessQR(A)
R = 3×3 100.0000 100.0000 100.0000 0 0.0000 0.0000 0 0 0.0000
To accrue with the effective height of m=16 rows, set the forgetting factor to the following.
m=16; forgettingFactor = exp(-1/(2*m))
forgettingFactor = 0.9692
Using the forgetting factor,
fixed.qlessQR would accumulate to about square root of 16.
R = fixed.qlessQR(A,forgettingFactor)
R = 3×3 3.9377 3.9377 3.9377 0 0.0000 0.0000 0 0 0.0000
A — Input matrix
Input matrix, specified as a matrix.
Complex Number Support: Yes
forgettingFactor — Forgetting factor
Forgetting factor, specified as a nonnegative scalar between 0 and 1. The forgetting
factor determines how much weight past data is given. The
forgettingFactor value is multiplied by R
before each row of
A is processed.
regularizationParameter — Regularization parameter
0 (default) | nonnegative scalar
Regularization parameter, specified as a nonnegative scalar. Small, positive values of the regularization parameter can improve the conditioning of the problem and reduce the variance of the estimates. While biased, the reduced variance of the estimate often results in a smaller mean squared error when compared to least-squares estimates.
R — Upper-triangular factor
Upper-triangular factor, returned as a matrix that satisfies A = QR.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Generate code for double-precision, single-precision, and fixed-point data types.
Design and simulate fixed-point systems using Fixed-Point Designer™.
A must be signed and use binary-point scaling. Slope-bias representation is not supported for fixed-point data types.