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@tie{}factorization of @var{A}, using standard @sc{lapack}\n\ subroutines. For example, given the matrix @code{@var{A} = [1, 2; 3, 4]},\n\ \n\ @example\n\ [@var{Q}, @var{R}] = qr (@var{A})\n\ @end example\n\ \n\ @noindent\n\ returns\n\ \n\ @example\n\ @group\n\ @var{Q} =\n\ \n\ -0.31623 -0.94868\n\ -0.94868 0.31623\n\ \n\ @var{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\ @tex\n\ $$\n\ \\min_x \\left\\Vert A x - b \\right\\Vert_2\n\ $$\n\ @end tex\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\ @tex\n\ $A$\n\ @end tex\n\ @ifnottex\n\ @var{A}\n\ @end ifnottex\n\ is a tall, thin matrix). The QR@tie{}factorization is\n\ @tex\n\ $QR = A$ where $Q$ is an orthogonal matrix and $R$ is upper triangular.\n\ @end tex\n\ @ifnottex\n\ @code{@var{Q} * @var{Q} = @var{A}} where @var{Q} is an orthogonal matrix and\n\ @var{R} is upper triangular.\n\ @end ifnottex\n\ \n\ If given a second argument of '0', @code{qr} returns an economy-sized\n\ QR@tie{}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@tie{}factorization\n\ @code{[@var{Q}, @var{R}, @var{P}] = qr (@var{A})} forms the\n\ QR@tie{}factorization such that the diagonal entries of @var{R} are\n\ decreasing in magnitude order. For example, given the matrix @code{a = [1,\n\ 2; 3, 4]},\n\ \n\ @example\n\ [@var{Q}, @var{R}, @var{P}] = qr (@var{A})\n\ @end example\n\ \n\ @noindent\n\ returns\n\ \n\ @example\n\ @group\n\ @var{Q} = \n\ \n\ -0.44721 -0.89443\n\ -0.89443 0.44721\n\ \n\ @var{R} =\n\ \n\ -4.47214 -3.13050\n\ 0.00000 0.44721\n\ \n\ @var{P} =\n\ \n\ 0 1\n\ 1 0\n\ @end group\n\ @end example\n\ \n\ The permuted @code{qr} factorization @code{[@var{Q}, @var{R}, @var{P}] = qr\n\ (@var{A})} 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\n\ QR@tie{}factorization of @var{A}, using @sc{CSparse}. As the matrix @var{Q}\n\ is in general a full matrix, this function returns the @var{Q}-less\n\ factorization @var{R} of @var{A}, such that @code{@var{R} = chol (@var{A}' *\n\ @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\ 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\n\ updates; thus, for k large enough, it will be both faster and more accurate\n\ to recompute the factorization from scratch.\n\ \n\ The QR@tie{}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\n\ recompute the factorization from scratch.\n\ \n\ If @var{orient} is @code{\"col\"},\n\ the QR@tie{}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\n\ recompute the factorization from scratch.\n\ \n\ If @var{orient} is @code{\"col\"},\n\ the QR@tie{}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 ( qrdelete  ,
args   
)
DEFUN_DLD ( qrinsert  ,
args   
)
DEFUN_DLD ( qrupdate  ,
args   
)
DEFUN_DLD ( qrshift  ,
args   
)
DEFUN_DLD ( qr  ,
args  ,
nargout   
)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines