"Francesco Perrone" <firstname.lastname@example.org> wrote in message <email@example.com>... > Dear Mr. Tursa, > > I have a certain n*n matrix. Then calling > > my_matrix = nn_matrix(itril(size(nn_matrix))); > > I am able to wrap it into a lower triangular factor. > > Afterwards, I manipulate my_matrix by means of a coherence function; the outcome, for only one step of the above mentioned FOR loop, is > > Coh_u = exp(-a.*my_matrix.*sqrt((f(ii)/Uhub).^2 + (0.12/Lc).^2)).*(df.*psd(ii,1)); > > Therefore, Coh_u is alread packed as spptrf input. > > Then I call the lapack wrapper as follows: > > [C1u,C2u,HH_u,C3u] = lapack('spptrf','L',size(nn_matrix,1),Coh_u,0); > > HH_u is the expected result. > > I would more than appreciate if you could write a mex file of the spptrf function for me. Unfortunately I started only now learning some C++ and it would require a long time for me to catch up with mex file. > > Look really forward to hearing from you.
Here is the mex function. It assumes you are passing it a lower triangular matrix in packed form (either single or double) and returns the same. You will have to link in the BLAS and LAPACK libraries. Here is how you would do it on 32-bit Windows:
/* File: spptrf.c * Syntax: B = spptrf(A) * [B,INFO] = spptrf(A) * Purpose: Computes the LAPACK function SPPTRF (or DPPTRF) of the input, which * is assumed to be in lower triangular packed form on input and output * Programmer: James Tursa * Date: 10-Apr-2013 */