Mercurial > hg > octave-nkf
comparison src/ov-range.h @ 2376:2142216bf85a
[project @ 1996-10-12 01:39:07 by jwe]
author | jwe |
---|---|
date | Sat, 12 Oct 1996 01:39:21 +0000 |
parents | |
children | 367485171742 |
comparison
equal
deleted
inserted
replaced
2375:7ef24992e290 | 2376:2142216bf85a |
---|---|
1 /* | |
2 | |
3 Copyright (C) 1996 John W. Eaton | |
4 | |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 2, or (at your option) any | |
10 later version. | |
11 | |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with Octave; see the file COPYING. If not, write to the Free | |
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 | |
21 */ | |
22 | |
23 #if !defined (octave_range_h) | |
24 #define octave_range_h 1 | |
25 | |
26 #if defined (__GNUG__) | |
27 #pragma interface | |
28 #endif | |
29 | |
30 #include <cstdlib> | |
31 | |
32 #include <string> | |
33 | |
34 class ostream; | |
35 | |
36 #include "Range.h" | |
37 | |
38 #include "lo-utils.h" | |
39 #include "mx-base.h" | |
40 #include "str-vec.h" | |
41 | |
42 #include "error.h" | |
43 #include "mappers.h" | |
44 #include "ov-base.h" | |
45 #include "ov-typeinfo.h" | |
46 | |
47 class Octave_map; | |
48 class octave_value_list; | |
49 | |
50 class tree_walker; | |
51 | |
52 // Range values. | |
53 | |
54 class | |
55 octave_range : public octave_base_value | |
56 { | |
57 public: | |
58 | |
59 octave_range (void) | |
60 : octave_base_value () { } | |
61 | |
62 octave_range (double base, double limit, double inc) | |
63 : octave_base_value (), range (base, limit, inc) | |
64 { | |
65 if (range.nelem () < 0) | |
66 ::error ("invalid range"); | |
67 } | |
68 | |
69 octave_range (const Range& r) | |
70 : octave_base_value (), range (r) | |
71 { | |
72 if (range.nelem () < 0) | |
73 ::error ("invalid range"); | |
74 } | |
75 | |
76 octave_range (const octave_range& r) | |
77 : octave_base_value (), range (r.range) { } | |
78 | |
79 ~octave_range (void) { } | |
80 | |
81 octave_value *clone (void) { return new octave_range (*this); } | |
82 | |
83 #if 0 | |
84 void *operator new (size_t size); | |
85 void operator delete (void *p, size_t size); | |
86 #endif | |
87 | |
88 numeric_conv_fcn numeric_conversion_function (void) const; | |
89 | |
90 idx_vector index_vector (void) const { return idx_vector (range); } | |
91 | |
92 int rows (void) const { return (columns () > 0); } | |
93 int columns (void) const { return range.nelem (); } | |
94 | |
95 bool is_defined (void) const { return true; } | |
96 | |
97 bool is_range (void) const { return true; } | |
98 | |
99 // XXX DO ME XXX | |
100 octave_value all (void) const; | |
101 octave_value any (void) const; | |
102 | |
103 bool is_real_type (void) const { return true; } | |
104 | |
105 bool valid_as_scalar_index (void) const | |
106 { | |
107 return (range.nelem () == 1 | |
108 && ! xisnan (range.base ()) | |
109 && NINT (range.base ()) == 1); | |
110 } | |
111 | |
112 bool valid_as_zero_index (void) const | |
113 { | |
114 return (range.nelem () == 1 | |
115 && ! xisnan (range.base ()) | |
116 && NINT (range.base ()) == 0); | |
117 } | |
118 | |
119 // XXX DO ME XXX | |
120 bool is_true (void) const; | |
121 | |
122 double double_value (bool) const; | |
123 | |
124 Matrix matrix_value (bool) const | |
125 { return range.matrix_value (); } | |
126 | |
127 Complex complex_value (bool) const; | |
128 | |
129 ComplexMatrix complex_matrix_value (bool) const | |
130 { return range.matrix_value (); } | |
131 | |
132 Range range_value (void) const { return range; } | |
133 | |
134 octave_value transpose (void) const; | |
135 | |
136 octave_value hermitian (void) const; | |
137 | |
138 void print (ostream& os); | |
139 | |
140 int type_id (void) const { return t_id; } | |
141 | |
142 string type_name (void) const { return t_name; } | |
143 | |
144 static int static_type_id (void) { return t_id; } | |
145 | |
146 static void register_type (void) | |
147 { t_id = octave_value_typeinfo::register_type (t_name); } | |
148 | |
149 private: | |
150 | |
151 Range range; | |
152 | |
153 static int t_id; | |
154 | |
155 static const string t_name; | |
156 }; | |
157 | |
158 #endif | |
159 | |
160 /* | |
161 ;;; Local Variables: *** | |
162 ;;; mode: C++ *** | |
163 ;;; End: *** | |
164 */ |