2376
|
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 (__GNUG__) |
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
|
31 #include "lo-ieee.h" |
|
32 #include "lo-utils.h" |
|
33 |
|
34 #include "gripes.h" |
|
35 #include "ops.h" |
|
36 #include "ov-range.h" |
|
37 #include "ov-re-mat.h" |
2410
|
38 #include "ov-scalar.h" |
2376
|
39 #include "pr-output.h" |
|
40 |
|
41 int octave_range::t_id = -1; |
|
42 |
|
43 const string octave_range::t_name ("range"); |
|
44 |
|
45 static octave_value * |
|
46 default_numeric_conversion_function (const octave_value& a) |
|
47 { |
|
48 CAST_CONV_ARG (const octave_range&); |
|
49 |
|
50 return new octave_matrix (v.matrix_value ()); |
|
51 } |
|
52 |
2427
|
53 type_conv_fcn |
2376
|
54 octave_range::numeric_conversion_function (void) const |
|
55 { |
|
56 return default_numeric_conversion_function; |
|
57 } |
|
58 |
2410
|
59 octave_value * |
|
60 octave_range::try_narrowing_conversion (void) |
|
61 { |
|
62 octave_value *retval = 0; |
|
63 |
|
64 switch (range.nelem ()) |
|
65 { |
|
66 case 1: |
|
67 retval = new octave_scalar (range.base ()); |
|
68 break; |
|
69 |
|
70 case 0: |
|
71 retval = new octave_matrix (Matrix ()); |
|
72 break; |
|
73 |
|
74 default: |
|
75 break; |
|
76 } |
|
77 |
|
78 return retval; |
|
79 } |
|
80 |
2376
|
81 double |
|
82 octave_range::double_value (bool) const |
|
83 { |
|
84 double retval = octave_NaN; |
|
85 |
|
86 int nel = range.nelem (); |
|
87 |
|
88 if (nel == 1 || (nel > 1 && Vdo_fortran_indexing)) |
|
89 retval = range.base (); |
|
90 else |
|
91 gripe_invalid_conversion ("range", "real scalar"); |
|
92 |
|
93 return retval; |
|
94 } |
|
95 |
|
96 octave_value |
|
97 octave_range::all (void) const |
|
98 { |
|
99 octave_value retval; |
|
100 error ("octave_range::all(): not implemented"); |
|
101 return retval; |
|
102 } |
|
103 |
|
104 octave_value |
|
105 octave_range::any (void) const |
|
106 { |
|
107 octave_value retval; |
|
108 error ("octave_range::any(): not implemented"); |
|
109 return retval; |
|
110 } |
|
111 |
|
112 bool |
|
113 octave_range::is_true (void) const |
|
114 { |
|
115 bool retval = false; |
|
116 error ("octave_range::is_true(): not implemented"); |
|
117 return retval; |
|
118 } |
|
119 |
|
120 Complex |
|
121 octave_range::complex_value (bool) const |
|
122 { |
|
123 Complex retval (octave_NaN, octave_NaN); |
|
124 |
|
125 int nel = range.nelem (); |
|
126 |
|
127 if (nel == 1 || (nel > 1 && Vdo_fortran_indexing)) |
|
128 retval = range.base (); |
|
129 else |
|
130 gripe_invalid_conversion ("range", "complex scalar"); |
|
131 |
|
132 return retval; |
|
133 } |
|
134 |
|
135 octave_value |
|
136 octave_range::transpose (void) const |
|
137 { |
|
138 Matrix tmp (matrix_value ()); |
|
139 return tmp.transpose (); |
|
140 } |
|
141 |
|
142 octave_value |
|
143 octave_range::hermitian (void) const |
|
144 { |
|
145 Matrix tmp (matrix_value ()); |
|
146 return tmp.transpose (); |
|
147 } |
|
148 |
|
149 void |
|
150 octave_range::print (ostream& os) |
|
151 { |
|
152 octave_print_internal (os, range, false, struct_indent); |
|
153 } |
|
154 |
|
155 /* |
|
156 ;;; Local Variables: *** |
|
157 ;;; mode: C++ *** |
|
158 ;;; End: *** |
|
159 */ |