Main Content

fixed.qlessQRMatrixSolve

Solve system of linear equations (A'A)X = B for X using Q-less QR decomposition

Since R2020b

Description

example

X = fixed.qlessQRMatrixSolve(A,B) solves the system of linear equations (A'A)X = B using QR decomposition, without computing the Q value.

The result of this code is equivalent to computing

[~,R] = qr(A,0);
X = R\(R'\B)
or
X = (A'*A)\B

example

X = fixed.qlessQRMatrixSolve(A,B,outputType) returns the solution to the system of linear equations (A'A)X = B as a variable with the output type specified by outputType.

X = fixed.qlessQRMatrixSolve(A,B,outputType,forgettingFactor) returns the solution to the system of linear equations, with the forgettingFactor multiplied by R after each row of A is processed.

X = fixed.qlessQRMatrixSolve(A,B,outputType,[],regularizationParameter) solves the matrix equation (λ2In+A'A)X=B where λ is the regularizationParameter.

X = fixed.qlessQRMatrixSolve(A,B,outputType,forgettingFactor,regularizationParameter) solves the matrix equation A'α,λAα,λX=B where

Aα,λ=[αmλIn[αmαm1α]A],

α is the forgettingFactor, λ is the regularizationParameter, and m is the number of rows in A.

Examples

collapse all

This example shows how to solve the system of linear equations (AA)X=B using QR decomposition, without explicitly calculating the Q factor of the QR decomposition.

rng('default');
m = 6;
n = 3;
p = 1;
A = randn(m,n);
B = randn(n,p);
X = fixed.qlessQRMatrixSolve(A,B)
X = 3×1

    0.2991
    0.0523
    0.4182

The fixed.qlessQRMatrixSolve function is equivalent to the following code, however the fixed.qlessQRMatrixSolve function is more efficient and supports fixed-point data types.

X = (A'*A)\B
X = 3×1

    0.2991
    0.0523
    0.4182

This example shows how to specify an output data type to solve a system of equations with fixed-point data.

Define the data representing the system of equations. Define the matrix A as a zero-mean, normally distributed random matrix with a standard deviation of 1.

rng('default');
m = 6;
n = 3;
p = 1;
A0 = randn(m,n);
B0 = randn(n,p);

Specify fixed-point data types for A and B as to avoid overflow during the computation of QR.

T.A = fi([],1,22,16);
T.B = fi([],1,22,16);
A = cast(A0,'like',T.A)
A = 
    0.5377   -0.4336    0.7254
    1.8339    0.3426   -0.0630
   -2.2589    3.5784    0.7147
    0.8622    2.7694   -0.2050
    0.3188   -1.3499   -0.1241
   -1.3077    3.0349    1.4897

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 22
        FractionLength: 16
B = cast(B0,'like',T.B)
B = 
    1.4090
    1.4172
    0.6715

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 22
        FractionLength: 16

Specify an output data type to avoid overflow in the back-substitution.

T.X = fi([],1,29,12);

Use the fixed.qlessQRMatrixSolve function to compute the solution, X.

X = fixed.qlessQRMatrixSolve(A,B,T.X)
X = 
    0.2988
    0.0522
    0.4180

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 29
        FractionLength: 12

Compare this result to the result of the built-in MATLAB® operations in double-precision floating-point.

X0 = (A0'*A0)\B0
X0 = 3×1

    0.2991
    0.0523
    0.4182

Input Arguments

collapse all

Coefficient matrix in the linear system of equations (A'A)X = B.

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

Input vector or matrix representing B in the linear system of equations (A'A)X = B.

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 | fi | numerictype

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 the output of the QR decomposition, R after each row of A is processed.

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

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.

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

Output Arguments

collapse all

Solution, returned as a vector or matrix. If A is an m-by-n matrix and B is an m-by-p matrix, then X is an n-by-p matrix.

Extended Capabilities

Version History

Introduced in R2020b

expand all