MATLAB COMPILER RELEASE NOTES User's Guide Page 113

  • Download
  • Add to my manuals
  • Print
  • Page
    / 264
  • Table of contents
  • TROUBLESHOOTING
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 112
Mixing M-Files and C or C++
4-43
mxArray *a, *b, *x, *y;
double x_pr[ROWS * COLS] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
double x_pi[ROWS * COLS] = {9, 2, 3, 4, 5, 6, 7, 8, 1};
double y_pr[ROWS * COLS] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
double y_pi[ROWS * COLS] = {2, 9, 3, 4, 5, 6, 7, 1, 8};
double *a_pr, *a_pi, value_of_scalar_b;
multpkgInitialize();/* Call multpkg initialization */
/* Install a print handler to tell mlfPrintMatrix how to
* display its output.
*/
mlfSetPrintHandler(PrintHandler);
/* Create input matrix "x" */
x = mxCreateDoubleMatrix(ROWS, COLS, mxCOMPLEX);
memcpy(mxGetPr(x), x_pr, ROWS * COLS * sizeof(double));
memcpy(mxGetPi(x), x_pi, ROWS * COLS * sizeof(double));
/* Create input matrix "y" */
y = mxCreateDoubleMatrix(ROWS, COLS, mxCOMPLEX);
memcpy(mxGetPr(y), y_pr, ROWS * COLS * sizeof(double));
memcpy(mxGetPi(y), y_pi, ROWS * COLS * sizeof(double));
/* Call the mlfMultarg function. */
a = (mxArray *)mlfMultarg(&b, x, y);
/* Display the entire contents of output matrix "a". */
mlfPrintMatrix(a);
/* Display the entire contents of output scalar "b" */
mlfPrintMatrix(b);
/* Deallocate temporary matrices. */
mxDestroyArray(a);
mxDestroyArray(b);
multpkgTerminate();/* Call multpkg termination */
return(0);
}
Page view 112
1 2 ... 108 109 110 111 112 113 114 115 116 117 118 ... 263 264

Comments to this Manuals

No comments