Mercurial > hg > octave-lyh
comparison src/pt-mat.cc @ 2602:9cbbbcf5b6f5
[project @ 1997-01-07 06:18:23 by jwe]
author | jwe |
---|---|
date | Tue, 07 Jan 1997 06:20:06 +0000 |
parents | fa7dd5fc7c59 |
children | 9aeba8e006a4 |
comparison
equal
deleted
inserted
replaced
2601:3723512a827a | 2602:9cbbbcf5b6f5 |
---|---|
69 { | 69 { |
70 public: | 70 public: |
71 | 71 |
72 tm_row_const_rep (void) | 72 tm_row_const_rep (void) |
73 : SLList<octave_value> (), count (1), nr (0), nc (0), | 73 : SLList<octave_value> (), count (1), nr (0), nc (0), |
74 all_str (false), is_cmplx (false), ok (false) { } | 74 all_str (false), is_cmplx (false), all_mt (true), ok (false) { } |
75 | 75 |
76 tm_row_const_rep (const tree_matrix_row& mr) | 76 tm_row_const_rep (const tree_matrix_row& mr) |
77 : SLList<octave_value> (), count (1), nr (0), nc (0), | 77 : SLList<octave_value> (), count (1), nr (0), nc (0), |
78 all_str (false), is_cmplx (false), ok (false) | 78 all_str (false), is_cmplx (false), all_mt (true), ok (false) |
79 { init (mr); } | 79 { init (mr); } |
80 | 80 |
81 ~tm_row_const_rep (void) { } | 81 ~tm_row_const_rep (void) { } |
82 | 82 |
83 int count; | 83 int count; |
85 int nr; | 85 int nr; |
86 int nc; | 86 int nc; |
87 | 87 |
88 bool all_str; | 88 bool all_str; |
89 bool is_cmplx; | 89 bool is_cmplx; |
90 bool all_mt; | |
90 | 91 |
91 bool ok; | 92 bool ok; |
92 | 93 |
93 void init (const tree_matrix_row&); | 94 void init (const tree_matrix_row&); |
94 | 95 |
143 int rows (void) { return rep->nr; } | 144 int rows (void) { return rep->nr; } |
144 int cols (void) { return rep->nc; } | 145 int cols (void) { return rep->nc; } |
145 | 146 |
146 bool all_strings (void) const { return rep->all_str; } | 147 bool all_strings (void) const { return rep->all_str; } |
147 bool is_complex (void) const { return rep->is_cmplx; } | 148 bool is_complex (void) const { return rep->is_cmplx; } |
149 bool all_empty (void) const { return rep->all_mt; } | |
148 | 150 |
149 octave_value& operator () (Pix p) { return rep->operator () (p); } | 151 octave_value& operator () (Pix p) { return rep->operator () (p); } |
150 | 152 |
151 const octave_value& operator () (Pix p) const | 153 const octave_value& operator () (Pix p) const |
152 { return rep->operator () (p); } | 154 { return rep->operator () (p); } |
196 break; | 198 break; |
197 } | 199 } |
198 } | 200 } |
199 else | 201 else |
200 { | 202 { |
203 all_mt = false; | |
204 | |
201 if (first_elem) | 205 if (first_elem) |
202 { | 206 { |
203 first_elem = false; | 207 first_elem = false; |
204 | 208 |
205 nr = this_elt_nr; | 209 nr = this_elt_nr; |
258 { | 262 { |
259 public: | 263 public: |
260 | 264 |
261 tm_const (const tree_matrix& tm) | 265 tm_const (const tree_matrix& tm) |
262 : SLList<tm_row_const> (), nr (0), nc (0), all_str (false), | 266 : SLList<tm_row_const> (), nr (0), nc (0), all_str (false), |
263 is_cmplx (false), ok (false) | 267 is_cmplx (false), all_mt (true), ok (false) |
264 { init (tm); } | 268 { init (tm); } |
265 | 269 |
266 ~tm_const (void) { } | 270 ~tm_const (void) { } |
267 | 271 |
268 int rows (void) const { return nr; } | 272 int rows (void) const { return nr; } |
269 int cols (void) const { return nc; } | 273 int cols (void) const { return nc; } |
270 | 274 |
271 bool all_strings (void) const { return all_str; } | 275 bool all_strings (void) const { return all_str; } |
272 bool is_complex (void) const { return is_cmplx; } | 276 bool is_complex (void) const { return is_cmplx; } |
277 bool all_empty (void) const { return all_mt; } | |
273 | 278 |
274 operator void* () const { return ok ? (void *) -1 : (void *) 0; } | 279 operator void* () const { return ok ? (void *) -1 : (void *) 0; } |
275 | 280 |
276 private: | 281 private: |
277 | 282 |
278 int nr; | 283 int nr; |
279 int nc; | 284 int nc; |
280 | 285 |
281 bool all_str; | 286 bool all_str; |
282 bool is_cmplx; | 287 bool is_cmplx; |
288 bool all_mt; | |
283 | 289 |
284 bool ok; | 290 bool ok; |
285 | 291 |
286 tm_const (void); | 292 tm_const (void); |
287 | 293 |
315 if (all_str && ! tmp.all_strings ()) | 321 if (all_str && ! tmp.all_strings ()) |
316 all_str = false; | 322 all_str = false; |
317 | 323 |
318 if (! is_cmplx && tmp.is_complex ()) | 324 if (! is_cmplx && tmp.is_complex ()) |
319 is_cmplx = true; | 325 is_cmplx = true; |
326 | |
327 if (all_mt && ! tmp.all_empty ()) | |
328 all_mt = false; | |
320 | 329 |
321 append (tmp); | 330 append (tmp); |
322 } | 331 } |
323 else | 332 else |
324 break; | 333 break; |
343 break; | 352 break; |
344 } | 353 } |
345 } | 354 } |
346 else | 355 else |
347 { | 356 { |
357 all_mt = false; | |
358 | |
348 if (first_elem) | 359 if (first_elem) |
349 { | 360 { |
350 first_elem = false; | 361 first_elem = false; |
351 | 362 |
352 nc = this_elt_nc; | 363 nc = this_elt_nc; |
460 { | 471 { |
461 octave_value retval; | 472 octave_value retval; |
462 | 473 |
463 tm_const tmp (*this); | 474 tm_const tmp (*this); |
464 | 475 |
476 bool all_strings = false; | |
477 bool all_empty = false; | |
478 | |
465 if (tmp) | 479 if (tmp) |
466 { | 480 { |
467 int nr = tmp.rows (); | 481 int nr = tmp.rows (); |
468 int nc = tmp.cols (); | 482 int nc = tmp.cols (); |
469 | 483 |
472 charMatrix chm; | 486 charMatrix chm; |
473 | 487 |
474 // Now, extract the values from the individual elements and | 488 // Now, extract the values from the individual elements and |
475 // insert them in the result matrix. | 489 // insert them in the result matrix. |
476 | 490 |
477 bool all_strings = tmp.all_strings (); | |
478 bool found_complex = tmp.is_complex (); | 491 bool found_complex = tmp.is_complex (); |
492 | |
493 all_strings = tmp.all_strings (); | |
494 all_empty = tmp.all_empty (); | |
479 | 495 |
480 if (all_strings) | 496 if (all_strings) |
481 chm.resize (nr, nc, Vstring_fill_char); | 497 chm.resize (nr, nc, Vstring_fill_char); |
482 else if (found_complex) | 498 else if (found_complex) |
483 cm.resize (nr, nc, 0.0); | 499 cm.resize (nr, nc, 0.0); |
552 } | 568 } |
553 } | 569 } |
554 | 570 |
555 done: | 571 done: |
556 | 572 |
573 if (! error_state && retval.is_undefined () && all_empty) | |
574 { | |
575 if (all_strings) | |
576 retval = ""; | |
577 else | |
578 retval = Matrix (); | |
579 } | |
580 | |
557 return retval; | 581 return retval; |
558 } | 582 } |
559 | 583 |
560 void | 584 void |
561 tree_matrix::accept (tree_walker& tw) | 585 tree_matrix::accept (tree_walker& tw) |