The copy of the data to the output would be faster using memcpy:
plhs[0] = mxCreateDoubleMatrix(outputRowLen, outputColLen, mxREAL);
memcpy(mxGetPr(plhs[0]), Sigma_Psi_inv_t,
outputRowLen*outputColLen * sizeof(double));
But you can use the data of the output array directly:
plhs[0] = mxCreateDoubleMatrix(rowSigma_Psi, colSigma_Psi, mxREAL);
mexPrintf("entering inverseMatrix");
inverseMatrix(rowSigma_Psi, arraySigma_Psi, mxGetPr(plhs[0]));
Do not use int for LAPACK calls in an 64 bit environment. Use mwSignedIndex instead, which is a 64 bit integer.
Best Answer