#! /bin/sh # # To apply this patch, cd to the top level Octave source directory and # run this file through /bin/sh. It will first remove any files that # have been deleted from the source distribution since the last # release and then update the sources with patch(1). # # Diffs for updating *.ps, *.dvi, *.info*, and *.html files are not # included because they can be recreated from the Texinfo files using # TeX, makeinfo, or texi2html. # # Diffs for updating parse.cc and y.tab.h are not included because # they can be recreated from the file parse.y using bison. # # Diffs for updating lex.cc are not included because it can be # recreated from lex.l using flex. # # John W. Eaton # jwe@bevo.che.wisc.edu # University of Wisconsin-Madison # Department of Chemical Engineering if test -f src/octave.cc ; then true else echo '***********************************************************' 1>&2 echo 'You must run this script in the top-level octave directory!' 1>&2 echo '***********************************************************' 1>&2 exit 1 fi ### ### Special commands should go here. ### echo 'patching existing files' patch -p1 << \PATCH_EOF diff -cNr octave-3.2.2/acx_blas_f77_func.m4 octave-3.2.3/acx_blas_f77_func.m4 *** octave-3.2.2/acx_blas_f77_func.m4 2009-05-25 08:04:58.000000000 +0200 --- octave-3.2.3/acx_blas_f77_func.m4 2009-08-24 10:18:51.000000000 +0200 *************** *** 64,69 **** --- 64,70 ---- if test "$cross_compiling" = yes ; then ifelse($3, ,$1,$3) elif test x"$acx_blas_ok" = xyes; then + save_acx_blas_f77_func_LIBS="$LIBS" LIBS="$BLAS_LIBS $LIBS" AC_LANG_PUSH(Fortran 77) # LSAME check (LOGICAL return values) *************** *** 95,101 **** [acx_blas_isamax_fcall_ok=no]) AC_MSG_RESULT([$acx_blas_isamax_fcall_ok]) # SDOT check (REAL return values) ! AC_MSG_CHECKING([whether DDOT is called correctly from Fortran]) AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ real sdot,a(1),b(1),w external sdot --- 96,102 ---- [acx_blas_isamax_fcall_ok=no]) AC_MSG_RESULT([$acx_blas_isamax_fcall_ok]) # SDOT check (REAL return values) ! AC_MSG_CHECKING([whether SDOT is called correctly from Fortran]) AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ real sdot,a(1),b(1),w external sdot *************** *** 157,162 **** --- 158,164 ---- acx_blas_f77_func_ok=no; $2 fi + LIBS="$save_acx_blas_f77_func_LIBS" fi ])dnl ACX_BLAS_F77_FUNC diff -cNr octave-3.2.2/ChangeLog octave-3.2.3/ChangeLog *** octave-3.2.2/ChangeLog 2009-07-21 06:52:31.000000000 +0200 --- octave-3.2.3/ChangeLog 2009-09-14 08:01:42.000000000 +0200 *************** *** 1,3 **** --- 1,23 ---- + 2009-09-18 Jaroslav Hajek + + Version 3.2.3 released. + + 2009-08-24 Jaroslav Hajek + + * acx_blas_f77_func.m4: Fix typo. + + 2009-08-18 John W. Eaton + + * acx_blas_f77_func.m4 (ACX_BLAS_F77_FUNC): Save and restore LIBS. + + 2009-07-16 John W. Eaton + + * Makeconf.in (MAGICK_LIBS): Don't pass --ldflags to $(MAGICK_CONFIG). + + 2009-07-09 John W. Eaton + + * configure.in: Don't use system strftime on MinGW systems. + 2009-07-21 Jaroslav Hajek Version 3.2.2 released. diff -cNr octave-3.2.2/configure octave-3.2.3/configure *** octave-3.2.2/configure 2009-06-24 08:40:12.000000000 +0200 --- octave-3.2.3/configure 2009-09-14 08:01:49.000000000 +0200 *************** *** 15721,15726 **** --- 15721,15727 ---- _ACEOF elif test x"$acx_blas_ok" = xyes; then + save_acx_blas_f77_func_LIBS="$LIBS" LIBS="$BLAS_LIBS $LIBS" ac_ext=f ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' *************** *** 15846,15853 **** { echo "$as_me:$LINENO: result: $acx_blas_isamax_fcall_ok" >&5 echo "${ECHO_T}$acx_blas_isamax_fcall_ok" >&6; } # SDOT check (REAL return values) ! { echo "$as_me:$LINENO: checking whether DDOT is called correctly from Fortran" >&5 ! echo $ECHO_N "checking whether DDOT is called correctly from Fortran... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 --- 15847,15854 ---- { echo "$as_me:$LINENO: result: $acx_blas_isamax_fcall_ok" >&5 echo "${ECHO_T}$acx_blas_isamax_fcall_ok" >&6; } # SDOT check (REAL return values) ! { echo "$as_me:$LINENO: checking whether SDOT is called correctly from Fortran" >&5 ! echo $ECHO_N "checking whether SDOT is called correctly from Fortran... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling See \`config.log' for more details." >&5 *************** *** 16097,16102 **** --- 16098,16104 ---- acx_blas_f77_func_ok=no; acx_blas_ok=no; BLAS_LIBS= fi + LIBS="$save_acx_blas_f77_func_LIBS" fi *************** *** 26197,26204 **** esac case "$canonical_host_type" in ! *-*-msdosmsvc) ! ## The %T format specifier for strftime is reportedly broken, ## so use our version. We could use an actual configure test ## for this. ;; --- 26199,26206 ---- esac case "$canonical_host_type" in ! *-*-msdosmsvc | *-*-mingw*) ! ## The %T and %e format specifiers for strftime are not implemented ## so use our version. We could use an actual configure test ## for this. ;; diff -cNr octave-3.2.2/configure.in octave-3.2.3/configure.in *** octave-3.2.2/configure.in 2009-05-26 13:38:48.000000000 +0200 --- octave-3.2.3/configure.in 2009-07-24 14:00:57.000000000 +0200 *************** *** 1640,1647 **** esac case "$canonical_host_type" in ! *-*-msdosmsvc) ! ## The %T format specifier for strftime is reportedly broken, ## so use our version. We could use an actual configure test ## for this. ;; --- 1640,1647 ---- esac case "$canonical_host_type" in ! *-*-msdosmsvc | *-*-mingw*) ! ## The %T and %e format specifiers for strftime are not implemented ## so use our version. We could use an actual configure test ## for this. ;; diff -cNr octave-3.2.2/doc/ChangeLog octave-3.2.3/doc/ChangeLog *** octave-3.2.2/doc/ChangeLog 2009-07-21 06:52:30.000000000 +0200 --- octave-3.2.3/doc/ChangeLog 2009-09-14 08:01:42.000000000 +0200 *************** *** 1,3 **** --- 1,11 ---- + 2009-09-18 Jaroslav Hajek + + Version 3.2.3 released. + + 2009-07-20 John W. Eaton + + * interpreter/contributors.in: Add Aleksej Saushev. + 2009-07-21 Jaroslav Hajek Version 3.2.2 released. diff -cNr octave-3.2.2/doc/interpreter/contributors.in octave-3.2.3/doc/interpreter/contributors.in *** octave-3.2.2/doc/interpreter/contributors.in 2009-06-25 06:35:23.000000000 +0200 --- octave-3.2.3/doc/interpreter/contributors.in 2009-07-27 06:49:25.000000000 +0200 *************** *** 183,188 **** --- 183,189 ---- Juhani Saastamoinen Radek Salac Ben Sapp + Aleksej Saushev Alois Schloegl Michel D. Schmid Julian Schnidder diff -cNr octave-3.2.2/doc/interpreter/contributors.texi octave-3.2.3/doc/interpreter/contributors.texi *** octave-3.2.2/doc/interpreter/contributors.texi 2009-07-21 07:11:11.000000000 +0200 --- octave-3.2.3/doc/interpreter/contributors.texi 2009-09-14 08:30:27.000000000 +0200 *************** *** 60,80 **** @item Petter Risholm @tab Matthew W. Roberts @tab Andrew Ross @item Mark van Rossum @tab Kevin Ruland @tab Ryan Rusaw @item Olli Saarela @tab Toni Saarela @tab Juhani Saastamoinen ! @item Radek Salac @tab Ben Sapp @tab Alois Schloegl ! @item Michel D. Schmid @tab Julian Schnidder @tab Nicol N. Schraudolph ! @item Sebastian Schubert @tab Ludwig Schwardt @tab Thomas L. Scofield ! @item Daniel J. Sebald @tab Dmitri A. Sergatskov @tab Baylis Shanks ! @item Joseph P. Skudlarek @tab John Smith @tab Julius Smith ! @item Shan G. Smith @tab Joerg Specht @tab Quentin H. Spencer ! @item Christoph Spiel @tab Richard Stallman @tab Russell Standish ! @item Doug Stewart @tab Jonathan Stickel @tab Thomas Stuart ! @item Ivan Sutoris @tab John Swensen @tab Ariel Tankus ! @item Georg Thimm @tab Duncan Temple Lang @tab Kris Thielemans ! @item Olaf Till @tab Thomas Treichl @tab Frederick Umminger ! @item Utkarsh Upadhyay @tab Stefan van der Walt @tab Peter Van Wieren ! @item James R. Van Zandt @tab Gregory Vanuxem @tab Ivana Varekova ! @item Thomas Walter @tab Olaf Weber @tab Thomas Weber ! @item Rik Wehbring @tab Bob Weigel @tab Andreas Weingessel ! @item Michael Weitzel @tab Fook Fah Yap @tab Michael Zeising ! @item Federico Zenith @tab Alex Zvoleff @end multitable --- 60,80 ---- @item Petter Risholm @tab Matthew W. Roberts @tab Andrew Ross @item Mark van Rossum @tab Kevin Ruland @tab Ryan Rusaw @item Olli Saarela @tab Toni Saarela @tab Juhani Saastamoinen ! @item Radek Salac @tab Ben Sapp @tab Aleksej Saushev ! @item Alois Schloegl @tab Michel D. Schmid @tab Julian Schnidder ! @item Nicol N. Schraudolph @tab Sebastian Schubert @tab Ludwig Schwardt ! @item Thomas L. Scofield @tab Daniel J. Sebald @tab Dmitri A. Sergatskov ! @item Baylis Shanks @tab Joseph P. Skudlarek @tab John Smith ! @item Julius Smith @tab Shan G. Smith @tab Joerg Specht ! @item Quentin H. Spencer @tab Christoph Spiel @tab Richard Stallman ! @item Russell Standish @tab Doug Stewart @tab Jonathan Stickel ! @item Thomas Stuart @tab Ivan Sutoris @tab John Swensen ! @item Ariel Tankus @tab Georg Thimm @tab Duncan Temple Lang ! @item Kris Thielemans @tab Olaf Till @tab Thomas Treichl ! @item Frederick Umminger @tab Utkarsh Upadhyay @tab Stefan van der Walt ! @item Peter Van Wieren @tab James R. Van Zandt @tab Gregory Vanuxem ! @item Ivana Varekova @tab Thomas Walter @tab Olaf Weber ! @item Thomas Weber @tab Rik Wehbring @tab Bob Weigel ! @item Andreas Weingessel @tab Michael Weitzel @tab Fook Fah Yap ! @item Michael Zeising @tab Federico Zenith @tab Alex Zvoleff @end multitable diff -cNr octave-3.2.2/doc/interpreter/doc-cache octave-3.2.3/doc/interpreter/doc-cache *** octave-3.2.2/doc/interpreter/doc-cache 2009-07-21 07:11:08.000000000 +0200 --- octave-3.2.3/doc/interpreter/doc-cache 2009-09-14 08:30:24.000000000 +0200 *************** *** 1,4 **** ! # Created by Octave 3.2.2, Tue Jul 21 07:11:08 2009 CEST # name: cache # type: cell # rows: 3 --- 1,4 ---- ! # Created by Octave 3.2.3, Mon Sep 14 08:30:24 2009 CEST # name: cache # type: cell # rows: 3 *************** *** 2694,2701 **** # name: # type: string # elements: 1 ! # length: 1199 ! -- Function File: norm (A, P, OPT) Compute the p-norm of the matrix A. If the second argument is missing, `p = 2' is assumed. If A is a matrix (or sparse matrix): --- 2694,2701 ---- # name: # type: string # elements: 1 ! # length: 1203 ! -- Built-in Function: norm (A, P, OPT) Compute the p-norm of the matrix A. If the second argument is missing, `p = 2' is assumed. If A is a matrix (or sparse matrix): *************** *** 3288,3295 **** # name: # type: string # elements: 1 ! # length: 363 ! -- Function File: issorted (A, ROWS) Returns true if the array is sorted, ascending or descending. NaNs are treated as by `sort'. If ROWS is supplied and has the value "rows", checks whether the array is sorted by rows as if output by `sortrows' (with no options). This function does not yet support sparse matrices. See also: sortrows, sort. --- 3288,3295 ---- # name: # type: string # elements: 1 ! # length: 367 ! -- Built-in Function: issorted (A, ROWS) Returns true if the array is sorted, ascending or descending. NaNs are treated as by `sort'. If ROWS is supplied and has the value "rows", checks whether the array is sorted by rows as if output by `sortrows' (with no options). This function does not yet support sparse matrices. See also: sortrows, sort. *************** *** 11931,11937 **** # name: # type: string # elements: 1 ! # length: 1053 -- Built-in Function: [IN, OUT, PID] = popen2 (COMMAND, ARGS) Start a subprocess with two-way communication. The name of the process is given by COMMAND, and ARGS is an array of strings containing options for the command. The file identifiers for the input and output streams of the subprocess are returned in IN and OUT. If execution of the command is successful, PID contains the process ID of the subprocess. Otherwise, PID is -1. --- 11931,11937 ---- # name: # type: string # elements: 1 ! # length: 1255 -- Built-in Function: [IN, OUT, PID] = popen2 (COMMAND, ARGS) Start a subprocess with two-way communication. The name of the process is given by COMMAND, and ARGS is an array of strings containing options for the command. The file identifiers for the input and output streams of the subprocess are returned in IN and OUT. If execution of the command is successful, PID contains the process ID of the subprocess. Otherwise, PID is -1. *************** *** 11954,11964 **** endif until (done) fclose (out); ! -| are ! -| some ! -| strings -| these # name: # type: string # elements: 1 --- 11954,11967 ---- endif until (done) fclose (out); ! waitpid (pid); -| these + -| strings + -| some + -| are + Note that `popen2', unlike `popen', will not "reap" the child process. If you don't use `waitpid' to check the child's exit status, it will linger until Octave exits. + # name: # type: string # elements: 1 diff -cNr octave-3.2.2/doc/interpreter/linalg.texi octave-3.2.3/doc/interpreter/linalg.texi *** octave-3.2.2/doc/interpreter/linalg.texi 2009-07-21 07:11:10.000000000 +0200 --- octave-3.2.3/doc/interpreter/linalg.texi 2009-09-14 08:30:26.000000000 +0200 *************** *** 324,330 **** @c data.cc @anchor{doc-norm} ! @deftypefn {Function File} {} norm (@var{a}, @var{p}, @var{opt}) Compute the p-norm of the matrix @var{a}. If the second argument is missing, @code{p = 2} is assumed. --- 324,330 ---- @c data.cc @anchor{doc-norm} ! @deftypefn {Built-in Function} {} norm (@var{a}, @var{p}, @var{opt}) Compute the p-norm of the matrix @var{a}. If the second argument is missing, @code{p = 2} is assumed. diff -cNr octave-3.2.2/doc/interpreter/matrix.texi octave-3.2.3/doc/interpreter/matrix.texi *** octave-3.2.2/doc/interpreter/matrix.texi 2009-07-21 07:11:10.000000000 +0200 --- octave-3.2.3/doc/interpreter/matrix.texi 2009-09-14 08:30:26.000000000 +0200 *************** *** 719,725 **** @c data.cc @anchor{doc-issorted} ! @deftypefn {Function File} {} issorted (@var{a}, @var{rows}) Returns true if the array is sorted, ascending or descending. NaNs are treated as by @code{sort}. If @var{rows} is supplied and has the value "rows", checks whether the array is sorted by rows --- 719,725 ---- @c data.cc @anchor{doc-issorted} ! @deftypefn {Built-in Function} {} issorted (@var{a}, @var{rows}) Returns true if the array is sorted, ascending or descending. NaNs are treated as by @code{sort}. If @var{rows} is supplied and has the value "rows", checks whether the array is sorted by rows Files octave-3.2.2/doc/interpreter/octave-a4.pdf and octave-3.2.3/doc/interpreter/octave-a4.pdf differ Files octave-3.2.2/doc/interpreter/octave.pdf and octave-3.2.3/doc/interpreter/octave.pdf differ diff -cNr octave-3.2.2/doc/interpreter/system.texi octave-3.2.3/doc/interpreter/system.texi *** octave-3.2.2/doc/interpreter/system.texi 2009-07-21 07:11:11.000000000 +0200 --- octave-3.2.3/doc/interpreter/system.texi 2009-09-14 08:30:27.000000000 +0200 *************** *** 1697,1707 **** endif until (done) fclose (out); ! @print{} are ! @print{} some ! @print{} strings @print{} these @end example @end deftypefn --- 1697,1712 ---- endif until (done) fclose (out); ! waitpid (pid); @print{} these + @print{} strings + @print{} some + @print{} are @end example + + Note that @code{popen2}, unlike @code{popen}, will not "reap" the + child process. If you don't use @code{waitpid} to check the child's + exit status, it will linger until Octave exits. @end deftypefn Files octave-3.2.2/doc/liboctave/liboctave.pdf and octave-3.2.3/doc/liboctave/liboctave.pdf differ diff -cNr octave-3.2.2/libcruft/ChangeLog octave-3.2.3/libcruft/ChangeLog *** octave-3.2.2/libcruft/ChangeLog 2009-07-21 06:52:30.000000000 +0200 --- octave-3.2.3/libcruft/ChangeLog 2009-09-14 08:01:42.000000000 +0200 *************** *** 1,3 **** --- 1,7 ---- + 2009-09-18 Jaroslav Hajek + + Version 3.2.3 released. + 2009-07-21 Jaroslav Hajek Version 3.2.2 released. diff -cNr octave-3.2.2/liboctave/Array-util.cc octave-3.2.3/liboctave/Array-util.cc *** octave-3.2.2/liboctave/Array-util.cc 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/liboctave/Array-util.cc 2009-08-24 07:58:35.000000000 +0200 *************** *** 455,460 **** --- 455,466 ---- rdv(0) = rhdv(0); rdv(1) = rhdv(1); } + else if (rhdv.length () == 2 + && ! i.is_scalar () && ! j.is_scalar ()) + { + rdv(0) = icol ? rhdv(0) : i.extent (0); + rdv(1) = jcol ? rhdv(1) : j.extent (0); + } else { dim_vector rhdv0 = rhdv; diff -cNr octave-3.2.2/liboctave/ChangeLog octave-3.2.3/liboctave/ChangeLog *** octave-3.2.2/liboctave/ChangeLog 2009-07-21 06:52:30.000000000 +0200 --- octave-3.2.3/liboctave/ChangeLog 2009-09-14 08:01:42.000000000 +0200 *************** *** 1,3 **** --- 1,44 ---- + 2009-09-18 Jaroslav Hajek + + Version 3.2.3 released. + + 2009-08-31 John W. Eaton + + * liboctave/lo-ieee.cc (octave_ieee_init): Abort if floating point + format is not recognized as IEEE. + + 2009-08-19 Jaroslav Hajek + + * Array-util.cc (zero_dims_inquire): Add matching ndims case. + + 2009-08-16 Jaroslav Hajek + + * dMatrix.cc, fMatrix.cc, CMatrix.cc, fCMatrix.cc: Add more tests. + * CMatrix.cc (xgemm): Fix vector * matrix case. + * fCMatrix.cc (xgemm): Ditto. + + 2009-08-16 Jaroslav Hajek + + * fMatrix.cc, fCMatrix.cc: Make tests use single precision. + + 2009-08-16 Jaroslav Hajek + + * CMatrix.cc (xgemm): Fix typo. Add test. + * fCMatrix.cc (xgemm): Ditto. + + 2009-07-20 John W. Eaton + + * lo-ieee.cc (octave_ieee_init) [__NetBSD__]: Call nan to + initialize Octave_NaN and nanf, to initialize Octave_Float_NaN. + + 2009-07-08 John W. Eaton + + * dim-vector.h (dim_vector::dim_vector_rep::dim_vector_rep + (octave_idx_type, const dim_vector_rep *, int)): + Enforce 2-d objects here. + (dim_vector::dim_vector_rep::dim_vector_rep): Simply copy object. + (dim_vector::resize): Allow N < 2. + 2009-07-21 Jaroslav Hajek Version 3.2.2 released. diff -cNr octave-3.2.2/liboctave/CMatrix.cc octave-3.2.3/liboctave/CMatrix.cc *** octave-3.2.2/liboctave/CMatrix.cc 2009-06-18 09:31:47.000000000 +0200 --- octave-3.2.3/liboctave/CMatrix.cc 2009-08-24 07:58:35.000000000 +0200 *************** *** 3746,3751 **** --- 3746,3752 ---- %!assert([1+i 2+i 3+i] * [ 4+i ; 5+i ; 6+i], 29+21i, 1e-14) %!assert([1+i 2+i ; 3+i 4+i ] * [5+i ; 6+i], [15 + 14i ; 37 + 18i], 1e-14) %!assert([1+i 2+i ; 3+i 4+i ] * [5+i 6+i ; 7+i 8+i], [17 + 15i 20 + 17i; 41 + 19i 48 + 21i], 1e-14) + %!assert([1 i]*[i 0]', -i); */ /* Test some simple identities *************** *** 3754,3760 **** --- 3755,3765 ---- %! cv = randn(10,1)+i*rand(10,1); %! rv = randn(1,10)+i*rand(1,10); %!assert([M*cv,M*cv],M*[cv,cv],1e-14) + %!assert([M.'*cv,M.'*cv],M.'*[cv,cv],1e-14) + %!assert([M'*cv,M'*cv],M'*[cv,cv],1e-14) %!assert([rv*M;rv*M],[rv;rv]*M,1e-14) + %!assert([rv*M.';rv*M.'],[rv;rv]*M.',1e-14) + %!assert([rv*M';rv*M'],[rv;rv]*M',1e-14) %!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-14) */ *************** *** 3839,3845 **** F77_FUNC (xzdotu, XZDOTU) (a_nc, a.data (), 1, b.data (), 1, *c); if (conja) *c = std::conj (*c); } ! else if (conjb) F77_FUNC (xzdotc, XZDOTC) (a_nc, a.data (), 1, b.data (), 1, *c); else F77_FUNC (xzdotc, XZDOTC) (a_nc, b.data (), 1, a.data (), 1, *c); --- 3844,3850 ---- F77_FUNC (xzdotu, XZDOTU) (a_nc, a.data (), 1, b.data (), 1, *c); if (conja) *c = std::conj (*c); } ! else if (conja) F77_FUNC (xzdotc, XZDOTC) (a_nc, a.data (), 1, b.data (), 1, *c); else F77_FUNC (xzdotc, XZDOTC) (a_nc, b.data (), 1, a.data (), 1, *c); *************** *** 3852,3858 **** b.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); } ! else if (a_nr == 1 && ! conja) { const char *crevtransb = get_blas_trans_arg (! transb, conjb); F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (crevtransb, 1), --- 3857,3863 ---- b.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); } ! else if (a_nr == 1 && ! conja && ! conjb) { const char *crevtransb = get_blas_trans_arg (! transb, conjb); F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (crevtransb, 1), diff -cNr octave-3.2.2/liboctave/dim-vector.h octave-3.2.3/liboctave/dim-vector.h *** octave-3.2.2/liboctave/dim-vector.h 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/liboctave/dim-vector.h 2009-07-24 13:56:21.000000000 +0200 *************** *** 75,82 **** } dim_vector_rep (const dim_vector_rep& dv) ! : dims (dv.ndims > 0 ? new octave_idx_type [dv.ndims] : 0), ! ndims (dv.ndims > 0 ? dv.ndims : 0), count (1) { if (dims) { --- 75,82 ---- } dim_vector_rep (const dim_vector_rep& dv) ! : dims (new octave_idx_type [dv.ndims]), ! ndims (dv.ndims), count (1) { if (dims) { *************** *** 87,96 **** dim_vector_rep (octave_idx_type n, const dim_vector_rep *dv, int fill_value = 0) ! : dims ((dv && n > 0) ? new octave_idx_type [n] : 0), ! ndims (n > 0 ? n : 0), count (1) { ! if (dims) { int dv_ndims = dv ? dv->ndims : 0; --- 87,108 ---- dim_vector_rep (octave_idx_type n, const dim_vector_rep *dv, int fill_value = 0) ! : dims (new octave_idx_type [n < 2 ? 2 : n]), ! ndims (n < 2 ? 2 : n), count (1) { ! if (n == 0) ! { ! // Result is 0x0. ! dims[0] = 0; ! dims[1] = 0; ! } ! else if (n == 1) ! { ! // Result is a column vector. ! dims[0] = dv->dims[0]; ! dims[1] = 1; ! } ! else { int dv_ndims = dv ? dv->ndims : 0; *************** *** 134,145 **** void chop_all_singletons (void) { int j = 0; for (int i = 0; i < ndims; i++) { if (dims[i] != 1) dims[j++] = dims[i]; } ! if (j == 1) dims[1] = 1; ndims = j > 2 ? j : 2; } --- 146,161 ---- void chop_all_singletons (void) { int j = 0; + for (int i = 0; i < ndims; i++) { if (dims[i] != 1) dims[j++] = dims[i]; } ! ! if (j == 1) ! dims[1] = 1; ! ndims = j > 2 ? j : 2; } *************** *** 223,235 **** if (n != len) { - if (n < 2) - { - (*current_liboctave_error_handler) - ("unable to resize object to fewer than 2 dimensions"); - return; - } - dim_vector_rep *old_rep = rep; rep = new dim_vector_rep (n, old_rep, fill_value); --- 239,244 ---- diff -cNr octave-3.2.2/liboctave/dMatrix.cc octave-3.2.3/liboctave/dMatrix.cc *** octave-3.2.2/liboctave/dMatrix.cc 2009-06-18 09:31:47.000000000 +0200 --- octave-3.2.3/liboctave/dMatrix.cc 2009-08-24 07:58:35.000000000 +0200 *************** *** 3159,3165 **** --- 3159,3167 ---- %! cv = randn(10,1); %! rv = randn(1,10); %!assert([M*cv,M*cv],M*[cv,cv],1e-14) + %!assert([M'*cv,M'*cv],M'*[cv,cv],1e-14) %!assert([rv*M;rv*M],[rv;rv]*M,1e-14) + %!assert([rv*M';rv*M'],[rv;rv]*M',1e-14) %!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-14) */ diff -cNr octave-3.2.2/liboctave/fCMatrix.cc octave-3.2.3/liboctave/fCMatrix.cc *** octave-3.2.2/liboctave/fCMatrix.cc 2009-06-18 09:31:47.000000000 +0200 --- octave-3.2.3/liboctave/fCMatrix.cc 2009-08-24 07:58:35.000000000 +0200 *************** *** 3736,3754 **** } /* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests ! %!assert([1+i 2+i 3+i] * [ 4+i ; 5+i ; 6+i], 29+21i, 1e-14) ! %!assert([1+i 2+i ; 3+i 4+i ] * [5+i ; 6+i], [15 + 14i ; 37 + 18i], 1e-14) ! %!assert([1+i 2+i ; 3+i 4+i ] * [5+i 6+i ; 7+i 8+i], [17 + 15i 20 + 17i; 41 + 19i 48 + 21i], 1e-14) */ /* Test some simple identities %!shared M, cv, rv ! %! M = randn(10,10)+i*rand(10,10); ! %! cv = randn(10,1)+i*rand(10,1); ! %! rv = randn(1,10)+i*rand(1,10); ! %!assert([M*cv,M*cv],M*[cv,cv],1e-14) ! %!assert([rv*M;rv*M],[rv;rv]*M,1e-14) ! %!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-14) */ static const char * --- 3736,3759 ---- } /* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests ! %!assert(single([1+i 2+i 3+i]) * single([ 4+i ; 5+i ; 6+i]), single(29+21i), 5e-7) ! %!assert(single([1+i 2+i ; 3+i 4+i ]) * single([5+i ; 6+i]), single([15 + 14i ; 37 + 18i]), 5e-7) ! %!assert(single([1+i 2+i ; 3+i 4+i ]) * single([5+i 6+i ; 7+i 8+i]), single([17 + 15i 20 + 17i; 41 + 19i 48 + 21i]), 5e-7) ! %!assert(single([1 i])*single([i 0])', single(-i)); */ /* Test some simple identities %!shared M, cv, rv ! %! M = single(randn(10,10))+i*single(rand(10,10)); ! %! cv = single(randn(10,1))+i*single(rand(10,1)); ! %! rv = single(randn(1,10))+i*single(rand(1,10)); ! %!assert([M*cv,M*cv],M*[cv,cv],5e-6) ! %!assert([M.'*cv,M.'*cv],M.'*[cv,cv],5e-6) ! %!assert([M'*cv,M'*cv],M'*[cv,cv],5e-6) ! %!assert([rv*M;rv*M],[rv;rv]*M,5e-6) ! %!assert([rv*M.';rv*M.'],[rv;rv]*M.',5e-6) ! %!assert([rv*M';rv*M'],[rv;rv]*M',5e-6) ! %!assert(2*rv*cv,[rv,rv]*[cv;cv],5e-6) */ static const char * *************** *** 3832,3838 **** F77_FUNC (xcdotu, XCDOTU) (a_nc, a.data (), 1, b.data (), 1, *c); if (conja) *c = std::conj (*c); } ! else if (conjb) F77_FUNC (xcdotc, XCDOTC) (a_nc, a.data (), 1, b.data (), 1, *c); else F77_FUNC (xcdotc, XCDOTC) (a_nc, b.data (), 1, a.data (), 1, *c); --- 3837,3843 ---- F77_FUNC (xcdotu, XCDOTU) (a_nc, a.data (), 1, b.data (), 1, *c); if (conja) *c = std::conj (*c); } ! else if (conja) F77_FUNC (xcdotc, XCDOTC) (a_nc, a.data (), 1, b.data (), 1, *c); else F77_FUNC (xcdotc, XCDOTC) (a_nc, b.data (), 1, a.data (), 1, *c); *************** *** 3845,3851 **** b.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); } ! else if (a_nr == 1 && ! conja) { const char *crevtransb = get_blas_trans_arg (! transb, conjb); F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (crevtransb, 1), --- 3850,3856 ---- b.data (), 1, 0.0, c, 1 F77_CHAR_ARG_LEN (1))); } ! else if (a_nr == 1 && ! conja && ! conjb) { const char *crevtransb = get_blas_trans_arg (! transb, conjb); F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (crevtransb, 1), diff -cNr octave-3.2.2/liboctave/file-ops.cc octave-3.2.3/liboctave/file-ops.cc *** octave-3.2.2/liboctave/file-ops.cc 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/liboctave/file-ops.cc 2009-07-24 14:02:13.000000000 +0200 *************** *** 210,222 **** #if defined (HAVE_SYMLINK) ! OCTAVE_LOCAL_BUFFER (char, old_nm, old_name.length ()); ! OCTAVE_LOCAL_BUFFER (char, new_nm, new_name.length ()); ! ! strcpy (old_nm, old_name.c_str ()); ! strcpy (new_nm, new_name.c_str ()); ! ! status = ::symlink (old_nm, new_nm); if (status < 0) { --- 210,216 ---- #if defined (HAVE_SYMLINK) ! status = ::symlink (old_name.c_str (), new_name.c_str ()); if (status < 0) { *************** *** 250,260 **** #if defined (HAVE_READLINK) char buf[MAXPATHLEN+1]; ! OCTAVE_LOCAL_BUFFER (char, p, path.length ()); ! ! strcpy (p, path.c_str ()); ! ! status = ::readlink (p, buf, MAXPATHLEN); if (status < 0) { --- 244,250 ---- #if defined (HAVE_READLINK) char buf[MAXPATHLEN+1]; ! status = ::readlink (path.c_str (), buf, MAXPATHLEN); if (status < 0) { diff -cNr octave-3.2.2/liboctave/fMatrix.cc octave-3.2.3/liboctave/fMatrix.cc *** octave-3.2.2/liboctave/fMatrix.cc 2009-06-18 09:31:47.000000000 +0200 --- octave-3.2.3/liboctave/fMatrix.cc 2009-08-24 07:58:35.000000000 +0200 *************** *** 3147,3165 **** // matrix by matrix -> matrix operations /* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests ! %!assert([1 2 3] * [ 4 ; 5 ; 6], 32, 1e-14) ! %!assert([1 2 ; 3 4 ] * [5 ; 6], [17 ; 39 ], 1e-14) ! %!assert([1 2 ; 3 4 ] * [5 6 ; 7 8], [19 22; 43 50], 1e-14) */ /* Test some simple identities %!shared M, cv, rv ! %! M = randn(10,10); ! %! cv = randn(10,1); ! %! rv = randn(1,10); ! %!assert([M*cv,M*cv],M*[cv,cv],1e-14) ! %!assert([rv*M;rv*M],[rv;rv]*M,1e-14) ! %!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-14) */ static const char * --- 3147,3167 ---- // matrix by matrix -> matrix operations /* Simple Dot Product, Matrix-Vector and Matrix-Matrix Unit tests ! %!assert(single([1 2 3]) * single([ 4 ; 5 ; 6]), single(32), 5e-7) ! %!assert(single([1 2 ; 3 4 ]) * single([5 ; 6]), single([17 ; 39 ]), 5e-7) ! %!assert(single([1 2 ; 3 4 ]) * single([5 6 ; 7 8]), single([19 22; 43 50]), 5e-7) */ /* Test some simple identities %!shared M, cv, rv ! %! M = single(randn(10,10)); ! %! cv = single(randn(10,1)); ! %! rv = single(randn(1,10)); ! %!assert([M*cv,M*cv],M*[cv,cv],5e-6) ! %!assert([M'*cv,M'*cv],M'*[cv,cv],5e-6) ! %!assert([rv*M;rv*M],[rv;rv]*M,5e-6) ! %!assert([rv*M';rv*M'],[rv;rv]*M',5e-6) ! %!assert(2*rv*cv,[rv,rv]*[cv;cv],5e-6) */ static const char * diff -cNr octave-3.2.2/liboctave/lo-ieee.cc octave-3.2.3/liboctave/lo-ieee.cc *** octave-3.2.2/liboctave/lo-ieee.cc 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/liboctave/lo-ieee.cc 2009-09-14 08:01:39.000000000 +0200 *************** *** 1,7 **** /* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, ! 2007, 2008 John W. Eaton This file is part of Octave. --- 1,7 ---- /* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, ! 2007, 2008, 2009 John W. Eaton This file is part of Octave. *************** *** 26,31 **** --- 26,32 ---- #endif #include + #include #if defined (HAVE_FLOATINGPOINT_H) #include *************** *** 93,98 **** --- 94,101 ---- #if defined (__alpha__) && defined (__osf__) extern unsigned int DQNAN[2]; octave_NaN = (*(X_CAST(double *, DQNAN))); + #elif defined (__NetBSD__) + octave_NaN = nan (""); #else octave_NaN = tmp_inf / tmp_inf; // try to ensure that lo_ieee_sign gives false for a NaN. *************** *** 139,145 **** --- 142,152 ---- } #endif + #if defined (__NetBSD__) + octave_Float_NaN = nanf (""); + #else octave_Float_NaN = float_tmp_inf / float_tmp_inf; + #endif octave_Float_Inf = float_tmp_inf; lo_ieee_float tf; *************** *** 151,163 **** case oct_mach_info::flt_fmt_cray: case oct_mach_info::flt_fmt_vax_d: case oct_mach_info::flt_fmt_vax_g: - break; - default: // If the format is unknown, then you will probably not have a // useful system, but we will just issue a warning and go on... ! (*current_liboctave_warning_handler) ! ("lo_ieee_init: unrecognized floating point format!"); } } --- 158,169 ---- case oct_mach_info::flt_fmt_cray: case oct_mach_info::flt_fmt_vax_d: case oct_mach_info::flt_fmt_vax_g: default: // If the format is unknown, then you will probably not have a // useful system, but we will just issue a warning and go on... ! (*current_liboctave_error_handler) ! ("lo_ieee_init: floating point format is not IEEE! Maybe DLAMCH is miscompiled, or you are using some strange system without IEEE floating point math?"); ! abort (); } } diff -cNr octave-3.2.2/liboctave/strftime.c octave-3.2.3/liboctave/strftime.c *** octave-3.2.2/liboctave/strftime.c 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/liboctave/strftime.c 2009-08-25 10:18:25.000000000 +0200 *************** *** 49,55 **** # endif #endif ! #if HAVE_TZNAME extern OCTAVE_IMPORT char *tzname[]; #endif --- 49,55 ---- # endif #endif ! #if HAVE_TZNAME && !HAVE_DECL_TZNAME extern OCTAVE_IMPORT char *tzname[]; #endif diff -cNr octave-3.2.2/Makeconf.in octave-3.2.3/Makeconf.in *** octave-3.2.2/Makeconf.in 2009-05-25 08:04:58.000000000 +0200 --- octave-3.2.3/Makeconf.in 2009-07-27 06:49:25.000000000 +0200 *************** *** 153,159 **** MAGICK_CONFIG = @MAGICK_CONFIG@ MAGICK_INCFLAGS = $(shell $(MAGICK_CONFIG) --cppflags) ! MAGICK_LIBS = $(shell $(MAGICK_CONFIG) --ldflags --libs) LIBFLAGS = -L$(TOPDIR) --- 153,159 ---- MAGICK_CONFIG = @MAGICK_CONFIG@ MAGICK_INCFLAGS = $(shell $(MAGICK_CONFIG) --cppflags) ! MAGICK_LIBS = $(shell $(MAGICK_CONFIG) --libs) LIBFLAGS = -L$(TOPDIR) diff -cNr octave-3.2.2/scripts/ChangeLog octave-3.2.3/scripts/ChangeLog *** octave-3.2.2/scripts/ChangeLog 2009-07-21 06:52:30.000000000 +0200 --- octave-3.2.3/scripts/ChangeLog 2009-09-14 08:01:42.000000000 +0200 *************** *** 1,3 **** --- 1,93 ---- + 2009-09-18 Jaroslav Hajek + + Version 3.2.3 released. + + 2009-07-23 John W. Eaton + + * image/imread.m: Fix test. + + 2009-06-23 Alexander Mamonov + + * image/imread.m: New test. + + 2009-09-09 Tatsuro Matsuoka + + * plot/gnuplot_drawnow.m: Avoid flickering windows by avoding + 'set multiplot' / 'unset multiplot' for gnuplot's windows and + wxt terminals. + + 2009-09-08 John W. Eaton + + * io/dlmwrite.m: Fix typo. + + 2009-09-05 John W. Eaton + + * plot/hold.m: Correctly toggle hold state. Set both figure and + axes "nextplot" property when turning hold state on. + * plot/ishold.m: Check figure and axes nextplot properties. + Accept axes or figure handle argument. + + 2009-08-17 Jaroslav Hajek + + * general/int2str.m: Convert to double before calling log10. + + 2009-08-29 John W. Eaton + + * time/datestr.m: Add missing semicolon. + + 2009-08-26 E. Joshua Rigler + + * time/datestr.m: Set tm.isdst to -1 before calling mktime. + + 2009-08-06 John W. Eaton + + * statistics/base/std.m: Correctly work along singleton dimension. + From Christoph Ellenberger . + + 2009-08-06 Olaf Till + + * geometry/griddata.m: Linearize arrays. + + 2009-08-25 John W. Eaton + + * plot/__gnuplot_open_stream__.m: Save pid in __plot_stream__ property. + * plot/gnuplot_drawnow.m: Wait for gnuplot subprocess when printing. + From Ben Abbott , Rob Mahurin , and + Dmitri Sergatskov . + + 2009-08-22 David Bateman + + * plot/__add_datasource__.m: Correct test for "datasource" argument + * plot/__countour__.m: Add edgecolor properties and make it an alias + for linecolor with the value "auto" being "flat" for the edgecolor. + + 2009-08-04 Pieter Eendebak + + * set/setxor.m: Support cell arrays of strings. + + 2009-08-05 Olli Saarela + + * plot/__gnuplot_get_var__.m: If read fails to return data, sleep + before trying again. + + 2009-08-02 Ben Abbott + + * plot/gnuplot_drawnow.m: Avoid the flickering x11 window seen with + rapid replots by avoidng setting multiplot mode. This fix only + functions for a single axes with no image objects. + * plot/__go_draw_figure__.m: Move 'set multiplot' to gnuplot_drawnow. + + 2009-07-29 Ben Abbott + + * plot/__go_draw_axes__.m: Fix ticklabels specified as 2D character + array. + + 2009-07-17 John W. Eaton + + * plot/__go_draw_axes__.m: Use "layer" property to decide whether + to send "set border front" or "set border layerdefault" to plot + stream. Don't send "set border front" to plot stream for image data. + 2009-07-21 Jaroslav Hajek Version 3.2.2 released. diff -cNr octave-3.2.2/scripts/general/int2str.m octave-3.2.3/scripts/general/int2str.m *** octave-3.2.2/scripts/general/int2str.m 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/scripts/general/int2str.m 2009-09-01 09:32:38.000000000 +0200 *************** *** 102,108 **** fmt = sprintf ("%%%dd", min_fw); else ## Could have anything. ! tfw = floor (log10 (abs (t))) + 1 + sep; fw = max (tfw); if (any (t(tfw == fw) < 0)) fw++; --- 102,108 ---- fmt = sprintf ("%%%dd", min_fw); else ## Could have anything. ! tfw = floor (log10 (double (abs (t)))) + 1 + sep; fw = max (tfw); if (any (t(tfw == fw) < 0)) fw++; diff -cNr octave-3.2.2/scripts/geometry/griddata.m octave-3.2.3/scripts/geometry/griddata.m *** octave-3.2.2/scripts/geometry/griddata.m 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/scripts/geometry/griddata.m 2009-09-01 09:25:54.000000000 +0200 *************** *** 63,68 **** --- 63,70 ---- [nr, nc] = size (xi); + x = x(:); y = y(:); z = z(:); + ## Triangulate data. tri = delaunay (x, y); zi = nan (size (xi)); diff -cNr octave-3.2.2/scripts/image/imread.m octave-3.2.3/scripts/image/imread.m *** octave-3.2.2/scripts/image/imread.m 2009-05-27 09:31:39.000000000 +0200 --- octave-3.2.3/scripts/image/imread.m 2009-09-14 07:57:39.000000000 +0200 *************** *** 88,90 **** --- 88,117 ---- end_try_catch endfunction + + %!test + %! vpng = [ ... + %! 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, ... + %! 0, 13, 73, 72, 68, 82, 0, 0, 0, 3, ... + %! 0, 0, 0, 3, 8, 2, 0, 0, 0, 217, ... + %! 74, 34, 232, 0, 0, 0, 1, 115, 82, 71, ... + %! 66, 0, 174, 206, 28, 233, 0, 0, 0, 4, ... + %! 103, 65, 77, 65, 0, 0, 177, 143, 11, 252, ... + %! 97, 5, 0, 0, 0, 32, 99, 72, 82, 77, ... + %! 0, 0, 122, 38, 0, 0, 128, 132, 0, 0, ... + %! 250, 0, 0, 0, 128, 232, 0, 0, 117, 48, ... + %! 0, 0, 234, 96, 0, 0, 58, 152, 0, 0, ... + %! 23, 112, 156, 186, 81, 60, 0, 0, 0, 25, ... + %! 73, 68, 65, 84, 24, 87, 99, 96, 96, 96, ... + %! 248, 255, 255, 63, 144, 4, 81, 111, 101, 84, ... + %! 16, 28, 160, 16, 0, 197, 214, 13, 34, 74, ... + %! 117, 213, 17, 0, 0, 0, 0, 73, 69, 78, ... + %! 68, 174, 66, 96, 130]; + %! fid = fopen('test.png', 'wb'); + %! fwrite(fid, vpng); + %! fclose(fid); + %! A = imread('test.png'); + %! delete('test.png'); + %! assert(A(:,:,1), uint8 ([0, 255, 0; 255, 237, 255; 0, 255, 0])); + %! assert(A(:,:,2), uint8 ([0, 255, 0; 255, 28, 255; 0, 255, 0])); + %! assert(A(:,:,3), uint8 ([0, 255, 0; 255, 36, 255; 0, 255, 0])); diff -cNr octave-3.2.2/scripts/io/dlmwrite.m octave-3.2.3/scripts/io/dlmwrite.m *** octave-3.2.2/scripts/io/dlmwrite.m 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/scripts/io/dlmwrite.m 2009-09-09 14:14:32.000000000 +0200 *************** *** 85,91 **** function dlmwrite (file, a, varargin) if (nargin < 2 || ! ischar (file)) ! ptint_usage (); endif ## set defaults --- 85,91 ---- function dlmwrite (file, a, varargin) if (nargin < 2 || ! ischar (file)) ! print_usage (); endif ## set defaults diff -cNr octave-3.2.2/scripts/plot/__add_datasource__.m octave-3.2.3/scripts/plot/__add_datasource__.m *** octave-3.2.2/scripts/plot/__add_datasource__.m 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/scripts/plot/__add_datasource__.m 2009-08-24 10:02:48.000000000 +0200 *************** *** 40,46 **** while (i < numel (varargin)) arg = varargin{++i}; if (i != numel(varargin) && ischar (arg) ! && length (arg) > 1 && strcmpi (arg(end-9:end), "datasource")) arg = tolower (arg); val = varargin{++i}; if (ischar (val)) --- 40,46 ---- while (i < numel (varargin)) arg = varargin{++i}; if (i != numel(varargin) && ischar (arg) ! && length (arg) > 9 && strcmpi (arg(end-9:end), "datasource")) arg = tolower (arg); val = varargin{++i}; if (ischar (val)) diff -cNr octave-3.2.2/scripts/plot/__contour__.m octave-3.2.3/scripts/plot/__contour__.m *** octave-3.2.2/scripts/plot/__contour__.m 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/scripts/plot/__contour__.m 2009-08-24 10:02:48.000000000 +0200 *************** *** 28,33 **** --- 28,34 ---- linespec.linestyle = "-"; linespec.color = "auto"; + edgecolor = "flat"; for i = 3 : nargin arg = varargin {i}; if ((ischar (arg) || iscell (arg))) *************** *** 52,57 **** --- 53,69 ---- varargin(i:i+1) = []; elseif (strcmpi (varargin{i}, "linecolor")) linespec.color = varargin {i + 1}; + edgecolor = linespec.color; + if (ischar (edgecolor) && strcmpi (edgecolor, "auto")) + edgecolor = "flat"; + endif + varargin(i:i+1) = []; + elseif (strcmpi (varargin{i}, "edgecolor")) + linespec.color = varargin {i + 1}; + edgecolor = linespec.color; + if (ischar (edgecolor) && strcmpi (edgecolor, "flat")) + linespec.color = "auto"; + endif varargin(i:i+1) = []; else opts{end+1} = varargin{i}; *************** *** 164,169 **** --- 176,185 ---- addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle); addproperty ("linewidth", hg, "linelinewidth", 0.5); + ## FIXME It would be good to hide this property which is just an undocumented + ## alias for linecolor + addproperty ("edgecolor", hg, "color", edgecolor, "{flat}|none"); + addlistener (hg, "fill", @update_data); addlistener (hg, "zlevelmode", @update_zlevel); *************** *** 185,190 **** --- 201,208 ---- addlistener (hg, "linestyle", @update_line); addlistener (hg, "linewidth", @update_line); + addlistener (hg, "edgecolor", @update_edgecolor); + add_patch_children (hg); if (!isempty (opts)) *************** *** 366,376 **** --- 384,410 ---- endswitch endfunction + function update_edgecolor (h, d) + ec = get (h, "edgecolor"); + lc = get (h, "linecolor"); + if (ischar (ec) && strcmpi (ec, "flat")) + if (! strcmpi (lc, "auto")) + set (h, "linecolor", "auto"); + endif + elseif (! isequal (ec, lc)) + set (h, "linecolor", ec); + endif + endfunction + function update_line (h, d) lc = get (h, "linecolor"); + ec = get (h, "edgecolor"); if (strcmpi (lc, "auto")) lc = "flat"; endif + if (! isequal (ec, lc)) + set (h, "edgecolor", lc); + endif set (findobj (h, "type", "patch"), "edgecolor", lc, "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle")); endfunction diff -cNr octave-3.2.2/scripts/plot/gnuplot_drawnow.m octave-3.2.3/scripts/plot/gnuplot_drawnow.m *** octave-3.2.2/scripts/plot/gnuplot_drawnow.m 2009-06-26 12:56:17.000000000 +0200 --- octave-3.2.3/scripts/plot/gnuplot_drawnow.m 2009-09-14 07:55:16.000000000 +0200 *************** *** 67,75 **** set (h, "__plot_stream__", default_plot_stream); if (! isempty (plot_stream)) pclose (plot_stream(1)); ! if (numel (plot_stream) == 2) pclose (plot_stream(2)); endif endif if (! isempty (fid)) fclose (fid); --- 67,78 ---- set (h, "__plot_stream__", default_plot_stream); if (! isempty (plot_stream)) pclose (plot_stream(1)); ! if (numel (plot_stream) > 1) pclose (plot_stream(2)); endif + if (numel (plot_stream) > 2) + waitpid (plot_stream(3)); + endif endif if (! isempty (fid)) fclose (fid); *************** *** 266,308 **** size_str = ""; endif ! ## Set the gnuplot terminal (type, enhanced?, title, & size). ! if (! isempty (term)) ! term_str = sprintf ("set terminal %s", term); ! if (any (strncmpi (term, {"x11", "wxt"}, 3)) && new_stream ! && __gnuplot_has_feature__ ("x11_figure_position")) ! ## The "close" is added to allow the figure position property ! ## to remain active. ! term_str = sprintf ("%s close", term_str); ! endif ! if (! isempty (enh_str)) ! term_str = sprintf ("%s %s", term_str, enh_str); ! endif ! if (! isempty (title_str)) ! term_str = sprintf ("%s %s", term_str, title_str); ! endif ! if (nargin > 3 && ischar (opts_str)) ! ## Options must go last. ! term_str = sprintf ("%s %s", term_str, opts_str); ! endif ! if (! isempty (size_str) && new_stream) ! ## size_str goes last to permit specification of canvas size ! ## for terminals cdr/corel. ! term_str = sprintf ("%s %s", term_str, size_str); endif fprintf (plot_stream, "%s\n", term_str); ! else ! ## gnuplot will pick up the GNUTERM environment variable itself ! ## so no need to set the terminal type if not also setting the ! ## figure title, enhanced mode, or position. endif endif - if (nargin == 5) - if (! isempty (file)) - fprintf (plot_stream, "set output '%s';\n", file); - endif - endif endfunction --- 269,320 ---- size_str = ""; endif ! ## Set the gnuplot terminal (type, enhanced, title, options & size). ! term_str = sprintf ("set terminal %s", term); ! if (! isempty (enh_str)) ! term_str = sprintf ("%s %s", term_str, enh_str); ! endif ! if (! isempty (title_str)) ! term_str = sprintf ("%s %s", term_str, title_str); ! endif ! if (nargin > 3 && ischar (opts_str)) ! ## Options must go last. ! term_str = sprintf ("%s %s", term_str, opts_str); ! endif ! if (! isempty (size_str) && new_stream) ! ## size_str comes after other options to permit specification of ! ## the canvas size for terminals cdr/corel. ! term_str = sprintf ("%s %s", term_str, size_str); ! endif ! ## Work around the gnuplot feature of growing the x11 window and ! ## flickering window (x11, windows, & wxt) when the mouse and ! ## multiplot are set in gnuplot. ! fputs (plot_stream, "unset multiplot;\n"); ! flickering_terms = {"x11", "windows", "wxt"}; ! if (! any (strcmp (term, flickering_terms)) ! || numel (findall (h, "type", "axes")) > 1 ! || numel (findall (h, "type", "image")) > 0) ! fprintf (plot_stream, "%s\n", term_str); ! if (nargin == 5) ! if (! isempty (file)) ! fprintf (plot_stream, "set output '%s';\n", file); ! endif endif + fputs (plot_stream, "set multiplot;\n"); + elseif (any (strcmp (term, flickering_terms))) fprintf (plot_stream, "%s\n", term_str); ! if (nargin == 5) ! if (! isempty (file)) ! fprintf (plot_stream, "set output '%s';\n", file); ! endif ! endif endif + else + ## gnuplot will pick up the GNUTERM environment variable itself + ## so no need to set the terminal type if not also setting the + ## figure title, enhanced mode, or position. endif endfunction diff -cNr octave-3.2.2/scripts/plot/__gnuplot_get_var__.m octave-3.2.3/scripts/plot/__gnuplot_get_var__.m *** octave-3.2.2/scripts/plot/__gnuplot_get_var__.m 2009-06-02 07:22:16.000000000 +0200 --- octave-3.2.3/scripts/plot/__gnuplot_get_var__.m 2009-08-06 07:31:45.000000000 +0200 *************** *** 127,133 **** str = {}; while (isempty (str)) str = char (fread (istream)'); ! if (! isempty (str)) str = regexp (str, "OCTAVE:.*", "match"); str = str{end}(8:end); endif --- 127,135 ---- str = {}; while (isempty (str)) str = char (fread (istream)'); ! if (isempty (str)) ! sleep (0.05); ! else str = regexp (str, "OCTAVE:.*", "match"); str = str{end}(8:end); endif diff -cNr octave-3.2.2/scripts/plot/__gnuplot_open_stream__.m octave-3.2.3/scripts/plot/__gnuplot_open_stream__.m *** octave-3.2.2/scripts/plot/__gnuplot_open_stream__.m 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/scripts/plot/__gnuplot_open_stream__.m 2009-08-26 08:17:09.000000000 +0200 *************** *** 28,33 **** --- 28,35 ---- [plot_stream(1), plot_stream(2), pid] = popen2 (cmd); if (pid < 0) error ("__gnuplot_open_stream__: failed to open connection to gnuplot."); + else + plot_stream(3) = pid; endif else plot_stream = popen (cmd, "w"); diff -cNr octave-3.2.2/scripts/plot/__go_draw_axes__.m octave-3.2.3/scripts/plot/__go_draw_axes__.m *** octave-3.2.2/scripts/plot/__go_draw_axes__.m 2009-06-23 12:57:58.000000000 +0200 --- octave-3.2.3/scripts/plot/__go_draw_axes__.m 2009-08-06 07:18:53.000000000 +0200 *************** *** 267,274 **** --- 267,279 ---- ## appearance of tics, so it is used even if the grid is absent. if (strcmpi (axis_obj.layer, "top")) fputs (plot_stream, "set grid front;\n"); + fputs (plot_stream, "set border front;\n"); else fputs (plot_stream, "set grid layerdefault;\n"); + ## FIXME -- the gnuplot help says that "layerdefault" should work + ## for set border too, but it fails for me with gnuplot 4.2.5. So + ## use "back" instead. + fputs (plot_stream, "set border back;\n"); endif if (! have_grid) fputs (plot_stream, "unset grid;\n"); *************** *** 369,375 **** elseif (strcmpi (obj.cdatamapping, "direct")) cdatadirect = true; endif - fputs (plot_stream, "set border front;\n"); data_idx++; is_image_data(data_idx) = true; parametric(data_idx) = false; --- 374,379 ---- *************** *** 1724,1740 **** endfunction function ticklabel = ticklabel_to_cell (ticklabel) ! if (! isempty (ticklabel) && ! iscell (ticklabel)) ! if (isnumeric (ticklabel)) ! ## Use upto 5 significant digits ! ticklabel = num2str (ticklabel(:), 5); ! endif ! n = setdiff (findstr (ticklabel, '|'), findstr (ticklabel, '\|')); ! if (! isempty (n)) ticklabel = strsplit (ticklabel, "|"); else ticklabel = cellstr (ticklabel); endif else ticklabel = ticklabel; endif --- 1728,1746 ---- endfunction function ticklabel = ticklabel_to_cell (ticklabel) ! if (isnumeric (ticklabel)) ! ## Use upto 5 significant digits ! ticklabel = num2str (ticklabel(:), 5); ! endif ! if (ischar (ticklabel)) ! if (size (ticklabel, 1) == 1 && any (ticklabel == "|")) ! n = setdiff (findstr (ticklabel, "|"), findstr (ticklabel, '\|')); ticklabel = strsplit (ticklabel, "|"); else ticklabel = cellstr (ticklabel); endif + elseif (isempty (ticklabel)) + ticklabel = {""}; else ticklabel = ticklabel; endif diff -cNr octave-3.2.2/scripts/plot/__go_draw_figure__.m octave-3.2.3/scripts/plot/__go_draw_figure__.m *** octave-3.2.2/scripts/plot/__go_draw_figure__.m 2009-06-25 06:36:46.000000000 +0200 --- octave-3.2.3/scripts/plot/__go_draw_figure__.m 2009-08-06 07:30:34.000000000 +0200 *************** *** 67,73 **** if (nkids > 0) fputs (plot_stream, "\nreset;\n"); fputs (plot_stream, "set autoscale keepfix;\n"); - fputs (plot_stream, "set multiplot;\n"); fputs (plot_stream, "set origin 0, 0\n"); fputs (plot_stream, "set size 1, 1\n"); for i = 1:nkids --- 67,72 ---- *************** *** 96,102 **** error ("__go_draw_figure__: unknown object class, %s", type); endswitch endfor - fputs (plot_stream, "unset multiplot;\n"); else fputs (plot_stream, "\nreset; clear;\n"); fflush (plot_stream); --- 95,100 ---- diff -cNr octave-3.2.2/scripts/plot/hold.m octave-3.2.3/scripts/plot/hold.m *** octave-3.2.2/scripts/plot/hold.m 2009-06-11 07:13:22.000000000 +0200 --- octave-3.2.3/scripts/plot/hold.m 2009-09-07 08:01:41.000000000 +0200 *************** *** 46,94 **** function hold (varargin) ! if (nargin > 0 && numel (varargin{1}) == 1 && ishandle (varargin{1}(1)) && strcmp (get (varargin{1}, "type"), "axes")) ! [h, varargin, nargs] = __plt_get_axis_arg__ ("hold", varargin{:}); ! elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1}(1))) print_usage (); else ! h = gcf (); nargs = numel (varargin); endif - hold_state = get (h, "nextplot"); - if (nargs == 0) ! if (strcmpi (hold_state, "add")) ! hold_state = "replace"; ! else ! hold_state = "add"; ! endif elseif (nargs == 1) state = varargin{1}; if (ischar (state)) if (strcmpi (state, "off")) ! hold_state = "replace"; elseif (strcmpi (state, "on")) ! hold_state = "add"; else ! print_usage (); endif endif else print_usage (); endif ! if (isfigure (h)) ! if (isempty (get (h, "currentaxes"))) ! set (h, "currentaxes", __go_axes__ (h)) ! endif ! axes_objs = findobj (h, "type", "axes"); ! h = [h; axes_objs]; endif - set (h, "nextplot", hold_state); - endfunction %!demo --- 46,86 ---- function hold (varargin) ! if (nargin > 0 && numel (varargin{1}) == 1 && ishandle (varargin{1}) && strcmp (get (varargin{1}, "type"), "axes")) ! [ax, varargin, nargs] = __plt_get_axis_arg__ ("hold", varargin{:}); ! elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1})) print_usage (); else ! ax = gca (); ! fig = gcf (); nargs = numel (varargin); endif if (nargs == 0) ! turn_hold_off = ishold (ax); elseif (nargs == 1) state = varargin{1}; if (ischar (state)) if (strcmpi (state, "off")) ! turn_hold_off = true; elseif (strcmpi (state, "on")) ! turn_hold_off = false; else ! error ("hold: invalid hold state"); endif endif else print_usage (); endif ! if (turn_hold_off) ! set (ax, "nextplot", "replace"); ! else ! set (ax, "nextplot", "add"); ! set (fig, "nextplot", "add"); endif endfunction %!demo diff -cNr octave-3.2.2/scripts/plot/ishold.m octave-3.2.3/scripts/plot/ishold.m *** octave-3.2.2/scripts/plot/ishold.m 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/scripts/plot/ishold.m 2009-09-07 08:01:41.000000000 +0200 *************** *** 1,4 **** ! ## Copyright (C) 2005, 2006, 2007, 2008 John W. Eaton ## ## This file is part of Octave. ## --- 1,4 ---- ! ## Copyright (C) 2005, 2006, 2007, 2008 2009 John W. Eaton ## ## This file is part of Octave. ## *************** *** 22,33 **** ## false if the plot device will be cleared before drawing the next line. ## @end deftypefn ! function retval = ishold () if (nargin == 0) ! retval = strcmpi (get (gca (), "nextplot"), "add"); else print_usage (); endif endfunction --- 22,55 ---- ## false if the plot device will be cleared before drawing the next line. ## @end deftypefn ! function retval = ishold (h) if (nargin == 0) ! ax = gca (); ! fig = gcf (); ! elseif (nargin == 1) ! if (ishandle (h)) ! if (isfigure (h)) ! ax = get (h, "currentaxes"); ! if (isempty (ax)) ! ax = __go_axes__ (h); ! set (h, "currentaxes", ax); ! endif ! fig = h; ! elseif (strcmpi (get (h, "type"), "axes")) ! ax = h; ! fig = get (h, "parent"); ! else ! error ("hold: expecting argument to be axes or figure graphics handle"); ! endif ! else ! error ("hold: expecting argument to be axes or figure graphics handle"); ! endif else print_usage (); endif + retval = (strcmpi (get (fig, "nextplot"), "add") + && strcmpi (get (ax, "nextplot"), "add")); + endfunction diff -cNr octave-3.2.2/scripts/set/setxor.m octave-3.2.3/scripts/set/setxor.m *** octave-3.2.2/scripts/set/setxor.m 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/scripts/set/setxor.m 2009-08-06 07:32:54.000000000 +0200 *************** *** 71,77 **** na = numel (a); nb = numel (b); [c, i] = sort ([a(:); b(:)]); n = length (c); ! idx = find (c(1:n-1) == c(2:n)); if (! isempty (idx)) c([idx, idx+1]) = []; i([idx, idx+1]) = []; --- 71,81 ---- na = numel (a); nb = numel (b); [c, i] = sort ([a(:); b(:)]); n = length (c); ! if (iscell (c)) ! idx = find (strcmp (c(1:n-1), c(2:n))); ! else ! idx = find (c(1:n-1) == c(2:n)); ! endif if (! isempty (idx)) c([idx, idx+1]) = []; i([idx, idx+1]) = []; diff -cNr octave-3.2.2/scripts/statistics/base/std.m octave-3.2.3/scripts/statistics/base/std.m *** octave-3.2.2/scripts/statistics/base/std.m 2009-05-25 08:04:59.000000000 +0200 --- octave-3.2.3/scripts/statistics/base/std.m 2009-09-01 09:26:33.000000000 +0200 *************** *** 64,70 **** if (nargin < 1 || nargin > 3) print_usage (); endif ! if nargin < 3 dim = find (size (a) > 1, 1); if (isempty (dim)) dim = 1; --- 64,70 ---- if (nargin < 1 || nargin > 3) print_usage (); endif ! if (nargin < 3) dim = find (size (a) > 1, 1); if (isempty (dim)) dim = 1; *************** *** 76,82 **** n = size (a, dim); if (n == 1) ! retval = zeros (sz); elseif (numel (a) > 0) retval = sqrt (sumsq (center (a, dim), dim) / (n + opt - 1)); else --- 76,82 ---- n = size (a, dim); if (n == 1) ! retval = zeros (size (a)); elseif (numel (a) > 0) retval = sqrt (sumsq (center (a, dim), dim) / (n + opt - 1)); else *************** *** 89,96 **** %! x = ones (10, 2); %! y = [1, 3]; %! assert(std (x) == [0, 0] && abs (std (y) - sqrt (2)) < sqrt (eps)); %!error std (); %!error std (1, 2, 3, 4); - --- 89,97 ---- %! x = ones (10, 2); %! y = [1, 3]; %! assert(std (x) == [0, 0] && abs (std (y) - sqrt (2)) < sqrt (eps)); + %! assert (std (x, 0, 3), zeros (10, 2)) + %! assert (std (ones (3, 1, 2), 0, 2), zeros (3, 1, 2)) %!error std (); %!error std (1, 2, 3, 4); diff -cNr octave-3.2.2/scripts/time/datestr.m octave-3.2.3/scripts/time/datestr.m *** octave-3.2.2/scripts/time/datestr.m 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/scripts/time/datestr.m 2009-09-01 09:31:39.000000000 +0200 *************** *** 277,283 **** sec = vi(6); tm.sec = fix (sec); tm.usec = fix (rem (sec, 1) * 1e6); ! str = strftime (df, localtime (mktime (tm))); if (i == 1) --- 277,285 ---- sec = vi(6); tm.sec = fix (sec); tm.usec = fix (rem (sec, 1) * 1e6); ! ## Force mktime to check for DST. ! tm.isdst = -1; ! str = strftime (df, localtime (mktime (tm))); if (i == 1) diff -cNr octave-3.2.2/src/bitfcns.cc octave-3.2.3/src/bitfcns.cc *** octave-3.2.2/src/bitfcns.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/bitfcns.cc 2009-07-27 06:49:25.000000000 +0200 *************** *** 381,387 **** { \ int bits_in_type = octave_ ## T :: nbits (); \ T ## NDArray m = m_arg.T ## _array_value (); \ ! octave_ ## T mask = ~0ULL; \ if ((N) < bits_in_type) \ mask = bitshift (mask, (N) - bits_in_type); \ else if ((N) < 1) \ --- 381,387 ---- { \ int bits_in_type = octave_ ## T :: nbits (); \ T ## NDArray m = m_arg.T ## _array_value (); \ ! octave_ ## T mask = octave_ ## T::max (); \ if ((N) < bits_in_type) \ mask = bitshift (mask, (N) - bits_in_type); \ else if ((N) < 1) \ *************** *** 395,405 **** { \ int bits_in_type = octave_ ## T :: nbits (); \ T ## NDArray m = m_arg.T ## _array_value (); \ ! octave_ ## T mask = -1; \ if ((N) < bits_in_type) \ mask = bitshift (mask, (N) - bits_in_type); \ else if ((N) < 1) \ mask = 0; \ DO_BITSHIFT (T); \ } \ while (0) --- 395,406 ---- { \ int bits_in_type = octave_ ## T :: nbits (); \ T ## NDArray m = m_arg.T ## _array_value (); \ ! octave_ ## T mask = octave_ ## T::max (); \ if ((N) < bits_in_type) \ mask = bitshift (mask, (N) - bits_in_type); \ else if ((N) < 1) \ mask = 0; \ + mask = mask | octave_ ## T :: min (); /* FIXME: 2's complement only? */ \ DO_BITSHIFT (T); \ } \ while (0) diff -cNr octave-3.2.2/src/ChangeLog octave-3.2.3/src/ChangeLog *** octave-3.2.2/src/ChangeLog 2009-07-21 06:52:30.000000000 +0200 --- octave-3.2.3/src/ChangeLog 2009-09-14 08:01:42.000000000 +0200 *************** *** 1,3 **** --- 1,133 ---- + 2009-09-18 Jaroslav Hajek + + Version 3.2.3 released. + + 2009-09-08 Rafael Laboissiere + + * pr-output.cc: New test. + + 2009-09-03 John W. Eaton + + * pr-output.cc (set_format (const Complex&, int&, int&)): + Avoid passing NaN or Inf to log10. + + 2008-09-01 David Bateman + + * DLD-FUNCTIONS/eig.cc (Feigs): Correct nesting error in option + parsing that prevented the use of a function for generalized + eigenvalue problems. + + 2009-09-01 Jaroslav Hajek + + * ov-class.cc (get_current_method_class): Check before slicing. + + 2009-08-26 Jaroslav Hajek + + * data.cc (Ffmod): Reverse order of args. + + 2009-08-26 Rob Mahurin + + * syscalls.cc: Recommend waitpid() in popen2() documentation. + + 2009-08-25 John W. Eaton + + * graphics.cc (gnuplot_backend::send_quit): Wait for gnuplot process. + + 2009-08-12 Jaroslav Hajek + + * data.cc (Fissorted, F__sort_rows_idx__, Fnorm): Mark as Built-in + Functions in the inline help. + + 2009-08-10 John W. Eaton + + * DLD-FUNCTIONS/dlmread.cc (Fdlmread): Perform tilde expansion on + filename argument. + + 2009-06-11 John W. Eaton + + * display.h (display_info::no_window_system): New static function. + (display_info::display_info, display_info::init, + display_info::instance_ok): New argument, QUERY. + (display_info::init): Skip query if QUERY is false. + + * octave.cc (long_opts, octave_main): Handle --no-window-system option. + (NO_WINDOW_SYSTEM_OPTION): New defined value. + (usage_string, verbose_usage): Mention --no-window-system option. + + 2009-08-09 John W. Eaton + + * parse.y (Fevalin): Also return output from CATCH expression. + + 2009-08-06 Jaroslav Hajek + + * OPERATORS/op-dm-template.cc, OPERATORS/op-pm-template.cc: + Also define conversions for null string and null sq_string. + + 2009-08-06 John W. Eaton + + * OPERATORS/op-cdm-m.cc, OPERATORS/op-dm-m.cc, OPERATORS/op-pm-m.cc: + Define LDMATRIX and DEFINENULLASSIGNCONV. + * OPERATORS/op-dm-template.cc, OPERATORS/op-pm-template.cc: + Include ov-null-mat.h and define assignment conversion for null + matrices if DEFINENULLASSIGNCONV is defined. Define OCTAVE_LDMATRIX. + + 2009-08-05 John W. Eaton + + * pt-eval.cc (tree_evaluator::visit_complex_for_command): + Use key_list order for iterating through map. + + 2009-08-07 Jaroslav Hajek + + * pt-idx.cc (tree_index_expression::lvalue): Implant code from + development version. + (get_numel): New assistant function. + + 2009-07-29 John W. Eaton + + * ov-float.cc, ov-flt-re-mat.cc, ov-re-mat.cc, ov-re-sparse.cc, + ov-scalar.cc: Use complex function for acos mapper if arg is out + of range [-1, 1]. + + 2009-07-29 John W. Eaton + + * parse.y (param_list_end): Also set + lexer_flags.looking_for_object_index to false. + + 2009-07-24 John W. Eaton + + * pt-mat.cc (DO_SINGLE_TYPE_CONCAT_NO_MUTATE): New macro. + (tree_matrix::rvalue1): Use it to avoid complex -> real conversion. + + 2009-07-23 Jaroslav Hajek + + * DLD-FUNCTIONS/chol.cc (Fcholupdate, + Fcholinsert, Fcholdelete, Fcholshift): Replace is_matrix_type -> + is_numeric_type. + + 2009-07-20 Aleksej Saushev + + * sysdep.cc: Also define BSD_init if __NetBSD__ is defined. + (sysdep_init): Also call BSD_init if __NetBSD__ is defined. + + 2009-07-20 Jaroslav Hajek + + * bitfcns.cc (DO_UBITSHIFT): Avoid overflow. + (DO_SBITSHIFT): Fix mask calculation. + + 2009-07-17 Benjamin Lindner + + * DLD-FUNCTIONS/__magick_read__.cc (F__magick_read__): + Determine correct number of bits required when reading images. + + 2009-07-16 John W. Eaton + + * graphics.cc (get_array_limits): Require min_pos value to be + greater than zero. + + 2009-07-08 John W. Eaton + + * pt-assign.cc (maybe_warn_former_built_in_variable): Improve message. + 2009-07-21 Jaroslav Hajek Version 3.2.2 released. diff -cNr octave-3.2.2/src/data.cc octave-3.2.3/src/data.cc *** octave-3.2.2/src/data.cc 2009-06-09 07:18:29.000000000 +0200 --- octave-3.2.3/src/data.cc 2009-08-26 08:17:09.000000000 +0200 *************** *** 1105,1112 **** if (nargin == 2 && args(0).is_defined () && args(1).is_defined ()) { ! octave_value arg_y = args(0); ! octave_value arg_x = args(1); dim_vector y_dims = arg_y.dims (); dim_vector x_dims = arg_x.dims (); --- 1105,1112 ---- if (nargin == 2 && args(0).is_defined () && args(1).is_defined ()) { ! octave_value arg_x = args(0); ! octave_value arg_y = args(1); dim_vector y_dims = arg_y.dims (); dim_vector x_dims = arg_x.dims (); *************** *** 4793,4799 **** DEFUN (norm, args, , "-*- texinfo -*-\n\ ! @deftypefn {Function File} {} norm (@var{a}, @var{p}, @var{opt})\n\ Compute the p-norm of the matrix @var{a}. If the second argument is\n\ missing, @code{p = 2} is assumed.\n\ \n\ --- 4793,4799 ---- DEFUN (norm, args, , "-*- texinfo -*-\n\ ! @deftypefn {Built-in Function} {} norm (@var{a}, @var{p}, @var{opt})\n\ Compute the p-norm of the matrix @var{a}. If the second argument is\n\ missing, @code{p = 2} is assumed.\n\ \n\ *************** *** 5763,5769 **** DEFUN (__sort_rows_idx__, args, , "-*- texinfo -*-\n\ ! @deftypefn {Function File} {} __sort_rows_idx__ (@var{a}, @var{mode})\n\ Undocumented internal function.\n\ @end deftypefn\n") { --- 5763,5769 ---- DEFUN (__sort_rows_idx__, args, , "-*- texinfo -*-\n\ ! @deftypefn {Built-in Function} {} __sort_rows_idx__ (@var{a}, @var{mode})\n\ Undocumented internal function.\n\ @end deftypefn\n") { *************** *** 5810,5816 **** DEFUN (issorted, args, , "-*- texinfo -*-\n\ ! @deftypefn {Function File} {} issorted (@var{a}, @var{rows})\n\ Returns true if the array is sorted, ascending or descending.\n\ NaNs are treated as by @code{sort}. If @var{rows} is supplied and\n\ has the value \"rows\", checks whether the array is sorted by rows\n\ --- 5810,5816 ---- DEFUN (issorted, args, , "-*- texinfo -*-\n\ ! @deftypefn {Built-in Function} {} issorted (@var{a}, @var{rows})\n\ Returns true if the array is sorted, ascending or descending.\n\ NaNs are treated as by @code{sort}. If @var{rows} is supplied and\n\ has the value \"rows\", checks whether the array is sorted by rows\n\ diff -cNr octave-3.2.2/src/display.cc octave-3.2.3/src/display.cc *** octave-3.2.2/src/display.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/display.cc 2009-08-13 07:56:02.000000000 +0200 *************** *** 40,141 **** display_info *display_info::instance = 0; void ! display_info::init (void) { #if defined (OCTAVE_USE_WINDOWS_API) ! HDC hdc = GetDC (0); ! if (hdc) ! { ! dp = GetDeviceCaps (hdc, BITSPIXEL); ! ht = GetDeviceCaps (hdc, VERTRES); ! wd = GetDeviceCaps (hdc, HORZRES); ! double ht_mm = GetDeviceCaps (hdc, VERTSIZE); ! double wd_mm = GetDeviceCaps (hdc, HORZSIZE); ! rx = wd * 25.4 / wd_mm; ! ry = ht * 25.4 / ht_mm; ! } ! else ! warning ("no graphical display found"); #elif defined (HAVE_FRAMEWORK_CARBON) ! CGDirectDisplayID display = CGMainDisplayID (); ! if (display) ! { ! dp = CGDisplayBitsPerPixel (display); ! ht = CGDisplayPixelsHigh (display); ! wd = CGDisplayPixelsWide (display); ! CGSize sz_mm = CGDisplayScreenSize (display); ! // On modern Mac systems (>= 10.5) CGSize is a struct keeping 2 ! // CGFloat values, but the CGFloat typedef is not present on ! // older systems, so use double instead. ! double ht_mm = sz_mm.height; ! double wd_mm = sz_mm.width; ! rx = wd * 25.4 / wd_mm; ! ry = ht * 25.4 / ht_mm; ! } ! else ! warning ("no graphical display found"); #elif defined (HAVE_X_WINDOWS) ! const char *display_name = getenv ("DISPLAY"); ! ! if (display_name && *display_name) ! { ! Display *display = XOpenDisplay (display_name); ! if (display) { ! Screen *screen = DefaultScreenOfDisplay (display); ! if (screen) { ! dp = DefaultDepthOfScreen (screen); ! ht = HeightOfScreen (screen); ! wd = WidthOfScreen (screen); ! int screen_number = XScreenNumberOfScreen (screen); ! double ht_mm = DisplayHeightMM (display, screen_number); ! double wd_mm = DisplayWidthMM (display, screen_number); ! rx = wd * 25.4 / wd_mm; ! ry = ht * 25.4 / ht_mm; } else ! warning ("X11 display has no default screen"); } else ! warning ("unable to open X11 DISPLAY"); ! } ! else ! warning ("X11 DISPLAY environment variable not set"); #else ! warning ("no graphical display found"); #endif } bool ! display_info::instance_ok (void) { bool retval = true; if (! instance) ! instance = new display_info (); if (! instance) { --- 40,144 ---- display_info *display_info::instance = 0; void ! display_info::init (bool query) { + if (query) + { #if defined (OCTAVE_USE_WINDOWS_API) ! HDC hdc = GetDC (0); ! if (hdc) ! { ! dp = GetDeviceCaps (hdc, BITSPIXEL); ! ht = GetDeviceCaps (hdc, VERTRES); ! wd = GetDeviceCaps (hdc, HORZRES); ! double ht_mm = GetDeviceCaps (hdc, VERTSIZE); ! double wd_mm = GetDeviceCaps (hdc, HORZSIZE); ! rx = wd * 25.4 / wd_mm; ! ry = ht * 25.4 / ht_mm; ! } ! else ! warning ("no graphical display found"); #elif defined (HAVE_FRAMEWORK_CARBON) ! CGDirectDisplayID display = CGMainDisplayID (); ! if (display) ! { ! dp = CGDisplayBitsPerPixel (display); ! ht = CGDisplayPixelsHigh (display); ! wd = CGDisplayPixelsWide (display); ! CGSize sz_mm = CGDisplayScreenSize (display); ! // On modern Mac systems (>= 10.5) CGSize is a struct keeping 2 ! // CGFloat values, but the CGFloat typedef is not present on ! // older systems, so use double instead. ! double ht_mm = sz_mm.height; ! double wd_mm = sz_mm.width; ! rx = wd * 25.4 / wd_mm; ! ry = ht * 25.4 / ht_mm; ! } ! else ! warning ("no graphical display found"); #elif defined (HAVE_X_WINDOWS) ! const char *display_name = getenv ("DISPLAY"); ! if (display_name && *display_name) { ! Display *display = XOpenDisplay (display_name); ! if (display) { ! Screen *screen = DefaultScreenOfDisplay (display); ! ! if (screen) ! { ! dp = DefaultDepthOfScreen (screen); ! ht = HeightOfScreen (screen); ! wd = WidthOfScreen (screen); ! int screen_number = XScreenNumberOfScreen (screen); ! double ht_mm = DisplayHeightMM (display, screen_number); ! double wd_mm = DisplayWidthMM (display, screen_number); ! rx = wd * 25.4 / wd_mm; ! ry = ht * 25.4 / ht_mm; ! } ! else ! warning ("X11 display has no default screen"); } else ! warning ("unable to open X11 DISPLAY"); } else ! warning ("X11 DISPLAY environment variable not set"); #else ! warning ("no graphical display found"); #endif + } } bool ! display_info::instance_ok (bool query) { bool retval = true; if (! instance) ! instance = new display_info (query); if (! instance) { diff -cNr octave-3.2.2/src/display.h octave-3.2.3/src/display.h *** octave-3.2.2/src/display.h 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/display.h 2009-08-13 07:56:02.000000000 +0200 *************** *** 29,38 **** { protected: ! display_info (void) : ht (1), wd (1), dp (0), rx (72), ry (72) { ! init (); } public: --- 29,38 ---- { protected: ! display_info (bool query = true) : ht (1), wd (1), dp (0), rx (72), ry (72) { ! init (query); } public: *************** *** 62,67 **** --- 62,74 ---- return instance_ok () ? instance->do_y_dpi () : 0; } + // To disable querying the window system for defaults, this function + // must be called before any other display_info function. + static void no_window_system (void) + { + instance_ok (false); + } + private: static display_info *instance; *************** *** 82,90 **** double do_x_dpi (void) const { return rx; } double do_y_dpi (void) const { return ry; } ! void init (void); ! static bool instance_ok (void); }; #endif --- 89,97 ---- double do_x_dpi (void) const { return rx; } double do_y_dpi (void) const { return ry; } ! void init (bool query = true); ! static bool instance_ok (bool query = true); }; #endif diff -cNr octave-3.2.2/src/DLD-FUNCTIONS/chol.cc octave-3.2.3/src/DLD-FUNCTIONS/chol.cc *** octave-3.2.2/src/DLD-FUNCTIONS/chol.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/DLD-FUNCTIONS/chol.cc 2009-07-27 06:49:25.000000000 +0200 *************** *** 619,625 **** octave_value argr = args(0); octave_value argu = args(1); ! if (argr.is_matrix_type () && argu.is_matrix_type () && (nargin < 3 || args(2).is_string ())) { octave_idx_type n = argr.rows (); --- 619,625 ---- octave_value argr = args(0); octave_value argu = args(1); ! if (argr.is_numeric_type () && argu.is_numeric_type () && (nargin < 3 || args(2).is_string ())) { octave_idx_type n = argr.rows (); *************** *** 830,836 **** octave_value argj = args(1); octave_value argu = args(2); ! if (argr.is_matrix_type () && argu.is_matrix_type () && argj.is_real_scalar ()) { octave_idx_type n = argr.rows (); --- 830,836 ---- octave_value argj = args(1); octave_value argu = args(2); ! if (argr.is_numeric_type () && argu.is_numeric_type () && argj.is_real_scalar ()) { octave_idx_type n = argr.rows (); *************** *** 1003,1009 **** octave_value argr = args(0); octave_value argj = args(1); ! if (argr.is_matrix_type () && argj.is_real_scalar ()) { octave_idx_type n = argr.rows (); octave_idx_type j = argj.scalar_value (); --- 1003,1009 ---- octave_value argr = args(0); octave_value argj = args(1); ! if (argr.is_numeric_type () && argj.is_real_scalar ()) { octave_idx_type n = argr.rows (); octave_idx_type j = argj.scalar_value (); *************** *** 1141,1147 **** octave_value argi = args(1); octave_value argj = args(2); ! if (argr.is_matrix_type () && argi.is_real_scalar () && argj.is_real_scalar ()) { octave_idx_type n = argr.rows (); octave_idx_type i = argi.scalar_value (); --- 1141,1147 ---- octave_value argi = args(1); octave_value argj = args(2); ! if (argr.is_numeric_type () && argi.is_real_scalar () && argj.is_real_scalar ()) { octave_idx_type n = argr.rows (); octave_idx_type i = argi.scalar_value (); diff -cNr octave-3.2.2/src/DLD-FUNCTIONS/dlmread.cc octave-3.2.3/src/DLD-FUNCTIONS/dlmread.cc *** octave-3.2.2/src/DLD-FUNCTIONS/dlmread.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/DLD-FUNCTIONS/dlmread.cc 2009-08-24 07:58:35.000000000 +0200 *************** *** 30,35 **** --- 30,36 ---- #include #include + #include "file-ops.h" #include "lo-ieee.h" #include "defun-dld.h" *************** *** 187,193 **** if (error_state) return retval; ! std::ifstream file (fname.c_str ()); if (!file) { error ("dlmread: unable to open file `%s'", fname.c_str ()); --- 188,196 ---- if (error_state) return retval; ! std::string tname = file_ops::tilde_expand (fname); ! ! std::ifstream file (tname.c_str ()); if (!file) { error ("dlmread: unable to open file `%s'", fname.c_str ()); diff -cNr octave-3.2.2/src/DLD-FUNCTIONS/eigs.cc octave-3.2.3/src/DLD-FUNCTIONS/eigs.cc *** octave-3.2.2/src/DLD-FUNCTIONS/eigs.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/DLD-FUNCTIONS/eigs.cc 2009-09-03 11:44:07.000000000 +0200 *************** *** 425,449 **** } } ! // Note hold off reading B till later to avoid issues of double ! // copies of the matrix if B is full/real while A is complex.. ! if (!error_state && nargin > 1 && !(args(1).is_real_scalar ())) { ! if (args(1).is_complex_type ()) ! { ! b_arg = 1+arg_offset; ! have_b = true; ! bmat = 'G'; ! b_is_complex = true; ! arg_offset++; ! } ! else ! { ! b_arg = 1+arg_offset; ! have_b = true; ! bmat = 'G'; ! arg_offset++; ! } } } --- 425,451 ---- } } ! } ! ! // Note hold off reading B till later to avoid issues of double ! // copies of the matrix if B is full/real while A is complex.. ! if (!error_state && nargin > 1 + arg_offset && ! !(args(1 + arg_offset).is_real_scalar ())) ! { ! if (args(1+arg_offset).is_complex_type ()) { ! b_arg = 1+arg_offset; ! have_b = true; ! bmat = 'G'; ! b_is_complex = true; ! arg_offset++; ! } ! else ! { ! b_arg = 1+arg_offset; ! have_b = true; ! bmat = 'G'; ! arg_offset++; } } *************** *** 834,839 **** --- 836,846 ---- %! d1 = eigs (fn, n, k, 4.1, opts); %! assert (d1, eigs(A,k,4.1), 1e-11); %!testif HAVE_ARPACK + %! AA = speye (10); + %! fn = @(x) AA * x; + %! opts.issym = 1; opts.isreal = 1; + %! assert (eigs (fn, 10, AA, 3, 'lm', opts), [1; 1; 1]); + %!testif HAVE_ARPACK %! [v1,d1] = eigs(A, k, 'lm'); %! d1 = diag(d1); %! for i=1:k diff -cNr octave-3.2.2/src/DLD-FUNCTIONS/__magick_read__.cc octave-3.2.3/src/DLD-FUNCTIONS/__magick_read__.cc *** octave-3.2.2/src/DLD-FUNCTIONS/__magick_read__.cc 2009-05-28 07:57:14.000000000 +0200 --- octave-3.2.3/src/DLD-FUNCTIONS/__magick_read__.cc 2009-08-25 10:26:01.000000000 +0200 *************** *** 416,426 **** else { unsigned int depth = imvec[0].modulusDepth (); ! int i = 0; ! while (depth >>= 1) ! i++; ! depth = 1 << i; ! switch (depth) { case 1: --- 416,430 ---- else { unsigned int depth = imvec[0].modulusDepth (); ! if (depth > 1) ! { ! --depth; ! int i = 1; ! while (depth >>= 1) ! i++; ! depth = 1 << i; ! } ! switch (depth) { case 1: diff -cNr octave-3.2.2/src/DOCSTRINGS octave-3.2.3/src/DOCSTRINGS *** octave-3.2.2/src/DOCSTRINGS 2009-07-21 07:10:51.000000000 +0200 --- octave-3.2.3/src/DOCSTRINGS 2009-09-14 08:29:47.000000000 +0200 *************** *** 2636,2642 **** norm @c data.cc -*- texinfo -*- ! @deftypefn {Function File} {} norm (@var{a}, @var{p}, @var{opt}) Compute the p-norm of the matrix @var{a}. If the second argument is missing, @code{p = 2} is assumed. --- 2636,2642 ---- norm @c data.cc -*- texinfo -*- ! @deftypefn {Built-in Function} {} norm (@var{a}, @var{p}, @var{opt}) Compute the p-norm of the matrix @var{a}. If the second argument is missing, @code{p = 2} is assumed. *************** *** 2955,2968 **** __sort_rows_idx__ @c data.cc -*- texinfo -*- ! @deftypefn {Function File} {} __sort_rows_idx__ (@var{a}, @var{mode}) Undocumented internal function. @end deftypefn issorted @c data.cc -*- texinfo -*- ! @deftypefn {Function File} {} issorted (@var{a}, @var{rows}) Returns true if the array is sorted, ascending or descending. NaNs are treated as by @code{sort}. If @var{rows} is supplied and has the value "rows", checks whether the array is sorted by rows --- 2955,2968 ---- __sort_rows_idx__ @c data.cc -*- texinfo -*- ! @deftypefn {Built-in Function} {} __sort_rows_idx__ (@var{a}, @var{mode}) Undocumented internal function. @end deftypefn issorted @c data.cc -*- texinfo -*- ! @deftypefn {Built-in Function} {} issorted (@var{a}, @var{rows}) Returns true if the array is sorted, ascending or descending. NaNs are treated as by @code{sort}. If @var{rows} is supplied and has the value "rows", checks whether the array is sorted by rows *************** *** 10246,10256 **** endif until (done) fclose (out); ! @print{} are ! @print{} some ! @print{} strings @print{} these @end example @end deftypefn fcntl @c syscalls.cc --- 10246,10261 ---- endif until (done) fclose (out); ! waitpid (pid); @print{} these + @print{} strings + @print{} some + @print{} are @end example + + Note that @code{popen2}, unlike @code{popen}, will not "reap" the + child process. If you don't use @code{waitpid} to check the child's + exit status, it will linger until Octave exits. @end deftypefn fcntl @c syscalls.cc diff -cNr octave-3.2.2/src/graphics.cc octave-3.2.3/src/graphics.cc *** octave-3.2.2/src/graphics.cc 2009-06-09 06:33:11.000000000 +0200 --- octave-3.2.3/src/graphics.cc 2009-08-26 08:17:09.000000000 +0200 *************** *** 472,478 **** if (e > emax) emax = e; ! if (e >= 0 && e < eminp) eminp = e; } } --- 472,478 ---- if (e > emax) emax = e; ! if (e > 0 && e < eminp) eminp = e; } } *************** *** 2033,2039 **** private: void send_quit (const octave_value& pstream) const { ! if (! pstream.is_empty()) { octave_value_list args; Matrix fids = pstream.matrix_value (); --- 2033,2039 ---- private: void send_quit (const octave_value& pstream) const { ! if (! pstream.is_empty ()) { octave_value_list args; Matrix fids = pstream.matrix_value (); *************** *** 2041,2055 **** if (! error_state) { args(1) = "\nquit;\n"; ! args(0) = octave_value (fids (0)); feval ("fputs", args); args.resize (1); feval ("fflush", args); feval ("pclose", args); if (fids.numel () > 1) { ! args(0) = octave_value (fids (1)); feval ("pclose", args); } } } --- 2041,2063 ---- if (! error_state) { args(1) = "\nquit;\n"; ! args(0) = fids(0); feval ("fputs", args); + args.resize (1); feval ("fflush", args); feval ("pclose", args); + if (fids.numel () > 1) { ! args(0) = fids(1); feval ("pclose", args); + + if (fids.numel () > 2) + { + args(0) = fids(2); + feval ("waitpid", args); + } } } } *************** *** 3364,3370 **** array_property& ticks, bool limmode_is_auto, bool is_logscale) { - // FIXME -- add log ticks and lims if (lims.get ().is_empty ()) --- 3372,3377 ---- diff -cNr octave-3.2.2/src/octave.cc octave-3.2.3/src/octave.cc *** octave-3.2.2/src/octave.cc 2009-06-24 07:32:26.000000000 +0200 --- octave-3.2.3/src/octave.cc 2009-08-13 07:56:02.000000000 +0200 *************** *** 54,59 **** --- 54,60 ---- #include #include "Cell.h" #include "defun.h" + #include "display.h" #include "error.h" #include "file-io.h" #include "input.h" *************** *** 127,133 **** "octave [-?HVdfhiqvx] [--debug] [--echo-commands] [--eval CODE]\n\ [--exec-path path] [--help] [--image-path path] [--info-file file]\n\ [--info-program prog] [--interactive] [--line-editing] [--no-history] [--no-init-file]\n\ ! [--no-line-editing] [--no-site-file] [--no-init-path] [-p path]\n\ [--path path] [--silent] [--traditional] [--verbose] [--version] [file]"; // This is here so that it's more likely that the usage message and --- 128,134 ---- "octave [-?HVdfhiqvx] [--debug] [--echo-commands] [--eval CODE]\n\ [--exec-path path] [--help] [--image-path path] [--info-file file]\n\ [--info-program prog] [--interactive] [--line-editing] [--no-history] [--no-init-file]\n\ ! [--no-line-editing] [--no-site-file] [--no-init-path] [--no-window-system] [-p path]\n\ [--path path] [--silent] [--traditional] [--verbose] [--version] [file]"; // This is here so that it's more likely that the usage message and *************** *** 156,161 **** --- 157,163 ---- #define PERSIST_OPTION 11 #define TRADITIONAL_OPTION 12 #define LINE_EDITING_OPTION 13 + #define NO_WINDOW_SYSTEM_OPTION 14 long_options long_opts[] = { { "debug", prog_args::no_arg, 0, 'd' }, *************** *** 175,180 **** --- 177,183 ---- { "no-line-editing", prog_args::no_arg, 0, NO_LINE_EDITING_OPTION }, { "no-site-file", prog_args::no_arg, 0, NO_SITE_FILE_OPTION }, { "no-init-path", prog_args::no_arg, 0, NO_INIT_PATH_OPTION }, + { "no-window-system", prog_args::no_arg, 0, NO_WINDOW_SYSTEM_OPTION }, { "norc", prog_args::no_arg, 0, 'f' }, { "path", prog_args::required_arg, 0, 'p' }, { "persist", prog_args::no_arg, 0, PERSIST_OPTION }, *************** *** 506,511 **** --- 509,515 ---- --no-init-path Don't initialize function search path.\n\ --no-line-editing Don't use readline for command-line editing.\n\ --no-site-file Don't read the site-wide octaverc file.\n\ + --no-window-system Disable window system, including graphics.\n\ --norc, -f Don't read any initialization files.\n\ --path PATH, -p PATH Add PATH to head of function search path.\n\ --persist Go interactive after --eval or reading from FILE.\n\ *************** *** 749,754 **** --- 753,762 ---- set_initial_path = false; break; + case NO_WINDOW_SYSTEM_OPTION: + display_info::no_window_system (); + break; + case TRADITIONAL_OPTION: traditional = true; break; diff -cNr octave-3.2.2/src/OPERATORS/op-cdm-m.cc octave-3.2.3/src/OPERATORS/op-cdm-m.cc *** octave-3.2.2/src/OPERATORS/op-cdm-m.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/OPERATORS/op-cdm-m.cc 2009-08-07 08:15:28.000000000 +0200 *************** *** 1,6 **** /* ! Copyright (C) 2008 Jaroslav Hajek This file is part of Octave. --- 1,6 ---- /* ! Copyright (C) 2008, 2009 Jaroslav Hajek This file is part of Octave. *************** *** 24,29 **** --- 24,30 ---- #define RINCLUDE "ov-re-mat.h" #define LMATRIX complex_diag_matrix + #define LDMATRIX complex_matrix #define RMATRIX matrix #define RDMATRIX complex_matrix *************** *** 31,36 **** --- 32,38 ---- #define RSHORT m #define DEFINELDIV + #define DEFINENULLASSIGNCONV #include "op-dm-template.cc" diff -cNr octave-3.2.2/src/OPERATORS/op-dm-m.cc octave-3.2.3/src/OPERATORS/op-dm-m.cc *** octave-3.2.2/src/OPERATORS/op-dm-m.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/OPERATORS/op-dm-m.cc 2009-08-07 08:15:28.000000000 +0200 *************** *** 1,6 **** /* ! Copyright (C) 2008 Jaroslav Hajek This file is part of Octave. --- 1,6 ---- /* ! Copyright (C) 2008, 2009 Jaroslav Hajek This file is part of Octave. *************** *** 24,35 **** --- 24,37 ---- #define RINCLUDE "ov-re-mat.h" #define LMATRIX diag_matrix + #define LDMATRIX matrix #define RMATRIX matrix #define LSHORT dm #define RSHORT m #define DEFINELDIV + #define DEFINENULLASSIGNCONV #include "op-dm-template.cc" diff -cNr octave-3.2.2/src/OPERATORS/op-dm-template.cc octave-3.2.3/src/OPERATORS/op-dm-template.cc *** octave-3.2.2/src/OPERATORS/op-dm-template.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/OPERATORS/op-dm-template.cc 2009-08-07 08:22:13.000000000 +0200 *************** *** 1,6 **** /* ! Copyright (C) 2008 Jaroslav Hajek This file is part of Octave. --- 1,6 ---- /* ! Copyright (C) 2008, 2009 Jaroslav Hajek This file is part of Octave. *************** *** 28,33 **** --- 28,36 ---- #include "xdiv.h" #include LINCLUDE #include RINCLUDE + #ifdef DEFINENULLASSIGNCONV + #include "ov-null-mat.h" + #endif // matrix by diag matrix ops. *************** *** 44,49 **** --- 47,53 ---- #endif #define OCTAVE_LMATRIX CONCAT2(octave_, LMATRIX) + #define OCTAVE_LDMATRIX CONCAT2(octave_, LDMATRIX) #define OCTAVE_RMATRIX CONCAT2(octave_, RMATRIX) #define LMATRIX_VALUE CONCAT2(LMATRIX, _value) #define RMATRIX_VALUE CONCAT2(RMATRIX, _value) *************** *** 83,88 **** #ifdef DEFINELDIV INSTALL_BINOP (op_ldiv, OCTAVE_LMATRIX, OCTAVE_RMATRIX, ldiv); #endif } - - --- 87,95 ---- #ifdef DEFINELDIV INSTALL_BINOP (op_ldiv, OCTAVE_LMATRIX, OCTAVE_RMATRIX, ldiv); #endif + #ifdef DEFINENULLASSIGNCONV + INSTALL_ASSIGNCONV (OCTAVE_LMATRIX, octave_null_matrix, OCTAVE_LDMATRIX); + INSTALL_ASSIGNCONV (OCTAVE_LMATRIX, octave_null_str, OCTAVE_LDMATRIX); + INSTALL_ASSIGNCONV (OCTAVE_LMATRIX, octave_null_sq_str, OCTAVE_LDMATRIX); + #endif } diff -cNr octave-3.2.2/src/OPERATORS/op-pm-m.cc octave-3.2.3/src/OPERATORS/op-pm-m.cc *** octave-3.2.2/src/OPERATORS/op-pm-m.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/OPERATORS/op-pm-m.cc 2009-08-07 08:15:28.000000000 +0200 *************** *** 1,6 **** /* ! Copyright (C) 2008 Jaroslav Hajek This file is part of Octave. --- 1,6 ---- /* ! Copyright (C) 2008, 2009 Jaroslav Hajek This file is part of Octave. *************** *** 23,33 **** --- 23,35 ---- #define MINCLUDE "ov-re-mat.h" #define LMATRIX perm_matrix + #define LDMATRIX matrix #define RMATRIX matrix #define LSHORT pm #define RSHORT m #define LEFT + #define DEFINENULLASSIGNCONV #include "op-pm-template.cc" diff -cNr octave-3.2.2/src/OPERATORS/op-pm-template.cc octave-3.2.3/src/OPERATORS/op-pm-template.cc *** octave-3.2.2/src/OPERATORS/op-pm-template.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/OPERATORS/op-pm-template.cc 2009-08-07 08:22:13.000000000 +0200 *************** *** 1,6 **** /* ! Copyright (C) 2008 Jaroslav Hajek This file is part of Octave. --- 1,6 ---- /* ! Copyright (C) 2008, 2009 Jaroslav Hajek This file is part of Octave. *************** *** 27,34 **** --- 27,42 ---- #include "ov-perm.h" #include MINCLUDE #include "ops.h" + #ifdef DEFINENULLASSIGNCONV + #include "ov-null-mat.h" + #endif + + #ifndef LDMATRIX + #define LDMATRIX LMATRIX + #endif #define OCTAVE_LMATRIX CONCAT2(octave_, LMATRIX) + #define OCTAVE_LDMATRIX CONCAT2(octave_, LDMATRIX) #define OCTAVE_RMATRIX CONCAT2(octave_, RMATRIX) #ifdef LEFT #define LMATRIX_VALUE perm_matrix_value *************** *** 74,77 **** --- 82,90 ---- #else INSTALL_BINOP (op_div, OCTAVE_LMATRIX, OCTAVE_RMATRIX, div); #endif + #ifdef DEFINENULLASSIGNCONV + INSTALL_ASSIGNCONV (OCTAVE_LMATRIX, octave_null_matrix, OCTAVE_LDMATRIX); + INSTALL_ASSIGNCONV (OCTAVE_LMATRIX, octave_null_str, OCTAVE_LDMATRIX); + INSTALL_ASSIGNCONV (OCTAVE_LMATRIX, octave_null_sq_str, OCTAVE_LDMATRIX); + #endif } diff -cNr octave-3.2.2/src/ov-class.cc octave-3.2.3/src/ov-class.cc *** octave-3.2.2/src/ov-class.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/ov-class.cc 2009-09-01 09:34:05.000000000 +0200 *************** *** 105,111 **** std::string method_class = file_ops::tail (my_dir); ! retval = method_class.substr (1); return retval; } --- 105,112 ---- std::string method_class = file_ops::tail (my_dir); ! if (method_class.size () > 0) ! retval = method_class.substr (1); return retval; } diff -cNr octave-3.2.2/src/ov-float.cc octave-3.2.3/src/ov-float.cc *** octave-3.2.2/src/ov-float.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/ov-float.cc 2009-08-04 09:55:38.000000000 +0200 *************** *** 279,285 **** SCALAR_MAPPER (gamma, xgamma) CD_SCALAR_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Float_Inf) SCALAR_MAPPER (abs, ::fabsf) ! SCALAR_MAPPER (acos, ::acosf) CD_SCALAR_MAPPER (acosh, ::acoshf, ::acosh, 1.0, octave_Float_Inf) SCALAR_MAPPER (angle, ::arg) SCALAR_MAPPER (arg, ::arg) --- 279,285 ---- SCALAR_MAPPER (gamma, xgamma) CD_SCALAR_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Float_Inf) SCALAR_MAPPER (abs, ::fabsf) ! CD_SCALAR_MAPPER (acos, ::acosf, ::acos, -1.0, 1.0) CD_SCALAR_MAPPER (acosh, ::acoshf, ::acosh, 1.0, octave_Float_Inf) SCALAR_MAPPER (angle, ::arg) SCALAR_MAPPER (arg, ::arg) diff -cNr octave-3.2.2/src/ov-flt-re-mat.cc octave-3.2.3/src/ov-flt-re-mat.cc *** octave-3.2.2/src/ov-flt-re-mat.cc 2009-06-08 07:34:33.000000000 +0200 --- octave-3.2.3/src/ov-flt-re-mat.cc 2009-08-04 09:55:38.000000000 +0200 *************** *** 783,789 **** ARRAY_MAPPER (erfc, FloatNDArray::dmapper, ::erfcf) ARRAY_MAPPER (gamma, FloatNDArray::dmapper, xgamma) CD_ARRAY_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Float_Inf) ! ARRAY_MAPPER (acos, FloatNDArray::dmapper, ::acosf) CD_ARRAY_MAPPER (acosh, ::acoshf, ::acosh, 1.0, octave_Float_Inf) ARRAY_MAPPER (angle, FloatNDArray::dmapper, ::arg) ARRAY_MAPPER (arg, FloatNDArray::dmapper, ::arg) --- 783,789 ---- ARRAY_MAPPER (erfc, FloatNDArray::dmapper, ::erfcf) ARRAY_MAPPER (gamma, FloatNDArray::dmapper, xgamma) CD_ARRAY_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Float_Inf) ! CD_ARRAY_MAPPER (acos, ::acosf, ::acos, -1.0, 1.0) CD_ARRAY_MAPPER (acosh, ::acoshf, ::acosh, 1.0, octave_Float_Inf) ARRAY_MAPPER (angle, FloatNDArray::dmapper, ::arg) ARRAY_MAPPER (arg, FloatNDArray::dmapper, ::arg) diff -cNr octave-3.2.2/src/ov-re-mat.cc octave-3.2.3/src/ov-re-mat.cc *** octave-3.2.2/src/ov-re-mat.cc 2009-06-08 07:34:33.000000000 +0200 --- octave-3.2.3/src/ov-re-mat.cc 2009-08-04 09:55:38.000000000 +0200 *************** *** 811,817 **** ARRAY_MAPPER (erfc, NDArray::dmapper, ::erfc) ARRAY_MAPPER (gamma, NDArray::dmapper, xgamma) CD_ARRAY_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Inf) ! ARRAY_MAPPER (acos, NDArray::dmapper, ::acos) CD_ARRAY_MAPPER (acosh, ::acosh, ::acosh, 1.0, octave_Inf) ARRAY_MAPPER (angle, NDArray::dmapper, ::arg) ARRAY_MAPPER (arg, NDArray::dmapper, ::arg) --- 811,817 ---- ARRAY_MAPPER (erfc, NDArray::dmapper, ::erfc) ARRAY_MAPPER (gamma, NDArray::dmapper, xgamma) CD_ARRAY_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Inf) ! CD_ARRAY_MAPPER (acos, ::acos, ::acos, -1.0, 1.0) CD_ARRAY_MAPPER (acosh, ::acosh, ::acosh, 1.0, octave_Inf) ARRAY_MAPPER (angle, NDArray::dmapper, ::arg) ARRAY_MAPPER (arg, NDArray::dmapper, ::arg) diff -cNr octave-3.2.2/src/ov-re-sparse.cc octave-3.2.3/src/ov-re-sparse.cc *** octave-3.2.2/src/ov-re-sparse.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/ov-re-sparse.cc 2009-08-04 09:55:38.000000000 +0200 *************** *** 876,882 **** SPARSE_MAPPER (gamma, SparseMatrix::dmapper, xgamma) CD_SPARSE_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Inf) SPARSE_MAPPER (abs, SparseMatrix::dmapper, ::fabs) ! SPARSE_MAPPER (acos, SparseMatrix::dmapper, ::acos) CD_SPARSE_MAPPER (acosh, ::acosh, ::acosh, 1.0, octave_Inf) SPARSE_MAPPER (angle, SparseMatrix::dmapper, ::arg) SPARSE_MAPPER (arg, SparseMatrix::dmapper, ::arg) --- 876,882 ---- SPARSE_MAPPER (gamma, SparseMatrix::dmapper, xgamma) CD_SPARSE_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Inf) SPARSE_MAPPER (abs, SparseMatrix::dmapper, ::fabs) ! CD_SPARSE_MAPPER (acos, ::acos, ::acos, -1.0, 1.0) CD_SPARSE_MAPPER (acosh, ::acosh, ::acosh, 1.0, octave_Inf) SPARSE_MAPPER (angle, SparseMatrix::dmapper, ::arg) SPARSE_MAPPER (arg, SparseMatrix::dmapper, ::arg) diff -cNr octave-3.2.2/src/ov-scalar.cc octave-3.2.3/src/ov-scalar.cc *** octave-3.2.2/src/ov-scalar.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/ov-scalar.cc 2009-08-04 09:55:38.000000000 +0200 *************** *** 294,300 **** SCALAR_MAPPER (gamma, xgamma) CD_SCALAR_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Inf) SCALAR_MAPPER (abs, ::fabs) ! SCALAR_MAPPER (acos, ::acos) CD_SCALAR_MAPPER (acosh, ::acosh, ::acosh, 1.0, octave_Inf) SCALAR_MAPPER (angle, ::arg) SCALAR_MAPPER (arg, ::arg) --- 294,300 ---- SCALAR_MAPPER (gamma, xgamma) CD_SCALAR_MAPPER (lgamma, xlgamma, xlgamma, 0.0, octave_Inf) SCALAR_MAPPER (abs, ::fabs) ! CD_SCALAR_MAPPER (acos, ::acos, ::acos, -1.0, 1.0) CD_SCALAR_MAPPER (acosh, ::acosh, ::acosh, 1.0, octave_Inf) SCALAR_MAPPER (angle, ::arg) SCALAR_MAPPER (arg, ::arg) diff -cNr octave-3.2.2/src/parse.y octave-3.2.3/src/parse.y *** octave-3.2.2/src/parse.y 2009-05-26 21:04:49.000000000 +0200 --- octave-3.2.3/src/parse.y 2009-08-10 11:14:48.000000000 +0200 *************** *** 1138,1144 **** ; param_list_end : ')' ! { lexer_flags.looking_at_parameter_list = false; } ; param_list : param_list_beg param_list1 param_list_end --- 1138,1147 ---- ; param_list_end : ')' ! { ! lexer_flags.looking_at_parameter_list = false; ! lexer_flags.looking_for_object_index = false; ! } ; param_list : param_list_beg param_list1 param_list_end *************** *** 4277,4285 **** buffer_error_messages--; ! eval_string (args(2), 0, parse_status, nargout); ! retval = octave_value_list (); } } --- 4280,4289 ---- buffer_error_messages--; ! tmp = eval_string (args(2), nargout > 0, ! parse_status, nargout); ! retval = (nargout > 0) ? tmp : octave_value_list (); } } diff -cNr octave-3.2.2/src/pr-output.cc octave-3.2.3/src/pr-output.cc *** octave-3.2.2/src/pr-output.cc 2009-07-02 06:31:30.000000000 +0200 --- octave-3.2.3/src/pr-output.cc 2009-09-09 14:14:32.000000000 +0200 *************** *** 852,861 **** double r_abs = rp < 0.0 ? -rp : rp; double i_abs = ip < 0.0 ? -ip : ip; ! int r_x = r_abs == 0.0 ? 0 : static_cast (floor (log10 (r_abs) + 1.0)); ! int i_x = i_abs == 0.0 ? 0 : static_cast (floor (log10 (i_abs) + 1.0)); int x_max, x_min; --- 852,861 ---- double r_abs = rp < 0.0 ? -rp : rp; double i_abs = ip < 0.0 ? -ip : ip; ! int r_x = (xisinf (rp) || xisnan (rp) || r_abs == 0.0) ? 0 : static_cast (floor (log10 (r_abs) + 1.0)); ! int i_x = (xisinf (ip) || xisnan (ip) || i_abs == 0.0) ? 0 : static_cast (floor (log10 (i_abs) + 1.0)); int x_max, x_min; *************** *** 3350,3355 **** --- 3350,3367 ---- return retval; } + /* + %!test + %! format short + %! fd = tmpfile (); + %! for r = [0, Inf -Inf, NaN] + %! for i = [0, Inf -Inf, NaN] + %! fdisp (fd, complex (r, i)); + %! endfor + %! endfor + %! fclose (fd); + */ + static void init_format_state (void) { diff -cNr octave-3.2.2/src/pt-assign.cc octave-3.2.3/src/pt-assign.cc *** octave-3.2.2/src/pt-assign.cc 2009-06-25 06:36:15.000000000 +0200 --- octave-3.2.3/src/pt-assign.cc 2009-07-24 13:58:47.000000000 +0200 *************** *** 153,161 **** } if (vars.find (nm) != vars.end ()) ! warning_with_id ("Octave:built-in-variable-assignment", ! "%s is no longer a built-in variable; please read the NEWS file or type `news' for details", ! nm.c_str ()); } tree_simple_assignment::tree_simple_assignment --- 153,165 ---- } if (vars.find (nm) != vars.end ()) ! { ! const char *nm_c_str = nm.c_str (); ! ! warning_with_id ("Octave:built-in-variable-assignment", ! "%s is now a function instead of a built-in variable. By assigning to %s, you have created a variable that hides the function %s. To remove the variable and restore the function, type \"clear %s\"", ! nm_c_str, nm_c_str, nm_c_str, nm_c_str); ! } } tree_simple_assignment::tree_simple_assignment diff -cNr octave-3.2.2/src/pt-eval.cc octave-3.2.3/src/pt-eval.cc *** octave-3.2.2/src/pt-eval.cc 2009-07-20 12:10:40.000000000 +0200 --- octave-3.2.3/src/pt-eval.cc 2009-08-07 08:13:22.000000000 +0200 *************** *** 435,451 **** octave_lvalue key_ref = elt->lvalue (); ! const Octave_map tmp_val (rhs.map_value ()); tree_statement_list *loop_body = cmd.body (); ! for (Octave_map::const_iterator q = tmp_val.begin (); q != tmp_val.end (); q++) { ! octave_value key = tmp_val.key (q); ! const Cell val_lst = tmp_val.contents (q); ! octave_idx_type n = tmp_val.numel (); octave_value val = (n == 1) ? val_lst(0) : octave_value (val_lst); --- 435,455 ---- octave_lvalue key_ref = elt->lvalue (); ! const Octave_map tmp_val = rhs.map_value (); tree_statement_list *loop_body = cmd.body (); ! string_vector keys = tmp_val.keys (); ! ! octave_idx_type nel = keys.numel (); ! ! for (octave_idx_type i = 0; i < nel; i++) { ! std::string key = keys[i]; ! const Cell val_lst = tmp_val.contents (key); ! octave_idx_type n = val_lst.numel (); octave_value val = (n == 1) ? val_lst(0) : octave_value (val_lst); diff -cNr octave-3.2.2/src/pt-idx.cc octave-3.2.3/src/pt-idx.cc *** octave-3.2.2/src/pt-idx.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/pt-idx.cc 2009-08-07 08:09:17.000000000 +0200 *************** *** 403,414 **** --- 403,441 ---- return retval; } + static octave_idx_type + get_numel (const octave_value& val, + const octave_value_list& idx) + { + octave_idx_type retval; + + octave_idx_type len = idx.length (); + + if (len == 0) + retval = val.numel (); + else + { + const dim_vector dv = val.dims ().redim (len); + retval = 1; + for (octave_idx_type i = 0; i < len; i++) + { + if (idx(i).is_magic_colon ()) + retval *= dv(i); + else + retval *= idx(i).numel (); + } + } + + return retval; + } + octave_lvalue tree_index_expression::lvalue (void) { octave_lvalue retval; std::list idx; + std::string tmp_type; int n = args.size (); *************** *** 420,435 **** if (! error_state) { - // I think it is OK to have a copy here. - const octave_value *tro = retval.object (); ! octave_value first_retval_object; if (tro) ! first_retval_object = *tro; - octave_value tmp = first_retval_object; octave_idx_type tmpi = 0; std::list tmpidx; --- 447,459 ---- if (! error_state) { const octave_value *tro = retval.object (); ! octave_value tmp; if (tro) ! tmp = *tro; octave_idx_type tmpi = 0; std::list tmpidx; *************** *** 437,490 **** { if (retval.numel () != 1) gripe_indexed_cs_list (); ! ! if (i > 0) { ! tree_argument_list *al = *p_args; ! ! if (al && al->has_magic_end ()) ! { ! // We have an expression like ! // ! // x{end}.a(end) ! // ! // and we are looking at the argument list that ! // contains the second (or third, etc.) "end" token, ! // so we must evaluate everything up to the point of ! // that argument list so we pass the appropriate ! // value to the built-in __end__ function. ! ! if (tmp.is_defined ()) ! { ! if (tmpi < i) ! { ! tmp = tmp.subsref (type.substr (tmpi, i - tmpi), tmpidx, true); ! ! tmpi = i; ! tmpidx.clear (); ! } ! } ! else ! gripe_invalid_inquiry_subscript (); ! ! if (tmp.is_undefined ()) ! gripe_invalid_inquiry_subscript (); ! else if (tmp.is_cs_list ()) ! gripe_indexed_cs_list (); ! ! if (error_state) ! break; ! } } switch (type[i]) { case '(': { octave_value_list tidx = make_value_list (*p_args, *p_arg_nm, &tmp); idx.push_back (tidx); ! tmpidx.push_back (tidx); } break; --- 461,494 ---- { if (retval.numel () != 1) gripe_indexed_cs_list (); ! else if (tmpi < i) { ! tmp = tmp.subsref (type.substr (tmpi, i - tmpi), tmpidx, true); ! tmpidx.clear (); } + if (error_state) + break; + switch (type[i]) { case '(': { octave_value_list tidx = make_value_list (*p_args, *p_arg_nm, &tmp); + idx.push_back (tidx); ! ! if (i < n - 1) ! { ! if (type[i+1] == '.') ! { ! tmpidx.push_back (tidx); ! tmpi = i+1; ! } ! else ! error ("() must be followed by . or close the index chain"); ! } } break; *************** *** 493,552 **** octave_value_list tidx = make_value_list (*p_args, *p_arg_nm, &tmp); ! if (! tidx.all_scalars ()) ! { ! octave_idx_type nel = 1; ! ! octave_idx_type nidx = tidx.length (); ! ! // Possible cs-list. ! bool has_magic_colon = tidx.has_magic_colon (); ! dim_vector dims; ! ! if (has_magic_colon) ! { ! if (tmp.is_defined ()) ! { ! if (tmpi < i) ! { ! tmp = tmp.subsref (type.substr (tmpi, i - tmpi), tmpidx, true); ! tmpi = i; ! tmpidx.clear (); ! } ! ! if (tmp.is_undefined ()) ! gripe_invalid_inquiry_subscript (); ! else if (tmp.is_cs_list ()) ! gripe_indexed_cs_list (); ! ! dims = (nidx == 1) ? dim_vector (tmp.numel (), 1) : tmp.dims (); ! } ! else ! gripe_invalid_inquiry_subscript (); ! ! if (error_state) ! break; ! } ! ! for (octave_idx_type j = 0; j < nidx; j++) ! { ! octave_value val = tidx(j); ! ! if (val.is_magic_colon ()) ! nel *= dims (j); ! else ! nel *= val.numel (); ! } ! retval.numel (nel); ! } if (error_state) break; idx.push_back (tidx); tmpidx.push_back (tidx); ! } break; --- 497,523 ---- octave_value_list tidx = make_value_list (*p_args, *p_arg_nm, &tmp); ! if (tmp.is_undefined ()) ! { ! if (tidx.has_magic_colon ()) ! gripe_invalid_inquiry_subscript (); ! else ! tmp = Cell (); ! } ! else if (tmp.is_zero_by_zero () ! && (tmp.is_matrix_type () || tmp.is_string ())) ! { ! tmp = Cell (); ! } ! retval.numel (get_numel (tmp, tidx)); if (error_state) break; idx.push_back (tidx); tmpidx.push_back (tidx); ! tmpi = i; } break; *************** *** 556,645 **** if (error_state) break; if (i > 0 && type [i-1] == '(') { ! // Possible cs-list. ! octave_value_list xidx = idx.back (); ! ! if (! xidx.all_scalars ()) { ! octave_idx_type nel = 1; ! ! octave_idx_type nidx = xidx.length (); ! // Possible cs-list. ! bool has_magic_colon = xidx.has_magic_colon (); ! dim_vector dims; ! ! if (has_magic_colon) ! { ! // Evaluate everything up to the point preceding the last paren. ! if (tmp.is_defined ()) ! { ! if (tmpi < i-1) ! { ! tmpidx.pop_back (); ! tmp = tmp.subsref (type.substr (tmpi, i-1 - tmpi), tmpidx, true); ! tmpi = i - 1; ! tmpidx.clear (); ! tmpidx.push_back (xidx); ! } ! ! if (tmp.is_undefined ()) ! gripe_invalid_inquiry_subscript (); ! else if (tmp.is_cs_list ()) ! gripe_indexed_cs_list (); ! ! dims = (nidx == 1) ? dim_vector (tmp.numel (), 1) : tmp.dims (); ! } ! else ! gripe_invalid_inquiry_subscript (); ! ! if (error_state) ! break; ! } ! ! for (octave_idx_type j = 0; j < nidx; j++) ! { ! octave_value val = xidx(j); ! ! if (val.is_magic_colon ()) ! nel *= dims (j); ! else ! nel *= val.numel (); ! } ! retval.numel (nel); ! } } else { ! // A plain struct component can also yield a list reference. ! if (tmp.is_defined () && tmpi < i) ! tmp = tmp.subsref (type.substr (tmpi, i - tmpi), tmpidx, true); ! ! tmpi = i; ! tmpidx.clear (); ! ! if (tmp.is_cs_list ()) ! gripe_indexed_cs_list (); ! else if (tmp.is_map ()) ! retval.numel (tmp.numel ()); else ! tmp = Octave_map (); ! ! if (error_state) ! break; } if (error_state) break; idx.push_back (tidx); - tmpidx.push_back (tidx); - } break; --- 527,575 ---- if (error_state) break; + bool autoconv = (tmp.is_zero_by_zero () + && (tmp.is_matrix_type () || tmp.is_string () + || tmp.is_cell ())); + if (i > 0 && type [i-1] == '(') { ! octave_value_list pidx = idx.back (); ! if (tmp.is_undefined ()) { ! if (pidx.has_magic_colon ()) ! gripe_invalid_inquiry_subscript (); ! else ! tmp = Octave_map (); ! } ! else if (autoconv) ! tmp = Octave_map (); ! retval.numel (get_numel (tmp, pidx)); ! tmpi = i-1; ! tmpidx.push_back (tidx); } else { ! if (tmp.is_undefined () || autoconv) ! { ! tmpi = i+1; ! tmp = octave_value (); ! } else ! { ! retval.numel (get_numel (tmp, octave_value_list ())); + tmpi = i; + tmpidx.push_back (tidx); + } } if (error_state) break; idx.push_back (tidx); } break; *************** *** 647,652 **** --- 577,585 ---- panic_impossible (); } + if (idx.back ().empty ()) + error ("invalid empty index list"); + if (error_state) break; diff -cNr octave-3.2.2/src/pt-mat.cc octave-3.2.3/src/pt-mat.cc *** octave-3.2.2/src/pt-mat.cc 2009-06-25 06:36:24.000000000 +0200 --- octave-3.2.3/src/pt-mat.cc 2009-07-27 06:49:25.000000000 +0200 *************** *** 41,46 **** --- 41,48 ---- #include "ov.h" #include "variables.h" + #include "ov-cx-mat.h" + #include "ov-flt-cx-mat.h" #include "ov-re-sparse.h" #include "ov-cx-sparse.h" *************** *** 766,777 **** { \ TYPE result (dv); \ \ ! SINGLE_TYPE_CONCAT(TYPE, EXTRACTOR); \ \ retval = result; \ } \ while (0) octave_value tree_matrix::rvalue1 (int) { --- 768,790 ---- { \ TYPE result (dv); \ \ ! SINGLE_TYPE_CONCAT (TYPE, EXTRACTOR); \ \ retval = result; \ } \ while (0) + #define DO_SINGLE_TYPE_CONCAT_NO_MUTATE(TYPE, EXTRACTOR, OV_TYPE) \ + do \ + { \ + TYPE result (dv); \ + \ + SINGLE_TYPE_CONCAT (TYPE, EXTRACTOR); \ + \ + retval = octave_value (new OV_TYPE (result)); \ + } \ + while (0) + octave_value tree_matrix::rvalue1 (int) { *************** *** 874,887 **** if (all_real_p) DO_SINGLE_TYPE_CONCAT (SparseMatrix, sparse_matrix_value); else ! DO_SINGLE_TYPE_CONCAT (SparseComplexMatrix, sparse_complex_matrix_value); } else { if (all_real_p) DO_SINGLE_TYPE_CONCAT (NDArray, array_value); else ! DO_SINGLE_TYPE_CONCAT (ComplexNDArray, complex_array_value); } } else if (result_type == "single") --- 887,904 ---- if (all_real_p) DO_SINGLE_TYPE_CONCAT (SparseMatrix, sparse_matrix_value); else ! DO_SINGLE_TYPE_CONCAT_NO_MUTATE (SparseComplexMatrix, ! sparse_complex_matrix_value, ! octave_sparse_complex_matrix); } else { if (all_real_p) DO_SINGLE_TYPE_CONCAT (NDArray, array_value); else ! DO_SINGLE_TYPE_CONCAT_NO_MUTATE (ComplexNDArray, ! complex_array_value, ! octave_complex_matrix); } } else if (result_type == "single") *************** *** 889,896 **** if (all_real_p) DO_SINGLE_TYPE_CONCAT (FloatNDArray, float_array_value); else ! DO_SINGLE_TYPE_CONCAT (FloatComplexNDArray, ! float_complex_array_value); } else if (result_type == "char") { --- 906,914 ---- if (all_real_p) DO_SINGLE_TYPE_CONCAT (FloatNDArray, float_array_value); else ! DO_SINGLE_TYPE_CONCAT_NO_MUTATE (FloatComplexNDArray, ! float_complex_array_value, ! octave_float_complex_matrix); } else if (result_type == "char") { diff -cNr octave-3.2.2/src/syscalls.cc octave-3.2.3/src/syscalls.cc *** octave-3.2.2/src/syscalls.cc 2009-05-25 08:05:00.000000000 +0200 --- octave-3.2.3/src/syscalls.cc 2009-08-26 09:04:30.000000000 +0200 *************** *** 252,262 **** endif\n\ until (done)\n\ fclose (out);\n\ ! @print{} are\n\ ! @print{} some\n\ ! @print{} strings\n\ @print{} these\n\ @end example\n\ @end deftypefn") { octave_value_list retval; --- 252,267 ---- endif\n\ until (done)\n\ fclose (out);\n\ ! waitpid (pid);\n\ @print{} these\n\ + @print{} strings\n\ + @print{} some\n\ + @print{} are\n\ @end example\n\ + \n\ + Note that @code{popen2}, unlike @code{popen}, will not \"reap\" the\n\ + child process. If you don't use @code{waitpid} to check the child's\n\ + exit status, it will linger until Octave exits.\n\ @end deftypefn") { octave_value_list retval; diff -cNr octave-3.2.2/src/sysdep.cc octave-3.2.3/src/sysdep.cc *** octave-3.2.2/src/sysdep.cc 2009-07-02 06:31:30.000000000 +0200 --- octave-3.2.3/src/sysdep.cc 2009-07-27 06:49:25.000000000 +0200 *************** *** 95,101 **** #define STDIN_FILENO 1 #endif ! #if defined (__386BSD__) || defined (__FreeBSD__) static void BSD_init (void) { --- 95,101 ---- #define STDIN_FILENO 1 #endif ! #if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__) static void BSD_init (void) { *************** *** 300,306 **** void sysdep_init (void) { ! #if defined (__386BSD__) || defined (__FreeBSD__) BSD_init (); #elif defined (__MINGW32__) MINGW_init (); --- 300,306 ---- void sysdep_init (void) { ! #if defined (__386BSD__) || defined (__FreeBSD__) || defined(__NetBSD__) BSD_init (); #elif defined (__MINGW32__) MINGW_init (); diff -cNr octave-3.2.2/src/version.h octave-3.2.3/src/version.h *** octave-3.2.2/src/version.h 2009-07-21 06:52:24.000000000 +0200 --- octave-3.2.3/src/version.h 2009-09-14 08:01:42.000000000 +0200 *************** *** 25,35 **** #if !defined (octave_version_h) #define octave_version_h 1 ! #define OCTAVE_VERSION "3.2.2" #define OCTAVE_API_VERSION "api-v37" ! #define OCTAVE_RELEASE_DATE "2009-07-21" #define OCTAVE_COPYRIGHT "Copyright (C) 2009 John W. Eaton and others." --- 25,35 ---- #if !defined (octave_version_h) #define octave_version_h 1 ! #define OCTAVE_VERSION "3.2.3" #define OCTAVE_API_VERSION "api-v37" ! #define OCTAVE_RELEASE_DATE "2009-09-18" #define OCTAVE_COPYRIGHT "Copyright (C) 2009 John W. Eaton and others." diff -cNr octave-3.2.2/test/ChangeLog octave-3.2.3/test/ChangeLog *** octave-3.2.2/test/ChangeLog 2009-07-21 06:52:31.000000000 +0200 --- octave-3.2.3/test/ChangeLog 2009-09-14 08:01:42.000000000 +0200 *************** *** 1,3 **** --- 1,7 ---- + 2009-09-18 Jaroslav Hajek + + Version 3.2.3 released. + 2009-07-21 Jaroslav Hajek Version 3.2.2 released. diff -cNr octave-3.2.2/test/test_sparse.m octave-3.2.3/test/test_sparse.m *** octave-3.2.2/test/test_sparse.m 2009-06-26 13:21:45.000000000 +0200 --- octave-3.2.3/test/test_sparse.m 1970-01-01 01:00:00.000000000 +0100 *************** *** 1,3070 **** - ## THIS IS AN AUTOMATICALLY GENERATED FILE --- DO NOT EDIT --- - ## instead modify build_sparse_tests.sh to generate the tests that you want. - ## - ## test_sparse - ## - ## run preset sparse tests. All should pass. - function [passes,tests] = test_sparse - disp("writing test output to sptest.log"); - test("test_sparse","normal","sptest.log"); - endfunction - - - # ============================================================== - - - # ============================================================== - - - %!test # segfault test from edd@debian.org - %! n = 510; - %! sparse(kron((1:n)', ones(n,1)), kron(ones(n,1), (1:n)'), ones(n)); - - %% segfault tests from Fabian@isas-berlin.de - %% Note that the last four do not fail, but rather give a warning - %% of a singular matrix, which is consistent with the full matrix - %% behaviour. They are therefore disabled.. - %!testif HAVE_UMFPACK - %! assert(inv(sparse([1,1;1,1+i])),sparse([1-1i,1i;1i,-1i]),10*eps); - % !error inv( sparse( [1,1;1,1] ) ); - % !error inv( sparse( [0,0;0,1] ) ); - % !error inv( sparse( [0,0;0,1+i] ) ); - % !error inv( sparse( [0,0;0,0] ) ); - - %% error handling in constructor - %!error sparse(1,[2,3],[1,2,3]); - %!error sparse([1,1],[1,1],[1,2],3,3,"bogus"); - %!error sparse([1,3],[1,-4],[3,5],2,2); - %!error sparse([1,3],[1,-4],[3,5i],2,2); - %!error sparse(-1,-1,1); - - # ============================================================== - - %!shared bf - %!test bf=realmin; - %% Make sure newly introduced zeros get eaten - %!assert(nnz(sparse([bf,bf,1]).^realmax),1); - %!assert(nnz(sparse([1,bf,bf]).^realmax),1); - %!assert(nnz(sparse([bf,bf,bf]).^realmax),0); - - %!assert(nnz(sparse([bf;bf;1]).^realmax),1); - %!assert(nnz(sparse([1;bf;bf]).^realmax),1); - %!assert(nnz(sparse([0.5;bf;bf]).^realmax),0); - - %!assert(nnz(sparse([bf,bf,1])*realmin),1); - %!assert(nnz(sparse([1,bf,bf])*realmin),1); - %!assert(nnz(sparse([bf,bf,bf])*realmin),0); - - %!assert(nnz(sparse([bf;bf;1])*realmin),1); - %!assert(nnz(sparse([1;bf;bf])*realmin),1); - %!assert(nnz(sparse([bf;bf;bf])*realmin),0); - - %!test bf=realmin+realmin*1i; - %% Make sure newly introduced zeros get eaten - %!assert(nnz(sparse([bf,bf,1]).^realmax),1); - %!assert(nnz(sparse([1,bf,bf]).^realmax),1); - %!assert(nnz(sparse([bf,bf,bf]).^realmax),0); - - %!assert(nnz(sparse([bf;bf;1]).^realmax),1); - %!assert(nnz(sparse([1;bf;bf]).^realmax),1); - %!assert(nnz(sparse([0.5;bf;bf]).^realmax),0); - - %!assert(nnz(sparse([bf,bf,1])*realmin),1); - %!assert(nnz(sparse([1,bf,bf])*realmin),1); - %!assert(nnz(sparse([bf,bf,bf])*realmin),0); - - %!assert(nnz(sparse([bf;bf;1])*realmin),1); - %!assert(nnz(sparse([1;bf;bf])*realmin),1); - %!assert(nnz(sparse([bf;bf;bf])*realmin),0); - - %!assert(nnz(sparse([-1,realmin,realmin]).^1.5),1); - %!assert(nnz(sparse([-1,realmin,realmin,1]).^1.5),2); - - %!assert(nnz(sparse(1,1,0)),0); # Make sure scalar v==0 doesn't confuse matters - %!assert(nnz(sparse(eye(3))*0),0); - %!assert(nnz(sparse(eye(3))-sparse(eye(3))),0); - - %!test - %! wdbz = warning ("query", "Octave:divide-by-zero"); - %! warning ("off", "Octave:divide-by-zero"); - %! assert(full(sparse(eye(3))/0),full(eye(3)/0)); - %! warning (wdbz.state, "Octave:divide-by-zero"); - - - # ============================================================== - - %!shared as,af,bs,bf - %!test af=[1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4]; - %!test bf=3; - %!test as=sparse(af); - %!test bs=bf; - %% Elementwise binary tests (uses as,af,bs,bf,scalar) - %!assert(as==bs,sparse(af==bf)) - %!assert(bf==as,sparse(bf==af)) - - %!assert(as!=bf,sparse(af!=bf)) - %!assert(bf!=as,sparse(bf!=af)) - - %!assert(as+bf,af+bf) - %!assert(bf+as,bf+af) - - %!assert(as-bf,af-bf) - %!assert(bf-as,bf-af) - - %!assert(as.*bf,sparse(af.*bf)) - %!assert(bf.*as,sparse(bf.*af)) - - %!assert(as./bf,sparse(af./bf),100*eps) - %!assert(bf.\as,sparse(bf.\af),100*eps) - - %!test - %! sv = as.^bf; - %! fv = af.^bf; - %! idx = find(af~=0); - %! assert(sv(:)(idx),sparse(fv(:)(idx)),100*eps) - - %% real values can be ordered (uses as,af) - %!assert(as<=bf,sparse(af<=bf)) - %!assert(bf<=as,sparse(bf<=af)) - - %!assert(as>=bf,sparse(af>=bf)) - %!assert(bf>=as,sparse(bf>=af)) - - %!assert(asbf,sparse(af>bf)) - %!assert(bf>as,sparse(bf>af)) - - %!test bf=bf+1i; - %!test bs=bf; - %% Elementwise binary tests (uses as,af,bs,bf,scalar) - %!assert(as==bs,sparse(af==bf)) - %!assert(bf==as,sparse(bf==af)) - - %!assert(as!=bf,sparse(af!=bf)) - %!assert(bf!=as,sparse(bf!=af)) - - %!assert(as+bf,af+bf) - %!assert(bf+as,bf+af) - - %!assert(as-bf,af-bf) - %!assert(bf-as,bf-af) - - %!assert(as.*bf,sparse(af.*bf)) - %!assert(bf.*as,sparse(bf.*af)) - - %!assert(as./bf,sparse(af./bf),100*eps) - %!assert(bf.\as,sparse(bf.\af),100*eps) - - %!test - %! sv = as.^bf; - %! fv = af.^bf; - %! idx = find(af~=0); - %! assert(sv(:)(idx),sparse(fv(:)(idx)),100*eps) - - - # ============================================================== - - %!test af=[1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4]; - %!test bf=[0,1-1i,0,0;2+1i,0,0,0;3-1i,2+3i,0,0]; - %!test as=sparse(af); - %!test bs=sparse(bf); - %% Unary matrix tests (uses af,as) - %!assert(abs(as),sparse(abs(af))) - %!assert(acos(as),sparse(acos(af))) - %!assert(acosh(as),sparse(acosh(af))) - %!assert(angle(as),sparse(angle(af))) - %!assert(arg(as),sparse(arg(af))) - %!assert(asin(as),sparse(asin(af))) - %!assert(asinh(as),sparse(asinh(af))) - %!assert(atan(as),sparse(atan(af))) - %!assert(atanh(as),sparse(atanh(af))) - %!assert(ceil(as),sparse(ceil(af))) - %!assert(conj(as),sparse(conj(af))) - %!assert(cos(as),sparse(cos(af))) - %!assert(cosh(as),sparse(cosh(af))) - %!assert(exp(as),sparse(exp(af))) - %!assert(finite(as),sparse(finite(af))) - %!assert(fix(as),sparse(fix(af))) - %!assert(floor(as),sparse(floor(af))) - %!assert(imag(as),sparse(imag(af))) - %!assert(isinf(as),sparse(isinf(af))) - %!assert(isna(as),sparse(isna(af))) - %!assert(isnan(as),sparse(isnan(af))) - %!assert(log(as),sparse(log(af))) - %!assert(real(as),sparse(real(af))) - %!assert(round(as),sparse(round(af))) - %!assert(sign(as),sparse(sign(af))) - %!assert(sin(as),sparse(sin(af))) - %!assert(sinh(as),sparse(sinh(af))) - %!assert(sqrt(as),sparse(sqrt(af))) - %!assert(tan(as),sparse(tan(af))) - %!assert(tanh(as),sparse(tanh(af))) - %!assert(issparse(abs(as))&&isreal(abs(as))) - %!assert(issparse(real(as))&&isreal(real(as))) - %!assert(issparse(imag(as))&&isreal(imag(as))) - - %% Unary matrix tests (uses af,as) - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (1) - %! assert(erf(as),sparse(erf(af))) - %! else - %! assert(erf(as),erf(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (1) - %! assert(erfc(as),sparse(erfc(af))) - %! else - %! assert(erfc(as),erfc(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isalnum(as),sparse(isalnum(af))) - %! else - %! assert(isalnum(as),isalnum(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isalpha(as),sparse(isalpha(af))) - %! else - %! assert(isalpha(as),isalpha(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isascii(as),sparse(isascii(af))) - %! else - %! assert(isascii(as),isascii(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(iscntrl(as),sparse(iscntrl(af))) - %! else - %! assert(iscntrl(as),iscntrl(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isdigit(as),sparse(isdigit(af))) - %! else - %! assert(isdigit(as),isdigit(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isgraph(as),sparse(isgraph(af))) - %! else - %! assert(isgraph(as),isgraph(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(islower(as),sparse(islower(af))) - %! else - %! assert(islower(as),islower(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isprint(as),sparse(isprint(af))) - %! else - %! assert(isprint(as),isprint(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(ispunct(as),sparse(ispunct(af))) - %! else - %! assert(ispunct(as),ispunct(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isspace(as),sparse(isspace(af))) - %! else - %! assert(isspace(as),isspace(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isupper(as),sparse(isupper(af))) - %! else - %! assert(isupper(as),isupper(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isxdigit(as),sparse(isxdigit(af))) - %! else - %! assert(isxdigit(as),isxdigit(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - - %% These mapper functions always return a full matrix - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! assert(toascii(as),toascii(af)) - %! assert(tolower(as),tolower(af)) - %! assert(toupper(as),toupper(af)) - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %% Unary matrix tests (uses af,as) - %!assert(issparse(as)) - %!assert(!issparse(af)) - %!assert(!(issparse(af)&&iscomplex(af))) - %!assert(!(issparse(af)&&isreal(af))) - %!assert(sum(as),sparse(sum(af))) - %!assert(sum(as,1),sparse(sum(af,1))) - %!assert(sum(as,2),sparse(sum(af,2))) - %!assert(cumsum(as),sparse(cumsum(af))) - %!assert(cumsum(as,1),sparse(cumsum(af,1))) - %!assert(cumsum(as,2),sparse(cumsum(af,2))) - %!assert(sumsq(as),sparse(sumsq(af))) - %!assert(sumsq(as,1),sparse(sumsq(af,1))) - %!assert(sumsq(as,2),sparse(sumsq(af,2))) - %!assert(prod(as),sparse(prod(af))) - %!assert(prod(as,1),sparse(prod(af,1))) - %!assert(prod(as,2),sparse(prod(af,2))) - %!assert(cumprod(as),sparse(cumprod(af))) - %!assert(cumprod(as,1),sparse(cumprod(af,1))) - %!assert(cumprod(as,2),sparse(cumprod(af,2))) - - %!assert(min(as),sparse(min(af))) - %!assert(full(min(as(:))),min(af(:))) - %!assert(min(as,[],1),sparse(min(af,[],1))) - %!assert(min(as,[],2),sparse(min(af,[],2))) - %!assert(min(as,[],1),sparse(min(af,[],1))) - %!assert(min(as,0),sparse(min(af,0))) - %!assert(min(as,bs),sparse(min(af,bf))) - %!assert(max(as),sparse(max(af))) - %!assert(full(max(as(:))),max(af(:))) - %!assert(max(as,[],1),sparse(max(af,[],1))) - %!assert(max(as,[],2),sparse(max(af,[],2))) - %!assert(max(as,[],1),sparse(max(af,[],1))) - %!assert(max(as,0),sparse(max(af,0))) - %!assert(max(as,bs),sparse(max(af,bf))) - - %!assert(as==as) - %!assert(as==af) - %!assert(af==as) - %!test - %! [ii,jj,vv,nr,nc] = find(as); - %! assert(af,full(sparse(ii,jj,vv,nr,nc))); - %!assert(nnz(as),sum(af(:)!=0)) - %!assert(nnz(as),nnz(af)) - %!assert(issparse(as.')) - %!assert(issparse(as')) - %!assert(issparse(-as)) - %!assert(~as,sparse(~af)) - %!assert(as.', sparse(af.')); - %!assert(as', sparse(af')); - %!assert(-as, sparse(-af)); - %!assert(~as, sparse(~af)); - %!error [i,j]=size(af);as(i-1,j+1); - %!error [i,j]=size(af);as(i+1,j-1); - %!test - %! [Is,Js,Vs] = find(as); - %! [If,Jf,Vf] = find(af); - %! assert(Is,If); - %! assert(Js,Jf); - %! assert(Vs,Vf); - %!error as(0,1); - %!error as(1,0); - %!assert(find(as),find(af)) - %!test - %! [i,j,v] = find(as); - %! [m,n] = size(as); - %! x = sparse(i,j,v,m,n); - %! assert(x,as); - %!test - %! [i,j,v,m,n] = find(as); - %! x = sparse(i,j,v,m,n); - %! assert(x,as); - %!assert(issparse(horzcat(as,as))); - %!assert(issparse(vertcat(as,as))); - %!assert(issparse(cat(1,as,as))); - %!assert(issparse(cat(2,as,as))); - %!assert(issparse([as,as])); - %!assert(issparse([as;as])); - %!assert(horzcat(as,as), sparse([af,af])); - %!assert(vertcat(as,as), sparse([af;af])); - %!assert(horzcat(as,as,as), sparse([af,af,af])); - %!assert(vertcat(as,as,as), sparse([af;af;af])); - %!assert([as,as], sparse([af,af])); - %!assert([as;as], sparse([af;af])); - %!assert([as,as,as], sparse([af,af,af])); - %!assert([as;as;as], sparse([af;af;af])); - %!assert(cat(2,as,as), sparse([af,af])); - %!assert(cat(1,as,as), sparse([af;af])); - %!assert(cat(2,as,as,as), sparse([af,af,af])); - %!assert(cat(1,as,as,as), sparse([af;af;af])); - %!assert(issparse([as,af])); - %!assert(issparse([af,as])); - %!assert([as,af], sparse([af,af])); - %!assert([as;af], sparse([af;af])); - - %% Elementwise binary tests (uses as,af,bs,bf,scalar) - %!assert(as==bs,sparse(af==bf)) - %!assert(bf==as,sparse(bf==af)) - - %!assert(as!=bf,sparse(af!=bf)) - %!assert(bf!=as,sparse(bf!=af)) - - %!assert(as+bf,af+bf) - %!assert(bf+as,bf+af) - - %!assert(as-bf,af-bf) - %!assert(bf-as,bf-af) - - %!assert(as.*bf,sparse(af.*bf)) - %!assert(bf.*as,sparse(bf.*af)) - - %!assert(as./bf,sparse(af./bf),100*eps) - %!assert(bf.\as,sparse(bf.\af),100*eps) - - %!test - %! sv = as.^bf; - %! fv = af.^bf; - %! idx = find(af~=0); - %! assert(sv(:)(idx),sparse(fv(:)(idx)),100*eps) - - %!assert(as==bs,sparse(af==bf)) - %!assert(as!=bs,sparse(af!=bf)) - %!assert(as+bs,sparse(af+bf)) - %!assert(as-bs,sparse(af-bf)) - %!assert(as.*bs,sparse(af.*bf)) - %!xtest assert(as./bs,sparse(af./bf),100*eps); - %!test - %! sv = as.^bs; - %! fv = af.^bf; - %! idx = find(af~=0); - %! assert(sv(:)(idx),sparse(fv(:)(idx)),100*eps) - - %% Matrix-matrix operators (uses af,as,bs,bf) - %!assert(as*bf',af*bf') - %!assert(af*bs',af*bf') - %!assert(as*bs',sparse(af*bf')) - - %% Matrix diagonal tests (uses af,as,bf,bs) - %!assert(diag(as),sparse(diag(af))) - %!assert(diag(bs),sparse(diag(bf))) - %!assert(diag(as,1),sparse(diag(af,1))) - %!assert(diag(bs,1),sparse(diag(bf,1))) - %!assert(diag(as,-1),sparse(diag(af,-1))) - %!assert(diag(bs,-1),sparse(diag(bf,-1))) - %!assert(diag(as(:)),sparse(diag(af(:)))) - %!assert(diag(as(:),1),sparse(diag(af(:),1))) - %!assert(diag(as(:),-1),sparse(diag(af(:),-1))) - %!assert(diag(as(:)'),sparse(diag(af(:)'))) - %!assert(diag(as(:)',1),sparse(diag(af(:)',1))) - %!assert(diag(as(:)',-1),sparse(diag(af(:)',-1))) - %!assert(spdiags(as,[0,1]),[diag(af,0),diag(af,1)]) - %!test [tb,tc]=spdiags(as); - %! assert(spdiags(tb,tc,sparse(zeros(size(as)))),as) - %! assert(spdiags(tb,tc,size(as,1),size(as,2)),as) - - %% Matrix diagonal tests (uses af,as,bf,bs) - %!assert(reshape(as,1,prod(size(as))),sparse(reshape(af,1,prod(size(af))))) - %!assert(reshape(as,prod(size(as)),1),sparse(reshape(af,prod(size(af)),1))) - %!assert(reshape(as,fliplr(size(as))),sparse(reshape(af,fliplr(size(af))))) - %!assert(reshape(bs,1,prod(size(as))),sparse(reshape(bf,1,prod(size(af))))) - %!assert(reshape(bs,prod(size(as)),1),sparse(reshape(bf,prod(size(af)),1))) - %!assert(reshape(bs,fliplr(size(as))),sparse(reshape(bf,fliplr(size(af))))) - - %!testif HAVE_UMFPACK ;# permuted LU - %! [L,U] = lu(bs); - %! assert(L*U,bs,1e-10); - - %!testif HAVE_UMFPACK ;# simple LU + row permutations - %! [L,U,P] = lu(bs); - %! assert(P'*L*U,bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# simple LU + row/col permutations - %! [L,U,P,Q] = lu(bs); - %! assert(P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with vector permutations - %! [L,U,P,Q] = lu(bs,'vector'); - %! assert(L(P,:)*U(:,Q),bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with scaling - %! [L,U,P,Q,R] = lu(bs); - %! assert(R*P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - - # ============================================================== - - %!test # save ascii - %! savefile= tmpnam(); - %! as_save=as; save("-text",savefile,"bf","as_save","af"); - %! clear as_save; - %! load(savefile,"as_save"); - %! unlink(savefile); - %! assert(as_save,sparse(af)); - %!test # save binary - %! savefile= tmpnam(); - %! as_save=as; save("-binary",savefile,"bf","as_save","af"); - %! clear as_save; - %! load(savefile,"as_save"); - %! unlink(savefile); - %! assert(as_save,sparse(af)); - %!testif HAVE_HDF5 # save hdf5 - %! savefile= tmpnam(); - %! as_save=as; save("-hdf5",savefile,"bf","as_save","af"); - %! clear as_save; - %! load(savefile,"as_save"); - %! unlink(savefile); - %! assert(as_save,sparse(af)); - ## FIXME -- we should skip (or mark as an expected failure) the test for - ## saving sparse matrices to MAT files when using 64-bit indexing since - ## that is not implemented yet. - %!test # save matlab - %! savefile= tmpnam(); - %! as_save=as; save("-mat",savefile,"bf","as_save","af"); - %! clear as_save; - %! load(savefile,"as_save"); - %! unlink(savefile); - %! assert(as_save,sparse(af)); - - # ============================================================== - - %!test bf=real(bf); - %!test as=sparse(af); - %!test bs=sparse(bf); - %% Unary matrix tests (uses af,as) - %!assert(abs(as),sparse(abs(af))) - %!assert(acos(as),sparse(acos(af))) - %!assert(acosh(as),sparse(acosh(af))) - %!assert(angle(as),sparse(angle(af))) - %!assert(arg(as),sparse(arg(af))) - %!assert(asin(as),sparse(asin(af))) - %!assert(asinh(as),sparse(asinh(af))) - %!assert(atan(as),sparse(atan(af))) - %!assert(atanh(as),sparse(atanh(af))) - %!assert(ceil(as),sparse(ceil(af))) - %!assert(conj(as),sparse(conj(af))) - %!assert(cos(as),sparse(cos(af))) - %!assert(cosh(as),sparse(cosh(af))) - %!assert(exp(as),sparse(exp(af))) - %!assert(finite(as),sparse(finite(af))) - %!assert(fix(as),sparse(fix(af))) - %!assert(floor(as),sparse(floor(af))) - %!assert(imag(as),sparse(imag(af))) - %!assert(isinf(as),sparse(isinf(af))) - %!assert(isna(as),sparse(isna(af))) - %!assert(isnan(as),sparse(isnan(af))) - %!assert(log(as),sparse(log(af))) - %!assert(real(as),sparse(real(af))) - %!assert(round(as),sparse(round(af))) - %!assert(sign(as),sparse(sign(af))) - %!assert(sin(as),sparse(sin(af))) - %!assert(sinh(as),sparse(sinh(af))) - %!assert(sqrt(as),sparse(sqrt(af))) - %!assert(tan(as),sparse(tan(af))) - %!assert(tanh(as),sparse(tanh(af))) - %!assert(issparse(abs(as))&&isreal(abs(as))) - %!assert(issparse(real(as))&&isreal(real(as))) - %!assert(issparse(imag(as))&&isreal(imag(as))) - - %% Unary matrix tests (uses af,as) - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (1) - %! assert(erf(as),sparse(erf(af))) - %! else - %! assert(erf(as),erf(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (1) - %! assert(erfc(as),sparse(erfc(af))) - %! else - %! assert(erfc(as),erfc(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isalnum(as),sparse(isalnum(af))) - %! else - %! assert(isalnum(as),isalnum(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isalpha(as),sparse(isalpha(af))) - %! else - %! assert(isalpha(as),isalpha(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isascii(as),sparse(isascii(af))) - %! else - %! assert(isascii(as),isascii(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(iscntrl(as),sparse(iscntrl(af))) - %! else - %! assert(iscntrl(as),iscntrl(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isdigit(as),sparse(isdigit(af))) - %! else - %! assert(isdigit(as),isdigit(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isgraph(as),sparse(isgraph(af))) - %! else - %! assert(isgraph(as),isgraph(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(islower(as),sparse(islower(af))) - %! else - %! assert(islower(as),islower(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isprint(as),sparse(isprint(af))) - %! else - %! assert(isprint(as),isprint(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(ispunct(as),sparse(ispunct(af))) - %! else - %! assert(ispunct(as),ispunct(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isspace(as),sparse(isspace(af))) - %! else - %! assert(isspace(as),isspace(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isupper(as),sparse(isupper(af))) - %! else - %! assert(isupper(as),isupper(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isxdigit(as),sparse(isxdigit(af))) - %! else - %! assert(isxdigit(as),isxdigit(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - - %% These mapper functions always return a full matrix - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! assert(toascii(as),toascii(af)) - %! assert(tolower(as),tolower(af)) - %! assert(toupper(as),toupper(af)) - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %% Unary matrix tests (uses af,as) - %!assert(issparse(as)) - %!assert(!issparse(af)) - %!assert(!(issparse(af)&&iscomplex(af))) - %!assert(!(issparse(af)&&isreal(af))) - %!assert(sum(as),sparse(sum(af))) - %!assert(sum(as,1),sparse(sum(af,1))) - %!assert(sum(as,2),sparse(sum(af,2))) - %!assert(cumsum(as),sparse(cumsum(af))) - %!assert(cumsum(as,1),sparse(cumsum(af,1))) - %!assert(cumsum(as,2),sparse(cumsum(af,2))) - %!assert(sumsq(as),sparse(sumsq(af))) - %!assert(sumsq(as,1),sparse(sumsq(af,1))) - %!assert(sumsq(as,2),sparse(sumsq(af,2))) - %!assert(prod(as),sparse(prod(af))) - %!assert(prod(as,1),sparse(prod(af,1))) - %!assert(prod(as,2),sparse(prod(af,2))) - %!assert(cumprod(as),sparse(cumprod(af))) - %!assert(cumprod(as,1),sparse(cumprod(af,1))) - %!assert(cumprod(as,2),sparse(cumprod(af,2))) - - %!assert(min(as),sparse(min(af))) - %!assert(full(min(as(:))),min(af(:))) - %!assert(min(as,[],1),sparse(min(af,[],1))) - %!assert(min(as,[],2),sparse(min(af,[],2))) - %!assert(min(as,[],1),sparse(min(af,[],1))) - %!assert(min(as,0),sparse(min(af,0))) - %!assert(min(as,bs),sparse(min(af,bf))) - %!assert(max(as),sparse(max(af))) - %!assert(full(max(as(:))),max(af(:))) - %!assert(max(as,[],1),sparse(max(af,[],1))) - %!assert(max(as,[],2),sparse(max(af,[],2))) - %!assert(max(as,[],1),sparse(max(af,[],1))) - %!assert(max(as,0),sparse(max(af,0))) - %!assert(max(as,bs),sparse(max(af,bf))) - - %!assert(as==as) - %!assert(as==af) - %!assert(af==as) - %!test - %! [ii,jj,vv,nr,nc] = find(as); - %! assert(af,full(sparse(ii,jj,vv,nr,nc))); - %!assert(nnz(as),sum(af(:)!=0)) - %!assert(nnz(as),nnz(af)) - %!assert(issparse(as.')) - %!assert(issparse(as')) - %!assert(issparse(-as)) - %!assert(~as,sparse(~af)) - %!assert(as.', sparse(af.')); - %!assert(as', sparse(af')); - %!assert(-as, sparse(-af)); - %!assert(~as, sparse(~af)); - %!error [i,j]=size(af);as(i-1,j+1); - %!error [i,j]=size(af);as(i+1,j-1); - %!test - %! [Is,Js,Vs] = find(as); - %! [If,Jf,Vf] = find(af); - %! assert(Is,If); - %! assert(Js,Jf); - %! assert(Vs,Vf); - %!error as(0,1); - %!error as(1,0); - %!assert(find(as),find(af)) - %!test - %! [i,j,v] = find(as); - %! [m,n] = size(as); - %! x = sparse(i,j,v,m,n); - %! assert(x,as); - %!test - %! [i,j,v,m,n] = find(as); - %! x = sparse(i,j,v,m,n); - %! assert(x,as); - %!assert(issparse(horzcat(as,as))); - %!assert(issparse(vertcat(as,as))); - %!assert(issparse(cat(1,as,as))); - %!assert(issparse(cat(2,as,as))); - %!assert(issparse([as,as])); - %!assert(issparse([as;as])); - %!assert(horzcat(as,as), sparse([af,af])); - %!assert(vertcat(as,as), sparse([af;af])); - %!assert(horzcat(as,as,as), sparse([af,af,af])); - %!assert(vertcat(as,as,as), sparse([af;af;af])); - %!assert([as,as], sparse([af,af])); - %!assert([as;as], sparse([af;af])); - %!assert([as,as,as], sparse([af,af,af])); - %!assert([as;as;as], sparse([af;af;af])); - %!assert(cat(2,as,as), sparse([af,af])); - %!assert(cat(1,as,as), sparse([af;af])); - %!assert(cat(2,as,as,as), sparse([af,af,af])); - %!assert(cat(1,as,as,as), sparse([af;af;af])); - %!assert(issparse([as,af])); - %!assert(issparse([af,as])); - %!assert([as,af], sparse([af,af])); - %!assert([as;af], sparse([af;af])); - - %% Elementwise binary tests (uses as,af,bs,bf,scalar) - %!assert(as==bs,sparse(af==bf)) - %!assert(bf==as,sparse(bf==af)) - - %!assert(as!=bf,sparse(af!=bf)) - %!assert(bf!=as,sparse(bf!=af)) - - %!assert(as+bf,af+bf) - %!assert(bf+as,bf+af) - - %!assert(as-bf,af-bf) - %!assert(bf-as,bf-af) - - %!assert(as.*bf,sparse(af.*bf)) - %!assert(bf.*as,sparse(bf.*af)) - - %!assert(as./bf,sparse(af./bf),100*eps) - %!assert(bf.\as,sparse(bf.\af),100*eps) - - %!test - %! sv = as.^bf; - %! fv = af.^bf; - %! idx = find(af~=0); - %! assert(sv(:)(idx),sparse(fv(:)(idx)),100*eps) - - %!assert(as==bs,sparse(af==bf)) - %!assert(as!=bs,sparse(af!=bf)) - %!assert(as+bs,sparse(af+bf)) - %!assert(as-bs,sparse(af-bf)) - %!assert(as.*bs,sparse(af.*bf)) - %!xtest assert(as./bs,sparse(af./bf),100*eps); - %!test - %! sv = as.^bs; - %! fv = af.^bf; - %! idx = find(af~=0); - %! assert(sv(:)(idx),sparse(fv(:)(idx)),100*eps) - - %% Matrix-matrix operators (uses af,as,bs,bf) - %!assert(as*bf',af*bf') - %!assert(af*bs',af*bf') - %!assert(as*bs',sparse(af*bf')) - - %% Matrix diagonal tests (uses af,as,bf,bs) - %!assert(diag(as),sparse(diag(af))) - %!assert(diag(bs),sparse(diag(bf))) - %!assert(diag(as,1),sparse(diag(af,1))) - %!assert(diag(bs,1),sparse(diag(bf,1))) - %!assert(diag(as,-1),sparse(diag(af,-1))) - %!assert(diag(bs,-1),sparse(diag(bf,-1))) - %!assert(diag(as(:)),sparse(diag(af(:)))) - %!assert(diag(as(:),1),sparse(diag(af(:),1))) - %!assert(diag(as(:),-1),sparse(diag(af(:),-1))) - %!assert(diag(as(:)'),sparse(diag(af(:)'))) - %!assert(diag(as(:)',1),sparse(diag(af(:)',1))) - %!assert(diag(as(:)',-1),sparse(diag(af(:)',-1))) - %!assert(spdiags(as,[0,1]),[diag(af,0),diag(af,1)]) - %!test [tb,tc]=spdiags(as); - %! assert(spdiags(tb,tc,sparse(zeros(size(as)))),as) - %! assert(spdiags(tb,tc,size(as,1),size(as,2)),as) - - %% Matrix diagonal tests (uses af,as,bf,bs) - %!assert(reshape(as,1,prod(size(as))),sparse(reshape(af,1,prod(size(af))))) - %!assert(reshape(as,prod(size(as)),1),sparse(reshape(af,prod(size(af)),1))) - %!assert(reshape(as,fliplr(size(as))),sparse(reshape(af,fliplr(size(af))))) - %!assert(reshape(bs,1,prod(size(as))),sparse(reshape(bf,1,prod(size(af))))) - %!assert(reshape(bs,prod(size(as)),1),sparse(reshape(bf,prod(size(af)),1))) - %!assert(reshape(bs,fliplr(size(as))),sparse(reshape(bf,fliplr(size(af))))) - - %!testif HAVE_UMFPACK ;# permuted LU - %! [L,U] = lu(bs); - %! assert(L*U,bs,1e-10); - - %!testif HAVE_UMFPACK ;# simple LU + row permutations - %! [L,U,P] = lu(bs); - %! assert(P'*L*U,bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# simple LU + row/col permutations - %! [L,U,P,Q] = lu(bs); - %! assert(P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with vector permutations - %! [L,U,P,Q] = lu(bs,'vector'); - %! assert(L(P,:)*U(:,Q),bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with scaling - %! [L,U,P,Q,R] = lu(bs); - %! assert(R*P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - - # ============================================================== - - %!assert(as<=bs,sparse(af<=bf)) - %!assert(as>=bs,sparse(af>=bf)) - %!assert(asbs,sparse(af>bf)) - - # ============================================================== - - %!test af=real(af); - %!test as=sparse(af); - %!test bs=sparse(bf); - %% Unary matrix tests (uses af,as) - %!assert(abs(as),sparse(abs(af))) - %!assert(acos(as),sparse(acos(af))) - %!assert(acosh(as),sparse(acosh(af))) - %!assert(angle(as),sparse(angle(af))) - %!assert(arg(as),sparse(arg(af))) - %!assert(asin(as),sparse(asin(af))) - %!assert(asinh(as),sparse(asinh(af))) - %!assert(atan(as),sparse(atan(af))) - %!assert(atanh(as),sparse(atanh(af))) - %!assert(ceil(as),sparse(ceil(af))) - %!assert(conj(as),sparse(conj(af))) - %!assert(cos(as),sparse(cos(af))) - %!assert(cosh(as),sparse(cosh(af))) - %!assert(exp(as),sparse(exp(af))) - %!assert(finite(as),sparse(finite(af))) - %!assert(fix(as),sparse(fix(af))) - %!assert(floor(as),sparse(floor(af))) - %!assert(imag(as),sparse(imag(af))) - %!assert(isinf(as),sparse(isinf(af))) - %!assert(isna(as),sparse(isna(af))) - %!assert(isnan(as),sparse(isnan(af))) - %!assert(log(as),sparse(log(af))) - %!assert(real(as),sparse(real(af))) - %!assert(round(as),sparse(round(af))) - %!assert(sign(as),sparse(sign(af))) - %!assert(sin(as),sparse(sin(af))) - %!assert(sinh(as),sparse(sinh(af))) - %!assert(sqrt(as),sparse(sqrt(af))) - %!assert(tan(as),sparse(tan(af))) - %!assert(tanh(as),sparse(tanh(af))) - %!assert(issparse(abs(as))&&isreal(abs(as))) - %!assert(issparse(real(as))&&isreal(real(as))) - %!assert(issparse(imag(as))&&isreal(imag(as))) - - %% Unary matrix tests (uses af,as) - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (1) - %! assert(erf(as),sparse(erf(af))) - %! else - %! assert(erf(as),erf(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (1) - %! assert(erfc(as),sparse(erfc(af))) - %! else - %! assert(erfc(as),erfc(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isalnum(as),sparse(isalnum(af))) - %! else - %! assert(isalnum(as),isalnum(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isalpha(as),sparse(isalpha(af))) - %! else - %! assert(isalpha(as),isalpha(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isascii(as),sparse(isascii(af))) - %! else - %! assert(isascii(as),isascii(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(iscntrl(as),sparse(iscntrl(af))) - %! else - %! assert(iscntrl(as),iscntrl(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isdigit(as),sparse(isdigit(af))) - %! else - %! assert(isdigit(as),isdigit(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isgraph(as),sparse(isgraph(af))) - %! else - %! assert(isgraph(as),isgraph(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(islower(as),sparse(islower(af))) - %! else - %! assert(islower(as),islower(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isprint(as),sparse(isprint(af))) - %! else - %! assert(isprint(as),isprint(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(ispunct(as),sparse(ispunct(af))) - %! else - %! assert(ispunct(as),ispunct(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isspace(as),sparse(isspace(af))) - %! else - %! assert(isspace(as),isspace(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isupper(as),sparse(isupper(af))) - %! else - %! assert(isupper(as),isupper(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isxdigit(as),sparse(isxdigit(af))) - %! else - %! assert(isxdigit(as),isxdigit(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - - %% These mapper functions always return a full matrix - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! assert(toascii(as),toascii(af)) - %! assert(tolower(as),tolower(af)) - %! assert(toupper(as),toupper(af)) - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %% Unary matrix tests (uses af,as) - %!assert(issparse(as)) - %!assert(!issparse(af)) - %!assert(!(issparse(af)&&iscomplex(af))) - %!assert(!(issparse(af)&&isreal(af))) - %!assert(sum(as),sparse(sum(af))) - %!assert(sum(as,1),sparse(sum(af,1))) - %!assert(sum(as,2),sparse(sum(af,2))) - %!assert(cumsum(as),sparse(cumsum(af))) - %!assert(cumsum(as,1),sparse(cumsum(af,1))) - %!assert(cumsum(as,2),sparse(cumsum(af,2))) - %!assert(sumsq(as),sparse(sumsq(af))) - %!assert(sumsq(as,1),sparse(sumsq(af,1))) - %!assert(sumsq(as,2),sparse(sumsq(af,2))) - %!assert(prod(as),sparse(prod(af))) - %!assert(prod(as,1),sparse(prod(af,1))) - %!assert(prod(as,2),sparse(prod(af,2))) - %!assert(cumprod(as),sparse(cumprod(af))) - %!assert(cumprod(as,1),sparse(cumprod(af,1))) - %!assert(cumprod(as,2),sparse(cumprod(af,2))) - - %!assert(min(as),sparse(min(af))) - %!assert(full(min(as(:))),min(af(:))) - %!assert(min(as,[],1),sparse(min(af,[],1))) - %!assert(min(as,[],2),sparse(min(af,[],2))) - %!assert(min(as,[],1),sparse(min(af,[],1))) - %!assert(min(as,0),sparse(min(af,0))) - %!assert(min(as,bs),sparse(min(af,bf))) - %!assert(max(as),sparse(max(af))) - %!assert(full(max(as(:))),max(af(:))) - %!assert(max(as,[],1),sparse(max(af,[],1))) - %!assert(max(as,[],2),sparse(max(af,[],2))) - %!assert(max(as,[],1),sparse(max(af,[],1))) - %!assert(max(as,0),sparse(max(af,0))) - %!assert(max(as,bs),sparse(max(af,bf))) - - %!assert(as==as) - %!assert(as==af) - %!assert(af==as) - %!test - %! [ii,jj,vv,nr,nc] = find(as); - %! assert(af,full(sparse(ii,jj,vv,nr,nc))); - %!assert(nnz(as),sum(af(:)!=0)) - %!assert(nnz(as),nnz(af)) - %!assert(issparse(as.')) - %!assert(issparse(as')) - %!assert(issparse(-as)) - %!assert(~as,sparse(~af)) - %!assert(as.', sparse(af.')); - %!assert(as', sparse(af')); - %!assert(-as, sparse(-af)); - %!assert(~as, sparse(~af)); - %!error [i,j]=size(af);as(i-1,j+1); - %!error [i,j]=size(af);as(i+1,j-1); - %!test - %! [Is,Js,Vs] = find(as); - %! [If,Jf,Vf] = find(af); - %! assert(Is,If); - %! assert(Js,Jf); - %! assert(Vs,Vf); - %!error as(0,1); - %!error as(1,0); - %!assert(find(as),find(af)) - %!test - %! [i,j,v] = find(as); - %! [m,n] = size(as); - %! x = sparse(i,j,v,m,n); - %! assert(x,as); - %!test - %! [i,j,v,m,n] = find(as); - %! x = sparse(i,j,v,m,n); - %! assert(x,as); - %!assert(issparse(horzcat(as,as))); - %!assert(issparse(vertcat(as,as))); - %!assert(issparse(cat(1,as,as))); - %!assert(issparse(cat(2,as,as))); - %!assert(issparse([as,as])); - %!assert(issparse([as;as])); - %!assert(horzcat(as,as), sparse([af,af])); - %!assert(vertcat(as,as), sparse([af;af])); - %!assert(horzcat(as,as,as), sparse([af,af,af])); - %!assert(vertcat(as,as,as), sparse([af;af;af])); - %!assert([as,as], sparse([af,af])); - %!assert([as;as], sparse([af;af])); - %!assert([as,as,as], sparse([af,af,af])); - %!assert([as;as;as], sparse([af;af;af])); - %!assert(cat(2,as,as), sparse([af,af])); - %!assert(cat(1,as,as), sparse([af;af])); - %!assert(cat(2,as,as,as), sparse([af,af,af])); - %!assert(cat(1,as,as,as), sparse([af;af;af])); - %!assert(issparse([as,af])); - %!assert(issparse([af,as])); - %!assert([as,af], sparse([af,af])); - %!assert([as;af], sparse([af;af])); - - %% Elementwise binary tests (uses as,af,bs,bf,scalar) - %!assert(as==bs,sparse(af==bf)) - %!assert(bf==as,sparse(bf==af)) - - %!assert(as!=bf,sparse(af!=bf)) - %!assert(bf!=as,sparse(bf!=af)) - - %!assert(as+bf,af+bf) - %!assert(bf+as,bf+af) - - %!assert(as-bf,af-bf) - %!assert(bf-as,bf-af) - - %!assert(as.*bf,sparse(af.*bf)) - %!assert(bf.*as,sparse(bf.*af)) - - %!assert(as./bf,sparse(af./bf),100*eps) - %!assert(bf.\as,sparse(bf.\af),100*eps) - - %!test - %! sv = as.^bf; - %! fv = af.^bf; - %! idx = find(af~=0); - %! assert(sv(:)(idx),sparse(fv(:)(idx)),100*eps) - - %!assert(as==bs,sparse(af==bf)) - %!assert(as!=bs,sparse(af!=bf)) - %!assert(as+bs,sparse(af+bf)) - %!assert(as-bs,sparse(af-bf)) - %!assert(as.*bs,sparse(af.*bf)) - %!xtest assert(as./bs,sparse(af./bf),100*eps); - %!test - %! sv = as.^bs; - %! fv = af.^bf; - %! idx = find(af~=0); - %! assert(sv(:)(idx),sparse(fv(:)(idx)),100*eps) - - %% Matrix-matrix operators (uses af,as,bs,bf) - %!assert(as*bf',af*bf') - %!assert(af*bs',af*bf') - %!assert(as*bs',sparse(af*bf')) - - %% Matrix diagonal tests (uses af,as,bf,bs) - %!assert(diag(as),sparse(diag(af))) - %!assert(diag(bs),sparse(diag(bf))) - %!assert(diag(as,1),sparse(diag(af,1))) - %!assert(diag(bs,1),sparse(diag(bf,1))) - %!assert(diag(as,-1),sparse(diag(af,-1))) - %!assert(diag(bs,-1),sparse(diag(bf,-1))) - %!assert(diag(as(:)),sparse(diag(af(:)))) - %!assert(diag(as(:),1),sparse(diag(af(:),1))) - %!assert(diag(as(:),-1),sparse(diag(af(:),-1))) - %!assert(diag(as(:)'),sparse(diag(af(:)'))) - %!assert(diag(as(:)',1),sparse(diag(af(:)',1))) - %!assert(diag(as(:)',-1),sparse(diag(af(:)',-1))) - %!assert(spdiags(as,[0,1]),[diag(af,0),diag(af,1)]) - %!test [tb,tc]=spdiags(as); - %! assert(spdiags(tb,tc,sparse(zeros(size(as)))),as) - %! assert(spdiags(tb,tc,size(as,1),size(as,2)),as) - - %% Matrix diagonal tests (uses af,as,bf,bs) - %!assert(reshape(as,1,prod(size(as))),sparse(reshape(af,1,prod(size(af))))) - %!assert(reshape(as,prod(size(as)),1),sparse(reshape(af,prod(size(af)),1))) - %!assert(reshape(as,fliplr(size(as))),sparse(reshape(af,fliplr(size(af))))) - %!assert(reshape(bs,1,prod(size(as))),sparse(reshape(bf,1,prod(size(af))))) - %!assert(reshape(bs,prod(size(as)),1),sparse(reshape(bf,prod(size(af)),1))) - %!assert(reshape(bs,fliplr(size(as))),sparse(reshape(bf,fliplr(size(af))))) - - %!testif HAVE_UMFPACK ;# permuted LU - %! [L,U] = lu(bs); - %! assert(L*U,bs,1e-10); - - %!testif HAVE_UMFPACK ;# simple LU + row permutations - %! [L,U,P] = lu(bs); - %! assert(P'*L*U,bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# simple LU + row/col permutations - %! [L,U,P,Q] = lu(bs); - %! assert(P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with vector permutations - %! [L,U,P,Q] = lu(bs,'vector'); - %! assert(L(P,:)*U(:,Q),bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with scaling - %! [L,U,P,Q,R] = lu(bs); - %! assert(R*P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - - # ============================================================== - - %!test # save ascii - %! savefile= tmpnam(); - %! as_save=as; save("-text",savefile,"bf","as_save","af"); - %! clear as_save; - %! load(savefile,"as_save"); - %! unlink(savefile); - %! assert(as_save,sparse(af)); - %!test # save binary - %! savefile= tmpnam(); - %! as_save=as; save("-binary",savefile,"bf","as_save","af"); - %! clear as_save; - %! load(savefile,"as_save"); - %! unlink(savefile); - %! assert(as_save,sparse(af)); - %!testif HAVE_HDF5 # save hdf5 - %! savefile= tmpnam(); - %! as_save=as; save("-hdf5",savefile,"bf","as_save","af"); - %! clear as_save; - %! load(savefile,"as_save"); - %! unlink(savefile); - %! assert(as_save,sparse(af)); - ## FIXME -- we should skip (or mark as an expected failure) the test for - ## saving sparse matrices to MAT files when using 64-bit indexing since - ## that is not implemented yet. - %!test # save matlab - %! savefile= tmpnam(); - %! as_save=as; save("-mat",savefile,"bf","as_save","af"); - %! clear as_save; - %! load(savefile,"as_save"); - %! unlink(savefile); - %! assert(as_save,sparse(af)); - - # ============================================================== - - %!test bf=bf+1i*(bf~=0); - %!test as=sparse(af); - %!test bs=sparse(bf); - %% Unary matrix tests (uses af,as) - %!assert(abs(as),sparse(abs(af))) - %!assert(acos(as),sparse(acos(af))) - %!assert(acosh(as),sparse(acosh(af))) - %!assert(angle(as),sparse(angle(af))) - %!assert(arg(as),sparse(arg(af))) - %!assert(asin(as),sparse(asin(af))) - %!assert(asinh(as),sparse(asinh(af))) - %!assert(atan(as),sparse(atan(af))) - %!assert(atanh(as),sparse(atanh(af))) - %!assert(ceil(as),sparse(ceil(af))) - %!assert(conj(as),sparse(conj(af))) - %!assert(cos(as),sparse(cos(af))) - %!assert(cosh(as),sparse(cosh(af))) - %!assert(exp(as),sparse(exp(af))) - %!assert(finite(as),sparse(finite(af))) - %!assert(fix(as),sparse(fix(af))) - %!assert(floor(as),sparse(floor(af))) - %!assert(imag(as),sparse(imag(af))) - %!assert(isinf(as),sparse(isinf(af))) - %!assert(isna(as),sparse(isna(af))) - %!assert(isnan(as),sparse(isnan(af))) - %!assert(log(as),sparse(log(af))) - %!assert(real(as),sparse(real(af))) - %!assert(round(as),sparse(round(af))) - %!assert(sign(as),sparse(sign(af))) - %!assert(sin(as),sparse(sin(af))) - %!assert(sinh(as),sparse(sinh(af))) - %!assert(sqrt(as),sparse(sqrt(af))) - %!assert(tan(as),sparse(tan(af))) - %!assert(tanh(as),sparse(tanh(af))) - %!assert(issparse(abs(as))&&isreal(abs(as))) - %!assert(issparse(real(as))&&isreal(real(as))) - %!assert(issparse(imag(as))&&isreal(imag(as))) - - %% Unary matrix tests (uses af,as) - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (1) - %! assert(erf(as),sparse(erf(af))) - %! else - %! assert(erf(as),erf(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (1) - %! assert(erfc(as),sparse(erfc(af))) - %! else - %! assert(erfc(as),erfc(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isalnum(as),sparse(isalnum(af))) - %! else - %! assert(isalnum(as),isalnum(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isalpha(as),sparse(isalpha(af))) - %! else - %! assert(isalpha(as),isalpha(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isascii(as),sparse(isascii(af))) - %! else - %! assert(isascii(as),isascii(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(iscntrl(as),sparse(iscntrl(af))) - %! else - %! assert(iscntrl(as),iscntrl(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isdigit(as),sparse(isdigit(af))) - %! else - %! assert(isdigit(as),isdigit(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isgraph(as),sparse(isgraph(af))) - %! else - %! assert(isgraph(as),isgraph(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(islower(as),sparse(islower(af))) - %! else - %! assert(islower(as),islower(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isprint(as),sparse(isprint(af))) - %! else - %! assert(isprint(as),isprint(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(ispunct(as),sparse(ispunct(af))) - %! else - %! assert(ispunct(as),ispunct(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isspace(as),sparse(isspace(af))) - %! else - %! assert(isspace(as),isspace(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isupper(as),sparse(isupper(af))) - %! else - %! assert(isupper(as),isupper(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! if (0) - %! assert(isxdigit(as),sparse(isxdigit(af))) - %! else - %! assert(isxdigit(as),isxdigit(af)) - %! endif - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - - %% These mapper functions always return a full matrix - %!test - %! wn2s = warning ("query", "Octave:num-to-str"); - %! warning ("off", "Octave:num-to-str"); - %! if isreal(af) - %! assert(toascii(as),toascii(af)) - %! assert(tolower(as),tolower(af)) - %! assert(toupper(as),toupper(af)) - %! endif - %! warning (wn2s.state, "Octave:num-to-str"); - - %% Unary matrix tests (uses af,as) - %!assert(issparse(as)) - %!assert(!issparse(af)) - %!assert(!(issparse(af)&&iscomplex(af))) - %!assert(!(issparse(af)&&isreal(af))) - %!assert(sum(as),sparse(sum(af))) - %!assert(sum(as,1),sparse(sum(af,1))) - %!assert(sum(as,2),sparse(sum(af,2))) - %!assert(cumsum(as),sparse(cumsum(af))) - %!assert(cumsum(as,1),sparse(cumsum(af,1))) - %!assert(cumsum(as,2),sparse(cumsum(af,2))) - %!assert(sumsq(as),sparse(sumsq(af))) - %!assert(sumsq(as,1),sparse(sumsq(af,1))) - %!assert(sumsq(as,2),sparse(sumsq(af,2))) - %!assert(prod(as),sparse(prod(af))) - %!assert(prod(as,1),sparse(prod(af,1))) - %!assert(prod(as,2),sparse(prod(af,2))) - %!assert(cumprod(as),sparse(cumprod(af))) - %!assert(cumprod(as,1),sparse(cumprod(af,1))) - %!assert(cumprod(as,2),sparse(cumprod(af,2))) - - %!assert(min(as),sparse(min(af))) - %!assert(full(min(as(:))),min(af(:))) - %!assert(min(as,[],1),sparse(min(af,[],1))) - %!assert(min(as,[],2),sparse(min(af,[],2))) - %!assert(min(as,[],1),sparse(min(af,[],1))) - %!assert(min(as,0),sparse(min(af,0))) - %!assert(min(as,bs),sparse(min(af,bf))) - %!assert(max(as),sparse(max(af))) - %!assert(full(max(as(:))),max(af(:))) - %!assert(max(as,[],1),sparse(max(af,[],1))) - %!assert(max(as,[],2),sparse(max(af,[],2))) - %!assert(max(as,[],1),sparse(max(af,[],1))) - %!assert(max(as,0),sparse(max(af,0))) - %!assert(max(as,bs),sparse(max(af,bf))) - - %!assert(as==as) - %!assert(as==af) - %!assert(af==as) - %!test - %! [ii,jj,vv,nr,nc] = find(as); - %! assert(af,full(sparse(ii,jj,vv,nr,nc))); - %!assert(nnz(as),sum(af(:)!=0)) - %!assert(nnz(as),nnz(af)) - %!assert(issparse(as.')) - %!assert(issparse(as')) - %!assert(issparse(-as)) - %!assert(~as,sparse(~af)) - %!assert(as.', sparse(af.')); - %!assert(as', sparse(af')); - %!assert(-as, sparse(-af)); - %!assert(~as, sparse(~af)); - %!error [i,j]=size(af);as(i-1,j+1); - %!error [i,j]=size(af);as(i+1,j-1); - %!test - %! [Is,Js,Vs] = find(as); - %! [If,Jf,Vf] = find(af); - %! assert(Is,If); - %! assert(Js,Jf); - %! assert(Vs,Vf); - %!error as(0,1); - %!error as(1,0); - %!assert(find(as),find(af)) - %!test - %! [i,j,v] = find(as); - %! [m,n] = size(as); - %! x = sparse(i,j,v,m,n); - %! assert(x,as); - %!test - %! [i,j,v,m,n] = find(as); - %! x = sparse(i,j,v,m,n); - %! assert(x,as); - %!assert(issparse(horzcat(as,as))); - %!assert(issparse(vertcat(as,as))); - %!assert(issparse(cat(1,as,as))); - %!assert(issparse(cat(2,as,as))); - %!assert(issparse([as,as])); - %!assert(issparse([as;as])); - %!assert(horzcat(as,as), sparse([af,af])); - %!assert(vertcat(as,as), sparse([af;af])); - %!assert(horzcat(as,as,as), sparse([af,af,af])); - %!assert(vertcat(as,as,as), sparse([af;af;af])); - %!assert([as,as], sparse([af,af])); - %!assert([as;as], sparse([af;af])); - %!assert([as,as,as], sparse([af,af,af])); - %!assert([as;as;as], sparse([af;af;af])); - %!assert(cat(2,as,as), sparse([af,af])); - %!assert(cat(1,as,as), sparse([af;af])); - %!assert(cat(2,as,as,as), sparse([af,af,af])); - %!assert(cat(1,as,as,as), sparse([af;af;af])); - %!assert(issparse([as,af])); - %!assert(issparse([af,as])); - %!assert([as,af], sparse([af,af])); - %!assert([as;af], sparse([af;af])); - - %% Elementwise binary tests (uses as,af,bs,bf,scalar) - %!assert(as==bs,sparse(af==bf)) - %!assert(bf==as,sparse(bf==af)) - - %!assert(as!=bf,sparse(af!=bf)) - %!assert(bf!=as,sparse(bf!=af)) - - %!assert(as+bf,af+bf) - %!assert(bf+as,bf+af) - - %!assert(as-bf,af-bf) - %!assert(bf-as,bf-af) - - %!assert(as.*bf,sparse(af.*bf)) - %!assert(bf.*as,sparse(bf.*af)) - - %!assert(as./bf,sparse(af./bf),100*eps) - %!assert(bf.\as,sparse(bf.\af),100*eps) - - %!test - %! sv = as.^bf; - %! fv = af.^bf; - %! idx = find(af~=0); - %! assert(sv(:)(idx),sparse(fv(:)(idx)),100*eps) - - %!assert(as==bs,sparse(af==bf)) - %!assert(as!=bs,sparse(af!=bf)) - %!assert(as+bs,sparse(af+bf)) - %!assert(as-bs,sparse(af-bf)) - %!assert(as.*bs,sparse(af.*bf)) - %!xtest assert(as./bs,sparse(af./bf),100*eps); - %!test - %! sv = as.^bs; - %! fv = af.^bf; - %! idx = find(af~=0); - %! assert(sv(:)(idx),sparse(fv(:)(idx)),100*eps) - - %% Matrix-matrix operators (uses af,as,bs,bf) - %!assert(as*bf',af*bf') - %!assert(af*bs',af*bf') - %!assert(as*bs',sparse(af*bf')) - - %% Matrix diagonal tests (uses af,as,bf,bs) - %!assert(diag(as),sparse(diag(af))) - %!assert(diag(bs),sparse(diag(bf))) - %!assert(diag(as,1),sparse(diag(af,1))) - %!assert(diag(bs,1),sparse(diag(bf,1))) - %!assert(diag(as,-1),sparse(diag(af,-1))) - %!assert(diag(bs,-1),sparse(diag(bf,-1))) - %!assert(diag(as(:)),sparse(diag(af(:)))) - %!assert(diag(as(:),1),sparse(diag(af(:),1))) - %!assert(diag(as(:),-1),sparse(diag(af(:),-1))) - %!assert(diag(as(:)'),sparse(diag(af(:)'))) - %!assert(diag(as(:)',1),sparse(diag(af(:)',1))) - %!assert(diag(as(:)',-1),sparse(diag(af(:)',-1))) - %!assert(spdiags(as,[0,1]),[diag(af,0),diag(af,1)]) - %!test [tb,tc]=spdiags(as); - %! assert(spdiags(tb,tc,sparse(zeros(size(as)))),as) - %! assert(spdiags(tb,tc,size(as,1),size(as,2)),as) - - %% Matrix diagonal tests (uses af,as,bf,bs) - %!assert(reshape(as,1,prod(size(as))),sparse(reshape(af,1,prod(size(af))))) - %!assert(reshape(as,prod(size(as)),1),sparse(reshape(af,prod(size(af)),1))) - %!assert(reshape(as,fliplr(size(as))),sparse(reshape(af,fliplr(size(af))))) - %!assert(reshape(bs,1,prod(size(as))),sparse(reshape(bf,1,prod(size(af))))) - %!assert(reshape(bs,prod(size(as)),1),sparse(reshape(bf,prod(size(af)),1))) - %!assert(reshape(bs,fliplr(size(as))),sparse(reshape(bf,fliplr(size(af))))) - - %!testif HAVE_UMFPACK ;# permuted LU - %! [L,U] = lu(bs); - %! assert(L*U,bs,1e-10); - - %!testif HAVE_UMFPACK ;# simple LU + row permutations - %! [L,U,P] = lu(bs); - %! assert(P'*L*U,bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# simple LU + row/col permutations - %! [L,U,P,Q] = lu(bs); - %! assert(P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with vector permutations - %! [L,U,P,Q] = lu(bs,'vector'); - %! assert(L(P,:)*U(:,Q),bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with scaling - %! [L,U,P,Q,R] = lu(bs); - %! assert(R*P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - - # ============================================================== - - %!test af=[1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4]; - %! as=sparse(af); - %!test bf=[0,1-1i,0,0;2+1i,0,0,0;3-1i,2+3i,0,0]; - %!test ;# invertible matrix - %! bf=af'*bf+max(abs([af(:);bf(:)]))*sparse(eye(columns(as))); - %! bs=sparse(bf); - - %% Matrix-matrix operators (uses af,as,bs,bf) - %!assert(as/bf,af/bf,100*eps) - %!assert(af/bs,af/bf,100*eps) - %!assert(as/bs,sparse(af/bf),100*eps) - %!assert(bs\af',bf\af',100*eps) - %!assert(bf\as',bf\af',100*eps) - %!assert(bs\as',sparse(bf\af'),100*eps) - - %!testif HAVE_UMFPACK - %! assert(det(bs+speye(size(bs))),det(bf+eye(size(bf))),100*eps*abs(det(bf+eye(size(bf))))) - - %!testif HAVE_UMFPACK - %! [l,u]=lu(sparse([1,1;1,1])); - %! assert(l*u,[1,1;1,1],10*eps); - - %!testif HAVE_UMFPACK - %! [l,u]=lu(sparse([1,1;1,1+i])); - %! assert(l,sparse([1,2,2],[1,1,2],1),10*eps); - %! assert(u,sparse([1,1,2],[1,2,2],[1,1,1i]),10*eps); - - %!testif HAVE_UMFPACK ;# permuted LU - %! [L,U] = lu(bs); - %! assert(L*U,bs,1e-10); - - %!testif HAVE_UMFPACK ;# simple LU + row permutations - %! [L,U,P] = lu(bs); - %! assert(P'*L*U,bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# simple LU + row/col permutations - %! [L,U,P,Q] = lu(bs); - %! assert(P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with vector permutations - %! [L,U,P,Q] = lu(bs,'vector'); - %! assert(L(P,:)*U(:,Q),bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with scaling - %! [L,U,P,Q,R] = lu(bs); - %! assert(R*P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# inverse - %! assert(inv(bs)*bs,sparse(eye(rows(bs))),1e-10); - - %!assert(bf\as',bf\af',100*eps); - %!assert(bs\af',bf\af',100*eps); - %!assert(bs\as',sparse(bf\af'),100*eps); - - - # ============================================================== - - %!test bf=real(bf); - %! bs=sparse(bf); - %% Matrix-matrix operators (uses af,as,bs,bf) - %!assert(as/bf,af/bf,100*eps) - %!assert(af/bs,af/bf,100*eps) - %!assert(as/bs,sparse(af/bf),100*eps) - %!assert(bs\af',bf\af',100*eps) - %!assert(bf\as',bf\af',100*eps) - %!assert(bs\as',sparse(bf\af'),100*eps) - - %!testif HAVE_UMFPACK - %! assert(det(bs+speye(size(bs))),det(bf+eye(size(bf))),100*eps*abs(det(bf+eye(size(bf))))) - - %!testif HAVE_UMFPACK - %! [l,u]=lu(sparse([1,1;1,1])); - %! assert(l*u,[1,1;1,1],10*eps); - - %!testif HAVE_UMFPACK - %! [l,u]=lu(sparse([1,1;1,1+i])); - %! assert(l,sparse([1,2,2],[1,1,2],1),10*eps); - %! assert(u,sparse([1,1,2],[1,2,2],[1,1,1i]),10*eps); - - %!testif HAVE_UMFPACK ;# permuted LU - %! [L,U] = lu(bs); - %! assert(L*U,bs,1e-10); - - %!testif HAVE_UMFPACK ;# simple LU + row permutations - %! [L,U,P] = lu(bs); - %! assert(P'*L*U,bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# simple LU + row/col permutations - %! [L,U,P,Q] = lu(bs); - %! assert(P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with vector permutations - %! [L,U,P,Q] = lu(bs,'vector'); - %! assert(L(P,:)*U(:,Q),bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with scaling - %! [L,U,P,Q,R] = lu(bs); - %! assert(R*P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# inverse - %! assert(inv(bs)*bs,sparse(eye(rows(bs))),1e-10); - - %!assert(bf\as',bf\af',100*eps); - %!assert(bs\af',bf\af',100*eps); - %!assert(bs\as',sparse(bf\af'),100*eps); - - - # ============================================================== - - %!test af=real(af); - %! as=sparse(af); - %% Matrix-matrix operators (uses af,as,bs,bf) - %!assert(as/bf,af/bf,100*eps) - %!assert(af/bs,af/bf,100*eps) - %!assert(as/bs,sparse(af/bf),100*eps) - %!assert(bs\af',bf\af',100*eps) - %!assert(bf\as',bf\af',100*eps) - %!assert(bs\as',sparse(bf\af'),100*eps) - - %!testif HAVE_UMFPACK - %! assert(det(bs+speye(size(bs))),det(bf+eye(size(bf))),100*eps*abs(det(bf+eye(size(bf))))) - - %!testif HAVE_UMFPACK - %! [l,u]=lu(sparse([1,1;1,1])); - %! assert(l*u,[1,1;1,1],10*eps); - - %!testif HAVE_UMFPACK - %! [l,u]=lu(sparse([1,1;1,1+i])); - %! assert(l,sparse([1,2,2],[1,1,2],1),10*eps); - %! assert(u,sparse([1,1,2],[1,2,2],[1,1,1i]),10*eps); - - %!testif HAVE_UMFPACK ;# permuted LU - %! [L,U] = lu(bs); - %! assert(L*U,bs,1e-10); - - %!testif HAVE_UMFPACK ;# simple LU + row permutations - %! [L,U,P] = lu(bs); - %! assert(P'*L*U,bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# simple LU + row/col permutations - %! [L,U,P,Q] = lu(bs); - %! assert(P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with vector permutations - %! [L,U,P,Q] = lu(bs,'vector'); - %! assert(L(P,:)*U(:,Q),bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with scaling - %! [L,U,P,Q,R] = lu(bs); - %! assert(R*P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# inverse - %! assert(inv(bs)*bs,sparse(eye(rows(bs))),1e-10); - - %!assert(bf\as',bf\af',100*eps); - %!assert(bs\af',bf\af',100*eps); - %!assert(bs\as',sparse(bf\af'),100*eps); - - - # ============================================================== - - %!test bf=bf+1i*(bf~=0); - %! bs=sparse(bf); - %% Matrix-matrix operators (uses af,as,bs,bf) - %!assert(as/bf,af/bf,100*eps) - %!assert(af/bs,af/bf,100*eps) - %!assert(as/bs,sparse(af/bf),100*eps) - %!assert(bs\af',bf\af',100*eps) - %!assert(bf\as',bf\af',100*eps) - %!assert(bs\as',sparse(bf\af'),100*eps) - - %!testif HAVE_UMFPACK - %! assert(det(bs+speye(size(bs))),det(bf+eye(size(bf))),100*eps*abs(det(bf+eye(size(bf))))) - - %!testif HAVE_UMFPACK - %! [l,u]=lu(sparse([1,1;1,1])); - %! assert(l*u,[1,1;1,1],10*eps); - - %!testif HAVE_UMFPACK - %! [l,u]=lu(sparse([1,1;1,1+i])); - %! assert(l,sparse([1,2,2],[1,1,2],1),10*eps); - %! assert(u,sparse([1,1,2],[1,2,2],[1,1,1i]),10*eps); - - %!testif HAVE_UMFPACK ;# permuted LU - %! [L,U] = lu(bs); - %! assert(L*U,bs,1e-10); - - %!testif HAVE_UMFPACK ;# simple LU + row permutations - %! [L,U,P] = lu(bs); - %! assert(P'*L*U,bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# simple LU + row/col permutations - %! [L,U,P,Q] = lu(bs); - %! assert(P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with vector permutations - %! [L,U,P,Q] = lu(bs,'vector'); - %! assert(L(P,:)*U(:,Q),bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# LU with scaling - %! [L,U,P,Q,R] = lu(bs); - %! assert(R*P'*L*U*Q',bs,1e-10); - %! # triangularity - %! [i,j,v]=find(L); - %! assert(i-j>=0); - %! [i,j,v]=find(U); - %! assert(j-i>=0); - - %!testif HAVE_UMFPACK ;# inverse - %! assert(inv(bs)*bs,sparse(eye(rows(bs))),1e-10); - - %!assert(bf\as',bf\af',100*eps); - %!assert(bs\af',bf\af',100*eps); - %!assert(bs\as',sparse(bf\af'),100*eps); - - - # ============================================================== - - %!test bf=[5,0,1+1i,0;0,5,0,1-2i;1-1i,0,5,0;0,1+2i,0,5]; - %! bs=sparse(bf); - %!testif HAVE_CHOLMOD - %! assert(chol(bs)'*chol(bs),bs,1e-10); - %!testif HAVE_CHOLMOD - %! assert(chol(bs,'lower')*chol(bs,'lower')',bs,1e-10); - %!testif HAVE_CHOLMOD - %! assert(chol(bs,'lower'),chol(bs)',1e-10); - - %!testif HAVE_CHOLMOD ;# Return Partial Cholesky factorization - %! [RS,PS] = chol(bs); - %! assert(RS'*RS,bs,1e-10); - %! assert(PS,0); - %! [LS,PS] = chol(bs,'lower'); - %! assert(LS*LS',bs,1e-10); - %! assert(PS,0); - - %!testif HAVE_CHOLMOD ;# Permuted Cholesky factorization - %! [RS,PS,QS] = chol(bs); - %! assert(RS'*RS,QS*bs*QS',1e-10); - %! assert(PS,0); - %! [LS,PS,QS] = chol(bs,'lower'); - %! assert(LS*LS',QS*bs*QS',1e-10); - %! assert(PS,0); - - - # ============================================================== - - %!test bf=real(bf); - %! bs=sparse(bf); - %!testif HAVE_CHOLMOD - %! assert(chol(bs)'*chol(bs),bs,1e-10); - %!testif HAVE_CHOLMOD - %! assert(chol(bs,'lower')*chol(bs,'lower')',bs,1e-10); - %!testif HAVE_CHOLMOD - %! assert(chol(bs,'lower'),chol(bs)',1e-10); - - %!testif HAVE_CHOLMOD ;# Return Partial Cholesky factorization - %! [RS,PS] = chol(bs); - %! assert(RS'*RS,bs,1e-10); - %! assert(PS,0); - %! [LS,PS] = chol(bs,'lower'); - %! assert(LS*LS',bs,1e-10); - %! assert(PS,0); - - %!testif HAVE_CHOLMOD ;# Permuted Cholesky factorization - %! [RS,PS,QS] = chol(bs); - %! assert(RS'*RS,QS*bs*QS',1e-10); - %! assert(PS,0); - %! [LS,PS,QS] = chol(bs,'lower'); - %! assert(LS*LS',QS*bs*QS',1e-10); - %! assert(PS,0); - - - # ============================================================== - - %!shared r,c,m,n,fsum,funiq - %!test - %! r=[1,1,2,1,2,3]; - %! c=[2,1,1,1,2,1]; - %! m=n=0; - %%Assembly tests - %!test - %! m=max([m;r(:)]); - %! n=max([n;c(:)]); - %! funiq=fsum=zeros(m,n); - %! funiq(r(:) + m*(c(:)-1) ) = ones(size(r(:))); - %! funiq = sparse(funiq); - %! for k=1:length(r), fsum(r(k),c(k)) += 1; end - %! fsum = sparse(fsum); - %!assert(sparse(r,c,1),sparse(fsum(1:max(r),1:max(c)))); - %!assert(sparse(r,c,1,"sum"),sparse(fsum(1:max(r),1:max(c)))); - %!assert(sparse(r,c,1,"unique"),sparse(funiq(1:max(r),1:max(c)))); - %!assert(sparse(r,c,1,m,n),sparse(fsum)); - %!assert(sparse(r,c,1,m,n,"sum"),sparse(fsum)); - %!assert(sparse(r,c,1,m,n,"unique"),sparse(funiq)); - - %!assert(sparse(r,c,1i),sparse(fsum(1:max(r),1:max(c))*1i)); - %!assert(sparse(r,c,1i,"sum"),sparse(fsum(1:max(r),1:max(c))*1i)); - %!assert(sparse(r,c,1i,"unique"),sparse(funiq(1:max(r),1:max(c))*1i)); - %!assert(sparse(r,c,1i,m,n),sparse(fsum*1i)); - %!assert(sparse(r,c,1i,m,n,"sum"),sparse(fsum*1i)); - %!assert(sparse(r,c,1i,m,n,"unique"),sparse(funiq*1i)); - - %!test - %! if (issparse(funiq)) - %! assert(sparse(full(1i*funiq)),sparse(1i*funiq)); - %! endif - - %!assert(sparse(full(funiq)),funiq); - - - - # ============================================================== - - %!shared ridx,cidx,idx,as,af - %!test - %! af=[1+1i,2-1i,0,0;0,0,0,3+2i;0,0,0,4]; - %! ridx=[1,3]; cidx=[2,3]; - %!assert (sparse(42)([1,1]),sparse([42,42])) - %!assert (sparse(42*1i)([1,1]),sparse([42,42].*1i)) - %!test as=sparse(af); - - %% Point tests - %!test idx=ridx(:)+rows(as)*(cidx(:)-1); - %!assert(sparse(as(idx)),sparse(af(idx))); - %!assert(as(idx),sparse(af(idx))); - %!assert(as(idx'),sparse(af(idx'))); - %!assert(as(flipud(idx(:))),sparse(af(flipud(idx(:))))) - %!assert(as([idx,idx]),sparse(af([idx,idx]))); - %!error(as(reshape([idx;idx],[1,length(idx),2]))); - - %% Slice tests - %!assert(as(ridx,cidx), sparse(af(ridx,cidx))) - %!assert(as(ridx,:), sparse(af(ridx,:))) - %!assert(as(:,cidx), sparse(af(:,cidx))) - %!assert(as(:,:), sparse(af(:,:))) - %!assert(as((size(as,1):-1:1),:),sparse(af((size(af,1):-1:1),:))) - %!assert(as(:,(size(as,2):-1:1)),sparse(af(:,(size(af,2):-1:1)))) - - %% Indexing tests - %!assert(full(as([1,1],:)), af([1,1],:)) - %!assert(full(as(:,[1,1])), af(:,[1,1])) - %!test - %! [i,j,v] = find (as); - %! assert (as(i(1),j(1))([1,1]), sparse([v(1),v(1)])) - - %% Assignment test - %!test - %! ts=as;ts(:,:)=ts(fliplr(1:size(as,1)),:); - %! tf=af;tf(:,:)=tf(fliplr(1:size(af,1)),:); - %! assert(ts,sparse(tf)); - %!test - %! ts=as;ts(fliplr(1:size(as,1)),:)=ts; - %! tf=af;tf(fliplr(1:size(af,1)),:)=tf; - %! assert(ts,sparse(tf)); - %!test - %! ts=as;ts(:,fliplr(1:size(as,2)))=ts; - %! tf=af;tf(:,fliplr(1:size(af,2)))=tf; - %! assert(ts,sparse(tf)); - %!test - %! ts(fliplr(1:size(as,1)))=as(:,1);tf(fliplr(1:size(af,1)))=af(:,1); - %! assert(ts,sparse(tf)); - - %% Deletion tests - %!test - %! ts=as;ts(1,:)=[];tf=af;tf(1,:)=[]; - %! assert(ts,sparse(tf)); - %!test - %! ts=as;ts(:,1)=[];tf=af;tf(:,1)=[]; - %! assert(ts,sparse(tf)); - - %% Test 'end' keyword - %!assert(full(as(end)), af(end)) - %!assert(full(as(1,end)), af(1,end)) - %!assert(full(as(end,1)), af(end,1)) - %!assert(full(as(end,end)), af(end,end)) - %!assert(as(2:end,2:end), sparse(af(2:end,2:end))) - %!assert(as(1:end-1,1:end-1), sparse(af(1:end-1,1:end-1))) - %!test af=real(af); - %!test as=sparse(af); - - %% Point tests - %!test idx=ridx(:)+rows(as)*(cidx(:)-1); - %!assert(sparse(as(idx)),sparse(af(idx))); - %!assert(as(idx),sparse(af(idx))); - %!assert(as(idx'),sparse(af(idx'))); - %!assert(as(flipud(idx(:))),sparse(af(flipud(idx(:))))) - %!assert(as([idx,idx]),sparse(af([idx,idx]))); - %!error(as(reshape([idx;idx],[1,length(idx),2]))); - - %% Slice tests - %!assert(as(ridx,cidx), sparse(af(ridx,cidx))) - %!assert(as(ridx,:), sparse(af(ridx,:))) - %!assert(as(:,cidx), sparse(af(:,cidx))) - %!assert(as(:,:), sparse(af(:,:))) - %!assert(as((size(as,1):-1:1),:),sparse(af((size(af,1):-1:1),:))) - %!assert(as(:,(size(as,2):-1:1)),sparse(af(:,(size(af,2):-1:1)))) - - %% Indexing tests - %!assert(full(as([1,1],:)), af([1,1],:)) - %!assert(full(as(:,[1,1])), af(:,[1,1])) - %!test - %! [i,j,v] = find (as); - %! assert (as(i(1),j(1))([1,1]), sparse([v(1),v(1)])) - - %% Assignment test - %!test - %! ts=as;ts(:,:)=ts(fliplr(1:size(as,1)),:); - %! tf=af;tf(:,:)=tf(fliplr(1:size(af,1)),:); - %! assert(ts,sparse(tf)); - %!test - %! ts=as;ts(fliplr(1:size(as,1)),:)=ts; - %! tf=af;tf(fliplr(1:size(af,1)),:)=tf; - %! assert(ts,sparse(tf)); - %!test - %! ts=as;ts(:,fliplr(1:size(as,2)))=ts; - %! tf=af;tf(:,fliplr(1:size(af,2)))=tf; - %! assert(ts,sparse(tf)); - %!test - %! ts(fliplr(1:size(as,1)))=as(:,1);tf(fliplr(1:size(af,1)))=af(:,1); - %! assert(ts,sparse(tf)); - - %% Deletion tests - %!test - %! ts=as;ts(1,:)=[];tf=af;tf(1,:)=[]; - %! assert(ts,sparse(tf)); - %!test - %! ts=as;ts(:,1)=[];tf=af;tf(:,1)=[]; - %! assert(ts,sparse(tf)); - - %% Test 'end' keyword - %!assert(full(as(end)), af(end)) - %!assert(full(as(1,end)), af(1,end)) - %!assert(full(as(end,1)), af(end,1)) - %!assert(full(as(end,end)), af(end,end)) - %!assert(as(2:end,2:end), sparse(af(2:end,2:end))) - %!assert(as(1:end-1,1:end-1), sparse(af(1:end-1,1:end-1))) - - # ============================================================== - - %!shared alpha,beta,df,pdf,lf,plf,uf,puf,bf,cf,bcf,tf,tcf,xf,ds,pds,ls,pls,us,pus,bs,cs,bcs,ts,tcs,xs - %!test alpha=1;beta=1; - %! n=8; - %! lf=diag(1:n);lf(n-1,1)=0.5*alpha;lf(n,2)=0.25*alpha;ls=sparse(lf); - %! uf=diag(1:n);uf(1,n-1)=2*alpha;uf(2,n)=alpha;us=sparse(uf); - %! ts=spdiags(ones(n,3),-1:1,n,n)+diag(1:n); tf = full(ts); - %! df = diag(1:n).* alpha; ds = sparse(df); - %! pdf = df(randperm(n),randperm(n)); pds = sparse(pdf); - %! plf = lf(randperm(n),randperm(n)); pls = sparse(plf); - %! puf = uf(randperm(n),randperm(n)); pus = sparse(puf); - %! bs = spdiags(repmat([1:n]',1,4),-2:1,n,n).*alpha; bf = full(bs); - %! cf = lf + lf'; cs = sparse(cf); - %! bcf = bf + bf'; bcs = sparse(bcf); - %! tcf = tf + tf'; tcs = sparse(tcf); - %! xf = diag(1:n) + fliplr(diag(1:n)).*beta; xs = sparse(xf); - %!assert(ds\xf,df\xf,1e-10); - %!assert(ds\xs,sparse(df\xf),1e-10); - %!assert(pds\xf,pdf\xf,1e-10); - %!assert(pds\xs,sparse(pdf\xf),1e-10); - %!assert(ls\xf,lf\xf,1e-10); - %!assert(sparse(ls\xs),sparse(lf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(pls\xf,plf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(pls\xs),sparse(plf\xf),1e-10); - %!assert(us\xf,uf\xf,1e-10); - %!assert(sparse(us\xs),sparse(uf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(pus\xf,puf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(pus\xs),sparse(puf\xf),1e-10); - %!assert(bs\xf,bf\xf,1e-10); - %!assert(sparse(bs\xs),sparse(bf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(cs\xf,cf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(cs\xs),sparse(cf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(bcs\xf,bcf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(bcs\xs),sparse(bcf\xf),1e-10); - %!assert(ts\xf,tf\xf,1e-10); - %!assert(sparse(ts\xs),sparse(tf\xf),1e-10); - %!assert(tcs\xf,tcf\xf,1e-10); - %!assert(sparse(tcs\xs),sparse(tcf\xf),1e-10); - - %% QR solver tests - - %!function f(a, sz, feps) - %! b = randn(sz); x = a \b; - %! assert (a * x, b, feps); - %! b = randn(sz)+1i*randn(sz); x = a \ b; - %! assert (a * x, b, feps); - %! b = sprandn(sz(1),sz(2),0.2); x = a \b; - %! assert (sparse(a * x), b, feps); - %! b = sprandn(sz(1),sz(2),0.2)+1i*sprandn(sz(1),sz(2),0.2); x = a \b; - %! assert (sparse(a * x), b, feps); - %!testif HAVE_CXSPARSE - %! a = alpha*sprandn(10,11,0.2)+speye(10,11); f(a,[10,2],1e-10); - %! ## Test this by forcing matrix_type, as can't get a certain - %! ## result for over-determined systems. - %! a = alpha*sprandn(10,10,0.2)+speye(10,10); matrix_type(a, "Singular"); - %! f(a,[10,2],1e-10); - - %% Rectanguar solver tests that don't use QR - - %!test - %! ds = alpha * spdiags([1:11]',0,10,11); - %! df = full(ds); - %! xf = beta * ones(10,2); - %! xs = speye(10,10); - %!assert(ds\xf,df\xf,100*eps) - %!assert(ds\xs,sparse(df\xs),100*eps) - %!test - %! pds = ds([2,1,3:10],:); - %! pdf = full(pds); - %!assert(pds\xf,pdf\xf,100*eps) - %!assert(pds\xs,sparse(pdf\xs),100*eps) - %!test - %! ds = alpha * spdiags([1:11]',0,11,10); - %! df = full(ds); - %! xf = beta * ones(11,2); - %! xs = speye(11,11); - %!assert(ds\xf,df\xf,100*eps) - %!assert(ds\xs,sparse(df\xs),100*eps) - %!test - %! pds = ds([2,1,3:11],:); - %! pdf = full(pds); - %!assert(pds\xf,pdf\xf,100*eps) - %!assert(pds\xs,sparse(pdf\xs),100*eps) - %!test - %! us = alpha*[[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]]; - %!testif HAVE_UMFPACK - %! assert(us*(us\xf),xf,100*eps) - %!testif HAVE_UMFPACK - %! assert(us*(us\xs),xs,100*eps) - %!test - %! pus = us(:,[2,1,3:12]); - %!testif HAVE_UMFPACK - %! assert(pus*(pus\xf),xf,100*eps) - %!testif HAVE_UMFPACK - %! assert(pus*(pus\xs),xs,100*eps) - %!test - %! us = alpha*[speye(11,9),[1;sparse(8,1);1;0]]; - %!testif HAVE_CXSPARSE - %! [c,r] = qr (us, xf); - %! assert(us\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (us, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(us\xs,r\c,100*eps) - %!test - %! pus = us(:,[1:8,10,9]); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pus, xf); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pus\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pus, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pus\xs,r\c,100*eps) - %!test - %! ls = alpha*[speye(9,11);[1,sparse(1,8),1,0]]; - %! xf = beta * ones(10,2); - %! xs = speye(10,10); - %!assert(ls*(ls\xf),xf,100*eps) - %!assert(ls*(ls\xs),xs,100*eps) - %!test - %! pls = ls([1:8,10,9],:); - %!assert(pls*(pls\xf),xf,100*eps) - %!assert(pls*(pls\xs),xs,100*eps) - %!test - %! ls = alpha*[speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]]; - %! xf = beta * ones(12,2); - %! xs = speye(12,12); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (ls, xf); - %! assert(ls\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (ls, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(ls\xs,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! pls = ls(:,[1:8,10,9]); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pls, xf); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pls\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pls, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pls\xs,r\c,100*eps) - - %!test alpha=1;beta=1i; - %! n=8; - %! lf=diag(1:n);lf(n-1,1)=0.5*alpha;lf(n,2)=0.25*alpha;ls=sparse(lf); - %! uf=diag(1:n);uf(1,n-1)=2*alpha;uf(2,n)=alpha;us=sparse(uf); - %! ts=spdiags(ones(n,3),-1:1,n,n)+diag(1:n); tf = full(ts); - %! df = diag(1:n).* alpha; ds = sparse(df); - %! pdf = df(randperm(n),randperm(n)); pds = sparse(pdf); - %! plf = lf(randperm(n),randperm(n)); pls = sparse(plf); - %! puf = uf(randperm(n),randperm(n)); pus = sparse(puf); - %! bs = spdiags(repmat([1:n]',1,4),-2:1,n,n).*alpha; bf = full(bs); - %! cf = lf + lf'; cs = sparse(cf); - %! bcf = bf + bf'; bcs = sparse(bcf); - %! tcf = tf + tf'; tcs = sparse(tcf); - %! xf = diag(1:n) + fliplr(diag(1:n)).*beta; xs = sparse(xf); - %!assert(ds\xf,df\xf,1e-10); - %!assert(ds\xs,sparse(df\xf),1e-10); - %!assert(pds\xf,pdf\xf,1e-10); - %!assert(pds\xs,sparse(pdf\xf),1e-10); - %!assert(ls\xf,lf\xf,1e-10); - %!assert(sparse(ls\xs),sparse(lf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(pls\xf,plf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(pls\xs),sparse(plf\xf),1e-10); - %!assert(us\xf,uf\xf,1e-10); - %!assert(sparse(us\xs),sparse(uf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(pus\xf,puf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(pus\xs),sparse(puf\xf),1e-10); - %!assert(bs\xf,bf\xf,1e-10); - %!assert(sparse(bs\xs),sparse(bf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(cs\xf,cf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(cs\xs),sparse(cf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(bcs\xf,bcf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(bcs\xs),sparse(bcf\xf),1e-10); - %!assert(ts\xf,tf\xf,1e-10); - %!assert(sparse(ts\xs),sparse(tf\xf),1e-10); - %!assert(tcs\xf,tcf\xf,1e-10); - %!assert(sparse(tcs\xs),sparse(tcf\xf),1e-10); - - %% QR solver tests - - %!function f(a, sz, feps) - %! b = randn(sz); x = a \b; - %! assert (a * x, b, feps); - %! b = randn(sz)+1i*randn(sz); x = a \ b; - %! assert (a * x, b, feps); - %! b = sprandn(sz(1),sz(2),0.2); x = a \b; - %! assert (sparse(a * x), b, feps); - %! b = sprandn(sz(1),sz(2),0.2)+1i*sprandn(sz(1),sz(2),0.2); x = a \b; - %! assert (sparse(a * x), b, feps); - %!testif HAVE_CXSPARSE - %! a = alpha*sprandn(10,11,0.2)+speye(10,11); f(a,[10,2],1e-10); - %! ## Test this by forcing matrix_type, as can't get a certain - %! ## result for over-determined systems. - %! a = alpha*sprandn(10,10,0.2)+speye(10,10); matrix_type(a, "Singular"); - %! f(a,[10,2],1e-10); - - %% Rectanguar solver tests that don't use QR - - %!test - %! ds = alpha * spdiags([1:11]',0,10,11); - %! df = full(ds); - %! xf = beta * ones(10,2); - %! xs = speye(10,10); - %!assert(ds\xf,df\xf,100*eps) - %!assert(ds\xs,sparse(df\xs),100*eps) - %!test - %! pds = ds([2,1,3:10],:); - %! pdf = full(pds); - %!assert(pds\xf,pdf\xf,100*eps) - %!assert(pds\xs,sparse(pdf\xs),100*eps) - %!test - %! ds = alpha * spdiags([1:11]',0,11,10); - %! df = full(ds); - %! xf = beta * ones(11,2); - %! xs = speye(11,11); - %!assert(ds\xf,df\xf,100*eps) - %!assert(ds\xs,sparse(df\xs),100*eps) - %!test - %! pds = ds([2,1,3:11],:); - %! pdf = full(pds); - %!assert(pds\xf,pdf\xf,100*eps) - %!assert(pds\xs,sparse(pdf\xs),100*eps) - %!test - %! us = alpha*[[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]]; - %!testif HAVE_UMFPACK - %! assert(us*(us\xf),xf,100*eps) - %!testif HAVE_UMFPACK - %! assert(us*(us\xs),xs,100*eps) - %!test - %! pus = us(:,[2,1,3:12]); - %!testif HAVE_UMFPACK - %! assert(pus*(pus\xf),xf,100*eps) - %!testif HAVE_UMFPACK - %! assert(pus*(pus\xs),xs,100*eps) - %!test - %! us = alpha*[speye(11,9),[1;sparse(8,1);1;0]]; - %!testif HAVE_CXSPARSE - %! [c,r] = qr (us, xf); - %! assert(us\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (us, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(us\xs,r\c,100*eps) - %!test - %! pus = us(:,[1:8,10,9]); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pus, xf); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pus\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pus, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pus\xs,r\c,100*eps) - %!test - %! ls = alpha*[speye(9,11);[1,sparse(1,8),1,0]]; - %! xf = beta * ones(10,2); - %! xs = speye(10,10); - %!assert(ls*(ls\xf),xf,100*eps) - %!assert(ls*(ls\xs),xs,100*eps) - %!test - %! pls = ls([1:8,10,9],:); - %!assert(pls*(pls\xf),xf,100*eps) - %!assert(pls*(pls\xs),xs,100*eps) - %!test - %! ls = alpha*[speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]]; - %! xf = beta * ones(12,2); - %! xs = speye(12,12); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (ls, xf); - %! assert(ls\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (ls, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(ls\xs,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! pls = ls(:,[1:8,10,9]); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pls, xf); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pls\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pls, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pls\xs,r\c,100*eps) - - %!test alpha=1i;beta=1; - %! n=8; - %! lf=diag(1:n);lf(n-1,1)=0.5*alpha;lf(n,2)=0.25*alpha;ls=sparse(lf); - %! uf=diag(1:n);uf(1,n-1)=2*alpha;uf(2,n)=alpha;us=sparse(uf); - %! ts=spdiags(ones(n,3),-1:1,n,n)+diag(1:n); tf = full(ts); - %! df = diag(1:n).* alpha; ds = sparse(df); - %! pdf = df(randperm(n),randperm(n)); pds = sparse(pdf); - %! plf = lf(randperm(n),randperm(n)); pls = sparse(plf); - %! puf = uf(randperm(n),randperm(n)); pus = sparse(puf); - %! bs = spdiags(repmat([1:n]',1,4),-2:1,n,n).*alpha; bf = full(bs); - %! cf = lf + lf'; cs = sparse(cf); - %! bcf = bf + bf'; bcs = sparse(bcf); - %! tcf = tf + tf'; tcs = sparse(tcf); - %! xf = diag(1:n) + fliplr(diag(1:n)).*beta; xs = sparse(xf); - %!assert(ds\xf,df\xf,1e-10); - %!assert(ds\xs,sparse(df\xf),1e-10); - %!assert(pds\xf,pdf\xf,1e-10); - %!assert(pds\xs,sparse(pdf\xf),1e-10); - %!assert(ls\xf,lf\xf,1e-10); - %!assert(sparse(ls\xs),sparse(lf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(pls\xf,plf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(pls\xs),sparse(plf\xf),1e-10); - %!assert(us\xf,uf\xf,1e-10); - %!assert(sparse(us\xs),sparse(uf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(pus\xf,puf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(pus\xs),sparse(puf\xf),1e-10); - %!assert(bs\xf,bf\xf,1e-10); - %!assert(sparse(bs\xs),sparse(bf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(cs\xf,cf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(cs\xs),sparse(cf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(bcs\xf,bcf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(bcs\xs),sparse(bcf\xf),1e-10); - %!assert(ts\xf,tf\xf,1e-10); - %!assert(sparse(ts\xs),sparse(tf\xf),1e-10); - %!assert(tcs\xf,tcf\xf,1e-10); - %!assert(sparse(tcs\xs),sparse(tcf\xf),1e-10); - - %% QR solver tests - - %!function f(a, sz, feps) - %! b = randn(sz); x = a \b; - %! assert (a * x, b, feps); - %! b = randn(sz)+1i*randn(sz); x = a \ b; - %! assert (a * x, b, feps); - %! b = sprandn(sz(1),sz(2),0.2); x = a \b; - %! assert (sparse(a * x), b, feps); - %! b = sprandn(sz(1),sz(2),0.2)+1i*sprandn(sz(1),sz(2),0.2); x = a \b; - %! assert (sparse(a * x), b, feps); - %!testif HAVE_CXSPARSE - %! a = alpha*sprandn(10,11,0.2)+speye(10,11); f(a,[10,2],1e-10); - %! ## Test this by forcing matrix_type, as can't get a certain - %! ## result for over-determined systems. - %! a = alpha*sprandn(10,10,0.2)+speye(10,10); matrix_type(a, "Singular"); - %! f(a,[10,2],1e-10); - - %% Rectanguar solver tests that don't use QR - - %!test - %! ds = alpha * spdiags([1:11]',0,10,11); - %! df = full(ds); - %! xf = beta * ones(10,2); - %! xs = speye(10,10); - %!assert(ds\xf,df\xf,100*eps) - %!assert(ds\xs,sparse(df\xs),100*eps) - %!test - %! pds = ds([2,1,3:10],:); - %! pdf = full(pds); - %!assert(pds\xf,pdf\xf,100*eps) - %!assert(pds\xs,sparse(pdf\xs),100*eps) - %!test - %! ds = alpha * spdiags([1:11]',0,11,10); - %! df = full(ds); - %! xf = beta * ones(11,2); - %! xs = speye(11,11); - %!assert(ds\xf,df\xf,100*eps) - %!assert(ds\xs,sparse(df\xs),100*eps) - %!test - %! pds = ds([2,1,3:11],:); - %! pdf = full(pds); - %!assert(pds\xf,pdf\xf,100*eps) - %!assert(pds\xs,sparse(pdf\xs),100*eps) - %!test - %! us = alpha*[[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]]; - %!testif HAVE_UMFPACK - %! assert(us*(us\xf),xf,100*eps) - %!testif HAVE_UMFPACK - %! assert(us*(us\xs),xs,100*eps) - %!test - %! pus = us(:,[2,1,3:12]); - %!testif HAVE_UMFPACK - %! assert(pus*(pus\xf),xf,100*eps) - %!testif HAVE_UMFPACK - %! assert(pus*(pus\xs),xs,100*eps) - %!test - %! us = alpha*[speye(11,9),[1;sparse(8,1);1;0]]; - %!testif HAVE_CXSPARSE - %! [c,r] = qr (us, xf); - %! assert(us\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (us, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(us\xs,r\c,100*eps) - %!test - %! pus = us(:,[1:8,10,9]); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pus, xf); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pus\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pus, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pus\xs,r\c,100*eps) - %!test - %! ls = alpha*[speye(9,11);[1,sparse(1,8),1,0]]; - %! xf = beta * ones(10,2); - %! xs = speye(10,10); - %!assert(ls*(ls\xf),xf,100*eps) - %!assert(ls*(ls\xs),xs,100*eps) - %!test - %! pls = ls([1:8,10,9],:); - %!assert(pls*(pls\xf),xf,100*eps) - %!assert(pls*(pls\xs),xs,100*eps) - %!test - %! ls = alpha*[speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]]; - %! xf = beta * ones(12,2); - %! xs = speye(12,12); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (ls, xf); - %! assert(ls\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (ls, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(ls\xs,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! pls = ls(:,[1:8,10,9]); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pls, xf); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pls\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pls, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pls\xs,r\c,100*eps) - - %!test alpha=1i;beta=1i; - %! n=8; - %! lf=diag(1:n);lf(n-1,1)=0.5*alpha;lf(n,2)=0.25*alpha;ls=sparse(lf); - %! uf=diag(1:n);uf(1,n-1)=2*alpha;uf(2,n)=alpha;us=sparse(uf); - %! ts=spdiags(ones(n,3),-1:1,n,n)+diag(1:n); tf = full(ts); - %! df = diag(1:n).* alpha; ds = sparse(df); - %! pdf = df(randperm(n),randperm(n)); pds = sparse(pdf); - %! plf = lf(randperm(n),randperm(n)); pls = sparse(plf); - %! puf = uf(randperm(n),randperm(n)); pus = sparse(puf); - %! bs = spdiags(repmat([1:n]',1,4),-2:1,n,n).*alpha; bf = full(bs); - %! cf = lf + lf'; cs = sparse(cf); - %! bcf = bf + bf'; bcs = sparse(bcf); - %! tcf = tf + tf'; tcs = sparse(tcf); - %! xf = diag(1:n) + fliplr(diag(1:n)).*beta; xs = sparse(xf); - %!assert(ds\xf,df\xf,1e-10); - %!assert(ds\xs,sparse(df\xf),1e-10); - %!assert(pds\xf,pdf\xf,1e-10); - %!assert(pds\xs,sparse(pdf\xf),1e-10); - %!assert(ls\xf,lf\xf,1e-10); - %!assert(sparse(ls\xs),sparse(lf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(pls\xf,plf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(pls\xs),sparse(plf\xf),1e-10); - %!assert(us\xf,uf\xf,1e-10); - %!assert(sparse(us\xs),sparse(uf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(pus\xf,puf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(pus\xs),sparse(puf\xf),1e-10); - %!assert(bs\xf,bf\xf,1e-10); - %!assert(sparse(bs\xs),sparse(bf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(cs\xf,cf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(cs\xs),sparse(cf\xf),1e-10); - %!testif HAVE_UMFPACK - %! assert(bcs\xf,bcf\xf,1e-10); - %!testif HAVE_UMFPACK - %! assert(sparse(bcs\xs),sparse(bcf\xf),1e-10); - %!assert(ts\xf,tf\xf,1e-10); - %!assert(sparse(ts\xs),sparse(tf\xf),1e-10); - %!assert(tcs\xf,tcf\xf,1e-10); - %!assert(sparse(tcs\xs),sparse(tcf\xf),1e-10); - - %% QR solver tests - - %!function f(a, sz, feps) - %! b = randn(sz); x = a \b; - %! assert (a * x, b, feps); - %! b = randn(sz)+1i*randn(sz); x = a \ b; - %! assert (a * x, b, feps); - %! b = sprandn(sz(1),sz(2),0.2); x = a \b; - %! assert (sparse(a * x), b, feps); - %! b = sprandn(sz(1),sz(2),0.2)+1i*sprandn(sz(1),sz(2),0.2); x = a \b; - %! assert (sparse(a * x), b, feps); - %!testif HAVE_CXSPARSE - %! a = alpha*sprandn(10,11,0.2)+speye(10,11); f(a,[10,2],1e-10); - %! ## Test this by forcing matrix_type, as can't get a certain - %! ## result for over-determined systems. - %! a = alpha*sprandn(10,10,0.2)+speye(10,10); matrix_type(a, "Singular"); - %! f(a,[10,2],1e-10); - - %% Rectanguar solver tests that don't use QR - - %!test - %! ds = alpha * spdiags([1:11]',0,10,11); - %! df = full(ds); - %! xf = beta * ones(10,2); - %! xs = speye(10,10); - %!assert(ds\xf,df\xf,100*eps) - %!assert(ds\xs,sparse(df\xs),100*eps) - %!test - %! pds = ds([2,1,3:10],:); - %! pdf = full(pds); - %!assert(pds\xf,pdf\xf,100*eps) - %!assert(pds\xs,sparse(pdf\xs),100*eps) - %!test - %! ds = alpha * spdiags([1:11]',0,11,10); - %! df = full(ds); - %! xf = beta * ones(11,2); - %! xs = speye(11,11); - %!assert(ds\xf,df\xf,100*eps) - %!assert(ds\xs,sparse(df\xs),100*eps) - %!test - %! pds = ds([2,1,3:11],:); - %! pdf = full(pds); - %!assert(pds\xf,pdf\xf,100*eps) - %!assert(pds\xs,sparse(pdf\xs),100*eps) - %!test - %! us = alpha*[[speye(10,10);sparse(1,10)],[[1,1];sparse(9,2);[1,1]]]; - %!testif HAVE_UMFPACK - %! assert(us*(us\xf),xf,100*eps) - %!testif HAVE_UMFPACK - %! assert(us*(us\xs),xs,100*eps) - %!test - %! pus = us(:,[2,1,3:12]); - %!testif HAVE_UMFPACK - %! assert(pus*(pus\xf),xf,100*eps) - %!testif HAVE_UMFPACK - %! assert(pus*(pus\xs),xs,100*eps) - %!test - %! us = alpha*[speye(11,9),[1;sparse(8,1);1;0]]; - %!testif HAVE_CXSPARSE - %! [c,r] = qr (us, xf); - %! assert(us\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (us, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(us\xs,r\c,100*eps) - %!test - %! pus = us(:,[1:8,10,9]); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pus, xf); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pus\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pus, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pus\xs,r\c,100*eps) - %!test - %! ls = alpha*[speye(9,11);[1,sparse(1,8),1,0]]; - %! xf = beta * ones(10,2); - %! xs = speye(10,10); - %!assert(ls*(ls\xf),xf,100*eps) - %!assert(ls*(ls\xs),xs,100*eps) - %!test - %! pls = ls([1:8,10,9],:); - %!assert(pls*(pls\xf),xf,100*eps) - %!assert(pls*(pls\xs),xs,100*eps) - %!test - %! ls = alpha*[speye(10,10),sparse(10,1);[1;1],sparse(2,9),[1;1]]; - %! xf = beta * ones(12,2); - %! xs = speye(12,12); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (ls, xf); - %! assert(ls\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (ls, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(ls\xs,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! pls = ls(:,[1:8,10,9]); - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pls, xf); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pls\xf,r\c,100*eps) - %!testif HAVE_CXSPARSE - %! [c,r] = qr (pls, xs); - %! r = matrix_type(r,"Singular"); ## Force Matrix Type - %! assert(pls\xs,r\c,100*eps) - - - # ============================================================== - --- 0 ---- PATCH_EOF