I did a A = 0.0; and the 1st element of the input parameter was
changed to 0 after I
const Matrix tmp = args(0).matrix_value();
//A_M = mxGetM(prhs);
A_M = tmp.rows();
//A_N = mxGetN(prhs);
A_N = tmp.cols();
//A = mxGetPr(prhs);
A = (double*) tmp.fortran_vec();
Solved my problem.
Yes, but the last line probably made a copy of the data with this last
line with the cast to (double *)!! Try adding A.print_info() after and
see what value rep->count has... If it is "1" you've made a copy..