Code covered by the BSD License  

Highlights from
Universal MEX wrapper

Universal MEX wrapper

by

 

Call any function in a shared library from Matlab (with some limits on the function signature).

inchol_test.m
%This tests examines a diagonal-pivoting incomplete Cholesky factorization
%for semidefinite dense matrices.  Note that there is no identical Matlab
%builtin. (chol is for PD matrices, ldl for symmetric indefinite matrices.)



dl_load(0); %Loading the resident namespace doesn't leak memory, so we 
%can call it as much as we want.
n = 2000;
rank = 1900;
work = rand(n, rank);
A = work*work';
intT = 'int64';
tic
[UPLO N A2 LDA PIV RNK TOL WORK INFO] = dl_exec('dpstrf_', ...
'L', cast(n,intT),...
A, cast(n,intT), cast(zeros(n,1), intT), ...
cast(0, intT),...
1e-12, zeros(2*n,1), cast(0,intT)); 
toc

L = tril(A2);
L = L(:,1:RNK);
norm(A(PIV, PIV) - L*L',1)

Contact us