c - My code crashes when calling my solve_chol() function using the lapack library -


#include "mex.h" #include <math.h> #include <string.h>  extern int dpotrs(char *, int *, int *, double *, int *, double *, int *, int *);  void mexfunction(int nlhs, mxarray *plhs[], int nrhs, const mxarray *prhs[]) {   double *c;   int n, m, q;    if (nrhs != 2 || nlhs > 1)                              /* check         input */     mexerrmsgtxt("usage: x = solve_chol(r, b)");    n = mxgetn(prhs[0]);    if (n != mxgetm(prhs[0]))     mexerrmsgtxt("error: first argument matrix must square");    if (n != mxgetm(prhs[1]))     mexerrmsgtxt("error: first , second argument matrices must have same     number of rows");    m = mxgetn(prhs[1]);   plhs[0] = mxcreatedoublematrix(n, m, mxreal); /* allocate space output */   c = mxgetpr(plhs[0]);    if (n==0) return;              /* if argument empty matrix, no more */     memcpy(c,mxgetpr(prhs[1]),n*m*sizeof(double));   /* copy argument matrix */     dpotrs("u", &n, &m, mxgetpr(prhs[0]), &n, c, &n, &q);   /* solve system */    if (q > 0)     mexerrmsgtxt("error: illegal input solve_chol"); } 

hello guys,

i having problem c-code. supposed solve matrix system (ax = b) a being symmetric, positive definite , in upper triangular form?

i created snippet boost matlab performance, unfortunately matlab crashes , debugging showed problem call of dpotrs() towards end of script. can see problem might be?

information on dpotrs() can found here: http://physics.oregonstate.edu/~rubin/nacphy/lapack/routines/dpotrs.html

would great if help


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -