Mercurial > octave
annotate liboctave/oct-inttypes.h @ 7997:2b8952e133c9
implement checked conversions between integers
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 30 Jul 2008 15:20:13 +0200 |
parents | 935be827eaf8 |
children | f7f2d867c523 |
rev | line source |
---|---|
4902 | 1 /* |
2 | |
7017 | 3 Copyright (C) 2004, 2005, 2006, 2007 John W. Eaton |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
4 Copyright (C) 2008 Jaroslav Hajek <highegg@gmail.com> |
4902 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
4902 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
4902 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_inttypes_h) | |
25 #define octave_inttypes_h 1 | |
26 | |
6482 | 27 #include <climits> |
28 | |
4902 | 29 #include <limits> |
30 #include <iostream> | |
31 | |
5828 | 32 #include "oct-types.h" |
4953 | 33 #include "lo-ieee.h" |
4969 | 34 #include "lo-mappers.h" |
4902 | 35 |
36 template <class T1, class T2> | |
37 class | |
38 octave_int_binop_traits | |
39 { | |
40 public: | |
41 // The return type for a T1 by T2 binary operation. | |
42 typedef T1 TR; | |
43 }; | |
44 | |
45 #define OCTAVE_INT_BINOP_TRAIT(T1, T2, T3) \ | |
46 template<> \ | |
47 class octave_int_binop_traits <T1, T2> \ | |
48 { \ | |
49 public: \ | |
50 typedef T3 TR; \ | |
51 } | |
52 | |
5828 | 53 OCTAVE_INT_BINOP_TRAIT (int8_t, int8_t, int8_t); |
54 OCTAVE_INT_BINOP_TRAIT (int8_t, int16_t, int8_t); | |
55 OCTAVE_INT_BINOP_TRAIT (int8_t, int32_t, int8_t); | |
56 OCTAVE_INT_BINOP_TRAIT (int8_t, int64_t, int8_t); | |
57 OCTAVE_INT_BINOP_TRAIT (int8_t, uint8_t, int8_t); | |
58 OCTAVE_INT_BINOP_TRAIT (int8_t, uint16_t, int8_t); | |
59 OCTAVE_INT_BINOP_TRAIT (int8_t, uint32_t, int8_t); | |
60 OCTAVE_INT_BINOP_TRAIT (int8_t, uint64_t, int8_t); | |
4902 | 61 |
5828 | 62 OCTAVE_INT_BINOP_TRAIT (int16_t, int8_t, int16_t); |
63 OCTAVE_INT_BINOP_TRAIT (int16_t, int16_t, int16_t); | |
64 OCTAVE_INT_BINOP_TRAIT (int16_t, int32_t, int16_t); | |
65 OCTAVE_INT_BINOP_TRAIT (int16_t, int64_t, int16_t); | |
66 OCTAVE_INT_BINOP_TRAIT (int16_t, uint8_t, int16_t); | |
67 OCTAVE_INT_BINOP_TRAIT (int16_t, uint16_t, int16_t); | |
68 OCTAVE_INT_BINOP_TRAIT (int16_t, uint32_t, int16_t); | |
69 OCTAVE_INT_BINOP_TRAIT (int16_t, uint64_t, int16_t); | |
4902 | 70 |
5828 | 71 OCTAVE_INT_BINOP_TRAIT (int32_t, int8_t, int32_t); |
72 OCTAVE_INT_BINOP_TRAIT (int32_t, int16_t, int32_t); | |
73 OCTAVE_INT_BINOP_TRAIT (int32_t, int32_t, int32_t); | |
74 OCTAVE_INT_BINOP_TRAIT (int32_t, int64_t, int32_t); | |
75 OCTAVE_INT_BINOP_TRAIT (int32_t, uint8_t, int32_t); | |
76 OCTAVE_INT_BINOP_TRAIT (int32_t, uint16_t, int32_t); | |
77 OCTAVE_INT_BINOP_TRAIT (int32_t, uint32_t, int32_t); | |
78 OCTAVE_INT_BINOP_TRAIT (int32_t, uint64_t, int32_t); | |
4902 | 79 |
5828 | 80 OCTAVE_INT_BINOP_TRAIT (int64_t, int8_t, int64_t); |
81 OCTAVE_INT_BINOP_TRAIT (int64_t, int16_t, int64_t); | |
82 OCTAVE_INT_BINOP_TRAIT (int64_t, int32_t, int64_t); | |
83 OCTAVE_INT_BINOP_TRAIT (int64_t, int64_t, int64_t); | |
84 OCTAVE_INT_BINOP_TRAIT (int64_t, uint8_t, int64_t); | |
85 OCTAVE_INT_BINOP_TRAIT (int64_t, uint16_t, int64_t); | |
86 OCTAVE_INT_BINOP_TRAIT (int64_t, uint32_t, int64_t); | |
87 OCTAVE_INT_BINOP_TRAIT (int64_t, uint64_t, int64_t); | |
4902 | 88 |
5828 | 89 OCTAVE_INT_BINOP_TRAIT (uint8_t, int8_t, int8_t); |
90 OCTAVE_INT_BINOP_TRAIT (uint8_t, int16_t, int8_t); | |
91 OCTAVE_INT_BINOP_TRAIT (uint8_t, int32_t, int8_t); | |
92 OCTAVE_INT_BINOP_TRAIT (uint8_t, int64_t, int8_t); | |
93 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint8_t, uint8_t); | |
94 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint16_t, uint8_t); | |
95 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint32_t, uint8_t); | |
96 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint64_t, uint8_t); | |
4902 | 97 |
5828 | 98 OCTAVE_INT_BINOP_TRAIT (uint16_t, int8_t, int16_t); |
99 OCTAVE_INT_BINOP_TRAIT (uint16_t, int16_t, int16_t); | |
100 OCTAVE_INT_BINOP_TRAIT (uint16_t, int32_t, int16_t); | |
101 OCTAVE_INT_BINOP_TRAIT (uint16_t, int64_t, int16_t); | |
102 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint8_t, uint16_t); | |
103 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint16_t, uint16_t); | |
104 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint32_t, uint16_t); | |
105 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint64_t, uint16_t); | |
4902 | 106 |
5828 | 107 OCTAVE_INT_BINOP_TRAIT (uint32_t, int8_t, int32_t); |
108 OCTAVE_INT_BINOP_TRAIT (uint32_t, int16_t, int32_t); | |
109 OCTAVE_INT_BINOP_TRAIT (uint32_t, int32_t, int32_t); | |
110 OCTAVE_INT_BINOP_TRAIT (uint32_t, int64_t, int32_t); | |
111 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint8_t, uint32_t); | |
112 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint16_t, uint32_t); | |
113 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint32_t, uint32_t); | |
114 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint64_t, uint32_t); | |
4902 | 115 |
5828 | 116 OCTAVE_INT_BINOP_TRAIT (uint64_t, int8_t, int64_t); |
117 OCTAVE_INT_BINOP_TRAIT (uint64_t, int16_t, int64_t); | |
118 OCTAVE_INT_BINOP_TRAIT (uint64_t, int32_t, int64_t); | |
119 OCTAVE_INT_BINOP_TRAIT (uint64_t, int64_t, int64_t); | |
120 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint8_t, uint64_t); | |
121 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint16_t, uint64_t); | |
122 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint32_t, uint64_t); | |
123 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint64_t, uint64_t); | |
4902 | 124 |
125 template <class T1, class T2> | |
126 inline T2 | |
127 octave_int_fit_to_range (const T1& x, const T2& mn, const T2& mx) | |
128 { | |
4963 | 129 return (x > mx ? mx : (x < mn ? mn : T2 (x))); |
4902 | 130 } |
131 | |
7598
a89b3fa632ee
partial specialization for octave_int_fit_to_range
John W. Eaton <jwe@octave.org>
parents:
7596
diff
changeset
|
132 template <typename T> |
a89b3fa632ee
partial specialization for octave_int_fit_to_range
John W. Eaton <jwe@octave.org>
parents:
7596
diff
changeset
|
133 inline T |
a89b3fa632ee
partial specialization for octave_int_fit_to_range
John W. Eaton <jwe@octave.org>
parents:
7596
diff
changeset
|
134 octave_int_fit_to_range (const double& x, const T& mn, const T& mx) |
a89b3fa632ee
partial specialization for octave_int_fit_to_range
John W. Eaton <jwe@octave.org>
parents:
7596
diff
changeset
|
135 { |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
136 return (__lo_ieee_isnan (x) ? 0 : (x > mx ? mx : (x < mn ? mn : static_cast<T> (x)))); |
7598
a89b3fa632ee
partial specialization for octave_int_fit_to_range
John W. Eaton <jwe@octave.org>
parents:
7596
diff
changeset
|
137 } |
7596
6929e40fc597
compatible handling of NaN -> int conversions
John W. Eaton <jwe@octave.org>
parents:
7534
diff
changeset
|
138 |
4943 | 139 // If X is unsigned and the new type is signed, then we only have to |
140 // check the upper limit, but we should cast the maximum value of the | |
141 // new type to an unsigned type before performing the comparison. | |
142 // This should always be OK because the maximum value should always be | |
143 // positive. | |
144 | |
5072 | 145 #define OCTAVE_US_S_FTR(T1, T2, TC) \ |
4943 | 146 template <> \ |
147 inline T2 \ | |
148 octave_int_fit_to_range<T1, T2> (const T1& x, const T2&, const T2& mx) \ | |
149 { \ | |
150 return x > static_cast<TC> (mx) ? mx : x; \ | |
151 } | |
152 | |
5072 | 153 #define OCTAVE_US_S_FTR_FCNS(T) \ |
154 OCTAVE_US_S_FTR (T, char, unsigned char) \ | |
155 OCTAVE_US_S_FTR (T, signed char, unsigned char) \ | |
156 OCTAVE_US_S_FTR (T, short, unsigned short) \ | |
157 OCTAVE_US_S_FTR (T, int, unsigned int) \ | |
158 OCTAVE_US_S_FTR (T, long, unsigned long) \ | |
159 OCTAVE_US_S_FTR (T, long long, unsigned long long) | |
4943 | 160 |
5072 | 161 OCTAVE_US_S_FTR_FCNS (unsigned char) |
162 OCTAVE_US_S_FTR_FCNS (unsigned short) | |
163 OCTAVE_US_S_FTR_FCNS (unsigned int) | |
164 OCTAVE_US_S_FTR_FCNS (unsigned long) | |
165 OCTAVE_US_S_FTR_FCNS (unsigned long long) | |
4943 | 166 |
167 // If X is signed and the new type is unsigned, then we only have to | |
168 // check the lower limit (which will always be 0 for an unsigned | |
169 // type). The upper limit will be enforced correctly by converting to | |
170 // the new type, even if the type of X is wider than the new type. | |
171 | |
5072 | 172 #define OCTAVE_S_US_FTR(T1, T2) \ |
4943 | 173 template <> \ |
174 inline T2 \ | |
175 octave_int_fit_to_range<T1, T2> (const T1& x, const T2&, const T2&) \ | |
176 { \ | |
5420 | 177 return x <= 0 ? 0 : x; \ |
4943 | 178 } |
179 | |
5072 | 180 #define OCTAVE_S_US_FTR_FCNS(T) \ |
181 OCTAVE_S_US_FTR (T, unsigned char) \ | |
182 OCTAVE_S_US_FTR (T, unsigned short) \ | |
183 OCTAVE_S_US_FTR (T, unsigned int) \ | |
184 OCTAVE_S_US_FTR (T, unsigned long) \ | |
185 OCTAVE_S_US_FTR (T, unsigned long long) | |
4943 | 186 |
5072 | 187 OCTAVE_S_US_FTR_FCNS (char) |
188 OCTAVE_S_US_FTR_FCNS (signed char) | |
189 OCTAVE_S_US_FTR_FCNS (short) | |
190 OCTAVE_S_US_FTR_FCNS (int) | |
191 OCTAVE_S_US_FTR_FCNS (long) | |
192 OCTAVE_S_US_FTR_FCNS (long long) | |
4943 | 193 |
4902 | 194 #define OCTAVE_INT_FIT_TO_RANGE(r, T) \ |
4943 | 195 octave_int_fit_to_range (r, \ |
196 std::numeric_limits<T>::min (), \ | |
197 std::numeric_limits<T>::max ()) | |
4902 | 198 |
199 #define OCTAVE_INT_MIN_VAL2(T1, T2) \ | |
200 std::numeric_limits<typename octave_int_binop_traits<T1, T2>::TR>::min () | |
201 | |
202 #define OCTAVE_INT_MAX_VAL2(T1, T2) \ | |
203 std::numeric_limits<typename octave_int_binop_traits<T1, T2>::TR>::max () | |
204 | |
205 #define OCTAVE_INT_FIT_TO_RANGE2(r, T1, T2) \ | |
206 octave_int_fit_to_range (r, \ | |
207 OCTAVE_INT_MIN_VAL2 (T1, T2), \ | |
208 OCTAVE_INT_MAX_VAL2 (T1, T2)) | |
209 | |
7534
ef755c763b62
avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
7521
diff
changeset
|
210 // We have all the machinery below (octave_int_helper) to avoid a few |
ef755c763b62
avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
7521
diff
changeset
|
211 // warnings from GCC about comparisons always false due to limited |
ef755c763b62
avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents:
7521
diff
changeset
|
212 // range of data types. Ugh. The cure may be worse than the disease. |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
213 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
214 // FIXME -- it would be nice to nest the helper class inside the |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
215 // octave_int class, but I don't see the magic for that at the moment. |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
216 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
217 template <class T> class octave_int; |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
218 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
219 template <class T, bool is_signed> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
220 class octave_int_helper |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
221 { |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
222 public: |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
223 static octave_int<T> abs (const T& x); |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
224 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
225 static octave_int<T> signum (const T& x); |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
226 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
227 template <class T2> static void rshift_eq (T& ival, const T2& x); |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
228 }; |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
229 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
230 template <class T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
231 class octave_int_helper<T, false> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
232 { |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
233 public: |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
234 static octave_int<T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
235 abs (const T& x) { return x; } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
236 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
237 static octave_int<T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
238 signum (const T& x) { return x > 0 ? 1 : 0; } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
239 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
240 template <class T2> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
241 static void |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
242 rshift_eq (T& ival, const T2& x) { ival = ival >> x; } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
243 }; |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
244 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
245 template <class T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
246 class octave_int_helper<T, true> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
247 { |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
248 public: |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
249 static octave_int<T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
250 abs (const T& x) { return x < 0 ? -x : x; } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
251 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
252 static octave_int<T> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
253 signum (const T& x) { return x < 0 ? -1 : (x > 0 ? 1 : 0); } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
254 |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
255 template <class T2> |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
256 static void |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
257 rshift_eq (T& ival, const T2& x) |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
258 { |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
259 if (ival < 0) |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
260 ival = - (((-ival) >> x) & std::numeric_limits<T>::max()); |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
261 else |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
262 ival = ival >> x; |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
263 } |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
264 }; |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
265 |
4902 | 266 template <class T> |
267 class | |
268 octave_int | |
269 { | |
270 public: | |
271 | |
4943 | 272 typedef T val_type; |
273 | |
4902 | 274 octave_int (void) : ival () { } |
275 | |
276 template <class U> | |
277 octave_int (U i) : ival (OCTAVE_INT_FIT_TO_RANGE (i, T)) { } | |
278 | |
6402 | 279 octave_int (double d) : ival (OCTAVE_INT_FIT_TO_RANGE (xround (d), T)) { } |
280 | |
4902 | 281 octave_int (bool b) : ival (b) { } |
282 | |
283 template <class U> | |
284 octave_int (const octave_int<U>& i) | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
285 : ival (OCTAVE_INT_FIT_TO_RANGE (i.value (), T)) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
286 { |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
287 trunc_flag = trunc_flag || (ival != i.value ()); |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
288 } |
4902 | 289 |
290 octave_int (const octave_int<T>& i) : ival (i.ival) { } | |
291 | |
292 octave_int& operator = (const octave_int<T>& i) | |
293 { | |
294 ival = i.ival; | |
295 return *this; | |
296 } | |
297 | |
298 ~octave_int (void) { } | |
299 | |
300 T value (void) const { return ival; } | |
301 | |
4949 | 302 const unsigned char * iptr (void) const |
303 { return reinterpret_cast<const unsigned char *> (& ival); } | |
304 | |
4902 | 305 bool operator ! (void) const { return ! ival; } |
306 | |
4906 | 307 octave_int<T> operator + (void) const { return *this; } |
4902 | 308 |
4906 | 309 octave_int<T> operator - (void) const |
4902 | 310 { |
4953 | 311 // Can't just return -ival because signed types are not |
312 // symmetric, which causes things like -intmin("int32") to be the | |
313 // same as intmin("int32") instead of intmax("int32") (which is | |
314 // what we should get with saturation semantics). | |
315 | |
316 return std::numeric_limits<T>::is_signed ? | |
317 OCTAVE_INT_FIT_TO_RANGE (- static_cast<double> (ival), T) : 0; | |
4902 | 318 } |
319 | |
7198 | 320 bool bool_value (void) const { return static_cast<bool> (value ()); } |
321 | |
322 char char_value (void) const { return static_cast<char> (value ()); } | |
323 | |
324 double double_value (void) const { return static_cast<double> (value ()); } | |
325 | |
326 float float_value (void) const { return static_cast<float> (value ()); } | |
327 | |
7177 | 328 operator T (void) const { return value (); } |
329 | |
7198 | 330 // char and bool operators intentionally omitted. |
5533 | 331 |
7198 | 332 operator double (void) const { return double_value (); } |
4902 | 333 |
7198 | 334 operator float (void) const { return float_value (); } |
5030 | 335 |
4902 | 336 octave_int<T>& operator += (const octave_int<T>& x) |
337 { | |
338 double t = static_cast<double> (value ()); | |
339 double tx = static_cast<double> (x.value ()); | |
340 ival = OCTAVE_INT_FIT_TO_RANGE (t + tx, T); | |
341 return *this; | |
342 } | |
343 | |
344 octave_int<T>& operator -= (const octave_int<T>& x) | |
345 { | |
346 double t = static_cast<double> (value ()); | |
347 double tx = static_cast<double> (x.value ()); | |
348 ival = OCTAVE_INT_FIT_TO_RANGE (t - tx, T); | |
349 return *this; | |
350 } | |
351 | |
4952 | 352 octave_int<T>& operator *= (const octave_int<T>& x) |
353 { | |
354 double t = static_cast<double> (value ()); | |
355 double tx = static_cast<double> (x.value ()); | |
356 ival = OCTAVE_INT_FIT_TO_RANGE (t * tx, T); | |
357 return *this; | |
358 } | |
359 | |
360 octave_int<T>& operator /= (const octave_int<T>& x) | |
361 { | |
362 double t = static_cast<double> (value ()); | |
363 double tx = static_cast<double> (x.value ()); | |
4968 | 364 double r = (t == 0 && tx == 0) ? 0 : xround (t / tx); |
4953 | 365 ival = OCTAVE_INT_FIT_TO_RANGE (r, T); |
4952 | 366 return *this; |
367 } | |
368 | |
369 template <class T2> | |
370 octave_int<T>& operator <<= (const T2& x) | |
371 { | |
6764 | 372 ival = ival << x; |
4952 | 373 return *this; |
374 } | |
375 | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
376 // Use helper functions in the operator >>=, abs, and signum |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
377 // functions to avoid "comparison of unsigned expression < 0 is |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
378 // always false" warnings from GCC when instantiating these funtions |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
379 // for unsigned types. |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
380 |
4952 | 381 template <class T2> |
382 octave_int<T>& operator >>= (const T2& x) | |
383 { | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
384 octave_int_helper<T, std::numeric_limits<T>::is_signed>::rshift_eq (ival, x); |
4952 | 385 return *this; |
386 } | |
387 | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
388 octave_int<T> abs (void) const |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
389 { |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
390 return octave_int_helper<T, std::numeric_limits<T>::is_signed>::abs (value ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
391 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
392 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
393 octave_int<T> signum (void) const |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
394 { |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
395 return octave_int_helper<T, std::numeric_limits<T>::is_signed>::signum (value ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
396 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7198
diff
changeset
|
397 |
4906 | 398 octave_int<T> min (void) const { return std::numeric_limits<T>::min (); } |
399 octave_int<T> max (void) const { return std::numeric_limits<T>::max (); } | |
400 | |
4919 | 401 static int nbits (void) { return sizeof (T) * CHAR_BIT; } |
4909 | 402 |
4949 | 403 static int byte_size (void) { return sizeof(T); } |
404 | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
405 static bool get_trunc_flag () { return trunc_flag; } |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
406 static void clear_trunc_flag () { trunc_flag = false; } |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
407 |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
408 static const char *type_name () { return "unknown type"; } |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
409 |
5900 | 410 // Unsafe. This function exists to support the MEX interface. |
411 // You should not use it anywhere else. | |
412 void *mex_get_data (void) const { return const_cast<T *> (&ival); } | |
413 | |
4902 | 414 private: |
415 | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
416 static bool trunc_flag; |
4902 | 417 T ival; |
418 }; | |
419 | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
420 template<class T> bool octave_int<T>::trunc_flag = false; |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
421 |
4902 | 422 template <class T> |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
423 bool |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
424 xisnan (const octave_int<T>&) |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
425 { |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
426 return false; |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
427 } |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
428 |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7789
diff
changeset
|
429 template <class T> |
4953 | 430 octave_int<T> |
431 pow (const octave_int<T>& a, const octave_int<T>& b) | |
4952 | 432 { |
4953 | 433 octave_int<T> retval; |
4952 | 434 |
4953 | 435 octave_int<T> zero = octave_int<T> (0); |
436 octave_int<T> one = octave_int<T> (1); | |
4952 | 437 |
438 if (b == zero) | |
439 retval = one; | |
440 else if (b < zero) | |
441 retval = zero; | |
442 else | |
443 { | |
4953 | 444 octave_int<T> a_val = a; |
445 octave_int<T> b_val = b; | |
4952 | 446 |
447 retval = a; | |
448 | |
449 b_val -= 1; | |
450 | |
5030 | 451 while (b_val != zero) |
4952 | 452 { |
5030 | 453 if ((b_val & one) != zero) |
4952 | 454 retval = retval * a_val; |
455 | |
456 b_val = b_val >> 1; | |
457 | |
458 if (b_val > zero) | |
459 a_val = a_val * a_val; | |
460 } | |
461 } | |
462 | |
463 return retval; | |
464 } | |
465 | |
466 template <class T> | |
4953 | 467 octave_int<T> |
468 pow (double a, const octave_int<T>& b) | |
469 { | |
470 double tb = static_cast<double> (b.value ()); | |
471 double r = pow (a, tb); | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
472 r = __lo_ieee_isnan (r) ? 0 : xround (r); |
4953 | 473 return OCTAVE_INT_FIT_TO_RANGE (r, T); |
474 } | |
475 | |
476 template <class T> | |
477 octave_int<T> | |
478 pow (const octave_int<T>& a, double b) | |
479 { | |
480 double ta = static_cast<double> (a.value ()); | |
481 double r = pow (ta, b); | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
482 r = __lo_ieee_isnan (r) ? 0 : xround (r); |
4953 | 483 return OCTAVE_INT_FIT_TO_RANGE (r, T); |
484 } | |
485 | |
486 template <class T> | |
4902 | 487 std::ostream& |
488 operator << (std::ostream& os, const octave_int<T>& ival) | |
489 { | |
490 os << ival.value (); | |
491 return os; | |
492 } | |
493 | |
494 template <class T> | |
495 std::istream& | |
496 operator >> (std::istream& is, octave_int<T>& ival) | |
497 { | |
498 T tmp = 0; | |
499 is >> tmp; | |
500 ival = tmp; | |
501 return is; | |
502 } | |
503 | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
504 // specialize the widening conversions to make them faster |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
505 // gosh. the syntax is tricky! |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
506 |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
507 #define SPECIALIZE_WIDENING_CONVERSION(T1, T2) \ |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
508 template <> template <> \ |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
509 inline octave_int<T2>::octave_int (T1 i) : ival (i) {} \ |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
510 template <> template <> \ |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
511 inline octave_int<T2>::octave_int (const octave_int<T1>& i) : ival (i.value ()) {} |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
512 |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
513 SPECIALIZE_WIDENING_CONVERSION(int8_t, int16_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
514 SPECIALIZE_WIDENING_CONVERSION(int8_t, int32_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
515 SPECIALIZE_WIDENING_CONVERSION(int8_t, int64_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
516 SPECIALIZE_WIDENING_CONVERSION(int16_t, int32_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
517 SPECIALIZE_WIDENING_CONVERSION(int16_t, int64_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
518 SPECIALIZE_WIDENING_CONVERSION(int32_t, int64_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
519 SPECIALIZE_WIDENING_CONVERSION(uint8_t, uint16_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
520 SPECIALIZE_WIDENING_CONVERSION(uint8_t, uint32_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
521 SPECIALIZE_WIDENING_CONVERSION(uint8_t, uint64_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
522 SPECIALIZE_WIDENING_CONVERSION(uint16_t, uint32_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
523 SPECIALIZE_WIDENING_CONVERSION(uint16_t, uint64_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
524 SPECIALIZE_WIDENING_CONVERSION(uint32_t, uint64_t) |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
525 |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
526 // declare type names |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
527 #define DECLARE_OCTAVE_INT_TYPENAME(TYPE, TYPENAME) \ |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
528 template<> \ |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
529 inline const char * \ |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
530 octave_int<TYPE>::type_name () { return TYPENAME; } |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
531 |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
532 DECLARE_OCTAVE_INT_TYPENAME(int8_t, "int8") |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
533 DECLARE_OCTAVE_INT_TYPENAME(int16_t, "int16") |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
534 DECLARE_OCTAVE_INT_TYPENAME(int32_t, "int32") |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
535 DECLARE_OCTAVE_INT_TYPENAME(int64_t, "int64") |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
536 DECLARE_OCTAVE_INT_TYPENAME(uint8_t, "uint8") |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
537 DECLARE_OCTAVE_INT_TYPENAME(uint16_t, "uint16") |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
538 DECLARE_OCTAVE_INT_TYPENAME(uint32_t, "uint32") |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
539 DECLARE_OCTAVE_INT_TYPENAME(uint64_t, "uint64") |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
540 |
5828 | 541 typedef octave_int<int8_t> octave_int8; |
542 typedef octave_int<int16_t> octave_int16; | |
543 typedef octave_int<int32_t> octave_int32; | |
544 typedef octave_int<int64_t> octave_int64; | |
4902 | 545 |
5828 | 546 typedef octave_int<uint8_t> octave_uint8; |
547 typedef octave_int<uint16_t> octave_uint16; | |
548 typedef octave_int<uint32_t> octave_uint32; | |
549 typedef octave_int<uint64_t> octave_uint64; | |
4902 | 550 |
551 #define OCTAVE_INT_BIN_OP(OP) \ | |
552 template <class T1, class T2> \ | |
553 octave_int<typename octave_int_binop_traits<T1, T2>::TR> \ | |
554 operator OP (const octave_int<T1>& x, const octave_int<T2>& y) \ | |
555 { \ | |
556 double tx = static_cast<double> (x.value ()); \ | |
557 double ty = static_cast<double> (y.value ()); \ | |
558 double r = tx OP ty; \ | |
559 return OCTAVE_INT_FIT_TO_RANGE2 (r, T1, T2); \ | |
4906 | 560 } |
4902 | 561 |
562 OCTAVE_INT_BIN_OP(+) | |
563 OCTAVE_INT_BIN_OP(-) | |
564 OCTAVE_INT_BIN_OP(*) | |
4953 | 565 |
566 template <class T1, class T2> | |
567 octave_int<typename octave_int_binop_traits<T1, T2>::TR> | |
568 operator / (const octave_int<T1>& x, const octave_int<T2>& y) | |
569 { | |
570 double tx = static_cast<double> (x.value ()); | |
571 double ty = static_cast<double> (y.value ()); | |
6402 | 572 double r = (tx == 0 && ty == 0) ? 0 : xround (tx / ty); |
4953 | 573 return OCTAVE_INT_FIT_TO_RANGE2 (r, T1, T2); |
574 } | |
575 | |
576 #define OCTAVE_INT_DOUBLE_BIN_OP(OP) \ | |
577 template <class T> \ | |
578 octave_int<T> \ | |
579 operator OP (const octave_int<T>& x, double y) \ | |
580 { \ | |
581 double tx = static_cast<double> (x.value ()); \ | |
4968 | 582 double r = xround (tx OP y); \ |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
583 r = __lo_ieee_isnan (r) ? 0 : xround (r); \ |
4953 | 584 return OCTAVE_INT_FIT_TO_RANGE (r, T); \ |
585 } | |
586 | |
587 OCTAVE_INT_DOUBLE_BIN_OP(+) | |
588 OCTAVE_INT_DOUBLE_BIN_OP(-) | |
589 OCTAVE_INT_DOUBLE_BIN_OP(*) | |
590 OCTAVE_INT_DOUBLE_BIN_OP(/) | |
591 | |
592 #define OCTAVE_DOUBLE_INT_BIN_OP(OP) \ | |
593 template <class T> \ | |
594 octave_int<T> \ | |
595 operator OP (double x, const octave_int<T>& y) \ | |
596 { \ | |
597 double ty = static_cast<double> (y.value ()); \ | |
598 double r = x OP ty; \ | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
599 r = __lo_ieee_isnan (r) ? 0 : xround (r); \ |
4953 | 600 return OCTAVE_INT_FIT_TO_RANGE (r, T); \ |
601 } | |
602 | |
603 OCTAVE_DOUBLE_INT_BIN_OP(+) | |
604 OCTAVE_DOUBLE_INT_BIN_OP(-) | |
605 OCTAVE_DOUBLE_INT_BIN_OP(*) | |
606 OCTAVE_DOUBLE_INT_BIN_OP(/) | |
4902 | 607 |
5029 | 608 #define OCTAVE_INT_DOUBLE_CMP_OP(OP) \ |
609 template <class T> \ | |
610 bool \ | |
611 operator OP (const octave_int<T>& x, const double& y) \ | |
612 { \ | |
613 double tx = static_cast<double> (x.value ()); \ | |
5030 | 614 return tx OP y; \ |
5029 | 615 } |
616 | |
617 OCTAVE_INT_DOUBLE_CMP_OP (<) | |
618 OCTAVE_INT_DOUBLE_CMP_OP (<=) | |
619 OCTAVE_INT_DOUBLE_CMP_OP (>=) | |
620 OCTAVE_INT_DOUBLE_CMP_OP (>) | |
621 OCTAVE_INT_DOUBLE_CMP_OP (==) | |
622 OCTAVE_INT_DOUBLE_CMP_OP (!=) | |
623 | |
624 #define OCTAVE_DOUBLE_INT_CMP_OP(OP) \ | |
625 template <class T> \ | |
626 bool \ | |
627 operator OP (const double& x, const octave_int<T>& y) \ | |
628 { \ | |
629 double ty = static_cast<double> (y.value ()); \ | |
5030 | 630 return x OP ty; \ |
5029 | 631 } |
632 | |
633 OCTAVE_DOUBLE_INT_CMP_OP (<) | |
634 OCTAVE_DOUBLE_INT_CMP_OP (<=) | |
635 OCTAVE_DOUBLE_INT_CMP_OP (>=) | |
636 OCTAVE_DOUBLE_INT_CMP_OP (>) | |
637 OCTAVE_DOUBLE_INT_CMP_OP (==) | |
638 OCTAVE_DOUBLE_INT_CMP_OP (!=) | |
639 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
640 #define OCTAVE_INT_FLOAT_BIN_OP(OP) \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
641 template <class T> \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
642 octave_int<T> \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
643 operator OP (const octave_int<T>& x, float y) \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
644 { \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
645 double tx = static_cast<double> (x.value ()); \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
646 double r = xround (tx OP y); \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
647 r = __lo_ieee_isnan (r) ? 0 : xround (r); \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
648 return OCTAVE_INT_FIT_TO_RANGE (r, T); \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
649 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
650 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
651 OCTAVE_INT_FLOAT_BIN_OP(+) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
652 OCTAVE_INT_FLOAT_BIN_OP(-) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
653 OCTAVE_INT_FLOAT_BIN_OP(*) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
654 OCTAVE_INT_FLOAT_BIN_OP(/) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
655 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
656 #define OCTAVE_FLOAT_INT_BIN_OP(OP) \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
657 template <class T> \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
658 octave_int<T> \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
659 operator OP (float x, const octave_int<T>& y) \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
660 { \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
661 double ty = static_cast<double> (y.value ()); \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
662 double r = x OP ty; \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
663 r = __lo_ieee_isnan (r) ? 0 : xround (r); \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
664 return OCTAVE_INT_FIT_TO_RANGE (r, T); \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
665 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
666 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
667 OCTAVE_FLOAT_INT_BIN_OP(+) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
668 OCTAVE_FLOAT_INT_BIN_OP(-) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
669 OCTAVE_FLOAT_INT_BIN_OP(*) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
670 OCTAVE_FLOAT_INT_BIN_OP(/) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
671 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
672 #define OCTAVE_INT_FLOAT_CMP_OP(OP) \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
673 template <class T> \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
674 bool \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
675 operator OP (const octave_int<T>& x, const float& y) \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
676 { \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
677 double tx = static_cast<double> (x.value ()); \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
678 return tx OP y; \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
679 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
680 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
681 OCTAVE_INT_FLOAT_CMP_OP (<) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
682 OCTAVE_INT_FLOAT_CMP_OP (<=) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
683 OCTAVE_INT_FLOAT_CMP_OP (>=) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
684 OCTAVE_INT_FLOAT_CMP_OP (>) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
685 OCTAVE_INT_FLOAT_CMP_OP (==) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
686 OCTAVE_INT_FLOAT_CMP_OP (!=) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
687 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
688 #define OCTAVE_FLOAT_INT_CMP_OP(OP) \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
689 template <class T> \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
690 bool \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
691 operator OP (const float& x, const octave_int<T>& y) \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
692 { \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
693 double ty = static_cast<double> (y.value ()); \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
694 return x OP ty; \ |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
695 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
696 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
697 OCTAVE_FLOAT_INT_CMP_OP (<) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
698 OCTAVE_FLOAT_INT_CMP_OP (<=) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
699 OCTAVE_FLOAT_INT_CMP_OP (>=) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
700 OCTAVE_FLOAT_INT_CMP_OP (>) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
701 OCTAVE_FLOAT_INT_CMP_OP (==) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
702 OCTAVE_FLOAT_INT_CMP_OP (!=) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7598
diff
changeset
|
703 |
4906 | 704 #define OCTAVE_INT_BITCMP_OP(OP) \ |
705 template <class T> \ | |
706 octave_int<T> \ | |
707 operator OP (const octave_int<T>& x, const octave_int<T>& y) \ | |
708 { \ | |
709 return x.value () OP y.value (); \ | |
710 } | |
711 | |
712 OCTAVE_INT_BITCMP_OP (&) | |
713 OCTAVE_INT_BITCMP_OP (|) | |
714 OCTAVE_INT_BITCMP_OP (^) | |
715 | |
4952 | 716 template <class T1, class T2> |
717 octave_int<T1> | |
718 operator << (const octave_int<T1>& x, const T2& y) | |
719 { | |
5030 | 720 octave_int<T1> retval = x; |
4952 | 721 return retval <<= y; |
722 } | |
4906 | 723 |
4952 | 724 template <class T1, class T2> |
725 octave_int<T1> | |
726 operator >> (const octave_int<T1>& x, const T2& y) | |
727 { | |
5030 | 728 octave_int<T1> retval = x; |
4952 | 729 return retval >>= y; |
730 } | |
4906 | 731 |
4909 | 732 template <class T> |
733 octave_int<T> | |
4920 | 734 bitshift (const octave_int<T>& a, int n, |
735 const octave_int<T>& mask = std::numeric_limits<T>::max ()) | |
4909 | 736 { |
737 if (n > 0) | |
4952 | 738 return (a << n) & mask; |
4909 | 739 else if (n < 0) |
4952 | 740 return (a >> -n) & mask; |
4909 | 741 else |
742 return a; | |
743 } | |
744 | |
4902 | 745 #define OCTAVE_INT_CMP_OP(OP) \ |
746 template <class T1, class T2> \ | |
747 bool \ | |
748 operator OP (const octave_int<T1>& x, const octave_int<T2>& y) \ | |
749 { \ | |
5072 | 750 return x.value () OP y.value (); \ |
4906 | 751 } |
4902 | 752 |
753 OCTAVE_INT_CMP_OP (<) | |
754 OCTAVE_INT_CMP_OP (<=) | |
755 OCTAVE_INT_CMP_OP (>=) | |
756 OCTAVE_INT_CMP_OP (>) | |
757 OCTAVE_INT_CMP_OP (==) | |
758 OCTAVE_INT_CMP_OP (!=) | |
759 | |
5072 | 760 // The following apply if the unsigned type is at least as wide as the |
761 // signed type (then we can cast postive signed values to the unsigned | |
762 // type and compare). | |
763 | |
764 #define OCTAVE_US_TYPE1_CMP_OP_DECL(OP, LTZ_VAL, UT, ST) \ | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
765 template <> \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
766 bool \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
767 OCTAVE_API operator OP (const octave_int<UT>& lhs, const octave_int<ST>& rhs); |
5072 | 768 |
769 #define OCTAVE_US_TYPE1_CMP_OP_DECLS(UT, ST) \ | |
770 OCTAVE_US_TYPE1_CMP_OP_DECL (<, false, UT, ST) \ | |
771 OCTAVE_US_TYPE1_CMP_OP_DECL (<=, false, UT, ST) \ | |
772 OCTAVE_US_TYPE1_CMP_OP_DECL (>=, true, UT, ST) \ | |
773 OCTAVE_US_TYPE1_CMP_OP_DECL (>, true, UT, ST) \ | |
774 OCTAVE_US_TYPE1_CMP_OP_DECL (==, false, UT, ST) \ | |
775 OCTAVE_US_TYPE1_CMP_OP_DECL (!=, true, UT, ST) | |
776 | |
777 #define OCTAVE_SU_TYPE1_CMP_OP_DECL(OP, LTZ_VAL, ST, UT) \ | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
778 template <> \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
779 bool \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
780 OCTAVE_API operator OP (const octave_int<ST>& lhs, const octave_int<UT>& rhs); |
5072 | 781 |
782 #define OCTAVE_SU_TYPE1_CMP_OP_DECLS(ST, UT) \ | |
783 OCTAVE_SU_TYPE1_CMP_OP_DECL (<, true, ST, UT) \ | |
784 OCTAVE_SU_TYPE1_CMP_OP_DECL (<=, true, ST, UT) \ | |
785 OCTAVE_SU_TYPE1_CMP_OP_DECL (>=, false, ST, UT) \ | |
786 OCTAVE_SU_TYPE1_CMP_OP_DECL (>, false, ST, UT) \ | |
787 OCTAVE_SU_TYPE1_CMP_OP_DECL (==, false, ST, UT) \ | |
788 OCTAVE_SU_TYPE1_CMP_OP_DECL (!=, true, ST, UT) | |
789 | |
790 #define OCTAVE_TYPE1_CMP_OP_DECLS(UT, ST) \ | |
791 OCTAVE_US_TYPE1_CMP_OP_DECLS (UT, ST) \ | |
792 OCTAVE_SU_TYPE1_CMP_OP_DECLS (ST, UT) | |
793 | |
5828 | 794 OCTAVE_TYPE1_CMP_OP_DECLS (uint32_t, int8_t) |
795 OCTAVE_TYPE1_CMP_OP_DECLS (uint32_t, int16_t) | |
796 OCTAVE_TYPE1_CMP_OP_DECLS (uint32_t, int32_t) | |
5072 | 797 |
5828 | 798 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int8_t) |
799 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int16_t) | |
800 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int32_t) | |
801 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int64_t) | |
5072 | 802 |
803 // The following apply if the signed type is wider than the unsigned | |
804 // type (then we can cast unsigned values to the signed type and | |
805 // compare if the signed value is positive). | |
806 | |
807 #define OCTAVE_US_TYPE2_CMP_OP_DECL(OP, LTZ_VAL, UT, ST) \ | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
808 template <> \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
809 bool \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
810 OCTAVE_API operator OP (const octave_int<UT>& lhs, const octave_int<ST>& rhs); |
5072 | 811 |
812 #define OCTAVE_US_TYPE2_CMP_OP_DECLS(ST, UT) \ | |
813 OCTAVE_US_TYPE2_CMP_OP_DECL (<, false, ST, UT) \ | |
814 OCTAVE_US_TYPE2_CMP_OP_DECL (<=, false, ST, UT) \ | |
815 OCTAVE_US_TYPE2_CMP_OP_DECL (>=, true, ST, UT) \ | |
816 OCTAVE_US_TYPE2_CMP_OP_DECL (>, true, ST, UT) \ | |
817 OCTAVE_US_TYPE2_CMP_OP_DECL (==, false, ST, UT) \ | |
818 OCTAVE_US_TYPE2_CMP_OP_DECL (!=, true, ST, UT) | |
819 | |
820 #define OCTAVE_SU_TYPE2_CMP_OP_DECL(OP, LTZ_VAL, ST, UT) \ | |
7521
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
821 template <> \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
822 bool \ |
6f10bbb2854a
avoid some GCC warnings for unsigned comparisons
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
823 OCTAVE_API operator OP (const octave_int<ST>& lhs, const octave_int<UT>& rhs); |
5072 | 824 |
825 #define OCTAVE_SU_TYPE2_CMP_OP_DECLS(ST, UT) \ | |
826 OCTAVE_SU_TYPE2_CMP_OP_DECL (<, true, ST, UT) \ | |
827 OCTAVE_SU_TYPE2_CMP_OP_DECL (<=, true, ST, UT) \ | |
828 OCTAVE_SU_TYPE2_CMP_OP_DECL (>=, false, ST, UT) \ | |
829 OCTAVE_SU_TYPE2_CMP_OP_DECL (>, false, ST, UT) \ | |
830 OCTAVE_SU_TYPE2_CMP_OP_DECL (==, false, ST, UT) \ | |
831 OCTAVE_SU_TYPE2_CMP_OP_DECL (!=, true, ST, UT) | |
832 | |
833 #define OCTAVE_TYPE2_CMP_OP_DECLS(UT, ST) \ | |
834 OCTAVE_US_TYPE2_CMP_OP_DECLS (UT, ST) \ | |
835 OCTAVE_SU_TYPE2_CMP_OP_DECLS (ST, UT) | |
836 | |
5828 | 837 OCTAVE_TYPE2_CMP_OP_DECLS (uint32_t, int64_t) |
5072 | 838 |
4902 | 839 #undef OCTAVE_INT_BINOP_TRAIT |
5072 | 840 #undef OCTAVE_US_S_FTR |
841 #undef OCTAVE_US_S_FTR_FCNS | |
842 #undef OCTAVE_S_US_FTR | |
843 #undef OCTAVE_S_US_FTR_FCNS | |
4902 | 844 #undef OCTAVE_INT_FIT_TO_RANGE |
845 #undef OCTAVE_INT_MIN_VAL2 | |
846 #undef OCTAVE_INT_MAX_VAL2 | |
847 #undef OCTAVE_INT_FIT_TO_RANGE2 | |
848 #undef OCTAVE_INT_BIN_OP | |
5072 | 849 #undef OCTAVE_INT_DOUBLE_BIN_OP |
850 #undef OCTAVE_DOUBLE_INT_BIN_OP | |
851 #undef OCTAVE_INT_DOUBLE_CMP_OP | |
852 #undef OCTAVE_DOUBLE_INT_CMP_OP | |
853 #undef OCTAVE_INT_BITCMP_OP | |
4902 | 854 #undef OCTAVE_INT_CMP_OP |
5072 | 855 #undef OCTAVE_US_TYPE1_CMP_OP_DECL |
856 #undef OCTAVE_US_TYPE1_CMP_OP_DECLS | |
857 #undef OCTAVE_SU_TYPE1_CMP_OP_DECL | |
858 #undef OCTAVE_SU_TYPE1_CMP_OP_DECLS | |
859 #undef OCTAVE_TYPE1_CMP_OP_DECLS | |
860 #undef OCTAVE_US_TYPE2_CMP_OP_DECL | |
861 #undef OCTAVE_US_TYPE2_CMP_OP_DECLS | |
862 #undef OCTAVE_SU_TYPE2_CMP_OP_DECL | |
863 #undef OCTAVE_SU_TYPE2_CMP_OP_DECLS | |
5074 | 864 #undef OCTAVE_TYPE2_CMP_OP_DECLS |
4902 | 865 |
866 #endif | |
867 | |
868 /* | |
869 ;;; Local Variables: *** | |
870 ;;; mode: C++ *** | |
871 ;;; End: *** | |
872 */ |