comparison liboctave/array/CMatrix.cc @ 20267:a9574e3c6e9e

Deprecate Array::length() and Sparse::length() in favour of ::numel(). * liboctave/array/Array.h (Array::length): deprecate for ::numel. * liboctave/array/Sparse.h (Sparse::length): deprecate for ::numel. * libgui/graphics/QtHandlesUtils.cc, libgui/src/octave-qt-link.cc, libinterp/corefcn/Cell.cc, libinterp/corefcn/__contourc__.cc, libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc, libinterp/corefcn/cellfun.cc, libinterp/corefcn/daspk.cc, libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc, libinterp/corefcn/data.cc, libinterp/corefcn/filter.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gl-render.cc, libinterp/corefcn/gl-render.h, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/help.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc, libinterp/corefcn/ls-oct-ascii.h, libinterp/corefcn/lsode.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h, libinterp/corefcn/pr-output.cc, libinterp/corefcn/quadcc.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc, libinterp/corefcn/symtab.h, libinterp/corefcn/syscalls.cc, libinterp/corefcn/tsearch.cc, libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/corefcn/xdiv.cc, libinterp/corefcn/xpow.cc, libinterp/dldfcn/__glpk__.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/audiodevinfo.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/colamd.cc, libinterp/octave-value/ov-cell.cc, libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov.cc, libinterp/operators/op-int.h, libinterp/parse-tree/pt-pr-code.cc, liboctave/array/Array-util.cc, liboctave/array/Array.cc, liboctave/array/CColVector.cc, liboctave/array/CDiagMatrix.cc, liboctave/array/CMatrix.cc, liboctave/array/CRowVector.cc, liboctave/array/DiagArray2.cc, liboctave/array/DiagArray2.h, liboctave/array/MArray.cc, liboctave/array/PermMatrix.cc, liboctave/array/PermMatrix.h, liboctave/array/Sparse.cc, liboctave/array/boolMatrix.cc, liboctave/array/chMatrix.cc, liboctave/array/chNDArray.cc, liboctave/array/dColVector.cc, liboctave/array/dDiagMatrix.cc, liboctave/array/dMatrix.cc, liboctave/array/dRowVector.cc, liboctave/array/fCColVector.cc, liboctave/array/fCDiagMatrix.cc, liboctave/array/fCMatrix.cc, liboctave/array/fCRowVector.cc, liboctave/array/fColVector.cc, liboctave/array/fDiagMatrix.cc, liboctave/array/fMatrix.cc, liboctave/array/fRowVector.cc, liboctave/array/idx-vector.cc, liboctave/array/intNDArray.cc, liboctave/numeric/CmplxCHOL.cc, liboctave/numeric/CmplxLU.cc, liboctave/numeric/CmplxQR.cc, liboctave/numeric/DASPK.cc, liboctave/numeric/DASRT.cc, liboctave/numeric/DASSL.cc, liboctave/numeric/LSODE.cc, liboctave/numeric/ODES.cc, liboctave/numeric/ODES.h, liboctave/numeric/base-dae.h, liboctave/numeric/base-lu.cc, liboctave/numeric/dbleCHOL.cc, liboctave/numeric/dbleLU.cc, liboctave/numeric/dbleQR.cc, liboctave/numeric/eigs-base.cc, liboctave/numeric/fCmplxCHOL.cc, liboctave/numeric/fCmplxLU.cc, liboctave/numeric/fCmplxQR.cc, liboctave/numeric/floatCHOL.cc, liboctave/numeric/floatLU.cc, liboctave/numeric/floatQR.cc, liboctave/numeric/lo-specfun.cc, liboctave/numeric/oct-rand.cc, liboctave/numeric/oct-spparms.cc, liboctave/numeric/sparse-base-chol.cc, liboctave/operators/mx-inlines.cc, liboctave/system/file-ops.cc, liboctave/util/glob-match.h, liboctave/util/kpse.cc, liboctave/util/lo-regexp.cc, liboctave/util/oct-glob.cc, liboctave/util/pathsearch.cc, liboctave/util/str-vec.cc, liboctave/util/str-vec.h, liboctave/util/url-transfer.cc: replace all usage of Array::length() and Sparse::length() with ::numel().
author Carnë Draug <carandraug@octave.org>
date Sat, 30 May 2015 03:14:07 +0100
parents b2100e1659ac
children 5ce959c55cc0
comparison
equal deleted inserted replaced
20266:83792dd9bcc1 20267:a9574e3c6e9e
364 ComplexMatrix::operator == (const ComplexMatrix& a) const 364 ComplexMatrix::operator == (const ComplexMatrix& a) const
365 { 365 {
366 if (rows () != a.rows () || cols () != a.cols ()) 366 if (rows () != a.rows () || cols () != a.cols ())
367 return false; 367 return false;
368 368
369 return mx_inline_equal (length (), data (), a.data ()); 369 return mx_inline_equal (numel (), data (), a.data ());
370 } 370 }
371 371
372 bool 372 bool
373 ComplexMatrix::operator != (const ComplexMatrix& a) const 373 ComplexMatrix::operator != (const ComplexMatrix& a) const
374 { 374 {
421 } 421 }
422 422
423 ComplexMatrix& 423 ComplexMatrix&
424 ComplexMatrix::insert (const RowVector& a, octave_idx_type r, octave_idx_type c) 424 ComplexMatrix::insert (const RowVector& a, octave_idx_type r, octave_idx_type c)
425 { 425 {
426 octave_idx_type a_len = a.length (); 426 octave_idx_type a_len = a.numel ();
427 427
428 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) 428 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
429 { 429 {
430 (*current_liboctave_error_handler) ("range error for insert"); 430 (*current_liboctave_error_handler) ("range error for insert");
431 return *this; 431 return *this;
444 444
445 ComplexMatrix& 445 ComplexMatrix&
446 ComplexMatrix::insert (const ColumnVector& a, 446 ComplexMatrix::insert (const ColumnVector& a,
447 octave_idx_type r, octave_idx_type c) 447 octave_idx_type r, octave_idx_type c)
448 { 448 {
449 octave_idx_type a_len = a.length (); 449 octave_idx_type a_len = a.numel ();
450 450
451 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) 451 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
452 { 452 {
453 (*current_liboctave_error_handler) ("range error for insert"); 453 (*current_liboctave_error_handler) ("range error for insert");
454 return *this; 454 return *this;
503 503
504 ComplexMatrix& 504 ComplexMatrix&
505 ComplexMatrix::insert (const ComplexRowVector& a, 505 ComplexMatrix::insert (const ComplexRowVector& a,
506 octave_idx_type r, octave_idx_type c) 506 octave_idx_type r, octave_idx_type c)
507 { 507 {
508 octave_idx_type a_len = a.length (); 508 octave_idx_type a_len = a.numel ();
509 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) 509 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
510 { 510 {
511 (*current_liboctave_error_handler) ("range error for insert"); 511 (*current_liboctave_error_handler) ("range error for insert");
512 return *this; 512 return *this;
513 } 513 }
520 520
521 ComplexMatrix& 521 ComplexMatrix&
522 ComplexMatrix::insert (const ComplexColumnVector& a, 522 ComplexMatrix::insert (const ComplexColumnVector& a,
523 octave_idx_type r, octave_idx_type c) 523 octave_idx_type r, octave_idx_type c)
524 { 524 {
525 octave_idx_type a_len = a.length (); 525 octave_idx_type a_len = a.numel ();
526 526
527 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) 527 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
528 { 528 {
529 (*current_liboctave_error_handler) ("range error for insert"); 529 (*current_liboctave_error_handler) ("range error for insert");
530 return *this; 530 return *this;
691 (*current_liboctave_error_handler) ("row dimension mismatch for append"); 691 (*current_liboctave_error_handler) ("row dimension mismatch for append");
692 return *this; 692 return *this;
693 } 693 }
694 694
695 octave_idx_type nc_insert = nc; 695 octave_idx_type nc_insert = nc;
696 ComplexMatrix retval (nr, nc + a.length ()); 696 ComplexMatrix retval (nr, nc + a.numel ());
697 retval.insert (*this, 0, 0); 697 retval.insert (*this, 0, 0);
698 retval.insert (a, 0, nc_insert); 698 retval.insert (a, 0, nc_insert);
699 return retval; 699 return retval;
700 } 700 }
701 701
702 ComplexMatrix 702 ComplexMatrix
703 ComplexMatrix::append (const ColumnVector& a) const 703 ComplexMatrix::append (const ColumnVector& a) const
704 { 704 {
705 octave_idx_type nr = rows (); 705 octave_idx_type nr = rows ();
706 octave_idx_type nc = cols (); 706 octave_idx_type nc = cols ();
707 if (nr != a.length ()) 707 if (nr != a.numel ())
708 { 708 {
709 (*current_liboctave_error_handler) ("row dimension mismatch for append"); 709 (*current_liboctave_error_handler) ("row dimension mismatch for append");
710 return *this; 710 return *this;
711 } 711 }
712 712
763 (*current_liboctave_error_handler) ("row dimension mismatch for append"); 763 (*current_liboctave_error_handler) ("row dimension mismatch for append");
764 return *this; 764 return *this;
765 } 765 }
766 766
767 octave_idx_type nc_insert = nc; 767 octave_idx_type nc_insert = nc;
768 ComplexMatrix retval (nr, nc + a.length ()); 768 ComplexMatrix retval (nr, nc + a.numel ());
769 retval.insert (*this, 0, 0); 769 retval.insert (*this, 0, 0);
770 retval.insert (a, 0, nc_insert); 770 retval.insert (a, 0, nc_insert);
771 return retval; 771 return retval;
772 } 772 }
773 773
774 ComplexMatrix 774 ComplexMatrix
775 ComplexMatrix::append (const ComplexColumnVector& a) const 775 ComplexMatrix::append (const ComplexColumnVector& a) const
776 { 776 {
777 octave_idx_type nr = rows (); 777 octave_idx_type nr = rows ();
778 octave_idx_type nc = cols (); 778 octave_idx_type nc = cols ();
779 if (nr != a.length ()) 779 if (nr != a.numel ())
780 { 780 {
781 (*current_liboctave_error_handler) ("row dimension mismatch for append"); 781 (*current_liboctave_error_handler) ("row dimension mismatch for append");
782 return *this; 782 return *this;
783 } 783 }
784 784
829 ComplexMatrix 829 ComplexMatrix
830 ComplexMatrix::stack (const RowVector& a) const 830 ComplexMatrix::stack (const RowVector& a) const
831 { 831 {
832 octave_idx_type nr = rows (); 832 octave_idx_type nr = rows ();
833 octave_idx_type nc = cols (); 833 octave_idx_type nc = cols ();
834 if (nc != a.length ()) 834 if (nc != a.numel ())
835 { 835 {
836 (*current_liboctave_error_handler) 836 (*current_liboctave_error_handler)
837 ("column dimension mismatch for stack"); 837 ("column dimension mismatch for stack");
838 return *this; 838 return *this;
839 } 839 }
856 ("column dimension mismatch for stack"); 856 ("column dimension mismatch for stack");
857 return *this; 857 return *this;
858 } 858 }
859 859
860 octave_idx_type nr_insert = nr; 860 octave_idx_type nr_insert = nr;
861 ComplexMatrix retval (nr + a.length (), nc); 861 ComplexMatrix retval (nr + a.numel (), nc);
862 retval.insert (*this, 0, 0); 862 retval.insert (*this, 0, 0);
863 retval.insert (a, nr_insert, 0); 863 retval.insert (a, nr_insert, 0);
864 return retval; 864 return retval;
865 } 865 }
866 866
905 ComplexMatrix 905 ComplexMatrix
906 ComplexMatrix::stack (const ComplexRowVector& a) const 906 ComplexMatrix::stack (const ComplexRowVector& a) const
907 { 907 {
908 octave_idx_type nr = rows (); 908 octave_idx_type nr = rows ();
909 octave_idx_type nc = cols (); 909 octave_idx_type nc = cols ();
910 if (nc != a.length ()) 910 if (nc != a.numel ())
911 { 911 {
912 (*current_liboctave_error_handler) 912 (*current_liboctave_error_handler)
913 ("column dimension mismatch for stack"); 913 ("column dimension mismatch for stack");
914 return *this; 914 return *this;
915 } 915 }
932 ("column dimension mismatch for stack"); 932 ("column dimension mismatch for stack");
933 return *this; 933 return *this;
934 } 934 }
935 935
936 octave_idx_type nr_insert = nr; 936 octave_idx_type nr_insert = nr;
937 ComplexMatrix retval (nr + a.length (), nc); 937 ComplexMatrix retval (nr + a.numel (), nc);
938 retval.insert (*this, 0, 0); 938 retval.insert (*this, 0, 0);
939 retval.insert (a, nr_insert, 0); 939 retval.insert (a, nr_insert, 0);
940 return retval; 940 return retval;
941 } 941 }
942 942
1227 ComplexMatrix U = result.left_singular_matrix (); 1227 ComplexMatrix U = result.left_singular_matrix ();
1228 ComplexMatrix V = result.right_singular_matrix (); 1228 ComplexMatrix V = result.right_singular_matrix ();
1229 1229
1230 ColumnVector sigma = S.extract_diag (); 1230 ColumnVector sigma = S.extract_diag ();
1231 1231
1232 octave_idx_type r = sigma.length () - 1; 1232 octave_idx_type r = sigma.numel () - 1;
1233 octave_idx_type nr = rows (); 1233 octave_idx_type nr = rows ();
1234 octave_idx_type nc = cols (); 1234 octave_idx_type nc = cols ();
1235 1235
1236 if (tol <= 0.0) 1236 if (tol <= 0.0)
1237 { 1237 {
2842 octave_idx_type nrhs = 1; 2842 octave_idx_type nrhs = 1;
2843 2843
2844 octave_idx_type m = rows (); 2844 octave_idx_type m = rows ();
2845 octave_idx_type n = cols (); 2845 octave_idx_type n = cols ();
2846 2846
2847 if (m != b.length ()) 2847 if (m != b.numel ())
2848 (*current_liboctave_error_handler) 2848 (*current_liboctave_error_handler)
2849 ("matrix dimension mismatch solution of linear equations"); 2849 ("matrix dimension mismatch solution of linear equations");
2850 else if (m == 0 || n == 0 || b.cols () == 0) 2850 else if (m == 0 || n == 0 || b.cols () == 0)
2851 retval = ComplexColumnVector (n, Complex (0.0, 0.0)); 2851 retval = ComplexColumnVector (n, Complex (0.0, 0.0));
2852 else 2852 else
2955 ComplexMatrix 2955 ComplexMatrix
2956 operator * (const ComplexColumnVector& v, const ComplexRowVector& a) 2956 operator * (const ComplexColumnVector& v, const ComplexRowVector& a)
2957 { 2957 {
2958 ComplexMatrix retval; 2958 ComplexMatrix retval;
2959 2959
2960 octave_idx_type len = v.length (); 2960 octave_idx_type len = v.numel ();
2961 2961
2962 if (len != 0) 2962 if (len != 0)
2963 { 2963 {
2964 octave_idx_type a_len = a.length (); 2964 octave_idx_type a_len = a.numel ();
2965 2965
2966 retval = ComplexMatrix (len, a_len); 2966 retval = ComplexMatrix (len, a_len);
2967 Complex *c = retval.fortran_vec (); 2967 Complex *c = retval.fortran_vec ();
2968 2968
2969 F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 ("N", 1), 2969 F77_XFCN (zgemm, ZGEMM, (F77_CONST_CHAR_ARG2 ("N", 1),
3083 if (nr == 0 || nc == 0) 3083 if (nr == 0 || nc == 0)
3084 return *this; 3084 return *this;
3085 3085
3086 Complex *d = fortran_vec (); // Ensures only one reference to my privates! 3086 Complex *d = fortran_vec (); // Ensures only one reference to my privates!
3087 3087
3088 mx_inline_add2 (length (), d, a.data ()); 3088 mx_inline_add2 (numel (), d, a.data ());
3089 return *this; 3089 return *this;
3090 } 3090 }
3091 3091
3092 ComplexMatrix& 3092 ComplexMatrix&
3093 ComplexMatrix::operator -= (const Matrix& a) 3093 ComplexMatrix::operator -= (const Matrix& a)
3107 if (nr == 0 || nc == 0) 3107 if (nr == 0 || nc == 0)
3108 return *this; 3108 return *this;
3109 3109
3110 Complex *d = fortran_vec (); // Ensures only one reference to my privates! 3110 Complex *d = fortran_vec (); // Ensures only one reference to my privates!
3111 3111
3112 mx_inline_sub2 (length (), d, a.data ()); 3112 mx_inline_sub2 (numel (), d, a.data ());
3113 return *this; 3113 return *this;
3114 } 3114 }
3115 3115
3116 // other operations 3116 // other operations
3117 3117
3999 octave_idx_type n) 3999 octave_idx_type n)
4000 4000
4001 { 4001 {
4002 if (n < 1) n = 1; 4002 if (n < 1) n = 1;
4003 4003
4004 octave_idx_type m = x1.length (); 4004 octave_idx_type m = x1.numel ();
4005 4005
4006 if (x2.length () != m) 4006 if (x2.numel () != m)
4007 (*current_liboctave_error_handler) 4007 (*current_liboctave_error_handler)
4008 ("linspace: vectors must be of equal length"); 4008 ("linspace: vectors must be of equal length");
4009 4009
4010 NoAlias<ComplexMatrix> retval; 4010 NoAlias<ComplexMatrix> retval;
4011 4011