Navigation

Operators and Keywords

Function List:

C++ API

qr.cc File Reference

#include "CmplxQR.h"
#include "CmplxQRP.h"
#include "dbleQR.h"
#include "dbleQRP.h"
#include "fCmplxQR.h"
#include "fCmplxQRP.h"
#include "floatQR.h"
#include "floatQRP.h"
#include "SparseQR.h"
#include "SparseCmplxQR.h"
#include "defun-dld.h"
#include "error.h"
#include "gripes.h"
#include "oct-obj.h"
#include "utils.h"

Include dependency graph for qr.cc:


Functions

 DEFUN_DLD (qr, args, nargout,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{q}, @var{r}, @var{p}] =} qr (@var{a})\n\ @deftypefnx {Loadable Function} {[@var{q}, @var{r}, @var{p}] =} qr (@var{a}, '0')\n\ @cindex QR factorization\n\ Compute the QR factorization of @var{a}, using standard @sc{lapack}\n\ subroutines. For example, given the matrix @code{a = [1, 2; 3, 4]},\n\ \n\ @example\n\ [q, r] = qr (a)\n\ @end example\n\ \n\ @noindent\n\ returns\n\ \n\ @example\n\ @group\n\ q =\n\ \n\ -0.31623 -0.94868\n\ -0.94868 0.31623\n\ \n\ r =\n\ \n\ -3.16228 -4.42719\n\ 0.00000 -0.63246\n\ @end group\n\ @end example\n\ \n\ The @code{qr} factorization has applications in the solution of least\n\ squares problems\n\ @iftex\n\ @tex\n\ $$\n\ \\min_x \\left\\Vert A x - b \\right\\Vert_2\n\ $$\n\ @end tex\n\ @end iftex\n\ @ifnottex\n\ \n\ @example\n\ @code{min norm(A x - b)}\n\ @end example\n\ \n\ @end ifnottex\n\ for overdetermined systems of equations (i.e.,\n\ @iftex\n\ @tex\n\ $A$\n\ @end tex\n\ @end iftex\n\ @ifnottex\n\ @code{a}\n\ @end ifnottex\n\ is a tall, thin matrix). The QR factorization is\n\ @iftex\n\ @tex\n\ $QR = A$ where $Q$ is an orthogonal matrix and $R$ is upper triangular.\n\ @end tex\n\ @end iftex\n\ @ifnottex\n\ @code{q * r = a} where @code{q} is an orthogonal matrix and @code{r} is\n\ upper triangular.\n\ @end ifnottex\n\ \n\ If given a second argument of '0', @code{qr} returns an economy-sized\n\ QR factorization, omitting zero rows of @var{R} and the corresponding\n\ columns of @var{Q}.\n\ \n\ If the matrix @var{a} is full, the permuted QR factorization\n\ @code{[@var{q}, @var{r}, @var{p}] = qr (@var{a})} forms the QR factorization\n\ such that the diagonal entries of @code{r} are decreasing in magnitude\n\ order. For example,given the matrix @code{a = [1, 2; 3, 4]},\n\ \n\ @example\n\ [q, r, p] = qr(a)\n\ @end example\n\ \n\ @noindent\n\ returns\n\ \n\ @example\n\ @group\n\ q = \n\ \n\ -0.44721 -0.89443\n\ -0.89443 0.44721\n\ \n\ r =\n\ \n\ -4.47214 -3.13050\n\ 0.00000 0.44721\n\ \n\ p =\n\ \n\ 0 1\n\ 1 0\n\ @end group\n\ @end example\n\ \n\ The permuted @code{qr} factorization @code{[q, r, p] = qr (a)}\n\ factorization allows the construction of an orthogonal basis of\n\ @code{span (a)}.\n\ \n\ If the matrix @var{a} is sparse, then compute the sparse QR factorization\n\ of @var{a}, using @sc{CSparse}. As the matrix @var{Q} is in general a full\n\ matrix, this function returns the @var{Q}-less factorization @var{r} of\n\ @var{a}, such that @code{@var{r} = chol (@var{a}' * @var{a})}.\n\ \n\ If the final argument is the scalar @code{0} and the number of rows is\n\ larger than the number of columns, then an economy factorization is\n\ returned. That is @var{r} will have only @code{size (@var{a},1)} rows.\n\ \n\ If an additional matrix @var{b} is supplied, then @code{qr} returns\n\ @var{c}, where @code{@var{c} = @var{q}' * @var{b}}. This allows the\n\ least squares approximation of @code{@var{a} \\ @var{b}} to be calculated\n\ as\n\ \n\ @example\n\ @group\n\ [@var{c},@var{r}] = spqr (@var{a},@var{b})\n\ @var{x} = @var{r} \\ @var{c}\n\ @end group\n\ @end example\n\ @end deftypefn")
 DEFUN_DLD (qrupdate, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{Q1}, @var{R1}] =} qrupdate (@var{Q}, @var{R}, @var{u}, @var{v})\n\ Given a QR@tie{}factorization of a real or complex matrix\n\ @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and\n\ @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization\n\ of @w{@var{A} + @var{u}*@var{v}'}, where @var{u} and @var{v} are\n\ column vectors (rank-1 update) or matrices with equal number of columns\n\ (rank-k update). Notice that the latter case is done as a sequence of rank-1 updates;\n\ thus, for k large enough, it will be both faster and more accurate to recompute\n\ the factorization from scratch.\n\ \n\ The QR factorization supplied may be either full\n\ (Q is square) or economized (R is square).\n\ \n\ @seealso{qr, qrinsert, qrdelete}\n\ @end deftypefn")
 DEFUN_DLD (qrinsert, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{Q1}, @var{R1}] =} qrinsert (@var{Q}, @var{R}, @var{j}, @var{x}, @var{orient})\n\ Given a QR@tie{}factorization of a real or complex matrix\n\ @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and\n\ @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of\n\ @w{[A(:,1:j-1) x A(:,j:n)]}, where @var{u} is a column vector to be\n\ inserted into @var{A} (if @var{orient} is @code{\"col\"}), or the\n\ QR@tie{}factorization of @w{[A(1:j-1,:);x;A(:,j:n)]}, where @var{x}\n\ is a row vector to be inserted into @var{A} (if @var{orient} is\n\ @code{\"row\"}).\n\ \n\ The default value of @var{orient} is @code{\"col\"}.\n\ If @var{orient} is @code{\"col\"},\n\ @var{u} may be a matrix and @var{j} an index vector\n\ resulting in the QR@tie{}factorization of a matrix @var{B} such that\n\ @w{B(:,@var{j})} gives @var{u} and @w{B(:,@var{j}) = []} gives @var{A}.\n\ Notice that the latter case is done as a sequence of k insertions;\n\ thus, for k large enough, it will be both faster and more accurate to recompute\n\ the factorization from scratch.\n\ \n\ If @var{orient} is @code{\"col\"},\n\ the QR factorization supplied may be either full\n\ (Q is square) or economized (R is square).\n\ \n\ If @var{orient} is @code{\"row\"}, full factorization is needed.\n\ @seealso{qr, qrupdate, qrdelete}\n\ @end deftypefn")
 DEFUN_DLD (qrdelete, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{Q1}, @var{R1}] =} qrdelete (@var{Q}, @var{R}, @var{j}, @var{orient})\n\ Given a QR@tie{}factorization of a real or complex matrix\n\ @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and\n\ @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization of\n\ @w{[A(:,1:j-1) A(:,j+1:n)]}, i.e., @var{A} with one column deleted\n\ (if @var{orient} is \"col\"), or the QR@tie{}factorization of\n\ @w{[A(1:j-1,:);A(:,j+1:n)]}, i.e., @var{A} with one row deleted (if\n\ @var{orient} is \"row\").\n\ \n\ The default value of @var{orient} is \"col\".\n\ \n\ If @var{orient} is @code{\"col\"},\n\ @var{j} may be an index vector\n\ resulting in the QR@tie{}factorization of a matrix @var{B} such that\n\ @w{A(:,@var{j}) = []} gives @var{B}.\n\ Notice that the latter case is done as a sequence of k deletions;\n\ thus, for k large enough, it will be both faster and more accurate to recompute\n\ the factorization from scratch.\n\ \n\ If @var{orient} is @code{\"col\"},\n\ the QR factorization supplied may be either full\n\ (Q is square) or economized (R is square).\n\ \n\ If @var{orient} is @code{\"row\"}, full factorization is needed.\n\ @seealso{qr, qrinsert, qrupdate}\n\ @end deftypefn")
 DEFUN_DLD (qrshift, args,,"-*- texinfo -*-\n\ @deftypefn {Loadable Function} {[@var{Q1}, @var{R1}] =} qrshift (@var{Q}, @var{R}, @var{i}, @var{j})\n\ Given a QR@tie{}factorization of a real or complex matrix\n\ @w{@var{A} = @var{Q}*@var{R}}, @var{Q}@tie{}unitary and\n\ @var{R}@tie{}upper trapezoidal, return the QR@tie{}factorization\n\ of @w{@var{A}(:,p)}, where @w{p} is the permutation @*\n\ @code{p = [1:i-1, shift(i:j, 1), j+1:n]} if @w{@var{i} < @var{j}} @*\n\ or @*\n\ @code{p = [1:j-1, shift(j:i,-1), i+1:n]} if @w{@var{j} < @var{i}}. @*\n\ \n\ @seealso{qr, qrinsert, qrdelete}\n\ @end deftypefn")

Function Documentation

DEFUN_DLD ( qrshift  ,
args   
)

DEFUN_DLD ( qrdelete  ,
args   
)

DEFUN_DLD ( qrinsert  ,
args   
)

DEFUN_DLD ( qrupdate  ,
args   
)

DEFUN_DLD ( qr  ,
args  ,
nargout   
)