7019
|
1 /* |
|
2 |
|
3 Copyright (C) 2007 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
|
20 |
|
21 */ |
|
22 |
6593
|
23 #include <string.h> |
|
24 #include "mex.h" |
|
25 |
|
26 void |
|
27 mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) |
|
28 { |
6686
|
29 mwIndex i, j; |
|
30 mwSize m, n; |
6593
|
31 mxChar *pi, *po; |
|
32 |
|
33 if (nrhs != 1 || ! mxIsChar (prhs[0]) || |
|
34 mxGetNumberOfDimensions (prhs[0]) > 2) |
|
35 mexErrMsgTxt ("expecting char matrix"); |
|
36 |
|
37 m = mxGetM (prhs[0]); |
|
38 n = mxGetN (prhs[0]); |
|
39 pi = mxGetChars (prhs[0]); |
|
40 plhs[0] = mxCreateNumericMatrix (m, n, mxCHAR_CLASS, mxREAL); |
|
41 po = mxGetChars (plhs[0]); |
|
42 |
|
43 for (j = 0; j < n; j++) |
|
44 for (i = 0; i < m; i++) |
|
45 po [j*m + m - 1 - i] = pi [j*m + i]; |
|
46 } |