4901
|
1 /* |
|
2 |
|
3 Copyright (C) 2004 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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
4901
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
4901
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include "gripes.h" |
|
28 #include "oct-obj.h" |
|
29 #include "ov.h" |
|
30 #include "ov-int8.h" |
|
31 #include "ov-int16.h" |
|
32 #include "ov-int32.h" |
|
33 #include "ov-int64.h" |
|
34 #include "ov-uint8.h" |
|
35 #include "ov-uint16.h" |
|
36 #include "ov-uint32.h" |
|
37 #include "ov-uint64.h" |
4907
|
38 #include "ov-range.h" |
5002
|
39 #include "ov-bool.h" |
|
40 #include "ov-bool-mat.h" |
4901
|
41 #include "ov-scalar.h" |
|
42 #include "ov-re-mat.h" |
5032
|
43 #include "ov-str-mat.h" |
4901
|
44 #include "ov-typeinfo.h" |
|
45 #include "ops.h" |
|
46 |
|
47 // conversion ops |
|
48 |
|
49 DEFCONVFN (scalar_to_int8, scalar, int8) |
|
50 DEFCONVFN (scalar_to_int16, scalar, int16) |
|
51 DEFCONVFN (scalar_to_int32, scalar, int32) |
|
52 DEFCONVFN (scalar_to_int64, scalar, int64) |
|
53 |
|
54 DEFCONVFN (scalar_to_uint8, scalar, uint8) |
|
55 DEFCONVFN (scalar_to_uint16, scalar, uint16) |
|
56 DEFCONVFN (scalar_to_uint32, scalar, uint32) |
|
57 DEFCONVFN (scalar_to_uint64, scalar, uint64) |
|
58 |
|
59 DEFCONVFN (matrix_to_int8, matrix, int8) |
|
60 DEFCONVFN (matrix_to_int16, matrix, int16) |
|
61 DEFCONVFN (matrix_to_int32, matrix, int32) |
|
62 DEFCONVFN (matrix_to_int64, matrix, int64) |
|
63 |
|
64 DEFCONVFN (matrix_to_uint8, matrix, uint8) |
|
65 DEFCONVFN (matrix_to_uint16, matrix, uint16) |
|
66 DEFCONVFN (matrix_to_uint32, matrix, uint32) |
|
67 DEFCONVFN (matrix_to_uint64, matrix, uint64) |
|
68 |
5002
|
69 DEFCONVFN (bool_to_int8, bool, int8) |
|
70 DEFCONVFN (bool_to_int16, bool, int16) |
|
71 DEFCONVFN (bool_to_int32, bool, int32) |
|
72 DEFCONVFN (bool_to_int64, bool, int64) |
|
73 |
|
74 DEFCONVFN (bool_to_uint8, bool, uint8) |
|
75 DEFCONVFN (bool_to_uint16, bool, uint16) |
|
76 DEFCONVFN (bool_to_uint32, bool, uint32) |
|
77 DEFCONVFN (bool_to_uint64, bool, uint64) |
|
78 |
|
79 DEFCONVFN (bool_matrix_to_int8, bool_matrix, int8) |
|
80 DEFCONVFN (bool_matrix_to_int16, bool_matrix, int16) |
|
81 DEFCONVFN (bool_matrix_to_int32, bool_matrix, int32) |
|
82 DEFCONVFN (bool_matrix_to_int64, bool_matrix, int64) |
|
83 |
|
84 DEFCONVFN (bool_matrix_to_uint8, bool_matrix, uint8) |
|
85 DEFCONVFN (bool_matrix_to_uint16, bool_matrix, uint16) |
|
86 DEFCONVFN (bool_matrix_to_uint32, bool_matrix, uint32) |
|
87 DEFCONVFN (bool_matrix_to_uint64, bool_matrix, uint64) |
|
88 |
6600
|
89 DEFSTRINTCONVFN (char_matrix_sq_str_to_int8, int8) |
|
90 DEFSTRINTCONVFN (char_matrix_sq_str_to_int16, int16) |
|
91 DEFSTRINTCONVFN (char_matrix_sq_str_to_int32, int32) |
|
92 DEFSTRINTCONVFN (char_matrix_sq_str_to_int64, int64) |
|
93 |
|
94 DEFSTRINTCONVFN (char_matrix_sq_str_to_uint8, uint8) |
|
95 DEFSTRINTCONVFN (char_matrix_sq_str_to_uint16, uint16) |
|
96 DEFSTRINTCONVFN (char_matrix_sq_str_to_uint32, uint32) |
|
97 DEFSTRINTCONVFN (char_matrix_sq_str_to_uint64, uint64) |
5032
|
98 |
6600
|
99 DEFSTRINTCONVFN (char_matrix_dq_str_to_int8, int8) |
|
100 DEFSTRINTCONVFN (char_matrix_dq_str_to_int16, int16) |
|
101 DEFSTRINTCONVFN (char_matrix_dq_str_to_int32, int32) |
|
102 DEFSTRINTCONVFN (char_matrix_dq_str_to_int64, int64) |
|
103 |
|
104 DEFSTRINTCONVFN (char_matrix_dq_str_to_uint8, uint8) |
|
105 DEFSTRINTCONVFN (char_matrix_dq_str_to_uint16, uint16) |
|
106 DEFSTRINTCONVFN (char_matrix_dq_str_to_uint32, uint32) |
|
107 DEFSTRINTCONVFN (char_matrix_dq_str_to_uint64, uint64) |
5032
|
108 |
4907
|
109 DEFCONVFN (range_to_int8, range, int8) |
|
110 DEFCONVFN (range_to_int16, range, int16) |
|
111 DEFCONVFN (range_to_int32, range, int32) |
|
112 DEFCONVFN (range_to_int64, range, int64) |
|
113 |
|
114 DEFCONVFN (range_to_uint8, range, uint8) |
|
115 DEFCONVFN (range_to_uint16, range, uint16) |
|
116 DEFCONVFN (range_to_uint32, range, uint32) |
|
117 DEFCONVFN (range_to_uint64, range, uint64) |
|
118 |
4901
|
119 #define INT_CONV_FUNCTIONS(tfrom) \ |
|
120 DEFCONVFN2 (tfrom ## _scalar_to_int8, tfrom, scalar, int8) \ |
|
121 DEFCONVFN2 (tfrom ## _scalar_to_int16, tfrom, scalar, int16) \ |
|
122 DEFCONVFN2 (tfrom ## _scalar_to_int32, tfrom, scalar, int32) \ |
|
123 DEFCONVFN2 (tfrom ## _scalar_to_int64, tfrom, scalar, int64) \ |
|
124 \ |
4952
|
125 DEFCONVFN2 (tfrom ## _scalar_to_uint8, tfrom, scalar, uint8) \ |
|
126 DEFCONVFN2 (tfrom ## _scalar_to_uint16, tfrom, scalar, uint16) \ |
|
127 DEFCONVFN2 (tfrom ## _scalar_to_uint32, tfrom, scalar, uint32) \ |
|
128 DEFCONVFN2 (tfrom ## _scalar_to_uint64, tfrom, scalar, uint64) \ |
4901
|
129 \ |
4952
|
130 DEFCONVFN2 (tfrom ## _matrix_to_int8, tfrom, matrix, int8) \ |
|
131 DEFCONVFN2 (tfrom ## _matrix_to_int16, tfrom, matrix, int16) \ |
|
132 DEFCONVFN2 (tfrom ## _matrix_to_int32, tfrom, matrix, int32) \ |
|
133 DEFCONVFN2 (tfrom ## _matrix_to_int64, tfrom, matrix, int64) \ |
4901
|
134 \ |
|
135 DEFCONVFN2 (tfrom ## _matrix_to_uint8, tfrom, matrix, uint8) \ |
|
136 DEFCONVFN2 (tfrom ## _matrix_to_uint16, tfrom, matrix, uint16) \ |
|
137 DEFCONVFN2 (tfrom ## _matrix_to_uint32, tfrom, matrix, uint32) \ |
|
138 DEFCONVFN2 (tfrom ## _matrix_to_uint64, tfrom, matrix, uint64) |
|
139 |
|
140 INT_CONV_FUNCTIONS (int8) |
|
141 INT_CONV_FUNCTIONS (int16) |
|
142 INT_CONV_FUNCTIONS (int32) |
|
143 INT_CONV_FUNCTIONS (int64) |
|
144 |
|
145 INT_CONV_FUNCTIONS (uint8) |
|
146 INT_CONV_FUNCTIONS (uint16) |
|
147 INT_CONV_FUNCTIONS (uint32) |
|
148 INT_CONV_FUNCTIONS (uint64) |
|
149 |
|
150 #define INSTALL_INT_CONV_FUNCTIONS(tfrom) \ |
|
151 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int8_matrix, tfrom ## _scalar_to_int8) \ |
|
152 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int16_matrix, tfrom ## _scalar_to_int16) \ |
|
153 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int32_matrix, tfrom ## _scalar_to_int32) \ |
|
154 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int64_matrix, tfrom ## _scalar_to_int64) \ |
|
155 \ |
|
156 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint8_matrix, tfrom ## _scalar_to_uint8) \ |
|
157 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint16_matrix, tfrom ## _scalar_to_uint16) \ |
|
158 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint32_matrix, tfrom ## _scalar_to_uint32) \ |
|
159 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint64_matrix, tfrom ## _scalar_to_uint64) \ |
|
160 \ |
|
161 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int8_matrix, tfrom ## _matrix_to_int8) \ |
|
162 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int16_matrix, tfrom ## _matrix_to_int16) \ |
|
163 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int32_matrix, tfrom ## _matrix_to_int32) \ |
|
164 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int64_matrix, tfrom ## _matrix_to_int64) \ |
|
165 \ |
|
166 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint8_matrix, tfrom ## _matrix_to_uint8) \ |
|
167 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint16_matrix, tfrom ## _matrix_to_uint16) \ |
|
168 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint32_matrix, tfrom ## _matrix_to_uint32) \ |
4907
|
169 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint64_matrix, tfrom ## _matrix_to_uint64) |
|
170 |
|
171 #define INSTALL_CONVOPS(tfrom) \ |
|
172 INSTALL_CONVOP (octave_ ## tfrom, octave_int8_matrix, tfrom ## _to_int8) \ |
|
173 INSTALL_CONVOP (octave_ ## tfrom, octave_int16_matrix, tfrom ## _to_int16) \ |
|
174 INSTALL_CONVOP (octave_ ## tfrom, octave_int32_matrix, tfrom ## _to_int32) \ |
|
175 INSTALL_CONVOP (octave_ ## tfrom, octave_int64_matrix, tfrom ## _to_int64) \ |
|
176 \ |
|
177 INSTALL_CONVOP (octave_ ## tfrom, octave_uint8_matrix, tfrom ## _to_uint8) \ |
|
178 INSTALL_CONVOP (octave_ ## tfrom, octave_uint16_matrix, tfrom ## _to_uint16) \ |
|
179 INSTALL_CONVOP (octave_ ## tfrom, octave_uint32_matrix, tfrom ## _to_uint32) \ |
|
180 INSTALL_CONVOP (octave_ ## tfrom, octave_uint64_matrix, tfrom ## _to_uint64) |
4901
|
181 |
|
182 void |
|
183 install_int_conv_ops (void) |
|
184 { |
4907
|
185 INSTALL_CONVOPS (scalar) |
|
186 INSTALL_CONVOPS (matrix) |
5002
|
187 INSTALL_CONVOPS (bool) |
|
188 INSTALL_CONVOPS (bool_matrix) |
4907
|
189 INSTALL_CONVOPS (range) |
6600
|
190 INSTALL_CONVOPS (char_matrix_sq_str) |
|
191 INSTALL_CONVOPS (char_matrix_dq_str) |
4901
|
192 |
|
193 INSTALL_INT_CONV_FUNCTIONS (int8) |
|
194 INSTALL_INT_CONV_FUNCTIONS (int16) |
|
195 INSTALL_INT_CONV_FUNCTIONS (int32) |
|
196 INSTALL_INT_CONV_FUNCTIONS (int64) |
|
197 |
|
198 INSTALL_INT_CONV_FUNCTIONS (uint8) |
|
199 INSTALL_INT_CONV_FUNCTIONS (uint16) |
|
200 INSTALL_INT_CONV_FUNCTIONS (uint32) |
|
201 INSTALL_INT_CONV_FUNCTIONS (uint64) |
|
202 } |
|
203 |
|
204 /* |
|
205 ;;; Local Variables: *** |
|
206 ;;; mode: C++ *** |
|
207 ;;; End: *** |
|
208 */ |