annotate test/mex/mexnumtst.c @ 28165:478ad929e77a

Fix compilation of BIST file mexnumtst.c. * test/mex/mexnumtst.c: #include "mex.h" rather than <mex.h>.
author Rik <rik@octave.org>
date Sat, 14 Mar 2020 20:23:01 -0700
parents 1188addabaad
children b24567df50ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28165
478ad929e77a Fix compilation of BIST file mexnumtst.c.
Rik <rik@octave.org>
parents: 28132
diff changeset
1 #include "mex.h"
28132
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 // To be called with
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 //
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 // single array
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 // complex single array
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 // double array
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 // complex double array
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 //
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 // Will return arrays of the same type, but created internally to test
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 // the mxArray -> octave_value conversion
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 void
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 mexFunction (int nlhs, mxArray *plhs[],
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 int nrhs, const mxArray *prhs[])
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 {
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 if (nrhs != 4 || nlhs != 4)
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 mexErrMsgTxt ("invalid arguments");
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 const mxArray *sngl_ra = prhs[0];
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 const mxArray *cplx_sngl_ra = prhs[1];
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 const mxArray *dble_ra = prhs[2];
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 const mxArray *cplx_dble_ra = prhs[3];
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #if MX_HAS_INTERLEAVED_COMPLEX
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 mxSingle *sngl_data = mxGetSingles (sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 size_t sngl_data_nr = mxGetM (sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 size_t sngl_data_nc = mxGetN (sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 plhs[0] = mxCreateNumericMatrix (sngl_data_nr, sngl_data_nc, mxSINGLE_CLASS, mxREAL);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 mxSetSingles (plhs[0], sngl_data);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 mxComplexSingle *cplx_sngl_data = mxGetComplexSingles (cplx_sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 size_t cplx_sngl_data_nr = mxGetM (cplx_sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 size_t cplx_sngl_data_nc = mxGetN (cplx_sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 plhs[1] = mxCreateNumericMatrix (cplx_sngl_data_nr, cplx_sngl_data_nc, mxSINGLE_CLASS, mxCOMPLEX);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 mxSetComplexSingles (plhs[1], cplx_sngl_data);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 mxDouble *dble_data = mxGetDoubles (dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 size_t dble_data_nr = mxGetM (dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 size_t dble_data_nc = mxGetN (dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 plhs[2] = mxCreateNumericMatrix (dble_data_nr, dble_data_nc, mxDOUBLE_CLASS, mxREAL);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 mxSetDoubles (plhs[2], dble_data);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 mxComplexDouble *cplx_dble_data = mxGetComplexDoubles (cplx_dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 size_t cplx_dble_data_nr = mxGetM (cplx_dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 size_t cplx_dble_data_nc = mxGetN (cplx_dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 plhs[3] = mxCreateNumericMatrix (cplx_dble_data_nr, cplx_dble_data_nc, mxDOUBLE_CLASS, mxCOMPLEX);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 mxSetComplexDoubles (plhs[3], cplx_dble_data);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 #else
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 mxSingle *sngl_data = (mxSingle *) mxGetData (sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 size_t sngl_data_nr = mxGetM (sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 size_t sngl_data_nc = mxGetN (sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 mxSingle *cplx_sngl_data_real = (mxSingle *) mxGetData (cplx_sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 mxSingle *cplx_sngl_data_imag = (mxSingle *) mxGetImagData (cplx_sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 size_t cplx_sngl_data_nr = mxGetM (cplx_sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 size_t cplx_sngl_data_nc = mxGetN (cplx_sngl_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 mxDouble *dble_data = (mxDouble *) mxGetData (dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 size_t dble_data_nr = mxGetM (dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 size_t dble_data_nc = mxGetN (dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 mxDouble *cplx_dble_data_real = (mxDouble *) mxGetData (cplx_dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 mxDouble *cplx_dble_data_imag = (mxDouble *) mxGetImagData (cplx_dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 size_t cplx_dble_data_nr = mxGetM (cplx_dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 size_t cplx_dble_data_nc = mxGetN (cplx_dble_ra);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 plhs[0] = mxCreateNumericMatrix (sngl_data_nr, sngl_data_nc, mxSINGLE_CLASS, mxREAL);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 mxSetData (plhs[0], sngl_data);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 plhs[1] = mxCreateNumericMatrix (cplx_sngl_data_nr, cplx_sngl_data_nc, mxSINGLE_CLASS, mxCOMPLEX);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 mxSetData (plhs[1], cplx_sngl_data_real);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 mxSetImagData (plhs[1], cplx_sngl_data_imag);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 plhs[2] = mxCreateNumericMatrix (dble_data_nr, dble_data_nc, mxDOUBLE_CLASS, mxREAL);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 mxSetData (plhs[2], dble_data);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 plhs[3] = mxCreateNumericMatrix (cplx_dble_data_nr, cplx_dble_data_nc, mxDOUBLE_CLASS, mxCOMPLEX);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 mxSetData (plhs[3], cplx_dble_data_real);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 mxSetImagData (plhs[3], cplx_dble_data_imag);
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 #endif
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90
1188addabaad simple test for new mex functionality
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 }