Doxygen Source Code Documentation
QRDecom.m
Go to the documentation of this file.00001 function [err, Qd, dfx, dmat2] = QRDecom(dmat, cmat)
00002 %
00003 % [err,] = QRDecom.m ()
00004 %
00005 %Purpose:
00006 %
00007 %
00008 %
00009 %Input Parameters:
00010 %
00011 %
00012 %
00013 %Output Parameters:
00014 % err : 0 No Problem
00015 % : 1 Problems
00016 %
00017 %
00018 %
00019 %Key Terms:
00020 %
00021 %More Info :
00022 %
00023 %
00024 %
00025 %
00026 % Author : Gang Chen
00027 % Date : Tue Mar 23 16:09:23 EST 2004
00028 % SSCC/NIMH/ National Institutes of Health, Bethesda MD 20892
00029
00030
00031 %Define the function name for easy referencing
00032 FuncName = 'QRDecom.m';
00033
00034 %Debug Flag
00035 DBG = 1;
00036
00037 %initailize return variables
00038 err = 1;
00039
00040 % Tolerance for computing rank from diag(R) after QR decomposition
00041 %[nrows,ncols] = size(dmat);
00042
00043 % Find the null space of the constraints matrix
00044 [Qc,Rc,Ec] = qr(cmat');
00045 pc = Rrank(Rc);
00046 Qc0 = Qc(:,pc+1:end);
00047
00048 % Do qr decomposition on design matrix projected to null space
00049 Dproj = dmat*Qc0;
00050 [Qd,Rd,Ed] = qr(Dproj,0);
00051 dfx = Rrank(Rd);
00052 Qd = Qd(:,1:dfx);
00053 %Rd = Rd(1:dfx,1:dfx);
00054
00055 % Return reduced design matrix if requested
00056 if nargout>3
00057 dmat2 = Qd' * dmat;
00058 end
00059
00060 err = 0;
00061 return;