Hello,
I am trying to call some BLAS routines from MEX code. First, I am trying to compute a scalar product with the fuction DDOT.
Here is my MEX file:
#include "mex.h"#include "blas.h"void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){ double *A, *B, C; int m, one=1; A = mxGetPr(prhs[0]); B = mxGetPr(prhs[1]); m = mxGetM(prhs[0]); /* number of rows */ /* Pass all arguments to Fortran by reference */ C = (double) ddot(&m,A,&one,B,&one); /* create output */ plhs[0] = mxCreateDoubleScalar(C); return; }
The compilation returns no error. When using it, though, I do not get the expected result:
>> a = ones(2,1);>> b = ones(2,1);>> mydot(a,b)ans = 0
Am I calling DDOT inappropriately?
— H. G.
Best Answer