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 |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 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, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include "gripes.h" |
|
32 #include "oct-obj.h" |
|
33 #include "ov.h" |
|
34 #include "ov-int8.h" |
|
35 #include "ov-int16.h" |
|
36 #include "ov-int32.h" |
|
37 #include "ov-int64.h" |
|
38 #include "ov-uint8.h" |
|
39 #include "ov-uint16.h" |
|
40 #include "ov-uint32.h" |
|
41 #include "ov-uint64.h" |
4907
|
42 #include "ov-range.h" |
4901
|
43 #include "ov-scalar.h" |
|
44 #include "ov-re-mat.h" |
|
45 #include "ov-typeinfo.h" |
|
46 #include "ops.h" |
|
47 |
|
48 // conversion ops |
|
49 |
|
50 DEFCONVFN (scalar_to_int8, scalar, int8) |
|
51 DEFCONVFN (scalar_to_int16, scalar, int16) |
|
52 DEFCONVFN (scalar_to_int32, scalar, int32) |
|
53 DEFCONVFN (scalar_to_int64, scalar, int64) |
|
54 |
|
55 DEFCONVFN (scalar_to_uint8, scalar, uint8) |
|
56 DEFCONVFN (scalar_to_uint16, scalar, uint16) |
|
57 DEFCONVFN (scalar_to_uint32, scalar, uint32) |
|
58 DEFCONVFN (scalar_to_uint64, scalar, uint64) |
|
59 |
|
60 DEFCONVFN (matrix_to_int8, matrix, int8) |
|
61 DEFCONVFN (matrix_to_int16, matrix, int16) |
|
62 DEFCONVFN (matrix_to_int32, matrix, int32) |
|
63 DEFCONVFN (matrix_to_int64, matrix, int64) |
|
64 |
|
65 DEFCONVFN (matrix_to_uint8, matrix, uint8) |
|
66 DEFCONVFN (matrix_to_uint16, matrix, uint16) |
|
67 DEFCONVFN (matrix_to_uint32, matrix, uint32) |
|
68 DEFCONVFN (matrix_to_uint64, matrix, uint64) |
|
69 |
4907
|
70 DEFCONVFN (range_to_int8, range, int8) |
|
71 DEFCONVFN (range_to_int16, range, int16) |
|
72 DEFCONVFN (range_to_int32, range, int32) |
|
73 DEFCONVFN (range_to_int64, range, int64) |
|
74 |
|
75 DEFCONVFN (range_to_uint8, range, uint8) |
|
76 DEFCONVFN (range_to_uint16, range, uint16) |
|
77 DEFCONVFN (range_to_uint32, range, uint32) |
|
78 DEFCONVFN (range_to_uint64, range, uint64) |
|
79 |
4901
|
80 #define INT_CONV_FUNCTIONS(tfrom) \ |
|
81 DEFCONVFN2 (tfrom ## _scalar_to_int8, tfrom, scalar, int8) \ |
|
82 DEFCONVFN2 (tfrom ## _scalar_to_int16, tfrom, scalar, int16) \ |
|
83 DEFCONVFN2 (tfrom ## _scalar_to_int32, tfrom, scalar, int32) \ |
|
84 DEFCONVFN2 (tfrom ## _scalar_to_int64, tfrom, scalar, int64) \ |
|
85 \ |
|
86 DEFCONVFN2 (tfrom ## _scalar_to_uint8, tfrom, scalar, int8) \ |
|
87 DEFCONVFN2 (tfrom ## _scalar_to_uint16, tfrom, scalar, int16) \ |
|
88 DEFCONVFN2 (tfrom ## _scalar_to_uint32, tfrom, scalar, int32) \ |
|
89 DEFCONVFN2 (tfrom ## _scalar_to_uint64, tfrom, scalar, int64) \ |
|
90 \ |
|
91 DEFCONVFN2 (tfrom ## _matrix_to_int8, tfrom, matrix, uint8) \ |
|
92 DEFCONVFN2 (tfrom ## _matrix_to_int16, tfrom, matrix, uint16) \ |
|
93 DEFCONVFN2 (tfrom ## _matrix_to_int32, tfrom, matrix, uint32) \ |
|
94 DEFCONVFN2 (tfrom ## _matrix_to_int64, tfrom, matrix, uint64) \ |
|
95 \ |
|
96 DEFCONVFN2 (tfrom ## _matrix_to_uint8, tfrom, matrix, uint8) \ |
|
97 DEFCONVFN2 (tfrom ## _matrix_to_uint16, tfrom, matrix, uint16) \ |
|
98 DEFCONVFN2 (tfrom ## _matrix_to_uint32, tfrom, matrix, uint32) \ |
|
99 DEFCONVFN2 (tfrom ## _matrix_to_uint64, tfrom, matrix, uint64) |
|
100 |
|
101 INT_CONV_FUNCTIONS (int8) |
|
102 INT_CONV_FUNCTIONS (int16) |
|
103 INT_CONV_FUNCTIONS (int32) |
|
104 INT_CONV_FUNCTIONS (int64) |
|
105 |
|
106 INT_CONV_FUNCTIONS (uint8) |
|
107 INT_CONV_FUNCTIONS (uint16) |
|
108 INT_CONV_FUNCTIONS (uint32) |
|
109 INT_CONV_FUNCTIONS (uint64) |
|
110 |
|
111 #define INSTALL_INT_CONV_FUNCTIONS(tfrom) \ |
|
112 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int8_matrix, tfrom ## _scalar_to_int8) \ |
|
113 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int16_matrix, tfrom ## _scalar_to_int16) \ |
|
114 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int32_matrix, tfrom ## _scalar_to_int32) \ |
|
115 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_int64_matrix, tfrom ## _scalar_to_int64) \ |
|
116 \ |
|
117 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint8_matrix, tfrom ## _scalar_to_uint8) \ |
|
118 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint16_matrix, tfrom ## _scalar_to_uint16) \ |
|
119 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint32_matrix, tfrom ## _scalar_to_uint32) \ |
|
120 INSTALL_CONVOP (octave_ ## tfrom ## _scalar, octave_uint64_matrix, tfrom ## _scalar_to_uint64) \ |
|
121 \ |
|
122 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int8_matrix, tfrom ## _matrix_to_int8) \ |
|
123 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int16_matrix, tfrom ## _matrix_to_int16) \ |
|
124 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int32_matrix, tfrom ## _matrix_to_int32) \ |
|
125 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_int64_matrix, tfrom ## _matrix_to_int64) \ |
|
126 \ |
|
127 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint8_matrix, tfrom ## _matrix_to_uint8) \ |
|
128 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint16_matrix, tfrom ## _matrix_to_uint16) \ |
|
129 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint32_matrix, tfrom ## _matrix_to_uint32) \ |
4907
|
130 INSTALL_CONVOP (octave_ ## tfrom ## _matrix, octave_uint64_matrix, tfrom ## _matrix_to_uint64) |
|
131 |
|
132 #define INSTALL_CONVOPS(tfrom) \ |
|
133 INSTALL_CONVOP (octave_ ## tfrom, octave_int8_matrix, tfrom ## _to_int8) \ |
|
134 INSTALL_CONVOP (octave_ ## tfrom, octave_int16_matrix, tfrom ## _to_int16) \ |
|
135 INSTALL_CONVOP (octave_ ## tfrom, octave_int32_matrix, tfrom ## _to_int32) \ |
|
136 INSTALL_CONVOP (octave_ ## tfrom, octave_int64_matrix, tfrom ## _to_int64) \ |
|
137 \ |
|
138 INSTALL_CONVOP (octave_ ## tfrom, octave_uint8_matrix, tfrom ## _to_uint8) \ |
|
139 INSTALL_CONVOP (octave_ ## tfrom, octave_uint16_matrix, tfrom ## _to_uint16) \ |
|
140 INSTALL_CONVOP (octave_ ## tfrom, octave_uint32_matrix, tfrom ## _to_uint32) \ |
|
141 INSTALL_CONVOP (octave_ ## tfrom, octave_uint64_matrix, tfrom ## _to_uint64) |
4901
|
142 |
|
143 void |
|
144 install_int_conv_ops (void) |
|
145 { |
4907
|
146 INSTALL_CONVOPS (scalar) |
|
147 INSTALL_CONVOPS (matrix) |
|
148 INSTALL_CONVOPS (range) |
4901
|
149 |
|
150 INSTALL_INT_CONV_FUNCTIONS (int8) |
|
151 INSTALL_INT_CONV_FUNCTIONS (int16) |
|
152 INSTALL_INT_CONV_FUNCTIONS (int32) |
|
153 INSTALL_INT_CONV_FUNCTIONS (int64) |
|
154 |
|
155 INSTALL_INT_CONV_FUNCTIONS (uint8) |
|
156 INSTALL_INT_CONV_FUNCTIONS (uint16) |
|
157 INSTALL_INT_CONV_FUNCTIONS (uint32) |
|
158 INSTALL_INT_CONV_FUNCTIONS (uint64) |
|
159 } |
|
160 |
|
161 /* |
|
162 ;;; Local Variables: *** |
|
163 ;;; mode: C++ *** |
|
164 ;;; End: *** |
|
165 */ |