Mercurial > hg > octave-lyh
comparison src/ov-range.cc @ 2436:a628e881be66
[project @ 1996-10-29 22:08:28 by jwe]
author | jwe |
---|---|
date | Tue, 29 Oct 1996 22:10:39 +0000 |
parents | 2f50b24ce84f |
children | 31d5588dbb61 |
comparison
equal
deleted
inserted
replaced
2435:3be97fe02051 | 2436:a628e881be66 |
---|---|
76 } | 76 } |
77 | 77 |
78 return retval; | 78 return retval; |
79 } | 79 } |
80 | 80 |
81 octave_value | |
82 octave_range::index (const octave_value_list& idx) const | |
83 { | |
84 // XXX FIXME XXX -- this doesn't solve the problem of | |
85 // | |
86 // a = 1:5; a(1, 1, 1) | |
87 // | |
88 // and similar constructions. Hmm... | |
89 | |
90 // XXX FIXME XXX -- using this constructor avoids possibly narrowing | |
91 // the range to a scalar value. Need a better solution to this | |
92 // problem. | |
93 | |
94 octave_value tmp (new octave_matrix (range.matrix_value ())); | |
95 | |
96 return tmp.index (idx); | |
97 } | |
98 | |
81 double | 99 double |
82 octave_range::double_value (bool) const | 100 octave_range::double_value (bool) const |
83 { | 101 { |
84 double retval = octave_NaN; | 102 double retval = octave_NaN; |
85 | 103 |
94 } | 112 } |
95 | 113 |
96 octave_value | 114 octave_value |
97 octave_range::all (void) const | 115 octave_range::all (void) const |
98 { | 116 { |
99 octave_value retval; | 117 // XXX FIXME XXX -- this is a potential waste of memory. |
100 error ("octave_range::all(): not implemented"); | 118 |
101 return retval; | 119 Matrix m = range.matrix_value (); |
120 | |
121 return m.all (); | |
102 } | 122 } |
103 | 123 |
104 octave_value | 124 octave_value |
105 octave_range::any (void) const | 125 octave_range::any (void) const |
106 { | 126 { |
107 octave_value retval; | 127 return (double) (range.base () != 0.0 || range.nelem () > 1); |
108 error ("octave_range::any(): not implemented"); | |
109 return retval; | |
110 } | 128 } |
111 | 129 |
112 bool | 130 bool |
113 octave_range::is_true (void) const | 131 octave_range::is_true (void) const |
114 { | 132 { |
115 bool retval = false; | 133 bool retval = false; |
116 error ("octave_range::is_true(): not implemented"); | 134 |
135 if (range.nelem () == 0) | |
136 { | |
137 int flag = Vpropagate_empty_matrices; | |
138 | |
139 if (flag < 0) | |
140 warning ("empty range used in conditional expression"); | |
141 else if (flag == 0) | |
142 error ("empty range used in conditional expression"); | |
143 } | |
144 else | |
145 { | |
146 // XXX FIXME XXX -- this is a potential waste of memory. | |
147 | |
148 Matrix m ((range.matrix_value () . all ()) . all ()); | |
149 | |
150 retval = (m.rows () == 1 && m.columns () == 1 && m (0, 0) != 0.0); | |
151 } | |
152 | |
117 return retval; | 153 return retval; |
118 } | 154 } |
119 | 155 |
120 Complex | 156 Complex |
121 octave_range::complex_value (bool) const | 157 octave_range::complex_value (bool) const |