Date: Sep 25, 2013 4:08 AM
Author: NIcholas
Subject: dgemm in 64-bit C++ error

I am being told that MATLAB has encountered an internal error and needs to close when running this very simple dgemm call in c++ (64-bit windows).  Does anyone know why?

// file: blasTest.cpp
#include "matrix.h"
#include "mex.h"
#include "blas.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
int K = 256; int M = 100;
double* Phi = (double*) mxMalloc(sizeof(double)*K*K);
for(int i=0; i<K*K; i++)
Phi[i] = double(i);

double* scratch = (double*) mxMalloc(sizeof(double)*K*M);
double* scratch2 = (double*) mxMalloc(sizeof(double)*K*M);
for(int i=0; i<K*M; i++)
scratch[i] = 1.0;

double zero = 0.0; double one = 1.0;
// scratch2 = Phi * scratch
dgemm("N", "N", (ptrdiff_t*)&K, (ptrdiff_t*)&M, (ptrdiff_t*)&K, &one, Phi, (ptrdiff_t*)&K, scratch, (ptrdiff_t*)&K, &zero, scratch2, (ptrdiff_t*)&K);

I am compiling it with these commands:
blaslib = fullfile(matlabroot, 'extern', 'lib', 'win64', 'microsoft', 'libmwblas.lib');
mex('blasTest.cpp', blaslib);