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