QRDecomposition - Maple Help

LinearAlgebra

 QRDecomposition
 compute QR factorization of a Matrix

 Calling Sequence QRDecomposition(A, fs, out, c, options, outopts)

Parameters

 A - Matrix fs - (optional) equation of the form fullspan=true or false; selects whether a full QR factorization is performed out - (optional) equation of the form output = obj where obj is one of 'Q', R', 'NAG', or 'rank', or a list containing one or more of these names; selects result objects to compute c - (optional) equation of the form conjugate=true or false; selects whether conjugations are performed in the Gram-Schmidt process options - (optional); constructor options for the result object(s) outopts - (optional) equation of the form outputoptions[o] = list where o is one of 'Q', 'R', or 'NAG'; constructor options for the specified result object

Description

 • The QRDecomposition function computes the QR decomposition of the Matrix A.
 • If A contains symbolic entries, a Gram-Schmidt process is used to generate the factorization of A. If the fullspan option (fs) is omitted or entered as fullspan=false, and A does not have full rank or has more rows than columns, a Q1R1 factorization is performed. The columns of the Q1 factor span the column space of A.
 If the fullspan option is specified as just the symbol fullspan or as fullspan=true, or A has full rank, then a full QR factorization is performed.
 If the QR decomposition is successful, then the Matrix is full rank. Otherwise, at some point a 0 column (on and below the diagonal) will be encountered. Thus the rank is an optional output object.
 By default, elements are conjugated during the Gram-Schmidt process. If conjugate=false is specified in the calling sequence, no conjugations are performed.
 • If A contains floating-point entries, Householder transformations are used to compute the factorization.
 • Depending on what is included in the output option (out), an expression sequence containing Q, R, rank or an expression sequence containing NAG, rank, can be returned. The objects are returned in the same order as specified in the output list.
 If rank is included in the output option along with R or NAG and A contains floating-point entries, then the rank is computed by counting the number of diagonal entries in the R (or NAG) factor which exceed a certain tolerance, equal to the product of $e$ and $c$, where $c$ is equal to the maximum absolute diagonal element of R. If R contains hardware floating-point entries, then $e$ is taken to be 10^(1-evalhf(Digits)), else $e$ is taken to be 10^(1-Digits) in the case of software floating-point entries.
 The output object NAG may only be requested if the input Matrix contains floating-point data. It may not be requested with either of the other Matrix output objects, Q or R. The NAG object is an expression sequence whose first item is a Matrix and whose second item is a Vector. The Matrix component of the NAG output object contains R in the upper triangle if m >= n, and in the lower triangle if m < n. The remaining portion of the Matrix component, and the Vector component of the NAG output object contain details of the reflectors that make up the factors of Q.
 The fullspan option is incompatible with the output=[NAG] option for a nonsquare Matrix A.
 If the output option is not included in the calling sequence, the returned expression sequence contains the objects Q and R.
 • The constructor options provide additional information (readonly, shape, storage, order, datatype, and attributes) to the Matrix or Vector constructor that builds the result(s). These options may also be provided in the form outputoptions[o]=[...], where [...] represents a Maple list.  If a constructor option is provided in both the calling sequence directly and in an outputoptions[o] option, the latter takes precedence (regardless of the order).
 The following list indicates permissible values for index [o] of outputoptions with their corresponding meaning.

 Q orthonormal (unitary) factor R upper triangular factor NAG compact (NAG-style) form

 • The QR decomposition of a Matrix can be used as input for the LinearSolve command. For more details on how to do this, see that help page.
 • This function is part of the LinearAlgebra package, and so it can be used in the form QRDecomposition(..) only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[QRDecomposition](..).

Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$
 > $A≔⟨⟨2,3,1⟩|⟨4,6,-1⟩|⟨-1,-\frac{3}{2},-2⟩⟩$
 ${A}{≔}\left[\begin{array}{ccc}{2}& {4}& {-1}\\ {3}& {6}& {-}\frac{{3}}{{2}}\\ {1}& {-1}& {-2}\end{array}\right]$ (1)
 > $\mathrm{Q1},\mathrm{R1}≔\mathrm{QRDecomposition}\left(A\right)$
 ${\mathrm{Q1}}{,}{\mathrm{R1}}{≔}\left[\begin{array}{cc}\frac{\sqrt{{14}}}{{7}}& \frac{\sqrt{{182}}}{{91}}\\ \frac{{3}{}\sqrt{{14}}}{{14}}& \frac{{3}{}\sqrt{{182}}}{{182}}\\ \frac{\sqrt{{14}}}{{14}}& {-}\frac{\sqrt{{182}}}{{14}}\end{array}\right]{,}\left[\begin{array}{ccc}\sqrt{{14}}& \frac{{25}{}\sqrt{{14}}}{{14}}& {-}\frac{{17}{}\sqrt{{14}}}{{28}}\\ {0}& \frac{{3}{}\sqrt{{182}}}{{14}}& \frac{{3}{}\sqrt{{182}}}{{28}}\end{array}\right]$ (2)
 > $Q,R≔\mathrm{QRDecomposition}\left(A,\mathrm{fullspan}\right)$
 ${Q}{,}{R}{≔}\left[\begin{array}{ccc}\frac{\sqrt{{14}}}{{7}}& \frac{\sqrt{{182}}}{{91}}& \frac{{3}{}\sqrt{{13}}}{{13}}\\ \frac{{3}{}\sqrt{{14}}}{{14}}& \frac{{3}{}\sqrt{{182}}}{{182}}& {-}\frac{{2}{}\sqrt{{13}}}{{13}}\\ \frac{\sqrt{{14}}}{{14}}& {-}\frac{\sqrt{{182}}}{{14}}& {0}\end{array}\right]{,}\left[\begin{array}{ccc}\sqrt{{14}}& \frac{{25}{}\sqrt{{14}}}{{14}}& {-}\frac{{17}{}\sqrt{{14}}}{{28}}\\ {0}& \frac{{3}{}\sqrt{{182}}}{{14}}& \frac{{3}{}\sqrt{{182}}}{{28}}\\ {0}& {0}& {0}\end{array}\right]$ (3)
 > $\mathrm{Equal}\left(\mathrm{Q1}·\mathrm{R1},A\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{Equal}\left(Q·R,A\right)$
 ${\mathrm{true}}$ (5)
 > $B≔\mathrm{RandomMatrix}\left(5,3,\mathrm{datatype}=\mathrm{float}\right)$
 ${B}{≔}\left[\begin{array}{ccc}{-55.}& {-58.}& {21.}\\ {-67.}& {-94.}& {-25.}\\ {77.}& {-7.}& {40.}\\ {-70.}& {12.}& {97.}\\ {13.}& {-53.}& {43.}\end{array}\right]$ (6)
 > $q,\mathrm{rank}≔\mathrm{QRDecomposition}\left(B,\mathrm{output}=\left['Q','\mathrm{rank}'\right]\right)$
 ${q}{,}{\mathrm{rank}}{≔}\left[\begin{array}{ccc}{-0.404236959526025}& {-0.325148151236784}& {-0.133500424154767}\\ {-0.492434114331703}& {-0.607208051444882}& {0.259722770127406}\\ {0.565931743336435}& {-0.342406118362327}& {-0.459567316295425}\\ {-0.514483403033123}& {0.362249263307967}& {-0.726932278450482}\\ {0.0955469177061514}& {-0.526412939951793}& {-0.418436451289387}\end{array}\right]{,}{3}$ (7)
 > $\mathrm{map}\left(\mathrm{fnormal},\mathrm{Transpose}\left(q\right)·q\right)$
 $\left[\begin{array}{ccc}{1.}& {-0.}& {0.}\\ {-0.}& {1.000000000}& {0.}\\ {0.}& {0.}& {1.000000000}\end{array}\right]$ (8)