comparison liboctave/idx-vector.cc @ 3928:e8627dc4bdf2

[project @ 2002-05-03 19:56:01 by jwe]
author jwe
date Fri, 03 May 2002 19:56:02 +0000
parents b8b0f5ff28e2
children 6e86256e9c54
comparison
equal deleted inserted replaced
3927:e7ad1397d67b 3928:e8627dc4bdf2
73 } 73 }
74 74
75 static inline int 75 static inline int
76 tree_to_mat_idx (double x) 76 tree_to_mat_idx (double x)
77 { 77 {
78 return (x > 0) ? ((int) (x + 0.5) - 1) : ((int) (x - 0.5) - 1); 78 return (x > 0)
79 ? (static_cast<int> (x + 0.5) - 1)
80 : (static_cast<int> (x - 0.5) - 1);
81 }
82
83 static inline int
84 tree_to_mat_idx (int i)
85 {
86 return i - 1;
79 } 87 }
80 88
81 static inline bool 89 static inline bool
82 idx_is_inf_or_nan (double x) 90 idx_is_inf_or_nan (double x)
83 { 91 {
181 } 189 }
182 190
183 init_state (); 191 init_state ();
184 } 192 }
185 193
186 IDX_VEC_REP::idx_vector_rep (double d)
187 {
188 data = 0;
189 initialized = 0;
190 frozen = 0;
191 colon_equiv_checked = 0;
192 colon_equiv = 0;
193 colon = 0;
194 one_zero = 0;
195
196 len = 1;
197
198 orig_nr = 1;
199 orig_nc = 1;
200
201 if (idx_is_inf_or_nan (d))
202 return;
203 else
204 {
205 data = new int [len];
206
207 data[0] = tree_to_mat_idx (d);
208 }
209
210 init_state ();
211 }
212
213 IDX_VEC_REP::idx_vector_rep (const Range& r) 194 IDX_VEC_REP::idx_vector_rep (const Range& r)
214 { 195 {
215 data = 0; 196 data = 0;
216 initialized = 0; 197 initialized = 0;
217 frozen = 0; 198 frozen = 0;
252 if (idx_is_inf_or_nan (val)) 233 if (idx_is_inf_or_nan (val))
253 return; 234 return;
254 else 235 else
255 data[i] = tree_to_mat_idx (val); 236 data[i] = tree_to_mat_idx (val);
256 } 237 }
238
239 init_state ();
240 }
241
242 IDX_VEC_REP::idx_vector_rep (double d)
243 {
244 data = 0;
245 initialized = 0;
246 frozen = 0;
247 colon_equiv_checked = 0;
248 colon_equiv = 0;
249 colon = 0;
250 one_zero = 0;
251
252 len = 1;
253
254 orig_nr = 1;
255 orig_nc = 1;
256
257 if (idx_is_inf_or_nan (d))
258 return;
259 else
260 {
261 data = new int [len];
262
263 data[0] = tree_to_mat_idx (d);
264 }
265
266 init_state ();
267 }
268
269 IDX_VEC_REP::idx_vector_rep (int i)
270 {
271 data = 0;
272 initialized = 0;
273 frozen = 0;
274 colon_equiv_checked = 0;
275 colon_equiv = 0;
276 colon = 0;
277 one_zero = 0;
278
279 len = 1;
280
281 orig_nr = 1;
282 orig_nc = 1;
283
284 data = new int [len];
285
286 data[0] = tree_to_mat_idx (i);
257 287
258 init_state (); 288 init_state ();
259 } 289 }
260 290
261 IDX_VEC_REP::idx_vector_rep (char c) 291 IDX_VEC_REP::idx_vector_rep (char c)