Mercurial > octave
comparison src/pt-exp-base.cc @ 1343:94bedeb289e5
[project @ 1995-09-04 00:29:21 by jwe]
author | jwe |
---|---|
date | Mon, 04 Sep 1995 00:42:19 +0000 |
parents | 64819a909ed7 |
children | 9e41dbb74bca |
comparison
equal
deleted
inserted
replaced
1342:61bb2bdee11e | 1343:94bedeb289e5 |
---|---|
27 | 27 |
28 #ifdef HAVE_CONFIG_H | 28 #ifdef HAVE_CONFIG_H |
29 #include <config.h> | 29 #include <config.h> |
30 #endif | 30 #endif |
31 | 31 |
32 #include <cstring> | |
33 #include <climits> | |
34 #include <cctype> | |
35 #include <cstdio> | |
36 | |
32 #include <sys/types.h> | 37 #include <sys/types.h> |
33 #ifdef HAVE_UNISTD_H | 38 #ifdef HAVE_UNISTD_H |
34 #include <unistd.h> | 39 #include <unistd.h> |
35 #endif | 40 #endif |
36 | 41 |
37 #include <iostream.h> | 42 #include <iostream.h> |
38 #include <strstream.h> | 43 #include <strstream.h> |
39 #include <string.h> | |
40 #include <limits.h> | |
41 #include <ctype.h> | |
42 #include <stdio.h> | |
43 | 44 |
44 #include "variables.h" | 45 #include "variables.h" |
45 #include "user-prefs.h" | 46 #include "user-prefs.h" |
46 #include "dynamic-ld.h" | 47 #include "dynamic-ld.h" |
47 #include "help.h" | 48 #include "help.h" |
334 int prev_nc = 0; | 335 int prev_nc = 0; |
335 | 336 |
336 Matrix m; | 337 Matrix m; |
337 ComplexMatrix cm; | 338 ComplexMatrix cm; |
338 | 339 |
339 char *string = 0; | 340 Octave_str_obj string; |
340 char *str_ptr = 0; | |
341 | 341 |
342 // Eliminate empties and gather stats. | 342 // Eliminate empties and gather stats. |
343 | 343 |
344 int found_new_row_in_empties = 0; | 344 int found_new_row_in_empties = 0; |
345 | 345 |
448 } | 448 } |
449 break; | 449 break; |
450 | 450 |
451 case md_down: | 451 case md_down: |
452 { | 452 { |
453 if (cols_this_row != col_total) | 453 if (cols_this_row != col_total && ! all_strings) |
454 { | 454 { |
455 ::error ("number of columns must match"); | 455 ::error ("number of columns must match"); |
456 goto done; | 456 goto done; |
457 } | 457 } |
458 first_row = 0; | 458 first_row = 0; |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 // Don\'t forget to check to see if the last element will fit. | 472 // Don\'t forget to check to see if the last element will fit. |
473 | 473 |
474 if (cols_this_row != col_total) | 474 if (cols_this_row != col_total && ! all_strings) |
475 { | 475 { |
476 ::error ("number of columns must match"); | 476 ::error ("number of columns must match"); |
477 goto done; | 477 goto done; |
478 } | 478 } |
479 | 479 |
480 // Now, extract the values from the individual elements and insert | 480 // Now, extract the values from the individual elements and insert |
481 // them in the result matrix. | 481 // them in the result matrix. |
482 | 482 |
483 if (all_strings && row_total == 1 && col_total > 0) | 483 if (all_strings) |
484 { | 484 string.resize (row_total); |
485 string = str_ptr = new char [col_total + 1]; | |
486 string[col_total] = '\0'; | |
487 } | |
488 else if (found_complex) | 485 else if (found_complex) |
489 cm.resize (row_total, col_total, 0.0); | 486 cm.resize (row_total, col_total, 0.0); |
490 else | 487 else |
491 m.resize (row_total, col_total, 0.0); | 488 m.resize (row_total, col_total, 0.0); |
492 | 489 |
552 { | 549 { |
553 if (tmp.is_real_scalar ()) | 550 if (tmp.is_real_scalar ()) |
554 { | 551 { |
555 m (put_row, put_col) = tmp.double_value (); | 552 m (put_row, put_col) = tmp.double_value (); |
556 } | 553 } |
557 else if (tmp.is_string () && all_strings && str_ptr) | 554 else if (tmp.is_string () && all_strings) |
558 { | 555 { |
559 memcpy (str_ptr, tmp.string_value (), nc); | 556 switch (list[i].direction) |
560 str_ptr += nc; | 557 { |
558 case md_right: | |
559 if (nr == 1) | |
560 string.append_right (put_row, tmp.string_value ()); | |
561 else | |
562 string.append_right (tmp.all_strings ()); | |
563 break; | |
564 | |
565 case md_none: | |
566 case md_down: | |
567 string.append_down (put_row, tmp.all_strings ()); | |
568 break; | |
569 | |
570 default: | |
571 panic_impossible (); | |
572 break; | |
573 } | |
561 } | 574 } |
562 else | 575 else |
563 { | 576 { |
564 Matrix m_tmp = tmp.matrix_value (); | 577 Matrix m_tmp = tmp.matrix_value (); |
565 | 578 |
572 | 585 |
573 prev_nr = nr; | 586 prev_nr = nr; |
574 prev_nc = nc; | 587 prev_nc = nc; |
575 } | 588 } |
576 | 589 |
577 if (all_strings && string) | 590 if (all_strings && string.num_strings () > 0) |
578 retval = tree_constant (string); | 591 retval = string; |
579 else if (found_complex) | 592 else if (found_complex) |
580 retval = tree_constant (cm); | 593 retval = cm; |
581 else | 594 else |
582 retval = tree_constant (m); | 595 retval = m; |
583 | 596 |
584 done: | 597 done: |
585 delete [] list; | 598 delete [] list; |
586 | 599 |
587 return retval; | 600 return retval; |