annotate liboctave/oct-inttypes.h @ 7177:57d2546ad8d5

[project @ 2007-11-14 22:21:35 by jwe]
author jwe
date Wed, 14 Nov 2007 22:21:36 +0000
parents a1dbe9d80eee
children 4555c116b420
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
1 /*
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 2004, 2005, 2006, 2007 John W. Eaton
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
4
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
6
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6764
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6764
diff changeset
10 option) any later version.
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
11
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
15 for more details.
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
16
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6764
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6764
diff changeset
19 <http://www.gnu.org/licenses/>.
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
20
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
21 */
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
22
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_inttypes_h)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
24 #define octave_inttypes_h 1
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
25
6482
7e958a1532c6 [project @ 2007-04-04 02:37:07 by jwe]
jwe
parents: 6402
diff changeset
26 #include <climits>
7e958a1532c6 [project @ 2007-04-04 02:37:07 by jwe]
jwe
parents: 6402
diff changeset
27
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
28 #include <limits>
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
29 #include <iostream>
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
30
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
31 #include "oct-types.h"
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
32 #include "lo-ieee.h"
4969
52f808101130 [project @ 2004-09-08 02:44:04 by jwe]
jwe
parents: 4968
diff changeset
33 #include "lo-mappers.h"
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
34
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
35 template <class T1, class T2>
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
36 class
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
37 octave_int_binop_traits
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
38 {
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
39 public:
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
40 // The return type for a T1 by T2 binary operation.
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
41 typedef T1 TR;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
42 };
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
43
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
44 #define OCTAVE_INT_BINOP_TRAIT(T1, T2, T3) \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
45 template<> \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
46 class octave_int_binop_traits <T1, T2> \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
47 { \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
48 public: \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
49 typedef T3 TR; \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
50 }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
51
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
52 OCTAVE_INT_BINOP_TRAIT (int8_t, int8_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
53 OCTAVE_INT_BINOP_TRAIT (int8_t, int16_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
54 OCTAVE_INT_BINOP_TRAIT (int8_t, int32_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
55 OCTAVE_INT_BINOP_TRAIT (int8_t, int64_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
56 OCTAVE_INT_BINOP_TRAIT (int8_t, uint8_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
57 OCTAVE_INT_BINOP_TRAIT (int8_t, uint16_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
58 OCTAVE_INT_BINOP_TRAIT (int8_t, uint32_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
59 OCTAVE_INT_BINOP_TRAIT (int8_t, uint64_t, int8_t);
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
60
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
61 OCTAVE_INT_BINOP_TRAIT (int16_t, int8_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
62 OCTAVE_INT_BINOP_TRAIT (int16_t, int16_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
63 OCTAVE_INT_BINOP_TRAIT (int16_t, int32_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
64 OCTAVE_INT_BINOP_TRAIT (int16_t, int64_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
65 OCTAVE_INT_BINOP_TRAIT (int16_t, uint8_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
66 OCTAVE_INT_BINOP_TRAIT (int16_t, uint16_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
67 OCTAVE_INT_BINOP_TRAIT (int16_t, uint32_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
68 OCTAVE_INT_BINOP_TRAIT (int16_t, uint64_t, int16_t);
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
69
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
70 OCTAVE_INT_BINOP_TRAIT (int32_t, int8_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
71 OCTAVE_INT_BINOP_TRAIT (int32_t, int16_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
72 OCTAVE_INT_BINOP_TRAIT (int32_t, int32_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
73 OCTAVE_INT_BINOP_TRAIT (int32_t, int64_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
74 OCTAVE_INT_BINOP_TRAIT (int32_t, uint8_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
75 OCTAVE_INT_BINOP_TRAIT (int32_t, uint16_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
76 OCTAVE_INT_BINOP_TRAIT (int32_t, uint32_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
77 OCTAVE_INT_BINOP_TRAIT (int32_t, uint64_t, int32_t);
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
78
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
79 OCTAVE_INT_BINOP_TRAIT (int64_t, int8_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
80 OCTAVE_INT_BINOP_TRAIT (int64_t, int16_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
81 OCTAVE_INT_BINOP_TRAIT (int64_t, int32_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
82 OCTAVE_INT_BINOP_TRAIT (int64_t, int64_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
83 OCTAVE_INT_BINOP_TRAIT (int64_t, uint8_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
84 OCTAVE_INT_BINOP_TRAIT (int64_t, uint16_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
85 OCTAVE_INT_BINOP_TRAIT (int64_t, uint32_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
86 OCTAVE_INT_BINOP_TRAIT (int64_t, uint64_t, int64_t);
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
87
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
88 OCTAVE_INT_BINOP_TRAIT (uint8_t, int8_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
89 OCTAVE_INT_BINOP_TRAIT (uint8_t, int16_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
90 OCTAVE_INT_BINOP_TRAIT (uint8_t, int32_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
91 OCTAVE_INT_BINOP_TRAIT (uint8_t, int64_t, int8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
92 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint8_t, uint8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
93 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint16_t, uint8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
94 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint32_t, uint8_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
95 OCTAVE_INT_BINOP_TRAIT (uint8_t, uint64_t, uint8_t);
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
96
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
97 OCTAVE_INT_BINOP_TRAIT (uint16_t, int8_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
98 OCTAVE_INT_BINOP_TRAIT (uint16_t, int16_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
99 OCTAVE_INT_BINOP_TRAIT (uint16_t, int32_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
100 OCTAVE_INT_BINOP_TRAIT (uint16_t, int64_t, int16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
101 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint8_t, uint16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
102 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint16_t, uint16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
103 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint32_t, uint16_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
104 OCTAVE_INT_BINOP_TRAIT (uint16_t, uint64_t, uint16_t);
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
105
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
106 OCTAVE_INT_BINOP_TRAIT (uint32_t, int8_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
107 OCTAVE_INT_BINOP_TRAIT (uint32_t, int16_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
108 OCTAVE_INT_BINOP_TRAIT (uint32_t, int32_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
109 OCTAVE_INT_BINOP_TRAIT (uint32_t, int64_t, int32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
110 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint8_t, uint32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
111 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint16_t, uint32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
112 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint32_t, uint32_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
113 OCTAVE_INT_BINOP_TRAIT (uint32_t, uint64_t, uint32_t);
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
114
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
115 OCTAVE_INT_BINOP_TRAIT (uint64_t, int8_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
116 OCTAVE_INT_BINOP_TRAIT (uint64_t, int16_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
117 OCTAVE_INT_BINOP_TRAIT (uint64_t, int32_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
118 OCTAVE_INT_BINOP_TRAIT (uint64_t, int64_t, int64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
119 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint8_t, uint64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
120 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint16_t, uint64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
121 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint32_t, uint64_t);
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
122 OCTAVE_INT_BINOP_TRAIT (uint64_t, uint64_t, uint64_t);
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
123
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
124 template <class T1, class T2>
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
125 inline T2
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
126 octave_int_fit_to_range (const T1& x, const T2& mn, const T2& mx)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
127 {
4963
573d23f9c9cf [project @ 2004-09-03 15:43:29 by jwe]
jwe
parents: 4953
diff changeset
128 return (x > mx ? mx : (x < mn ? mn : T2 (x)));
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
129 }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
130
4943
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
131 // If X is unsigned and the new type is signed, then we only have to
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
132 // check the upper limit, but we should cast the maximum value of the
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
133 // new type to an unsigned type before performing the comparison.
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
134 // This should always be OK because the maximum value should always be
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
135 // positive.
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
136
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
137 #define OCTAVE_US_S_FTR(T1, T2, TC) \
4943
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
138 template <> \
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
139 inline T2 \
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
140 octave_int_fit_to_range<T1, T2> (const T1& x, const T2&, const T2& mx) \
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
141 { \
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
142 return x > static_cast<TC> (mx) ? mx : x; \
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
143 }
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
144
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
145 #define OCTAVE_US_S_FTR_FCNS(T) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
146 OCTAVE_US_S_FTR (T, char, unsigned char) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
147 OCTAVE_US_S_FTR (T, signed char, unsigned char) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
148 OCTAVE_US_S_FTR (T, short, unsigned short) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
149 OCTAVE_US_S_FTR (T, int, unsigned int) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
150 OCTAVE_US_S_FTR (T, long, unsigned long) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
151 OCTAVE_US_S_FTR (T, long long, unsigned long long)
4943
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
152
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
153 OCTAVE_US_S_FTR_FCNS (unsigned char)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
154 OCTAVE_US_S_FTR_FCNS (unsigned short)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
155 OCTAVE_US_S_FTR_FCNS (unsigned int)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
156 OCTAVE_US_S_FTR_FCNS (unsigned long)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
157 OCTAVE_US_S_FTR_FCNS (unsigned long long)
4943
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
158
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
159 // If X is signed and the new type is unsigned, then we only have to
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
160 // check the lower limit (which will always be 0 for an unsigned
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
161 // type). The upper limit will be enforced correctly by converting to
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
162 // the new type, even if the type of X is wider than the new type.
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
163
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
164 #define OCTAVE_S_US_FTR(T1, T2) \
4943
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
165 template <> \
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
166 inline T2 \
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
167 octave_int_fit_to_range<T1, T2> (const T1& x, const T2&, const T2&) \
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
168 { \
5420
f608ac74f92c [project @ 2005-07-25 21:32:51 by jwe]
jwe
parents: 5307
diff changeset
169 return x <= 0 ? 0 : x; \
4943
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
170 }
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
171
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
172 #define OCTAVE_S_US_FTR_FCNS(T) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
173 OCTAVE_S_US_FTR (T, unsigned char) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
174 OCTAVE_S_US_FTR (T, unsigned short) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
175 OCTAVE_S_US_FTR (T, unsigned int) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
176 OCTAVE_S_US_FTR (T, unsigned long) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
177 OCTAVE_S_US_FTR (T, unsigned long long)
4943
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
178
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
179 OCTAVE_S_US_FTR_FCNS (char)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
180 OCTAVE_S_US_FTR_FCNS (signed char)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
181 OCTAVE_S_US_FTR_FCNS (short)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
182 OCTAVE_S_US_FTR_FCNS (int)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
183 OCTAVE_S_US_FTR_FCNS (long)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
184 OCTAVE_S_US_FTR_FCNS (long long)
4943
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
185
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
186 #define OCTAVE_INT_FIT_TO_RANGE(r, T) \
4943
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
187 octave_int_fit_to_range (r, \
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
188 std::numeric_limits<T>::min (), \
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
189 std::numeric_limits<T>::max ())
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
190
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
191 #define OCTAVE_INT_MIN_VAL2(T1, T2) \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
192 std::numeric_limits<typename octave_int_binop_traits<T1, T2>::TR>::min ()
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
193
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
194 #define OCTAVE_INT_MAX_VAL2(T1, T2) \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
195 std::numeric_limits<typename octave_int_binop_traits<T1, T2>::TR>::max ()
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
196
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
197 #define OCTAVE_INT_FIT_TO_RANGE2(r, T1, T2) \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
198 octave_int_fit_to_range (r, \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
199 OCTAVE_INT_MIN_VAL2 (T1, T2), \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
200 OCTAVE_INT_MAX_VAL2 (T1, T2))
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
201
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
202 template <class T>
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
203 class
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
204 octave_int
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
205 {
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
206 public:
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
207
4943
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
208 typedef T val_type;
1a499d0c58f5 [project @ 2004-08-31 00:51:31 by jwe]
jwe
parents: 4920
diff changeset
209
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
210 octave_int (void) : ival () { }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
211
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
212 template <class U>
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
213 octave_int (U i) : ival (OCTAVE_INT_FIT_TO_RANGE (i, T)) { }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
214
6402
fe9817a6ee98 [project @ 2007-03-13 02:25:31 by jwe]
jwe
parents: 6108
diff changeset
215 octave_int (double d) : ival (OCTAVE_INT_FIT_TO_RANGE (xround (d), T)) { }
fe9817a6ee98 [project @ 2007-03-13 02:25:31 by jwe]
jwe
parents: 6108
diff changeset
216
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
217 octave_int (bool b) : ival (b) { }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
218
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
219 template <class U>
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
220 octave_int (const octave_int<U>& i)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
221 : ival (OCTAVE_INT_FIT_TO_RANGE (i.value (), T)) { }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
222
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
223 octave_int (const octave_int<T>& i) : ival (i.ival) { }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
224
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
225 octave_int& operator = (const octave_int<T>& i)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
226 {
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
227 ival = i.ival;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
228 return *this;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
229 }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
230
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
231 ~octave_int (void) { }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
232
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
233 T value (void) const { return ival; }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
234
4949
f6b63ff1119b [project @ 2004-08-31 19:17:44 by jwe]
jwe
parents: 4943
diff changeset
235 const unsigned char * iptr (void) const
f6b63ff1119b [project @ 2004-08-31 19:17:44 by jwe]
jwe
parents: 4943
diff changeset
236 { return reinterpret_cast<const unsigned char *> (& ival); }
f6b63ff1119b [project @ 2004-08-31 19:17:44 by jwe]
jwe
parents: 4943
diff changeset
237
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
238 bool operator ! (void) const { return ! ival; }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
239
4906
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
240 octave_int<T> operator + (void) const { return *this; }
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
241
4906
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
242 octave_int<T> operator - (void) const
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
243 {
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
244 // Can't just return -ival because signed types are not
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
245 // symmetric, which causes things like -intmin("int32") to be the
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
246 // same as intmin("int32") instead of intmax("int32") (which is
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
247 // what we should get with saturation semantics).
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
248
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
249 return std::numeric_limits<T>::is_signed ?
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
250 OCTAVE_INT_FIT_TO_RANGE (- static_cast<double> (ival), T) : 0;
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
251 }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
252
7177
57d2546ad8d5 [project @ 2007-11-14 22:21:35 by jwe]
jwe
parents: 7017
diff changeset
253 operator T (void) const { return value (); }
57d2546ad8d5 [project @ 2007-11-14 22:21:35 by jwe]
jwe
parents: 7017
diff changeset
254
5898
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5828
diff changeset
255 operator bool (void) const { return static_cast<bool> (value ()); }
da843f35775c [project @ 2006-07-19 18:18:08 by jwe]
jwe
parents: 5828
diff changeset
256
5533
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5420
diff changeset
257 operator char (void) const { return static_cast<char> (value ()); }
667ad2becb63 [project @ 2005-11-10 21:40:48 by jwe]
jwe
parents: 5420
diff changeset
258
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
259 operator double (void) const { return static_cast<double> (value ()); }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
260
5030
160365410ad4 [project @ 2004-09-24 03:22:23 by jwe]
jwe
parents: 5029
diff changeset
261 operator float (void) const { return static_cast<float> (value ()); }
160365410ad4 [project @ 2004-09-24 03:22:23 by jwe]
jwe
parents: 5029
diff changeset
262
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
263 octave_int<T>& operator += (const octave_int<T>& x)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
264 {
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
265 double t = static_cast<double> (value ());
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
266 double tx = static_cast<double> (x.value ());
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
267 ival = OCTAVE_INT_FIT_TO_RANGE (t + tx, T);
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
268 return *this;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
269 }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
270
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
271 octave_int<T>& operator -= (const octave_int<T>& x)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
272 {
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
273 double t = static_cast<double> (value ());
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
274 double tx = static_cast<double> (x.value ());
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
275 ival = OCTAVE_INT_FIT_TO_RANGE (t - tx, T);
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
276 return *this;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
277 }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
278
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
279 octave_int<T>& operator *= (const octave_int<T>& x)
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
280 {
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
281 double t = static_cast<double> (value ());
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
282 double tx = static_cast<double> (x.value ());
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
283 ival = OCTAVE_INT_FIT_TO_RANGE (t * tx, T);
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
284 return *this;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
285 }
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
286
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
287 octave_int<T>& operator /= (const octave_int<T>& x)
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
288 {
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
289 double t = static_cast<double> (value ());
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
290 double tx = static_cast<double> (x.value ());
4968
c09cbec51190 [project @ 2004-09-08 02:13:55 by jwe]
jwe
parents: 4964
diff changeset
291 double r = (t == 0 && tx == 0) ? 0 : xround (t / tx);
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
292 ival = OCTAVE_INT_FIT_TO_RANGE (r, T);
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
293 return *this;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
294 }
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
295
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
296 template <class T2>
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
297 octave_int<T>& operator <<= (const T2& x)
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
298 {
6764
2a83fce5a097 [project @ 2007-06-27 19:02:59 by dbateman]
dbateman
parents: 6482
diff changeset
299 ival = ival << x;
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
300 return *this;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
301 }
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
302
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
303 template <class T2>
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
304 octave_int<T>& operator >>= (const T2& x)
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
305 {
6764
2a83fce5a097 [project @ 2007-06-27 19:02:59 by dbateman]
dbateman
parents: 6482
diff changeset
306 if (ival < 0)
2a83fce5a097 [project @ 2007-06-27 19:02:59 by dbateman]
dbateman
parents: 6482
diff changeset
307 ival = - (((-ival) >> x) & std::numeric_limits<T>::max());
2a83fce5a097 [project @ 2007-06-27 19:02:59 by dbateman]
dbateman
parents: 6482
diff changeset
308 else
2a83fce5a097 [project @ 2007-06-27 19:02:59 by dbateman]
dbateman
parents: 6482
diff changeset
309 ival = ival >> x;
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
310 return *this;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
311 }
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
312
4906
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
313 octave_int<T> min (void) const { return std::numeric_limits<T>::min (); }
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
314 octave_int<T> max (void) const { return std::numeric_limits<T>::max (); }
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
315
4919
a1073eef650c [project @ 2004-07-27 15:22:50 by jwe]
jwe
parents: 4915
diff changeset
316 static int nbits (void) { return sizeof (T) * CHAR_BIT; }
4909
5c9e36402f17 [project @ 2004-07-12 17:08:24 by jwe]
jwe
parents: 4906
diff changeset
317
4949
f6b63ff1119b [project @ 2004-08-31 19:17:44 by jwe]
jwe
parents: 4943
diff changeset
318 static int byte_size (void) { return sizeof(T); }
f6b63ff1119b [project @ 2004-08-31 19:17:44 by jwe]
jwe
parents: 4943
diff changeset
319
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
320 // Unsafe. This function exists to support the MEX interface.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
321 // You should not use it anywhere else.
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
322 void *mex_get_data (void) const { return const_cast<T *> (&ival); }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5898
diff changeset
323
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
324 private:
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
325
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
326 T ival;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
327 };
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
328
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
329 template <class T>
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
330 octave_int<T>
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
331 pow (const octave_int<T>& a, const octave_int<T>& b)
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
332 {
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
333 octave_int<T> retval;
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
334
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
335 octave_int<T> zero = octave_int<T> (0);
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
336 octave_int<T> one = octave_int<T> (1);
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
337
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
338 if (b == zero)
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
339 retval = one;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
340 else if (b < zero)
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
341 retval = zero;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
342 else
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
343 {
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
344 octave_int<T> a_val = a;
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
345 octave_int<T> b_val = b;
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
346
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
347 retval = a;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
348
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
349 b_val -= 1;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
350
5030
160365410ad4 [project @ 2004-09-24 03:22:23 by jwe]
jwe
parents: 5029
diff changeset
351 while (b_val != zero)
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
352 {
5030
160365410ad4 [project @ 2004-09-24 03:22:23 by jwe]
jwe
parents: 5029
diff changeset
353 if ((b_val & one) != zero)
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
354 retval = retval * a_val;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
355
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
356 b_val = b_val >> 1;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
357
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
358 if (b_val > zero)
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
359 a_val = a_val * a_val;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
360 }
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
361 }
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
362
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
363 return retval;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
364 }
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
365
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
366 template <class T>
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
367 octave_int<T>
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
368 pow (double a, const octave_int<T>& b)
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
369 {
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
370 double tb = static_cast<double> (b.value ());
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
371 double r = pow (a, tb);
4968
c09cbec51190 [project @ 2004-09-08 02:13:55 by jwe]
jwe
parents: 4964
diff changeset
372 r = lo_ieee_isnan (r) ? 0 : xround (r);
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
373 return OCTAVE_INT_FIT_TO_RANGE (r, T);
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
374 }
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
375
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
376 template <class T>
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
377 octave_int<T>
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
378 pow (const octave_int<T>& a, double b)
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
379 {
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
380 double ta = static_cast<double> (a.value ());
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
381 double r = pow (ta, b);
4968
c09cbec51190 [project @ 2004-09-08 02:13:55 by jwe]
jwe
parents: 4964
diff changeset
382 r = lo_ieee_isnan (r) ? 0 : xround (r);
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
383 return OCTAVE_INT_FIT_TO_RANGE (r, T);
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
384 }
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
385
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
386 template <class T>
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
387 std::ostream&
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
388 operator << (std::ostream& os, const octave_int<T>& ival)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
389 {
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
390 os << ival.value ();
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
391 return os;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
392 }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
393
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
394 template <class T>
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
395 std::istream&
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
396 operator >> (std::istream& is, octave_int<T>& ival)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
397 {
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
398 T tmp = 0;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
399 is >> tmp;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
400 ival = tmp;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
401 return is;
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
402 }
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
403
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
404 typedef octave_int<int8_t> octave_int8;
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
405 typedef octave_int<int16_t> octave_int16;
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
406 typedef octave_int<int32_t> octave_int32;
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
407 typedef octave_int<int64_t> octave_int64;
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
408
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
409 typedef octave_int<uint8_t> octave_uint8;
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
410 typedef octave_int<uint16_t> octave_uint16;
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
411 typedef octave_int<uint32_t> octave_uint32;
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
412 typedef octave_int<uint64_t> octave_uint64;
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
413
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
414 #define OCTAVE_INT_BIN_OP(OP) \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
415 template <class T1, class T2> \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
416 octave_int<typename octave_int_binop_traits<T1, T2>::TR> \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
417 operator OP (const octave_int<T1>& x, const octave_int<T2>& y) \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
418 { \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
419 double tx = static_cast<double> (x.value ()); \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
420 double ty = static_cast<double> (y.value ()); \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
421 double r = tx OP ty; \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
422 return OCTAVE_INT_FIT_TO_RANGE2 (r, T1, T2); \
4906
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
423 }
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
424
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
425 OCTAVE_INT_BIN_OP(+)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
426 OCTAVE_INT_BIN_OP(-)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
427 OCTAVE_INT_BIN_OP(*)
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
428
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
429 template <class T1, class T2>
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
430 octave_int<typename octave_int_binop_traits<T1, T2>::TR>
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
431 operator / (const octave_int<T1>& x, const octave_int<T2>& y)
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
432 {
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
433 double tx = static_cast<double> (x.value ());
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
434 double ty = static_cast<double> (y.value ());
6402
fe9817a6ee98 [project @ 2007-03-13 02:25:31 by jwe]
jwe
parents: 6108
diff changeset
435 double r = (tx == 0 && ty == 0) ? 0 : xround (tx / ty);
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
436 return OCTAVE_INT_FIT_TO_RANGE2 (r, T1, T2);
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
437 }
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
438
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
439 #define OCTAVE_INT_DOUBLE_BIN_OP(OP) \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
440 template <class T> \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
441 octave_int<T> \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
442 operator OP (const octave_int<T>& x, double y) \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
443 { \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
444 double tx = static_cast<double> (x.value ()); \
4968
c09cbec51190 [project @ 2004-09-08 02:13:55 by jwe]
jwe
parents: 4964
diff changeset
445 double r = xround (tx OP y); \
c09cbec51190 [project @ 2004-09-08 02:13:55 by jwe]
jwe
parents: 4964
diff changeset
446 r = lo_ieee_isnan (r) ? 0 : xround (r); \
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
447 return OCTAVE_INT_FIT_TO_RANGE (r, T); \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
448 }
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
449
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
450 OCTAVE_INT_DOUBLE_BIN_OP(+)
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
451 OCTAVE_INT_DOUBLE_BIN_OP(-)
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
452 OCTAVE_INT_DOUBLE_BIN_OP(*)
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
453 OCTAVE_INT_DOUBLE_BIN_OP(/)
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
454
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
455 #define OCTAVE_DOUBLE_INT_BIN_OP(OP) \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
456 template <class T> \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
457 octave_int<T> \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
458 operator OP (double x, const octave_int<T>& y) \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
459 { \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
460 double ty = static_cast<double> (y.value ()); \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
461 double r = x OP ty; \
4968
c09cbec51190 [project @ 2004-09-08 02:13:55 by jwe]
jwe
parents: 4964
diff changeset
462 r = lo_ieee_isnan (r) ? 0 : xround (r); \
4953
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
463 return OCTAVE_INT_FIT_TO_RANGE (r, T); \
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
464 }
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
465
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
466 OCTAVE_DOUBLE_INT_BIN_OP(+)
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
467 OCTAVE_DOUBLE_INT_BIN_OP(-)
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
468 OCTAVE_DOUBLE_INT_BIN_OP(*)
7a3a480e8645 [project @ 2004-09-01 21:10:28 by jwe]
jwe
parents: 4952
diff changeset
469 OCTAVE_DOUBLE_INT_BIN_OP(/)
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
470
5029
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
471 #define OCTAVE_INT_DOUBLE_CMP_OP(OP) \
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
472 template <class T> \
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
473 bool \
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
474 operator OP (const octave_int<T>& x, const double& y) \
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
475 { \
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
476 double tx = static_cast<double> (x.value ()); \
5030
160365410ad4 [project @ 2004-09-24 03:22:23 by jwe]
jwe
parents: 5029
diff changeset
477 return tx OP y; \
5029
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
478 }
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
479
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
480 OCTAVE_INT_DOUBLE_CMP_OP (<)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
481 OCTAVE_INT_DOUBLE_CMP_OP (<=)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
482 OCTAVE_INT_DOUBLE_CMP_OP (>=)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
483 OCTAVE_INT_DOUBLE_CMP_OP (>)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
484 OCTAVE_INT_DOUBLE_CMP_OP (==)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
485 OCTAVE_INT_DOUBLE_CMP_OP (!=)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
486
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
487 #define OCTAVE_DOUBLE_INT_CMP_OP(OP) \
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
488 template <class T> \
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
489 bool \
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
490 operator OP (const double& x, const octave_int<T>& y) \
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
491 { \
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
492 double ty = static_cast<double> (y.value ()); \
5030
160365410ad4 [project @ 2004-09-24 03:22:23 by jwe]
jwe
parents: 5029
diff changeset
493 return x OP ty; \
5029
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
494 }
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
495
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
496 OCTAVE_DOUBLE_INT_CMP_OP (<)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
497 OCTAVE_DOUBLE_INT_CMP_OP (<=)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
498 OCTAVE_DOUBLE_INT_CMP_OP (>=)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
499 OCTAVE_DOUBLE_INT_CMP_OP (>)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
500 OCTAVE_DOUBLE_INT_CMP_OP (==)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
501 OCTAVE_DOUBLE_INT_CMP_OP (!=)
1ec26bdb120c [project @ 2004-09-23 16:58:57 by jwe]
jwe
parents: 4969
diff changeset
502
4906
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
503 #define OCTAVE_INT_BITCMP_OP(OP) \
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
504 template <class T> \
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
505 octave_int<T> \
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
506 operator OP (const octave_int<T>& x, const octave_int<T>& y) \
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
507 { \
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
508 return x.value () OP y.value (); \
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
509 }
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
510
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
511 OCTAVE_INT_BITCMP_OP (&)
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
512 OCTAVE_INT_BITCMP_OP (|)
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
513 OCTAVE_INT_BITCMP_OP (^)
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
514
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
515 template <class T1, class T2>
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
516 octave_int<T1>
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
517 operator << (const octave_int<T1>& x, const T2& y)
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
518 {
5030
160365410ad4 [project @ 2004-09-24 03:22:23 by jwe]
jwe
parents: 5029
diff changeset
519 octave_int<T1> retval = x;
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
520 return retval <<= y;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
521 }
4906
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
522
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
523 template <class T1, class T2>
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
524 octave_int<T1>
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
525 operator >> (const octave_int<T1>& x, const T2& y)
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
526 {
5030
160365410ad4 [project @ 2004-09-24 03:22:23 by jwe]
jwe
parents: 5029
diff changeset
527 octave_int<T1> retval = x;
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
528 return retval >>= y;
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
529 }
4906
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
530
4909
5c9e36402f17 [project @ 2004-07-12 17:08:24 by jwe]
jwe
parents: 4906
diff changeset
531 template <class T>
5c9e36402f17 [project @ 2004-07-12 17:08:24 by jwe]
jwe
parents: 4906
diff changeset
532 octave_int<T>
4920
b22a7a1db0d5 [project @ 2004-07-27 18:15:25 by jwe]
jwe
parents: 4919
diff changeset
533 bitshift (const octave_int<T>& a, int n,
b22a7a1db0d5 [project @ 2004-07-27 18:15:25 by jwe]
jwe
parents: 4919
diff changeset
534 const octave_int<T>& mask = std::numeric_limits<T>::max ())
4909
5c9e36402f17 [project @ 2004-07-12 17:08:24 by jwe]
jwe
parents: 4906
diff changeset
535 {
5c9e36402f17 [project @ 2004-07-12 17:08:24 by jwe]
jwe
parents: 4906
diff changeset
536 if (n > 0)
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
537 return (a << n) & mask;
4909
5c9e36402f17 [project @ 2004-07-12 17:08:24 by jwe]
jwe
parents: 4906
diff changeset
538 else if (n < 0)
4952
bfd57b466752 [project @ 2004-09-01 00:49:05 by jwe]
jwe
parents: 4949
diff changeset
539 return (a >> -n) & mask;
4909
5c9e36402f17 [project @ 2004-07-12 17:08:24 by jwe]
jwe
parents: 4906
diff changeset
540 else
5c9e36402f17 [project @ 2004-07-12 17:08:24 by jwe]
jwe
parents: 4906
diff changeset
541 return a;
5c9e36402f17 [project @ 2004-07-12 17:08:24 by jwe]
jwe
parents: 4906
diff changeset
542 }
5c9e36402f17 [project @ 2004-07-12 17:08:24 by jwe]
jwe
parents: 4906
diff changeset
543
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
544 #define OCTAVE_INT_CMP_OP(OP) \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
545 template <class T1, class T2> \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
546 bool \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
547 operator OP (const octave_int<T1>& x, const octave_int<T2>& y) \
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
548 { \
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
549 return x.value () OP y.value (); \
4906
6754342ef7ad [project @ 2004-06-23 11:11:50 by jwe]
jwe
parents: 4902
diff changeset
550 }
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
551
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
552 OCTAVE_INT_CMP_OP (<)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
553 OCTAVE_INT_CMP_OP (<=)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
554 OCTAVE_INT_CMP_OP (>=)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
555 OCTAVE_INT_CMP_OP (>)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
556 OCTAVE_INT_CMP_OP (==)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
557 OCTAVE_INT_CMP_OP (!=)
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
558
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
559 // The following apply if the unsigned type is at least as wide as the
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
560 // signed type (then we can cast postive signed values to the unsigned
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
561 // type and compare).
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
562
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
563 #define OCTAVE_US_TYPE1_CMP_OP_DECL(OP, LTZ_VAL, UT, ST) \
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5900
diff changeset
564 bool OCTAVE_API operator OP (const octave_int<UT>& lhs, const octave_int<ST>& rhs);
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
565
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
566 #define OCTAVE_US_TYPE1_CMP_OP_DECLS(UT, ST) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
567 OCTAVE_US_TYPE1_CMP_OP_DECL (<, false, UT, ST) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
568 OCTAVE_US_TYPE1_CMP_OP_DECL (<=, false, UT, ST) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
569 OCTAVE_US_TYPE1_CMP_OP_DECL (>=, true, UT, ST) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
570 OCTAVE_US_TYPE1_CMP_OP_DECL (>, true, UT, ST) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
571 OCTAVE_US_TYPE1_CMP_OP_DECL (==, false, UT, ST) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
572 OCTAVE_US_TYPE1_CMP_OP_DECL (!=, true, UT, ST)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
573
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
574 #define OCTAVE_SU_TYPE1_CMP_OP_DECL(OP, LTZ_VAL, ST, UT) \
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5900
diff changeset
575 bool OCTAVE_API operator OP (const octave_int<ST>& lhs, const octave_int<UT>& rhs);
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
576
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
577 #define OCTAVE_SU_TYPE1_CMP_OP_DECLS(ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
578 OCTAVE_SU_TYPE1_CMP_OP_DECL (<, true, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
579 OCTAVE_SU_TYPE1_CMP_OP_DECL (<=, true, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
580 OCTAVE_SU_TYPE1_CMP_OP_DECL (>=, false, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
581 OCTAVE_SU_TYPE1_CMP_OP_DECL (>, false, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
582 OCTAVE_SU_TYPE1_CMP_OP_DECL (==, false, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
583 OCTAVE_SU_TYPE1_CMP_OP_DECL (!=, true, ST, UT)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
584
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
585 #define OCTAVE_TYPE1_CMP_OP_DECLS(UT, ST) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
586 OCTAVE_US_TYPE1_CMP_OP_DECLS (UT, ST) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
587 OCTAVE_SU_TYPE1_CMP_OP_DECLS (ST, UT)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
588
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
589 OCTAVE_TYPE1_CMP_OP_DECLS (uint32_t, int8_t)
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
590 OCTAVE_TYPE1_CMP_OP_DECLS (uint32_t, int16_t)
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
591 OCTAVE_TYPE1_CMP_OP_DECLS (uint32_t, int32_t)
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
592
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
593 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int8_t)
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
594 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int16_t)
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
595 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int32_t)
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
596 OCTAVE_TYPE1_CMP_OP_DECLS (uint64_t, int64_t)
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
597
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
598 // The following apply if the signed type is wider than the unsigned
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
599 // type (then we can cast unsigned values to the signed type and
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
600 // compare if the signed value is positive).
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
601
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
602 #define OCTAVE_US_TYPE2_CMP_OP_DECL(OP, LTZ_VAL, UT, ST) \
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5900
diff changeset
603 bool OCTAVE_API operator OP (const octave_int<UT>& lhs, const octave_int<ST>& rhs);
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
604
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
605 #define OCTAVE_US_TYPE2_CMP_OP_DECLS(ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
606 OCTAVE_US_TYPE2_CMP_OP_DECL (<, false, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
607 OCTAVE_US_TYPE2_CMP_OP_DECL (<=, false, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
608 OCTAVE_US_TYPE2_CMP_OP_DECL (>=, true, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
609 OCTAVE_US_TYPE2_CMP_OP_DECL (>, true, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
610 OCTAVE_US_TYPE2_CMP_OP_DECL (==, false, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
611 OCTAVE_US_TYPE2_CMP_OP_DECL (!=, true, ST, UT)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
612
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
613 #define OCTAVE_SU_TYPE2_CMP_OP_DECL(OP, LTZ_VAL, ST, UT) \
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5900
diff changeset
614 bool OCTAVE_API operator OP (const octave_int<ST>& lhs, const octave_int<UT>& rhs);
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
615
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
616 #define OCTAVE_SU_TYPE2_CMP_OP_DECLS(ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
617 OCTAVE_SU_TYPE2_CMP_OP_DECL (<, true, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
618 OCTAVE_SU_TYPE2_CMP_OP_DECL (<=, true, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
619 OCTAVE_SU_TYPE2_CMP_OP_DECL (>=, false, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
620 OCTAVE_SU_TYPE2_CMP_OP_DECL (>, false, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
621 OCTAVE_SU_TYPE2_CMP_OP_DECL (==, false, ST, UT) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
622 OCTAVE_SU_TYPE2_CMP_OP_DECL (!=, true, ST, UT)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
623
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
624 #define OCTAVE_TYPE2_CMP_OP_DECLS(UT, ST) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
625 OCTAVE_US_TYPE2_CMP_OP_DECLS (UT, ST) \
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
626 OCTAVE_SU_TYPE2_CMP_OP_DECLS (ST, UT)
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
627
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5533
diff changeset
628 OCTAVE_TYPE2_CMP_OP_DECLS (uint32_t, int64_t)
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
629
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
630 #undef OCTAVE_INT_BINOP_TRAIT
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
631 #undef OCTAVE_US_S_FTR
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
632 #undef OCTAVE_US_S_FTR_FCNS
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
633 #undef OCTAVE_S_US_FTR
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
634 #undef OCTAVE_S_US_FTR_FCNS
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
635 #undef OCTAVE_INT_FIT_TO_RANGE
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
636 #undef OCTAVE_INT_MIN_VAL2
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
637 #undef OCTAVE_INT_MAX_VAL2
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
638 #undef OCTAVE_INT_FIT_TO_RANGE2
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
639 #undef OCTAVE_INT_BIN_OP
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
640 #undef OCTAVE_INT_DOUBLE_BIN_OP
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
641 #undef OCTAVE_DOUBLE_INT_BIN_OP
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
642 #undef OCTAVE_INT_DOUBLE_CMP_OP
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
643 #undef OCTAVE_DOUBLE_INT_CMP_OP
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
644 #undef OCTAVE_INT_BITCMP_OP
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
645 #undef OCTAVE_INT_CMP_OP
5072
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
646 #undef OCTAVE_US_TYPE1_CMP_OP_DECL
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
647 #undef OCTAVE_US_TYPE1_CMP_OP_DECLS
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
648 #undef OCTAVE_SU_TYPE1_CMP_OP_DECL
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
649 #undef OCTAVE_SU_TYPE1_CMP_OP_DECLS
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
650 #undef OCTAVE_TYPE1_CMP_OP_DECLS
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
651 #undef OCTAVE_US_TYPE2_CMP_OP_DECL
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
652 #undef OCTAVE_US_TYPE2_CMP_OP_DECLS
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
653 #undef OCTAVE_SU_TYPE2_CMP_OP_DECL
97b62f0c1bee [project @ 2004-11-09 05:51:30 by jwe]
jwe
parents: 5030
diff changeset
654 #undef OCTAVE_SU_TYPE2_CMP_OP_DECLS
5074
c348a7236185 [project @ 2004-11-09 19:41:46 by jwe]
jwe
parents: 5073
diff changeset
655 #undef OCTAVE_TYPE2_CMP_OP_DECLS
4902
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
656
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
657 #endif
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
658
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
659 /*
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
660 ;;; Local Variables: ***
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
661 ;;; mode: C++ ***
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
662 ;;; End: ***
bd043a433918 [project @ 2004-06-14 18:46:20 by jwe]
jwe
parents:
diff changeset
663 */