Hi, I wrote some software a while ago, and it uses BLAS in a mex file. Everything compiles well in 2008b, but in the newer versions the files with BLAS crash when running (newer version could only be tested on 64-bit unix). I already replaced all integers by mxSignedIndex – it did not help. Any suggestions what else changed and needs to be updated? Below is an excerpt from the code. Thanks!
#ifdef _WIN32 double ddot(mwSignedIndex*, double*, mwSignedIndex*, double*, mwSignedIndex*);#else double ddot_(mwSignedIndex*, double*, mwSignedIndex*, double*, mwSignedIndex*);#endifvoid mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){double *k, *dK, *t, *w, *tdiff;double *inds;double sigma, dprod, oneD=-1.0;mwSignedIndex n, m, nw, i, j, colind, oneI = 1, nm;k = mxGetPr(prhs[0]);inds = (double*) mxGetPr(prhs[1]);w = mxGetPr(prhs[2]);t = mxGetPr(prhs[3]);sigma = *mxGetPr(prhs[4]);sigma *= -sigma;sigma = 1/sigma;n = mxGetM(prhs[0]); /* number of samples */m = mxGetN(prhs[0]); /* number of indices (called d elsewhere) */nw = mxGetN(prhs[2]); /* length of w: number of sources */nm = n*m;plhs[0] = mxCreateDoubleMatrix(nm, nw, mxREAL);dK = mxGetPr(plhs[0]);tdiff = mxCalloc(nw, sizeof(double));for (i=0; i<m; ++i){ /* column index */ colind = (mwSignedIndex)(inds[i]) - 1; for (j=0; j<n; ++j){ /* tdiff = tj - ti */ dcopy_(&nw, &t[j*nw], &oneI, tdiff, &oneI); daxpy_(&nw, &oneD, &t[colind*nw], &oneI, tdiff, &oneI); /* dprod = w * (ti - tj) */ dprod = ddot_(&nw, w, &oneI, tdiff, &oneI); /* dK( (i,j),:) = -K(i,j)/sigma * w * (tj - ti)(tj - ti)' */ dcopy_(&nw, tdiff, &oneI, &dK[i*n + j], &nm); dprod *= k[i*n + j] * sigma; dscal_(&nw, &dprod, &dK[i*n + j], &nm); } }mxFree(tdiff);return;}
Best Answer