comparison src/pt-mat.cc @ 11586:12df7854fa7c

strip trailing whitespace from source files
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:24:59 -0500
parents 57632dea2446
children a21a3875ca83
comparison
equal deleted inserted replaced
11585:1473d0cf86d2 11586:12df7854fa7c
254 retval = c1; 254 retval = c1;
255 else if (c1 == "cell" && c2 == c1) 255 else if (c1 == "cell" && c2 == c1)
256 retval = c1; 256 retval = c1;
257 } 257 }
258 258
259 return retval; 259 return retval;
260 } 260 }
261 261
262 static void 262 static void
263 eval_error (const char *msg, int l, int c, 263 eval_error (const char *msg, int l, int c,
264 const dim_vector& x, const dim_vector& y) 264 const dim_vector& x, const dim_vector& y)
265 { 265 {
266 if (l == -1 && c == -1) 266 if (l == -1 && c == -1)
267 { 267 {
268 ::error ("%s (%s vs %s)", msg, x.str ().c_str (), y.str ().c_str ()); 268 ::error ("%s (%s vs %s)", msg, x.str ().c_str (), y.str ().c_str ());
269 } 269 }
270 else 270 else
271 { 271 {
272 ::error ("%s (%s vs %s) near line %d, column %d", msg, 272 ::error ("%s (%s vs %s) near line %d, column %d", msg,
273 x.str ().c_str (), y.str ().c_str (), l, c); 273 x.str ().c_str (), y.str ().c_str (), l, c);
274 } 274 }
275 } 275 }
276 276
277 bool 277 bool
543 { 543 {
544 first_elem = false; 544 first_elem = false;
545 545
546 dv = this_elt_dv; 546 dv = this_elt_dv;
547 } 547 }
548 else if (all_str && dv.length () == 2 548 else if (all_str && dv.length () == 2
549 && this_elt_dv.length () == 2) 549 && this_elt_dv.length () == 2)
550 { 550 {
551 // FIXME: this is Octave's specialty. Character matrices allow 551 // FIXME: this is Octave's specialty. Character matrices allow
552 // rows of unequal length. 552 // rows of unequal length.
553 if (this_elt_nc > cols ()) 553 if (this_elt_nc > cols ())
554 dv(1) = this_elt_nc; 554 dv(1) = this_elt_nc;
555 dv(0) += this_elt_nr; 555 dv(0) += this_elt_nr;
556 } 556 }
557 else if (! dv.hvcat (this_elt_dv, 0)) 557 else if (! dv.hvcat (this_elt_dv, 0))
558 { 558 {
559 eval_error ("vertical dimensions mismatch", -1, -1, 559 eval_error ("vertical dimensions mismatch", -1, -1,
560 dv, this_elt_dv); 560 dv, this_elt_dv);
561 return; 561 return;
562 } 562 }
563 } 563 }
564 } 564 }
628 warning_with_id ("Octave:string-concat", 628 warning_with_id ("Octave:string-concat",
629 "concatenation of different character string types may have unintended consequences"); 629 "concatenation of different character string types may have unintended consequences");
630 } 630 }
631 631
632 template<class TYPE, class T> 632 template<class TYPE, class T>
633 static void 633 static void
634 single_type_concat (Array<T>& result, 634 single_type_concat (Array<T>& result,
635 tm_const& tmp) 635 tm_const& tmp)
636 { 636 {
637 octave_idx_type r = 0, c = 0; 637 octave_idx_type r = 0, c = 0;
638 638
672 c = 0; 672 c = 0;
673 } 673 }
674 } 674 }
675 675
676 template<class TYPE, class T> 676 template<class TYPE, class T>
677 static void 677 static void
678 single_type_concat (Array<T>& result, 678 single_type_concat (Array<T>& result,
679 const dim_vector& dv, 679 const dim_vector& dv,
680 tm_const& tmp) 680 tm_const& tmp)
681 { 681 {
682 if (dv.any_zero ()) 682 if (dv.any_zero ())
726 single_type_concat<TYPE> (result, tmp); 726 single_type_concat<TYPE> (result, tmp);
727 } 727 }
728 } 728 }
729 729
730 template<class TYPE, class T> 730 template<class TYPE, class T>
731 static void 731 static void
732 single_type_concat (Sparse<T>& result, 732 single_type_concat (Sparse<T>& result,
733 const dim_vector& dv, 733 const dim_vector& dv,
734 tm_const& tmp) 734 tm_const& tmp)
735 { 735 {
736 if (dv.any_zero ()) 736 if (dv.any_zero ())
767 767
768 result = Sparse<T>::cat (-1, nrows, sparse_row_list); 768 result = Sparse<T>::cat (-1, nrows, sparse_row_list);
769 } 769 }
770 770
771 template<class MAP> 771 template<class MAP>
772 static void 772 static void
773 single_type_concat (octave_map& result, 773 single_type_concat (octave_map& result,
774 const dim_vector& dv, 774 const dim_vector& dv,
775 tm_const& tmp) 775 tm_const& tmp)
776 { 776 {
777 if (dv.any_zero ()) 777 if (dv.any_zero ())
805 805
806 result = octave_map::cat (-1, nrows, map_row_list); 806 result = octave_map::cat (-1, nrows, map_row_list);
807 } 807 }
808 808
809 template<class TYPE> 809 template<class TYPE>
810 static octave_value 810 static octave_value
811 do_single_type_concat (const dim_vector& dv, 811 do_single_type_concat (const dim_vector& dv,
812 tm_const& tmp) 812 tm_const& tmp)
813 { 813 {
814 TYPE result; 814 TYPE result;
815 815
817 817
818 return result; 818 return result;
819 } 819 }
820 820
821 template<> 821 template<>
822 octave_value 822 octave_value
823 do_single_type_concat<octave_map> (const dim_vector& dv, 823 do_single_type_concat<octave_map> (const dim_vector& dv,
824 tm_const& tmp) 824 tm_const& tmp)
825 { 825 {
826 octave_map result; 826 octave_map result;
827 827
883 else 883 else
884 { 884 {
885 octave_value_list tmp1 (row.length (), octave_value ()); 885 octave_value_list tmp1 (row.length (), octave_value ());
886 886
887 int i = 0; 887 int i = 0;
888 for (tm_row_const::iterator q = row.begin (); 888 for (tm_row_const::iterator q = row.begin ();
889 q != row.end (); q++) 889 q != row.end (); q++)
890 tmp1 (i++) = *q; 890 tmp1 (i++) = *q;
891 891
892 octave_value_list tmp2; 892 octave_value_list tmp2;
893 octave_value fcn = 893 octave_value fcn =
894 symbol_table::find_function ("horzcat", tmp1); 894 symbol_table::find_function ("horzcat", tmp1);
895 895
896 if (fcn.is_defined ()) 896 if (fcn.is_defined ())
897 { 897 {
898 tmp2 = fcn.do_multi_index_op (1, tmp1); 898 tmp2 = fcn.do_multi_index_op (1, tmp1);
899 899
900 if (error_state) 900 if (error_state)
901 goto done; 901 goto done;
902 902
903 tmp3 (j++) = tmp2 (0); 903 tmp3 (j++) = tmp2 (0);
904 } 904 }
918 octave_value fcn = symbol_table::find_function ("vertcat", tmp3); 918 octave_value fcn = symbol_table::find_function ("vertcat", tmp3);
919 919
920 if (fcn.is_defined ()) 920 if (fcn.is_defined ())
921 { 921 {
922 tmp2 = fcn.do_multi_index_op (1, tmp3); 922 tmp2 = fcn.do_multi_index_op (1, tmp3);
923 923
924 if (! error_state) 924 if (! error_state)
925 retval = tmp2 (0); 925 retval = tmp2 (0);
926 } 926 }
927 else 927 else
928 ::error ("cat not find overloaded vertcat function"); 928 ::error ("cat not find overloaded vertcat function");
929 } 929 }
930 } 930 }
931 else if (result_type == "double") 931 else if (result_type == "double")
932 { 932 {
933 if (any_sparse_p) 933 if (any_sparse_p)
934 { 934 {
935 if (all_real_p) 935 if (all_real_p)
936 retval = do_single_type_concat<SparseMatrix> (dv, tmp); 936 retval = do_single_type_concat<SparseMatrix> (dv, tmp);
937 else 937 else
938 retval = do_single_type_concat<SparseComplexMatrix> (dv, tmp); 938 retval = do_single_type_concat<SparseComplexMatrix> (dv, tmp);
939 } 939 }
1017 if (any_sparse_p) 1017 if (any_sparse_p)
1018 { 1018 {
1019 // Start with sparse matrix to avoid issues memory issues 1019 // Start with sparse matrix to avoid issues memory issues
1020 // with things like [ones(1,4),sprandn(1e8,4,1e-4)] 1020 // with things like [ones(1,4),sprandn(1e8,4,1e-4)]
1021 if (all_real_p) 1021 if (all_real_p)
1022 ctmp = octave_sparse_matrix ().resize (dv); 1022 ctmp = octave_sparse_matrix ().resize (dv);
1023 else 1023 else
1024 ctmp = octave_sparse_complex_matrix ().resize (dv); 1024 ctmp = octave_sparse_complex_matrix ().resize (dv);
1025 } 1025 }
1026 else 1026 else
1027 { 1027 {
1028 for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++) 1028 for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++)
1029 { 1029 {
1030 octave_quit (); 1030 octave_quit ();
1031 1031
1032 tm_row_const row = *p; 1032 tm_row_const row = *p;
1033 1033
1034 for (tm_row_const::iterator q = row.begin (); 1034 for (tm_row_const::iterator q = row.begin ();
1035 q != row.end (); q++) 1035 q != row.end (); q++)
1036 { 1036 {
1037 octave_quit (); 1037 octave_quit ();
1038 1038
1039 ctmp = *q; 1039 ctmp = *q;