Q-less QR decomposition
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
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 after 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 after 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
after each row of
A is processed.
R— Upper-triangular factor
Upper-triangular factor, returned as a matrix that satisfies A = Q*R.
Generate code for double-precision, single-precision, and fixed-point data types.
A must be signed and use binary-point scaling. Slope-bias representation is not supported for fixed-point data types.