%This test requires that the user download and compile libqrupdate
%http://sourceforge.net/projects/qrupdate/. This is an interesting
%test case because it depends on BLAS/LAPACK. However, I think it
%is impossible to link to Matlab's libmwblas.so and libmwlapack.so
%in recent versions. Therefore, you'll have to link to some other
%BLAS on compilation and then shallow bind.
%
%This test assumes you have called dl_load('libqrupdate.so',0);
%at some previous time.
n = 1000;
A = rand(n+1);
Afull = A'*A;
A = Afull(1:n,1:n);
u = Afull(:,end);
tic;
R = chol(A);
toc
R = [R zeros(n,1); zeros(1,n+1)];
intT = 'int64';
u = [u(end); u(1:end-1)];
tic
[N R2 LDR J U WORK INFO] = dl_exec('dchinx_', cast(n,intT),...
R, cast(n+1,intT), cast(1,intT), u, zeros(n+1,1), cast(0, intT));
toc
A1 = [u'; u(2:end), A];
%tic
%R3 = chol(A1);
%toc
norm(A1-R2'*R2,1)