- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

#include

#include

#include

typedef size_t INT;

#define MKL_INT INT

#include "mkl_lapacke.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

{

/* Locals */

lapack_int n, nr, lda, ldb, info;

double *ar, *br;

ar = mxGetPr(prhs[0]); /* pointer to first input matrix */

br = mxGetPr(prhs[1]); /* pointer to second input matrix */

// dimensions of input matrix A //

lda = mxGetM(prhs[0]);

n = mxGetM(prhs[1]);

// dimensions of input matrix B //

ldb = n;

nr = mxGetN(prhs[1]);

if (lda != (ldb*(ldb+1)/2))

mexErrMsgTxt("Error, size mismatch.");

// Local arrays //

lapack_int *ipiv;

ipiv = (lapack_int *) mxMalloc(2*n*sizeof(lapack_int));

//lapack_int ipiv;

info = LAPACKE_dspsv( LAPACK_COL_MAJOR, 'U', n, nr, ar, ipiv, br, ldb);

mxFree(ipiv);

}

Link Copied

2 Replies

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

[cpp]info = LAPACKE_dgesv( LAPACK_COL_MAJOR, n, nr, ar, lda, ipiv, br, ldb);[/cpp]

everything seems to work perfectly. At least I haven't been able to crash it yet. Using dspsv, it would generally run once, and then crash the next time it ran. The input matrix is a column matrix that has the right number of elements for a packed storage matrix (n*(n+1)/2), so I have no idea what the problem could be, especially since it seems to work correctly for very small arrays and when it does run it runs fine for large arrays as well. Any ideas?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page