Universal MEX wrapper
19 Mar 2012
Call any function in a shared library from Matlab (with some limits on the function signature).
%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);
R = chol(A);
R = [R zeros(n,1); zeros(1,n+1)];
intT = 'int64';
u = [u(end); u(1:end-1)];
[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));
A1 = [u'; u(2:end), A];
%R3 = chol(A1);