Mercurial > hg > octave-nkf
changeset 14461:80e8c03548a4 gui
Merge default onto gui
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Tue, 13 Mar 2012 19:11:52 -0400 |
parents | d738c29a2528 (current diff) 6c3441f3146b (diff) |
children | 86847bd1ccf0 |
files | NEWS configure.ac doc/interpreter/contributors.in scripts/plot/__gnuplot_drawnow__.m |
diffstat | 126 files changed, 2966 insertions(+), 2364 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags +++ b/.hgtags @@ -59,3 +59,4 @@ 72aebe6196414e38ef802469ff6e238f914f04c9 rc-3-6-0-0 64d9f33313cc8c691974bcd123357e24bccbabdc rc-3-6-0-1 704f7895eef03008dd79848eb9da4bfb40787d73 release-3.6.0 +95c43fc8dbe1a07a46fefb3372df5b2309d874fd rc-3-6-1-0
--- a/Makefile.am +++ b/Makefile.am @@ -70,8 +70,7 @@ # Subdirectories in which to run `make all'. SUBDIRS = libgnu libcruft liboctave src scripts @DOCDIR@ examples test -if AMCOND_BUILD_DOCS -else +if ! AMCOND_BUILD_DOCS dist-hook: echo "Documentation disabled. Cannot package distribution!" ; exit 1; endif @@ -119,8 +118,10 @@ cp $< $@; \ fi +if AMCOND_BUILD_DOCS AUTHORS BUGS INSTALL.OCTAVE: $(MAKE) -C doc/interpreter ../../$@ +endif .PHONY: AUTHORS BUGS INSTALL.OCTAVE ChangeLog:
--- a/NEWS +++ b/NEWS @@ -51,7 +51,7 @@ http://forge.scilab.org/index.php/p/arpack-ng ** Many of Octave's binary operators (.*, .^, +, -, ...) now perform - automatic broadcasting for array operations that allows you to use + automatic broadcasting for array operations which allows you to use operator notation instead of calling bsxfun or expanding arrays (and unnecessarily wasting memory) with repmat or similar idioms. For example, to scale the columns of a matrix by the elements of a row @@ -84,7 +84,7 @@ rem xor - additionally, since the A op= B assginment operators are equivalent + additionally, since the A op= B assignment operators are equivalent to A = A op B, the following operators are also affected: += -= .+= .-= .*= ./= .\= .^= .**= &= |= @@ -112,8 +112,8 @@ scripts. negative binomial function has been extended to real, non-integer - inputs. The discrete_inv fucntion now returns v(1) for 0 instead of - NaN. The nbincdf fucntion has bbeen recoded to use a closed form + inputs. The discrete_inv function now returns v(1) for 0 instead of + NaN. The nbincdf function has been recoded to use a closed form solution with betainc. ** strread, textscan, and textread have been completely revamped. @@ -175,7 +175,7 @@ string now supported. datestr: Numerical formats 21, 22, 29 changed to match Matlab. - Now accepts cellstr inputs. + Now accepts cellstr input. ** The following warning IDs have been removed: @@ -204,7 +204,7 @@ The uiXXX functions above are experimental. Except for uiwait and uiresume, the uiXXX functions are not - supported with the the FLTK+OpenGL graphics toolkit. + supported with the FLTK+OpenGL graphics toolkit. The gnuplot graphics toolkit does not support any of the uiXXX functions nor the waitfor function. @@ -248,6 +248,10 @@ __error_text__ studentize error_text sylvester_matrix + ** The following functions have been modified for Matlab compatibility: + + randperm + Summary of important user-visible changes for version 3.4.3: -----------------------------------------------------------
--- a/configure.ac +++ b/configure.ac @@ -33,7 +33,7 @@ OCTAVE_VERSION="$PACKAGE_VERSION" OCTAVE_API_VERSION_NUMBER="48" OCTAVE_API_VERSION="api-v$OCTAVE_API_VERSION_NUMBER+" -OCTAVE_RELEASE_DATE="2012-01-15" +OCTAVE_RELEASE_DATE="2012-02-22" OCTAVE_COPYRIGHT="Copyright (C) 2012 John W. Eaton and others." AC_SUBST(OCTAVE_VERSION) AC_SUBST(OCTAVE_API_VERSION_NUMBER)
--- a/doc/interpreter/contributors.in +++ b/doc/interpreter/contributors.in @@ -152,6 +152,7 @@ Hoxide Ma James Macnicol Jens-Uwe Mager +Colin Macdonald Rob Mahurin Ricardo Marranita Orestes Mas @@ -164,6 +165,7 @@ JĂșlio Hoffimann Mendes Thorsten Meyer Petr Mikulik +Mike Miller Stefan Monnier Antoine Moreau Kai P. Mueller @@ -267,6 +269,7 @@ Karsten Trulsen Frederick Umminger Utkarsh Upadhyay +Daniel Wagenaar Stefan van der Walt Peter Van Wieren James R. Van Zandt
--- a/doc/interpreter/diagperm.txi +++ b/doc/interpreter/diagperm.txi @@ -23,7 +23,7 @@ * Basic Usage:: Creation and Manipulation of Diagonal and Permutation Matrices * Matrix Algebra:: Linear Algebra with Diagonal and Permutation Matrices * Function Support:: Functions That Are Aware of These Matrices -* Example Codes:: Some Examples of Usage +* Example Code:: Some Examples of Usage * Zeros Treatment:: The Differences in Treatment of Zero Elements @end menu @@ -412,7 +412,7 @@ The @dfn{find} function will also work efficiently with a permutation matrix, making it possible to conveniently obtain the permutation indices. -@node Example Codes +@node Example Code @section Some Examples of Usage The following can be used to solve a linear system @code{A*x = b} @@ -426,12 +426,23 @@ @end example @noindent -This is how you normalize columns of a matrix @var{X} to unit norm: +This is one way to normalize columns of a matrix @var{X} to unit norm: @example @group s = norm (X, "columns"); - X = diag (s) \ X; + X /= diag (s); +@end group +@end example + +@noindent +The same can also be accomplished with broadcasting +(@pxref{Broadcasting}): + +@example +@group + s = norm (X, "columns"); + X ./= s; @end group @end example @@ -445,7 +456,7 @@ @end example @noindent -Finally, here's how you solve a linear system @code{A*x = b} +Finally, here's how you solve a linear system @code{A*x = b} with Tikhonov regularization (ridge regression) using SVD (a skeleton only): @example
--- a/doc/interpreter/func.txi +++ b/doc/interpreter/func.txi @@ -29,6 +29,7 @@ like built-in functions. @menu +* Introduction to Function and Script Files:: * Defining Functions:: * Multiple Return Values:: * Variable-length Argument Lists:: @@ -43,6 +44,31 @@ * Organization of Functions:: @end menu +@node Introduction to Function and Script Files +@section Introduction to Function and Script Files + +There are six different things covered in this section. +@enumerate +@item +Typing in a function at the command prompt. +@item +Storing a group of commands in a file - called a script file. +@item +Storing a function in a file - called a function file. +@item +Sub-functions in function files. +@item +Multiple functions in one script file. +@item +Private functions. +@end enumerate + +Both function files and script files end with an extension of .m, for +@sc{Matlab} compatibility. If you want more than one independent +functions in a file, it must be a script file (@pxref{Script Files}), +and to use these functions you must execute the script file before you +can use the functions that are in the script file. + @node Defining Functions @section Defining Functions @cindex @code{function} statement
--- a/doc/interpreter/numbers.txi +++ b/doc/interpreter/numbers.txi @@ -773,9 +773,9 @@ @example @group x = ones (2, 2); -x (1, 1) = single (2) - @result{} x = 2 1 - 1 1 +x(1, 1) = single (2) + @result{} x = 2 1 + 1 1 @end group @end example
--- a/doc/interpreter/octave.texi +++ b/doc/interpreter/octave.texi @@ -644,7 +644,7 @@ * Basic Usage:: Creation and Manipulation of Diagonal and Permutation Matrices * Matrix Algebra:: Linear Algebra with Diagonal and Permutation Matrices * Function Support:: Functions That Are Aware of These Matrices -* Example Codes:: Some Examples of Usage +* Example Code:: Some Examples of Usage * Zeros Treatment:: The Differences in Treatment of Zero Elements Basic Usage
--- a/doc/interpreter/plot.txi +++ b/doc/interpreter/plot.txi @@ -834,15 +834,22 @@ @cindex printing plots @cindex saving plots -The @code{print} command allows you to save plots in a variety of -formats. For example, +The @code{print} command allows you to send plots to you printer and +to save plots in a variety of formats. For example, + +@example +print -dpsc +@end example + +@noindent +prints the current figure to a color PostScript printer. And, @example print -deps foo.eps @end example @noindent -writes the current figure to an encapsulated PostScript file called +saves the current figure to an encapsulated PostScript file called @file{foo.eps}. @DOCSTRING(print)
--- a/doc/interpreter/strings.txi +++ b/doc/interpreter/strings.txi @@ -187,14 +187,14 @@ @example @group -ischar(collection) - @result{} ans = 1 +ischar (collection) + @result{} 1 -ischar(collection) && isvector(collection) - @result{} ans = 0 +ischar (collection) && isvector (collection) + @result{} 0 -ischar("my string") && isvector("my string") - @result{} ans = 1 +ischar ("my string") && isvector ("my string") + @result{} 1 @end group @end example @@ -243,9 +243,8 @@ @example @group -char([98, 97, 110, 97, 110, 97]) - @result{} ans = - banana +char ([98, 97, 110, 97, 110, 97]) + @result{} banana @end group @end example @@ -256,16 +255,14 @@ @example @group -char("an apple", "two pears") - @result{} ans = - an apple +char ("an apple", "two pears") + @result{} an apple two pears @end group @group -strcat("oc", "tave", " is", " good", " for you") - @result{} ans = - octave is good for you +strcat ("oc", "tave", " is", " good", " for you") + @result{} octave is good for you @end group @end example @@ -275,18 +272,16 @@ @example @group -char("orange", "green", "", "red") - @result{} ans = - orange +char ("orange", "green", "", "red") + @result{} orange green red @end group @group -strvcat("orange", "green", "", "red") - @result{} ans = - orange +strvcat ("orange", "green", "", "red") + @result{} orange green red @end group @@ -299,21 +294,20 @@ @example @group -char(@{"red", "green", "", "blue"@}) - @result{} ans = - red - green +char (@{"red", "green", "", "blue"@}) + @result{} red + green - blue + blue @end group @group -strcat(@{"abc"; "ghi"@}, @{"def"; "jkl"@}) - @result{} ans = - @{ - [1,1] = abcdef - [2,1] = ghijkl - @} +strcat (@{"abc"; "ghi"@}, @{"def"; "jkl"@}) + @result{} + @{ + [1,1] = abcdef + [2,1] = ghijkl + @} @end group @end example @@ -323,17 +317,15 @@ @example @group -strcat(["dir1";"directory2"], ["/";"/"], ["file1";"file2"]) - @result{} ans = - dir1/file1 - directory2/file2 +strcat (["dir1";"directory2"], ["/";"/"], ["file1";"file2"]) + @result{} dir1/file1 + directory2/file2 @end group @group -cstrcat(["thirteen apples"; "a banana"], [" 5$";" 1$"]) - @result{} ans = - thirteen apples 5$ - a banana 1$ +cstrcat (["thirteen apples"; "a banana"], [" 5$";" 1$"]) + @result{} thirteen apples 5$ + a banana 1$ @end group @end example @@ -467,7 +459,7 @@ @example @group hex2dec ("FF") - @result{} ans = 255 + @result{} 255 @end group @end example
--- a/libcruft/Makefile.am +++ b/libcruft/Makefile.am @@ -20,7 +20,10 @@ include $(top_srcdir)/build-aux/common.mk -AM_CPPFLAGS = @CPPFLAGS@ -I../libgnu -I$(top_srcdir)/libgnu +## Search local directories before those specified by the user. +AM_CPPFLAGS = \ + -I../libgnu -I$(top_srcdir)/libgnu \ + @CPPFLAGS@ AUTOMAKE_OPTIONS = subdir-objects
--- a/libcruft/lapack-xtra/crsf2csf.f +++ b/libcruft/lapack-xtra/crsf2csf.f @@ -25,6 +25,9 @@ real c(n-1),s(n-1) real x,y,z integer j + do j = 1,n-1 + c(j) = 1 + end do j = 1 do while (j < n) c apply previous rotations to rows @@ -33,10 +36,9 @@ y = t(j+1,j) if (y /= 0) then c 2x2 block, form Givens rotation [c, i*s; i*s, c] - x = t(j,j) z = t(j,j+1) c(j) = sqrt(z/(z-y)) - s(j) = sign(sqrt(-y/(z-y)),z) + s(j) = sqrt(y/(y-z)) c apply new rotation to t(j:j+1,j) call crcrot1(2,t(j,j),c(j),s(j)) c apply all rotations to t(1:j+1,j+1) @@ -45,10 +47,8 @@ call crcrot2(j+1,t(1,j),t(1,j+1),c(j),s(j)) c zero subdiagonal entry, skip next row t(j+1,j) = 0 - c(j+1) = 1 j = j + 2 else - c(j) = 1 j = j + 1 end if end do
--- a/libcruft/lapack-xtra/zrsf2csf.f +++ b/libcruft/lapack-xtra/zrsf2csf.f @@ -25,6 +25,9 @@ double precision c(n-1),s(n-1) double precision x,y,z integer j + do j = 1,n-1 + c(j) = 1 + end do j = 1 do while (j < n) c apply previous rotations to rows @@ -33,10 +36,9 @@ y = t(j+1,j) if (y /= 0) then c 2x2 block, form Givens rotation [c, i*s; i*s, c] - x = t(j,j) z = t(j,j+1) c(j) = sqrt(z/(z-y)) - s(j) = sign(sqrt(-y/(z-y)),z) + s(j) = sqrt(y/(y-z)) c apply new rotation to t(j:j+1,j) call zrcrot1(2,t(j,j),c(j),s(j)) c apply all rotations to t(1:j+1,j+1) @@ -45,10 +47,8 @@ call zrcrot2(j+1,t(1,j),t(1,j+1),c(j),s(j)) c zero subdiagonal entry, skip next row t(j+1,j) = 0 - c(j+1) = 1 j = j + 2 else - c(j) = 1 j = j + 1 end if end do
--- a/libcruft/slatec-fn/atanh.f +++ b/libcruft/slatec-fn/atanh.f @@ -57,8 +57,14 @@ FIRST = .FALSE. C Y = ABS(X) - IF (Y .GE. 1.0) CALL XERMSG ('SLATEC', 'ATANH', 'ABS(X) GE 1', 2, - + 2) + IF (Y .GE. 1.0) THEN + IF (Y .GT. 1.0) THEN + ATANH = (X - X) / (X - X) + ELSE + ATANH = X / 0.0 + ENDIF + RETURN + ENDIF C IF (1.0-Y .LT. DXREL) CALL XERMSG ('SLATEC', 'ATANH', + 'ANSWER LT HALF PRECISION BECAUSE ABS(X) TOO NEAR 1', 1, 1)
--- a/libcruft/slatec-fn/datanh.f +++ b/libcruft/slatec-fn/datanh.f @@ -68,8 +68,14 @@ FIRST = .FALSE. C Y = ABS(X) - IF (Y .GE. 1.D0) CALL XERMSG ('SLATEC', 'DATANH', 'ABS(X) GE 1', - + 2, 2) + IF (Y .GE. 1.D0) THEN + IF (Y .GT. 1.D0) THEN + DATANH = (X - X) / (X - X) + ELSE + DATANH = X / 0.D0 + ENDIF + RETURN + ENDIF C IF (1.D0-Y .LT. DXREL) CALL XERMSG ('SLATEC', 'DATANH', + 'ANSWER LT HALF PRECISION BECAUSE ABS(X) TOO NEAR 1', 1, 1)
--- a/libcruft/slatec-fn/derfc.f +++ b/libcruft/slatec-fn/derfc.f @@ -191,6 +191,11 @@ ENDIF FIRST = .FALSE. C + IF (ISNAN(X)) THEN + DERFC = X + RETURN + ENDIF +C IF (X.GT.XSML) GO TO 20 C C ERFC(X) = 1.0 - ERF(X) FOR X .LT. XSML @@ -219,8 +224,7 @@ IF (X.LT.0.D0) DERFC = 2.0D0 - DERFC RETURN C - 40 CALL XERMSG ('SLATEC', 'DERFC', 'X SO BIG ERFC UNDERFLOWS', 1, 1) - DERFC = 0.D0 + 40 DERFC = 0.D0 RETURN C END
--- a/libcruft/slatec-fn/erfc.f +++ b/libcruft/slatec-fn/erfc.f @@ -121,6 +121,11 @@ ENDIF FIRST = .FALSE. C + IF (ISNAN(X)) THEN + ERFC = X + RETURN + ENDIF +C IF (X.GT.XSML) GO TO 20 C C ERFC(X) = 1.0 - ERF(X) FOR X .LT. XSML @@ -149,8 +154,7 @@ IF (X.LT.0.) ERFC = 2.0 - ERFC RETURN C - 40 CALL XERMSG ('SLATEC', 'ERFC', 'X SO BIG ERFC UNDERFLOWS', 1, 1) - ERFC = 0. + 40 ERFC = 0. RETURN C END
--- a/liboctave/Array.cc +++ b/liboctave/Array.cc @@ -1645,24 +1645,24 @@ %! m9 = reshape (1 : 9*8, 8, 9); %! mt9 = [mt8; 65:72]; -%!assert(m7', mt7) -%!assert((1i*m7).', 1i * mt7) -%!assert((1i*m7)', conj (1i * mt7)) -%!assert(m8', mt8) -%!assert((1i*m8).', 1i * mt8) -%!assert((1i*m8)', conj (1i * mt8)) -%!assert(m9', mt9) -%!assert((1i*m9).', 1i * mt9) -%!assert((1i*m9)', conj (1i * mt9)) -%!assert([m7, m8; m7, m8]', [mt7, mt7; mt8, mt8]) -%!assert((1i*[m7, m8; m7, m8]).', 1i * [mt7, mt7; mt8, mt8]) -%!assert((1i*[m7, m8; m7, m8])', conj (1i * [mt7, mt7; mt8, mt8])) -%!assert([m8, m8; m8, m8]', [mt8, mt8; mt8, mt8]) -%!assert((1i*[m8, m8; m8, m8]).', 1i * [mt8, mt8; mt8, mt8]) -%!assert((1i*[m8, m8; m8, m8])', conj (1i * [mt8, mt8; mt8, mt8])) -%!assert([m9, m8; m9, m8]', [mt9, mt9; mt8, mt8]) -%!assert((1i*[m9, m8; m9, m8]).', 1i * [mt9, mt9; mt8, mt8]) -%!assert((1i*[m9, m8; m9, m8])', conj (1i * [mt9, mt9; mt8, mt8])) +%!assert (m7', mt7) +%!assert ((1i*m7).', 1i * mt7) +%!assert ((1i*m7)', conj (1i * mt7)) +%!assert (m8', mt8) +%!assert ((1i*m8).', 1i * mt8) +%!assert ((1i*m8)', conj (1i * mt8)) +%!assert (m9', mt9) +%!assert ((1i*m9).', 1i * mt9) +%!assert ((1i*m9)', conj (1i * mt9)) +%!assert ([m7, m8; m7, m8]', [mt7, mt7; mt8, mt8]) +%!assert ((1i*[m7, m8; m7, m8]).', 1i * [mt7, mt7; mt8, mt8]) +%!assert ((1i*[m7, m8; m7, m8])', conj (1i * [mt7, mt7; mt8, mt8])) +%!assert ([m8, m8; m8, m8]', [mt8, mt8; mt8, mt8]) +%!assert ((1i*[m8, m8; m8, m8]).', 1i * [mt8, mt8; mt8, mt8]) +%!assert ((1i*[m8, m8; m8, m8])', conj (1i * [mt8, mt8; mt8, mt8])) +%!assert ([m9, m8; m9, m8]', [mt9, mt9; mt8, mt8]) +%!assert ((1i*[m9, m8; m9, m8]).', 1i * [mt9, mt9; mt8, mt8]) +%!assert ((1i*[m9, m8; m9, m8])', conj (1i * [mt9, mt9; mt8, mt8])) */ @@ -2253,6 +2253,7 @@ dv(dim) = std::min (nn, ns); dv.chop_trailing_singletons (); + dim = std::min (dv.length (), dim); Array<T> m (dv);
--- a/liboctave/CColVector.cc +++ b/liboctave/CColVector.cc @@ -346,13 +346,19 @@ if (nr != 0) { - Complex *y = retval.fortran_vec (); + if (nc == 0) + retval.fill (0.0); + else + { + Complex *y = retval.fortran_vec (); - F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 ("N", 1), - nr, nc, 1.0, m.data (), nr, - a.data (), 1, 0.0, y, 1 - F77_CHAR_ARG_LEN (1))); + F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 ("N", 1), + nr, nc, 1.0, m.data (), nr, + a.data (), 1, 0.0, y, 1 + F77_CHAR_ARG_LEN (1))); + } } + } return retval;
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -3702,25 +3702,27 @@ return ComplexMatrix (m) * a; } -/* 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) -%!assert([1 i]*[i 0]', -i); -*/ - -/* Test some simple identities +/* + +## 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) +%!assert ([1 i]*[i 0]', -i); + +## 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([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) +%! 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 ([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) + */ static inline char
--- a/liboctave/Makefile.am +++ b/liboctave/Makefile.am @@ -20,9 +20,11 @@ include $(top_srcdir)/build-aux/common.mk +## Search local directories before those specified by the user. AM_CPPFLAGS = \ - @CPPFLAGS@ -I../libgnu -I$(top_srcdir)/libgnu \ - -I$(top_srcdir)/libcruft/misc + -I../libgnu -I$(top_srcdir)/libgnu \ + -I$(top_srcdir)/libcruft/misc \ + @CPPFLAGS@ EXTRA_DIST = \ config-ops.sh \ @@ -521,7 +523,7 @@ # Increment these as needed and according to the rules in the libtool # manual: liboctave_current = 1 -liboctave_revision = 0 +liboctave_revision = 1 liboctave_age = 0 liboctave_version_info = $(liboctave_current):$(liboctave_revision):$(liboctave_age)
--- a/liboctave/Sparse.cc +++ b/liboctave/Sparse.cc @@ -1404,7 +1404,11 @@ if (idx.is_range () && idx.increment () == -1) { retval = Sparse<T> (nr, 1, nz); - std::reverse_copy (ridx (), ridx () + nz, retval.ridx ()); + + for (octave_idx_type j = 0; j < nz; j++) + retval.ridx (j) = nr - ridx (nz - j - 1) - 1; + + copy_or_memcpy (2, cidx (), retval.cidx ()); std::reverse_copy (data (), data () + nz, retval.data ()); } else @@ -2571,7 +2575,7 @@ * Tests * -%!function x = set_slice(x, dim, slice, arg) +%!function x = set_slice (x, dim, slice, arg) %! switch dim %! case 11 %! x(slice) = 2; @@ -2580,151 +2584,155 @@ %! case 22 %! x(:, slice) = 2; %! otherwise -%! error("invalid dim, '%d'", dim); +%! error ("invalid dim, '%d'", dim); %! endswitch -%! endfunction +%!endfunction -%!function x = set_slice2(x, dim, slice) +%!function x = set_slice2 (x, dim, slice) %! switch dim %! case 11 -%! x(slice) = 2 * ones (size(slice)); +%! x(slice) = 2 * ones (size (slice)); %! case 21 -%! x(slice, :) = 2 * ones (length(slice), columns (x)); +%! x(slice, :) = 2 * ones (length (slice), columns (x)); %! case 22 -%! x(:, slice) = 2 * ones (rows (x), length(slice)); +%! x(:, slice) = 2 * ones (rows (x), length (slice)); %! otherwise -%! error("invalid dim, '%d'", dim); +%! error ("invalid dim, '%d'", dim); %! endswitch -%! endfunction +%!endfunction -%!function test_sparse_slice(size, dim, slice) -%! x = ones(size); -%! s = set_slice(sparse(x), dim, slice); -%! f = set_slice(x, dim, slice); +%!function test_sparse_slice (size, dim, slice) +%! x = ones (size); +%! s = set_slice (sparse (x), dim, slice); +%! f = set_slice (x, dim, slice); %! assert (nnz(s), nnz(f)); -%! assert(full(s), f); -%! s = set_slice2(sparse(x), dim, slice); -%! f = set_slice2(x, dim, slice); +%! assert (full(s), f); +%! s = set_slice2 (sparse(x), dim, slice); +%! f = set_slice2 (x, dim, slice); %! assert (nnz(s), nnz(f)); -%! assert(full(s), f); -%! endfunction +%! assert (full(s), f); +%!endfunction #### 1d indexing ## size = [2 0] -%!test test_sparse_slice([2 0], 11, []); -%!assert(set_slice(sparse(ones([2 0])), 11, 1), sparse([2 0]')); # sparse different from full -%!assert(set_slice(sparse(ones([2 0])), 11, 2), sparse([0 2]')); # sparse different from full -%!assert(set_slice(sparse(ones([2 0])), 11, 3), sparse([0 0; 2 0]')); # sparse different from full -%!assert(set_slice(sparse(ones([2 0])), 11, 4), sparse([0 0; 0 2]')); # sparse different from full +%!test test_sparse_slice ([2 0], 11, []); +%!assert (set_slice (sparse (ones ([2 0])), 11, 1), sparse ([2 0]')) # sparse different from full +%!assert (set_slice (sparse (ones ([2 0])), 11, 2), sparse ([0 2]')) # sparse different from full +%!assert (set_slice (sparse (ones ([2 0])), 11, 3), sparse ([0 0; 2 0]')) # sparse different from full +%!assert (set_slice (sparse (ones ([2 0])), 11, 4), sparse ([0 0; 0 2]')) # sparse different from full ## size = [0 2] -%!test test_sparse_slice([0 2], 11, []); -%!assert(set_slice(sparse(ones([0 2])), 11, 1), sparse([2 0])); # sparse different from full -%!test test_sparse_slice([0 2], 11, 2); -%!test test_sparse_slice([0 2], 11, 3); -%!test test_sparse_slice([0 2], 11, 4); -%!test test_sparse_slice([0 2], 11, [4, 4]); +%!test test_sparse_slice ([0 2], 11, []); +%!assert (set_slice (sparse (ones ([0 2])), 11, 1), sparse ([2 0])) # sparse different from full +%!test test_sparse_slice ([0 2], 11, 2); +%!test test_sparse_slice ([0 2], 11, 3); +%!test test_sparse_slice ([0 2], 11, 4); +%!test test_sparse_slice ([0 2], 11, [4, 4]); ## size = [2 1] -%!test test_sparse_slice([2 1], 11, []); -%!test test_sparse_slice([2 1], 11, 1); -%!test test_sparse_slice([2 1], 11, 2); -%!test test_sparse_slice([2 1], 11, 3); -%!test test_sparse_slice([2 1], 11, 4); -%!test test_sparse_slice([2 1], 11, [4, 4]); +%!test test_sparse_slice ([2 1], 11, []); +%!test test_sparse_slice ([2 1], 11, 1); +%!test test_sparse_slice ([2 1], 11, 2); +%!test test_sparse_slice ([2 1], 11, 3); +%!test test_sparse_slice ([2 1], 11, 4); +%!test test_sparse_slice ([2 1], 11, [4, 4]); ## size = [1 2] -%!test test_sparse_slice([1 2], 11, []); -%!test test_sparse_slice([1 2], 11, 1); -%!test test_sparse_slice([1 2], 11, 2); -%!test test_sparse_slice([1 2], 11, 3); -%!test test_sparse_slice([1 2], 11, 4); -%!test test_sparse_slice([1 2], 11, [4, 4]); +%!test test_sparse_slice ([1 2], 11, []); +%!test test_sparse_slice ([1 2], 11, 1); +%!test test_sparse_slice ([1 2], 11, 2); +%!test test_sparse_slice ([1 2], 11, 3); +%!test test_sparse_slice ([1 2], 11, 4); +%!test test_sparse_slice ([1 2], 11, [4, 4]); ## size = [2 2] -%!test test_sparse_slice([2 2], 11, []); -%!test test_sparse_slice([2 2], 11, 1); -%!test test_sparse_slice([2 2], 11, 2); -%!test test_sparse_slice([2 2], 11, 3); -%!test test_sparse_slice([2 2], 11, 4); -%!test test_sparse_slice([2 2], 11, [4, 4]); +%!test test_sparse_slice ([2 2], 11, []); +%!test test_sparse_slice ([2 2], 11, 1); +%!test test_sparse_slice ([2 2], 11, 2); +%!test test_sparse_slice ([2 2], 11, 3); +%!test test_sparse_slice ([2 2], 11, 4); +%!test test_sparse_slice ([2 2], 11, [4, 4]); # These 2 errors are the same as in the full case -%!error id=Octave:invalid-resize set_slice(sparse(ones([2 2])), 11, 5); -%!error id=Octave:invalid-resize set_slice(sparse(ones([2 2])), 11, 6); +%!error id=Octave:invalid-resize set_slice (sparse (ones ([2 2])), 11, 5) +%!error id=Octave:invalid-resize set_slice (sparse (ones ([2 2])), 11, 6) #### 2d indexing ## size = [2 0] -%!test test_sparse_slice([2 0], 21, []); -%!test test_sparse_slice([2 0], 21, 1); -%!test test_sparse_slice([2 0], 21, 2); -%!test test_sparse_slice([2 0], 21, [2,2]); -%!assert(set_slice(sparse(ones([2 0])), 21, 3), sparse(3,0)); -%!assert(set_slice(sparse(ones([2 0])), 21, 4), sparse(4,0)); -%!test test_sparse_slice([2 0], 22, []); -%!test test_sparse_slice([2 0], 22, 1); -%!test test_sparse_slice([2 0], 22, 2); -%!test test_sparse_slice([2 0], 22, [2,2]); -%!assert(set_slice(sparse(ones([2 0])), 22, 3), sparse([0 0 2;0 0 2])); # sparse different from full -%!assert(set_slice(sparse(ones([2 0])), 22, 4), sparse([0 0 0 2;0 0 0 2])); # sparse different from full +%!test test_sparse_slice ([2 0], 21, []); +%!test test_sparse_slice ([2 0], 21, 1); +%!test test_sparse_slice ([2 0], 21, 2); +%!test test_sparse_slice ([2 0], 21, [2,2]); +%!assert (set_slice (sparse (ones ([2 0])), 21, 3), sparse (3,0)) +%!assert (set_slice (sparse (ones ([2 0])), 21, 4), sparse (4,0)) +%!test test_sparse_slice ([2 0], 22, []); +%!test test_sparse_slice ([2 0], 22, 1); +%!test test_sparse_slice ([2 0], 22, 2); +%!test test_sparse_slice ([2 0], 22, [2,2]); +%!assert (set_slice (sparse (ones ([2 0])), 22, 3), sparse ([0 0 2;0 0 2])) # sparse different from full +%!assert (set_slice (sparse (ones ([2 0])), 22, 4), sparse ([0 0 0 2;0 0 0 2])) # sparse different from full ## size = [0 2] -%!test test_sparse_slice([0 2], 21, []); -%!test test_sparse_slice([0 2], 21, 1); -%!test test_sparse_slice([0 2], 21, 2); -%!test test_sparse_slice([0 2], 21, [2,2]); -%!assert(set_slice(sparse(ones([0 2])), 21, 3), sparse([0 0;0 0;2 2])); # sparse different from full -%!assert(set_slice(sparse(ones([0 2])), 21, 4), sparse([0 0;0 0;0 0;2 2])); # sparse different from full -%!test test_sparse_slice([0 2], 22, []); -%!test test_sparse_slice([0 2], 22, 1); -%!test test_sparse_slice([0 2], 22, 2); -%!test test_sparse_slice([0 2], 22, [2,2]); -%!assert(set_slice(sparse(ones([0 2])), 22, 3), sparse(0,3)); -%!assert(set_slice(sparse(ones([0 2])), 22, 4), sparse(0,4)); +%!test test_sparse_slice ([0 2], 21, []); +%!test test_sparse_slice ([0 2], 21, 1); +%!test test_sparse_slice ([0 2], 21, 2); +%!test test_sparse_slice ([0 2], 21, [2,2]); +%!assert (set_slice (sparse (ones ([0 2])), 21, 3), sparse ([0 0;0 0;2 2])) # sparse different from full +%!assert (set_slice (sparse (ones ([0 2])), 21, 4), sparse ([0 0;0 0;0 0;2 2])) # sparse different from full +%!test test_sparse_slice ([0 2], 22, []); +%!test test_sparse_slice ([0 2], 22, 1); +%!test test_sparse_slice ([0 2], 22, 2); +%!test test_sparse_slice ([0 2], 22, [2,2]); +%!assert (set_slice (sparse (ones ([0 2])), 22, 3), sparse (0,3)) +%!assert (set_slice (sparse (ones ([0 2])), 22, 4), sparse (0,4)) ## size = [2 1] -%!test test_sparse_slice([2 1], 21, []); -%!test test_sparse_slice([2 1], 21, 1); -%!test test_sparse_slice([2 1], 21, 2); -%!test test_sparse_slice([2 1], 21, [2,2]); -%!test test_sparse_slice([2 1], 21, 3); -%!test test_sparse_slice([2 1], 21, 4); -%!test test_sparse_slice([2 1], 22, []); -%!test test_sparse_slice([2 1], 22, 1); -%!test test_sparse_slice([2 1], 22, 2); -%!test test_sparse_slice([2 1], 22, [2,2]); -%!test test_sparse_slice([2 1], 22, 3); -%!test test_sparse_slice([2 1], 22, 4); +%!test test_sparse_slice ([2 1], 21, []); +%!test test_sparse_slice ([2 1], 21, 1); +%!test test_sparse_slice ([2 1], 21, 2); +%!test test_sparse_slice ([2 1], 21, [2,2]); +%!test test_sparse_slice ([2 1], 21, 3); +%!test test_sparse_slice ([2 1], 21, 4); +%!test test_sparse_slice ([2 1], 22, []); +%!test test_sparse_slice ([2 1], 22, 1); +%!test test_sparse_slice ([2 1], 22, 2); +%!test test_sparse_slice ([2 1], 22, [2,2]); +%!test test_sparse_slice ([2 1], 22, 3); +%!test test_sparse_slice ([2 1], 22, 4); ## size = [1 2] -%!test test_sparse_slice([1 2], 21, []); -%!test test_sparse_slice([1 2], 21, 1); -%!test test_sparse_slice([1 2], 21, 2); -%!test test_sparse_slice([1 2], 21, [2,2]); -%!test test_sparse_slice([1 2], 21, 3); -%!test test_sparse_slice([1 2], 21, 4); -%!test test_sparse_slice([1 2], 22, []); -%!test test_sparse_slice([1 2], 22, 1); -%!test test_sparse_slice([1 2], 22, 2); -%!test test_sparse_slice([1 2], 22, [2,2]); -%!test test_sparse_slice([1 2], 22, 3); -%!test test_sparse_slice([1 2], 22, 4); +%!test test_sparse_slice ([1 2], 21, []); +%!test test_sparse_slice ([1 2], 21, 1); +%!test test_sparse_slice ([1 2], 21, 2); +%!test test_sparse_slice ([1 2], 21, [2,2]); +%!test test_sparse_slice ([1 2], 21, 3); +%!test test_sparse_slice ([1 2], 21, 4); +%!test test_sparse_slice ([1 2], 22, []); +%!test test_sparse_slice ([1 2], 22, 1); +%!test test_sparse_slice ([1 2], 22, 2); +%!test test_sparse_slice ([1 2], 22, [2,2]); +%!test test_sparse_slice ([1 2], 22, 3); +%!test test_sparse_slice ([1 2], 22, 4); ## size = [2 2] -%!test test_sparse_slice([2 2], 21, []); -%!test test_sparse_slice([2 2], 21, 1); -%!test test_sparse_slice([2 2], 21, 2); -%!test test_sparse_slice([2 2], 21, [2,2]); -%!test test_sparse_slice([2 2], 21, 3); -%!test test_sparse_slice([2 2], 21, 4); -%!test test_sparse_slice([2 2], 22, []); -%!test test_sparse_slice([2 2], 22, 1); -%!test test_sparse_slice([2 2], 22, 2); -%!test test_sparse_slice([2 2], 22, [2,2]); -%!test test_sparse_slice([2 2], 22, 3); -%!test test_sparse_slice([2 2], 22, 4); +%!test test_sparse_slice ([2 2], 21, []); +%!test test_sparse_slice ([2 2], 21, 1); +%!test test_sparse_slice ([2 2], 21, 2); +%!test test_sparse_slice ([2 2], 21, [2,2]); +%!test test_sparse_slice ([2 2], 21, 3); +%!test test_sparse_slice ([2 2], 21, 4); +%!test test_sparse_slice ([2 2], 22, []); +%!test test_sparse_slice ([2 2], 22, 1); +%!test test_sparse_slice ([2 2], 22, 2); +%!test test_sparse_slice ([2 2], 22, [2,2]); +%!test test_sparse_slice ([2 2], 22, 3); +%!test test_sparse_slice ([2 2], 22, 4); + +bug #35570: + +%!assert (speye (3,1)(3:-1:1), sparse ([0; 0; 1])) */
--- a/liboctave/config-ops.sh +++ b/liboctave/config-ops.sh @@ -34,7 +34,7 @@ case "$src_type" in inc | all) VX_INC=$($AWK -f $mk_ops prefix=vx list_h_files=1 $liboctave_dir/vx-ops) - echo "VX_OP_INC = $(echo $VX_INC)" > $liboctave_dir/vx-op-inc.mk-t + echo "VX_OP_INC = $VX_INC" > $liboctave_dir/vx-op-inc.mk-t $move_if_change $liboctave_dir/vx-op-inc.mk-t $liboctave_dir/vx-op-inc.mk ;; esac @@ -46,7 +46,7 @@ case "$src_type" in src | all) VX_SRC=$($AWK -f $mk_ops prefix=vx list_cc_files=1 $liboctave_dir/vx-ops) - echo "VX_OP_SRC = $(echo $VX_SRC)" > $liboctave_dir/vx-op-src.mk-t + echo "VX_OP_SRC = $VX_SRC" > $liboctave_dir/vx-op-src.mk-t $move_if_change $liboctave_dir/vx-op-src.mk-t $liboctave_dir/vx-op-src.mk ;; esac @@ -58,7 +58,7 @@ case "$src_type" in inc | all) MX_INC=$($AWK -f $mk_ops prefix=mx list_h_files=1 $liboctave_dir/mx-ops) - echo "MX_OP_INC = $(echo $MX_INC)" > $liboctave_dir/mx-op-inc.mk-t + echo "MX_OP_INC = $MX_INC" > $liboctave_dir/mx-op-inc.mk-t $move_if_change $liboctave_dir/mx-op-inc.mk-t $liboctave_dir/mx-op-inc.mk ;; esac @@ -70,7 +70,7 @@ case "$src_type" in src | all) MX_SRC=$($AWK -f $mk_ops prefix=mx list_cc_files=1 $liboctave_dir/mx-ops) - echo "MX_OP_SRC = $(echo $MX_SRC)" > $liboctave_dir/mx-op-src.mk-t + echo "MX_OP_SRC = $MX_SRC" > $liboctave_dir/mx-op-src.mk-t $move_if_change $liboctave_dir/mx-op-src.mk-t $liboctave_dir/mx-op-src.mk ;; esac @@ -82,7 +82,7 @@ case "$src_type" in inc | all) SMX_INC=$($AWK -f $sparse_mk_ops prefix=smx list_h_files=1 $liboctave_dir/sparse-mx-ops) - echo "SMX_OP_INC = $(echo $SMX_INC)" > $liboctave_dir/smx-op-inc.mk-t + echo "SMX_OP_INC = $SMX_INC" > $liboctave_dir/smx-op-inc.mk-t $move_if_change $liboctave_dir/smx-op-inc.mk-t $liboctave_dir/smx-op-inc.mk ;; esac @@ -94,7 +94,7 @@ case "$src_type" in src | all) SMX_SRC=$($AWK -f $sparse_mk_ops prefix=smx list_cc_files=1 $liboctave_dir/sparse-mx-ops) - echo "SMX_OP_SRC = $(echo $SMX_SRC)" > $liboctave_dir/smx-op-src.mk-t + echo "SMX_OP_SRC = $SMX_SRC" > $liboctave_dir/smx-op-src.mk-t $move_if_change $liboctave_dir/smx-op-src.mk-t $liboctave_dir/smx-op-src.mk ;; esac
--- a/liboctave/dColVector.cc +++ b/liboctave/dColVector.cc @@ -212,12 +212,17 @@ if (nr != 0) { - double *y = retval.fortran_vec (); + if (nc == 0) + retval.fill (0.0); + else + { + double *y = retval.fortran_vec (); - F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 ("N", 1), - nr, nc, 1.0, m.data (), nr, - a.data (), 1, 0.0, y, 1 - F77_CHAR_ARG_LEN (1))); + F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 ("N", 1), + nr, nc, 1.0, m.data (), nr, + a.data (), 1, 0.0, y, 1 + F77_CHAR_ARG_LEN (1))); + } } }
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -3113,26 +3113,28 @@ // 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 +/* + +## 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, Mt, rvt -%! M = randn(10,10)+100*eye(10,10); +%! M = randn (10,10) + 100*eye (10,10); %! Mt = M'; -%! cv = randn(10,1); -%! rv = randn(1,10); +%! cv = randn (10,1); +%! rv = randn (1,10); %! rvt = rv'; -%!assert([M*cv,M*cv],M*[cv,cv],1e-13) -%!assert([M'*cv,M'*cv],M'*[cv,cv],1e-13) -%!assert([rv*M;rv*M],[rv;rv]*M,1e-13) -%!assert([rv*M';rv*M'],[rv;rv]*M',1e-13) -%!assert(2*rv*cv,[rv,rv]*[cv;cv],1e-13) -%!assert(M'\cv,Mt\cv,1e-14) -%!assert(M'\rv',Mt\rvt,1e-14) +%!assert ([M*cv,M*cv], M*[cv,cv], 1e-13) +%!assert ([M'*cv,M'*cv], M'*[cv,cv], 1e-13) +%!assert ([rv*M;rv*M], [rv;rv]*M, 1e-13) +%!assert ([rv*M';rv*M'], [rv;rv]*M', 1e-13) +%!assert (2*rv*cv, [rv,rv]*[cv;cv], 1e-13) +%!assert (M'\cv, Mt\cv, 1e-14) +%!assert (M'\rv', Mt\rvt, 1e-14) + */ static inline char
--- a/liboctave/dim-vector.h +++ b/liboctave/dim-vector.h @@ -129,10 +129,10 @@ { if (count () > 1) { - octave_idx_type *new_rep = clonerep (); + octave_idx_type *new_rep = clonerep (); - if (OCTREFCOUNT_ATOMIC_DECREMENT(&(count())) == 0) - freerep (); + if (OCTREFCOUNT_ATOMIC_DECREMENT(&(count())) == 0) + freerep (); rep = new_rep; }
--- a/liboctave/fCColVector.cc +++ b/liboctave/fCColVector.cc @@ -346,12 +346,17 @@ if (nr != 0) { - FloatComplex *y = retval.fortran_vec (); + if (nc == 0) + retval.fill (0.0); + else + { + FloatComplex *y = retval.fortran_vec (); - F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 ("N", 1), - nr, nc, 1.0f, m.data (), nr, - a.data (), 1, 0.0f, y, 1 - F77_CHAR_ARG_LEN (1))); + F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 ("N", 1), + nr, nc, 1.0f, m.data (), nr, + a.data (), 1, 0.0f, y, 1 + F77_CHAR_ARG_LEN (1))); + } } }
--- a/liboctave/fCMatrix.cc +++ b/liboctave/fCMatrix.cc @@ -3698,25 +3698,27 @@ return m * FloatComplexMatrix (a); } -/* 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 +/* + +## 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) +%! 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 char
--- a/liboctave/fColVector.cc +++ b/liboctave/fColVector.cc @@ -211,12 +211,17 @@ if (nr != 0) { - float *y = retval.fortran_vec (); + if (nc == 0) + retval.fill (0.0); + else + { + float *y = retval.fortran_vec (); - F77_XFCN (sgemv, SGEMV, (F77_CONST_CHAR_ARG2 ("N", 1), - nr, nc, 1.0f, m.data (), nr, - a.data (), 1, 0.0f, y, 1 - F77_CHAR_ARG_LEN (1))); + F77_XFCN (sgemv, SGEMV, (F77_CONST_CHAR_ARG2 ("N", 1), + nr, nc, 1.0f, m.data (), nr, + a.data (), 1, 0.0f, y, 1 + F77_CHAR_ARG_LEN (1))); + } } }
--- a/liboctave/fMatrix.cc +++ b/liboctave/fMatrix.cc @@ -3113,22 +3113,23 @@ // 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 +/* +## 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) +%! 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 char
--- a/liboctave/mk-ops.awk +++ b/liboctave/mk-ops.awk @@ -93,13 +93,13 @@ if (list_cc_files) { - print cc_file; + printf (" %s", cc_file); next; } if (list_h_files) { - print h_file; + printf (" %s", h_file); next; }
--- a/liboctave/oct-inttypes.cc +++ b/liboctave/oct-inttypes.cc @@ -630,24 +630,23 @@ INSTANTIATE_INTTYPE (uint64_t); -// Tests follow. - /* -%!assert(intmax("int64")/intmin("int64"),int64(-1)) -%!assert(intmin("int64")/int64(-1),intmax("int64")) -%!assert(int64(2**63),intmax("int64")) -%!assert(uint64(2**64),intmax("uint64")) +%!assert (intmax ("int64") / intmin ("int64"), int64 (-1)) +%!assert (intmin ("int64") / int64 (-1), intmax ("int64")) +%!assert (int64 (2**63), intmax ("int64")) +%!assert (uint64 (2**64), intmax ("uint64")) %!test -%! a = 1.9*2^61; b = uint64(a); b++; assert(b > a) +%! a = 1.9*2^61; b = uint64 (a); b++; assert (b > a); %!test -%! a = -1.9*2^61; b = int64(a); b++; assert(b > a) +%! a = -1.9*2^61; b = int64 (a); b++; assert (b > a); %!test -%! a = int64(-2**60) + 2; assert(1.25*a == (5*a)/4) +%! a = int64 (-2**60) + 2; assert (1.25*a == (5*a)/4); %!test -%! a = uint64(2**61) + 2; assert(1.25*a == (5*a)/4) -%!assert(int32(2**31+0.5),intmax('int32')) -%!assert(int32(-2**31-0.5),intmin('int32')) -%!assert((int64(2**62)+1)**1, int64(2**62)+1) -%!assert((int64(2**30)+1)**2, int64(2**60+2**31) + 1) +%! a = uint64 (2**61) + 2; assert (1.25*a == (5*a)/4); +%!assert (int32 (2**31+0.5), intmax ("int32")) +%!assert (int32 (-2**31-0.5), intmin ("int32")) +%!assert ((int64 (2**62)+1)**1, int64 (2**62)+1) +%!assert ((int64 (2**30)+1)**2, int64 (2**60+2**31) + 1) + */
--- a/liboctave/regexp.cc +++ b/liboctave/regexp.cc @@ -333,8 +333,7 @@ { if (ovector[2*i] >= 0 && ovector[2*i+1] > 0 && (i == 1 || ovector[2*i] != ovector[2*i-2] - || ovector[2*i-1] != ovector[2*i+1]) - && ovector[2*i] >= 0 && ovector[2*i+1] > 0) + || ovector[2*i-1] != ovector[2*i+1])) { token_extents(pos_match,0) = double (ovector[2*i]+1); token_extents(pos_match++,1) = double (ovector[2*i+1]); @@ -371,8 +370,21 @@ || ovector[2*i-1] != ovector[2*i+1]) { if (namecount > 0) - named_tokens(named_idx(i-pos_offset-1)) = - std::string (*(listptr+nidx[i-pos_offset-1])); + { + // FIXME: Should probably do this with a map() + // rather than a linear search. However, + // the number of captured, named expressions + // is usually pretty small (< 4) + for (int j = 0; j < namecount; j++) + { + if (nidx[j] == i) + { + named_tokens(named_idx(j)) = + std::string (*(listptr+i-pos_offset)); + break; + } + } + } tokens(pos_match++) = std::string (*(listptr+i)); }
--- a/liboctave/regexp.h +++ b/liboctave/regexp.h @@ -89,7 +89,7 @@ std::string replace (const std::string& buffer, const std::string& replacement); - struct opts + class opts { public:
--- a/liboctave/sparse-mk-ops.awk +++ b/liboctave/sparse-mk-ops.awk @@ -92,13 +92,13 @@ if (list_cc_files) { - print cc_file; + printf (" %s", cc_file); next; } if (list_h_files) { - print h_file; + printf (" %s", h_file); next; }
--- a/m4/acinclude.m4 +++ b/m4/acinclude.m4 @@ -478,7 +478,7 @@ LEXLIB= ;; *) - LEX='$(top_srcdir)/missing flex' + LEX='$(top_srcdir)/build-aux/missing flex' warn_flex="I didn't find flex, but it's only a problem if you need to reconstruct lex.cc" AC_MSG_WARN([$warn_flex]) ;; @@ -494,7 +494,7 @@ bison*) ;; *) - YACC='$(top_srcdir)/missing bison' + YACC='$(top_srcdir)/build-aux/missing bison' warn_bison="I didn't find bison, but it's only a problem if you need to reconstruct parse.cc" AC_MSG_WARN([$warn_bison]) ;; @@ -553,7 +553,7 @@ AC_DEFUN([OCTAVE_PROG_GPERF], [ AC_CHECK_PROG(GPERF, gperf, gperf, []) if test -z "$GPERF"; then - GPERF='$(top_srcdir)/missing gperf' + GPERF='$(top_srcdir)/build-aux/missing gperf' warn_gperf="I didn't find gperf, but it's only a problem if you need to reconstruct oct-gperf.h" AC_MSG_WARN([$warn_gperf]) fi @@ -574,7 +574,7 @@ esac AC_CHECK_PROGS(GHOSTSCRIPT, [$gs_names]) if test -z "$GHOSTSCRIPT"; then - GHOSTSCRIPT='$(top_srcdir)/missing gs' + GHOSTSCRIPT='$(top_srcdir)/build-aux/missing gs' warn_ghostscript="I didn't find ghostscript, so reconstructing figures for the manual will fail, and saving graphics in some output formats will fail when using Octave" AC_MSG_WARN([$warn_ghostscript]) fi @@ -587,7 +587,7 @@ AC_DEFUN([OCTAVE_PROG_TEXI2DVI], [ AC_CHECK_PROG(TEXI2DVI, texi2dvi, texi2dvi, []) if test -z "$TEXI2DVI"; then - TEXI2DVI='$(top_srcdir)/missing texi2dvi' + TEXI2DVI='$(top_srcdir)/build-aux/missing texi2dvi' warn_texi2dvi="I didn't find texi2dvi, but it's only a problem if you need to reconstruct the DVI version of the manual" AC_MSG_WARN([$warn_texi2dvi]) fi @@ -610,7 +610,7 @@ missing=false; fi if $missing; then - TEXI2PDF='$(top_srcdir)/missing texi2pdf' + TEXI2PDF='$(top_srcdir)/build-aux/missing texi2pdf' warn_texi2pdf="I didn't find texi2pdf, but it's only a problem if you need to reconstruct the PDF version of the manual" AC_MSG_WARN([$warn_texi2pdf]) fi
--- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -74,7 +74,11 @@ FCN_FILES_IN = $(GEN_FCN_FILES:.m=.in) +if AMCOND_BUILD_DOCS all-local: $(GEN_FCN_FILES) $(PKG_ADD_FILES) .DOCSTRINGS +else +all-local: $(GEN_FCN_FILES) $(PKG_ADD_FILES) +endif octave_dirstamp = $(am__leading_dot)dirstamp @@ -320,6 +324,7 @@ $(MKDIR_P) time : > time/$(octave_dirstamp) +if AMCOND_BUILD_DOCS ## Program compiled only to help build documentation. No installation needed. noinst_PROGRAMS = gethelp @@ -335,6 +340,7 @@ @$(srcdir)/mkdoc "$(srcdir)" $(FCN_FILES) -- $(GEN_FCN_FILES) > $@ $(top_srcdir)/build-aux/move-if-change $@ DOCSTRINGS touch $@ +endif $(GEN_FCN_FILES) : %.m : %.in Makefile @$(do_subst_config_vals)
--- a/scripts/general/int2str.m +++ b/scripts/general/int2str.m @@ -32,7 +32,7 @@ ## 4 5 6 ## ## whos s -## @result{} s = +## @result{} ## Attr Name Size Bytes Class ## ==== ==== ==== ===== ===== ## s 2x7 14 char
--- a/scripts/general/prepad.m +++ b/scripts/general/prepad.m @@ -46,7 +46,7 @@ c = 0; else if (! isscalar (c)) - error ("prepad: third argument must be empty or a scalar"); + error ("prepad: pad value C must be empty or a scalar"); endif endif @@ -63,7 +63,7 @@ endif if (! isscalar (l) || l < 0) - error ("prepad: second argument must be a positive scaler"); + error ("prepad: length L must be a positive scalar"); endif if (dim > nd) @@ -97,5 +97,10 @@ %!error prepad () %!error prepad (1) %!error prepad (1,2,3,4,5) -%!error prepad ([1,2], 2, 2,3) +%!error <C must be empty or a scalar> prepad ([1,2], 2, ones (2)) +%!error <DIM must be an integer> prepad ([1,2], 2, 2, ones (3)) +%!error <DIM must be an integer> prepad ([1,2], 2, 2, 1.1) +%!error <DIM must be an integer> prepad ([1,2], 2, 2, 3) +%!error <L must be a positive scalar> prepad ([1,2], ones (2)) +%!error <L must be a positive scalar> prepad ([1,2], -1)
--- a/scripts/general/profshow.m +++ b/scripts/general/profshow.m @@ -98,5 +98,7 @@ %!error profshow () %!error profshow (1, 2, 3) -%!error profshow (struct (), 1.2) +%!error <N must be a positive integer> profshow (struct (), ones (2)) +%!error <N must be a positive integer> profshow (struct (), 1+i) +%!error <N must be a positive integer> profshow (struct (), -1)
--- a/scripts/geometry/griddata3.m +++ b/scripts/geometry/griddata3.m @@ -17,13 +17,13 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}) -## @deftypefnx {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}, @var{method}) -## @deftypefnx {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}, @var{method}, @var{options}) +## @deftypefn {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v}, @var{xi}, @var{yi}, @var{zi}) +## @deftypefnx {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v}, @var{xi}, @var{yi}, @var{zi}, @var{method}) +## @deftypefnx {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v}, @var{xi}, @var{yi}, @var{zi}, @var{method}, @var{options}) ## ## Generate a regular mesh from irregular data using interpolation. -## The function is defined by @code{@var{y} = f (@var{x},@var{y},@var{z})}. -## The interpolation points are all @var{xi}. +## The function is defined by @code{@var{v} = f (@var{x}, @var{y}, @var{z})}. +## The interpolation points are specified by @var{xi}, @var{yi}, @var{zi}. ## ## The interpolation method can be @code{"nearest"} or @code{"linear"}. ## If method is omitted it defaults to @code{"linear"}.
--- a/scripts/io/fileread.m +++ b/scripts/io/fileread.m @@ -38,7 +38,7 @@ endif unwind_protect - str = fread (fid, "*char"); + str = (fread (fid, "*char")).'; unwind_protect_cleanup fclose (fid); end_unwind_protect @@ -53,7 +53,7 @@ %! fprintf (fid, "%s\n", cstr{:}); %! fclose (fid); %! str = fileread (fname); -%! assert (str', [cstr{1} "\n" cstr{2} "\n" cstr{3} "\n"]); +%! assert (str, [cstr{1} "\n" cstr{2} "\n" cstr{3} "\n"]); %! unlink (fname); %% Test input validation
--- a/scripts/io/textread.m +++ b/scripts/io/textread.m @@ -71,8 +71,8 @@ fskipl (fid, varargin{headerlines + 1}); varargin(headerlines:headerlines+1) = []; endif - - if (nargin > 2 && isnumeric (varargin{1})) + + if (! isempty (varargin) && isnumeric (varargin{1})) nlines = varargin{1}; else nlines = Inf; @@ -140,6 +140,14 @@ %! assert (b, d(4:5, 2), 1e-2); %! assert (c, d(4:5, 3), 1e-2); +%!test +%! f = tmpnam (); +%! d = rand (7, 2); +%! dlmwrite (f, d, "precision", "%5.2f"); +%! [a, b] = textread (f, "%f, %f", "headerlines", 1); +%! unlink (f); +%! assert (a, d(2:7, 1), 1e-2); + %% Test input validation %!error textread () %!error textread (1)
--- a/scripts/linear-algebra/logm.m +++ b/scripts/linear-algebra/logm.m @@ -104,7 +104,7 @@ s = 2^k * u * s * u'; ## Remove small complex values (O(eps)) which may have entered calculation - if (real_eig) + if (real_eig && isreal(A)) s = real (s); endif @@ -162,6 +162,7 @@ %!assert (logm (10), log (10)) %!assert (full (logm (eye (3))), logm (full (eye (3)))) %!assert (full (logm (10*eye (3))), logm (full (10*eye (3))), 8*eps) +%!assert (logm (expm ([0 1i; -1i 0])), [0 1i; -1i 0], 10 * eps) %% Test input validation %!error logm ()
--- a/scripts/optimization/fminunc.m +++ b/scripts/optimization/fminunc.m @@ -350,15 +350,16 @@ gx = []; endif - if (! (isreal (fx) && isreal (jx))) + if (! (isreal (fx) && isreal (gx))) error ("fminunc:notreal", "fminunc: non-real value encountered"); - elseif (complexeqn && ! (isnumeric (fx) && isnumeric(jx))) - error ("fminunc:notnum", "fminunc: non-numeric value encountered"); elseif (any (isnan (fx(:)))) error ("fminunc:isnan", "fminunc: NaN value encountered"); + elseif (any (isinf (fx(:)))) + error ("fminunc:isinf", "fminunc: Inf value encountered"); endif endfunction + %!function f = __rosenb (x) %! n = length (x); %! f = sumsq (1 - x(1:n-1)) + 100 * sumsq (x(2:n) - x(1:n-1).^2); @@ -375,6 +376,12 @@ %! assert (info > 0); %! assert (x, ones (1, 4), tol); %! assert (fval, 0, tol); +%% Test FunValCheck works correctly +%!assert (fminunc (@(x) x^2, 1, optimset ("FunValCheck", "on")), 0, eps) +%!error <non-real value> fminunc (@(x) x + i, 1, optimset ("FunValCheck", "on")) +%!error <NaN value> fminunc (@(x) x + NaN, 1, optimset ("FunValCheck", "on")) +%!error <Inf value> fminunc (@(x) x + Inf, 1, optimset ("FunValCheck", "on")) + ## Solve the double dogleg trust-region minimization problem: ## Minimize 1/2*norm(r*x)^2 subject to the constraint norm(d.*x) <= delta,
--- a/scripts/optimization/fsolve.m +++ b/scripts/optimization/fsolve.m @@ -450,6 +450,8 @@ error ("fsolve:notnum", "fsolve: non-numeric value encountered"); elseif (any (isnan (fx(:)))) error ("fsolve:isnan", "fsolve: NaN value encountered"); + elseif (any (isinf (fx(:)))) + error ("fsolve:isinf", "fsolve: Inf value encountered"); endif endfunction
--- a/scripts/optimization/optimset.m +++ b/scripts/optimization/optimset.m @@ -34,8 +34,11 @@ ## @item FinDiffType ## ## @item FunValCheck -## When enabled, display an error if the objective function returns a complex -## value or NaN@. Must be set to "on" or "off" [default]. +## When enabled, display an error if the objective function returns an invalid +## value (a complex value, NaN, or Inf). Must be set to "on" or "off" +## [default]. Note: the functions @code{fzero} and @code{fminbnd} correctly +## handle Inf values and only complex values or NaN will cause an error in this +## case. ## ## @item GradObj ## When set to "on", the function to be minimized must return a second argument
--- a/scripts/pkg/pkg.m +++ b/scripts/pkg/pkg.m @@ -1751,7 +1751,8 @@ value = strip (line (colon+1:end)); if (length (value) == 0) fclose (fid); - error ("the keyword %s has an empty value", desc.keywords{end}); + error ("The keyword `%s' of the package `%s' has an empty value", + keyword, desc.name); endif desc.(keyword) = value; endif
--- a/scripts/plot/__gnuplot_drawnow__.m +++ b/scripts/plot/__gnuplot_drawnow__.m @@ -197,6 +197,9 @@ "gif", "jpeg", "latex", "pbm", "pdf", ... "pdfcairo", "postscript", "png", "pngcairo", ... "pstex", "pslatex", "svg", "tikz"}; + if (__gnuplot_has_feature__ ("windows_figure_position")) + terminals_with_size{end+1} = "windows"; + endif if (__gnuplot_has_feature__ ("x11_figure_position")) terminals_with_size{end+1} = "x11"; endif @@ -226,9 +229,11 @@ otherwise size_str = ""; endswitch - if (strncmpi (term, "x11", 3) - && __gnuplot_has_feature__ ("x11_figure_position")) - ## X11 allows the window to be positioned as well. + if ((strncmpi (term, "x11", 3) + && __gnuplot_has_feature__ ("x11_figure_position")) + || (strcmpi (term, "windows") + && __gnuplot_has_feature__ ("windows_figure_position"))) + ## X11/Windows allows the window to be positioned as well. units = get (0, "units"); unwind_protect set (0, "units", "pixels"); @@ -237,7 +242,7 @@ set (0, "units", units); end_unwind_protect if (all (screen_size > 0)) - ## For X11, set the figure positon as well as the size + ## For X11/Windows, set the figure positon as well as the size ## gnuplot position is UL, Octave's is LL (same for screen/window) gnuplot_pos(2) = screen_size(2) - gnuplot_pos(2) - gnuplot_size(2); gnuplot_pos = max (gnuplot_pos, 1);
--- a/scripts/plot/box.m +++ b/scripts/plot/box.m @@ -17,11 +17,16 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} box (@var{arg}) -## @deftypefnx {Function File} {} box (@var{h}, @dots{}) +## @deftypefn {Function File} {} box +## @deftypefnx {Function File} {} box ("on") +## @deftypefnx {Function File} {} box ("off") +## @deftypefnx {Function File} {} box (@var{hax}, @dots{}) ## Control the display of a border around the plot. ## The argument may be either @code{"on"} or @code{"off"}. If it is ## omitted, the current box state is toggled. +## +## If the first argument is an axis handle, @var{hax}, operate on the +## specified axis object. ## @seealso{grid} ## @end deftypefn @@ -29,14 +34,11 @@ function box (varargin) - h = gca (); - - box_state = get (h, "box"); - - nargs = numel (varargin); + [ax, varargin, nargs] = __plt_get_axis_arg__ ("box", varargin{:}); if (nargs == 0) - if (strcmpi (box_state, "on")) + box_state = get (ax, "box"); + if (strcmp (box_state, "on")) box_state = "off"; else box_state = "on"; @@ -49,13 +51,15 @@ elseif (strcmpi (state, "on")) box_state = "on"; else - print_usage (); + error ('box: argument must be "on" or "off"'); endif + else + error ('box: argument must be "on" or "off"'); endif else print_usage (); endif - set (h, "box", box_state); + set (ax, "box", box_state); endfunction
--- a/scripts/plot/ezpolar.m +++ b/scripts/plot/ezpolar.m @@ -20,20 +20,25 @@ ## @deftypefn {Function File} {} ezpolar (@var{f}) ## @deftypefnx {Function File} {} ezpolar (@dots{}, @var{dom}) ## @deftypefnx {Function File} {} ezpolar (@dots{}, @var{n}) -## @deftypefnx {Function File} {} ezpolar (@var{h}, @dots{}) +## @deftypefnx {Function File} {} ezpolar (@var{hax}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} ezpolar (@dots{}) ## -## Plot a function in polar coordinates. The function @var{f} is either -## a string, inline function or function handle with one arguments defining -## the function. By default the plot is over the domain @code{0 < @var{x} < -## 2*pi} with 60 points. +## Plot a function in polar coordinates. The function @var{f} is +## a string, inline function, or function handle with a single argument. +## The expected form of the function is +## @code{@var{rho} = @var{f}(@var{theta})}. +## By default the plot is over the domain @code{0 < @var{theta} < 2*pi} with 60 +## points. ## ## If @var{dom} is a two element vector, it represents the minimum and maximum -## value of both @var{t}. @var{n} is a scalar defining the number of points to -## use. +## values of @var{theta}. @var{n} is a scalar defining the number of points to +## use. If the optional input @var{hax} is given then the plot is placed into +## the specified axes rather than the current axes. ## ## The optional return value @var{h} is a graphics handle to the created plot. ## +## Example: +## ## @example ## ezpolar (@@(t) 1 + sin (t)); ## @end example
--- a/scripts/plot/mesh.m +++ b/scripts/plot/mesh.m @@ -63,5 +63,25 @@ endfunction -%% FIXME: Need demo or test for function +%!demo +%! clf (); +%! x = logspace(0,1,11); +%! z = x'*x; +%! mesh (x, x, z, z.^2); +%! xlabel xlabel +%! ylabel ylabel +%! zlabel "linear scale" +%!demo +%! clf (); +%! x = logspace(0,1,11); +%! z = x'*x; +%! mesh (x, x, z, z.^2); +%! set (gca, "zscale", "log") +%! xlabel xlabel +%! ylabel ylabel +%! zlabel "log scale" +%! if (strcmp (get (gcf, "__graphics_toolkit__"), "gnuplot")) +%! title ({"Gnuplot: mesh color is wrong", "This a Gnuplot bug"}) +%! endif +
--- a/scripts/plot/print.m +++ b/scripts/plot/print.m @@ -21,17 +21,29 @@ ## @deftypefnx {Function File} {} print (@var{options}) ## @deftypefnx {Function File} {} print (@var{filename}, @var{options}) ## @deftypefnx {Function File} {} print (@var{h}, @var{filename}, @var{options}) -## Print a graph, or save it to a file -## -## @var{filename} defines the file name of the output file. If the -## file name has no suffix, one is inferred from the specified -## device and appended to the file name. If no -## filename is specified, the output is sent to the printer. +## Print a graph, or save it to a file. Both output formatted for +## printing (PDF and PostScript), and many bitmapped and vector +## image formats are supported. ## ## @var{h} specifies the figure handle. If no handle is specified ## the handle for the current figure is used. ## -## @var{options}: +## @var{filename} defines the name of the output file. If the +## file name has no suffix, one is inferred from the specified +## device and appended to the file name. If no filename is +## specified, the output is sent to the printer. +## +## For output to a printer, to a PostScript file, or a PDF file, +## the paper size is specified by the figure's @code{papersize} +## property. The location and size of the image on the page are +## specified by the figure's @code{paperposition} property. The +## orientation of the page is specified by the figure's +## @code{paperorientation} property. +## +## The width and height of images are specified by the figure's +## @code{paperpositon(3:4)} property values. +## +## The @code{print} command supports several @var{options}: ## ## @table @code ## @item -f@var{h}
--- a/scripts/plot/private/__bar__.m +++ b/scripts/plot/private/__bar__.m @@ -82,7 +82,9 @@ [linespec, valid] = __pltopt__ (func, varargin{idx}, false); if (valid) have_line_spec = true; - newargs = [{"facecolor", linespec.color}, newargs] + ## FIXME: strange parse error requires semicolon to be spaced + ## away from closing ']' on next line. + newargs = [{"facecolor", linespec.color}, newargs] ; idx++; continue; endif
--- a/scripts/plot/private/__fltk_print__.m +++ b/scripts/plot/private/__fltk_print__.m @@ -148,6 +148,17 @@ opts.pipeline = pipeline; + ## Tell gl2ps to use different rendering options for 2D plots + haxes = findall (opts.figure, "type", "axes"); + vw = get (haxes, "view"); + if (iscell (vw)) + vw = vertcat (vw{:}); + end + is2D = all (abs (vw(:,2)) == 90); + if (is2D) + gl2ps_device{end} = [gl2ps_device{end}, "is2D"]; + endif + for n = 1:numel(pipeline) if (opts.debug) fprintf ("fltk-pipeline: '%s'\n", pipeline{n});
--- a/scripts/plot/private/__gnuplot_has_feature__.m +++ b/scripts/plot/private/__gnuplot_has_feature__.m @@ -34,7 +34,8 @@ "epslatexstandalone_terminal", "screen_coordinates_for_{lrtb}margin", "variable_GPVAL_TERMINALS", - "key_has_font_properties"}; + "key_has_font_properties", + "windows_figure_position"}; if (isempty (has_features)) try @@ -43,8 +44,8 @@ ## Don't throw an error if gnuplot isn't installed gnuplot_version = "0.0.0"; end_try_catch - versions = {"4.2.5", "4.4", "4.4", "4.4", "4.2", "4.2", "4.4", "4.4", "4.4"}; - operators = {">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">="}; + versions = {"4.2.5", "4.4", "4.4", "4.4", "4.2", "4.2", "4.4", "4.4", "4.4", "4.4"}; + operators = {">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">=", ">="}; have_features = logical (zeros (size (features))); for n = 1 : numel (have_features) has_features(n) = compare_versions (gnuplot_version, versions{n}, operators{n});
--- a/scripts/plot/private/__go_draw_figure__.m +++ b/scripts/plot/private/__go_draw_figure__.m @@ -177,11 +177,17 @@ endif case "uimenu" ## ignore uimenu objects + kids(i) = []; otherwise error ("__go_draw_figure__: unknown object class, %s", type); endswitch endfor - fputs (plot_stream, "\nunset multiplot;\n"); + if (isempty (kids)) + fputs (plot_stream, "\nreset; clear;\n"); + fflush (plot_stream); + else + fputs (plot_stream, "\nunset multiplot;\n"); + endif else fputs (plot_stream, "\nreset; clear;\n"); fflush (plot_stream);
--- a/scripts/plot/private/__line__.m +++ b/scripts/plot/private/__line__.m @@ -35,8 +35,8 @@ nvargs = numel (varargin); - if (nvargs > 1 && isnumeric (varargin{1}) && isnumeric (varargin{2})) - if (nvargs > 2 && isnumeric (varargin{3})) + if (nvargs > 1 && ! ischar (varargin{1}) && ! ischar (varargin{2})) + if (nvargs > 2 && ! ischar (varargin{3})) num_data_args = 3; else num_data_args = 2; @@ -90,11 +90,14 @@ data = cell (1, 3); if (num_data_args > 1) - data(1) = varargin{1}; - data(2) = varargin{2}; - if (num_data_args == 3) - data(3) = varargin{3}; - endif + data(1:num_data_args) = varargin(1:num_data_args); + for i = 1:num_data_args + if (islogical (data{i})) + data(i) = double (data{i}); + elseif (iscomplex (data{i})) + data(i) = real (data{i}); + endif + endfor endif data_args = reshape ({"xdata", "ydata", "zdata"; data{:}}, [1, 6]);
--- a/scripts/plot/private/__plt__.m +++ b/scripts/plot/private/__plt__.m @@ -177,14 +177,17 @@ [nr, nc] = size (x1); if (nr == 1) x1 = x1.'; - tmp = nr; - nr = nc; - nc = tmp; + [nr, nc] = deal (nc, nr); # Swap rows and columns endif - x1_i = imag (x1); - if (any (any (x1_i))) - x2 = x1_i; - x1 = real (x1); + if (iscomplex (x1)) + x1_i = imag (x1); + if (any ((x1_i(:)))) + x2 = x1_i; + x1 = real (x1); + else + x2 = x1; + x1 = (1:nr)'; + endif else x2 = x1; x1 = (1:nr)'; @@ -212,11 +215,15 @@ error ("__plt1__: options must be a struct array"); endif - if (any (any (imag (x1)))) + if (islogical (x1)) + x1 = int8 (x1); + elseif (iscomplex ((x1))) x1 = real (x1); endif - if (any (any (imag (x2)))) + if (islogical (x2)) + x2 = int8 (x2); + elseif (iscomplex (x2)) x2 = real (x2); endif
--- a/scripts/plot/private/__print_parse_opts__.m +++ b/scripts/plot/private/__print_parse_opts__.m @@ -423,8 +423,17 @@ %! assert (opts.figure, 5); function cmd = __quote_path__ (cmd) - if (any (cmd == " ") && ! (cmd(1) == """" && cmd(end) == """")) - cmd = strcat ("""", strrep (cmd, """", """"""), """"); + if (! isempty (cmd)) + is_quoted = all (cmd([1, end]) == "'"); + if (! is_quoted) + dos_shell = ! isunix () && ispc (); + if (dos_shell && any (cmd == "/")) + cmd = strrep (cmd, "/", "\\"); + endif + if (any (cmd == " ")) + cmd = strcat ('"', strrep (cmd, '"', '""') ,'"'); + endif + endif endif endfunction
--- a/scripts/polynomial/polyfit.m +++ b/scripts/polynomial/polyfit.m @@ -23,7 +23,7 @@ ## Return the coefficients of a polynomial @var{p}(@var{x}) of degree ## @var{n} that minimizes the least-squares-error of the fit to the points ## @code{[@var{x}, @var{y}]}. If @var{n} is a logical vector, it is used -## as a mask to selectivelly force the corresponding polynomial +## as a mask to selectively force the corresponding polynomial ## coefficients to be used or ignored. ## ## The polynomial coefficients are returned in a row vector.
--- a/scripts/statistics/base/kurtosis.m +++ b/scripts/statistics/base/kurtosis.m @@ -29,7 +29,11 @@ ## @ifnottex ## ## @example -## kurtosis (x) = 1/N std(x)^(-4) sum ((x - mean(x)).^4) - 3 +## @group +## 1 sum ((x - mean(x)).^4) +## kurtosis (x) = --- * ---------------------- - 3 +## N std(x)^4 +## @end group ## @end example ## ## @end ifnottex
--- a/scripts/statistics/base/median.m +++ b/scripts/statistics/base/median.m @@ -102,6 +102,16 @@ %!assert (median (single ([1,2,3])), single (2)) %!assert (median ([1,2,NaN;4,5,6;NaN,8,9]), [NaN, 5, NaN]) +%% Test multidimensional arrays (bug #35679) +%!shared a, b, x, y +%! rand ("seed", 2); +%! a = rand (2,3,4,5); +%! b = rand (3,4,6,5); +%! x = sort (a, 4); +%! y = sort (b, 3); +%!assert (median (a, 4), x(:, :, :, 3)); +%!assert (median (b, 3), (y(:, :, 3, :) + y(:, :, 4, :))/2); + %% Test input validation %!error median () %!error median (1, 2, 3)
--- a/scripts/strings/base2dec.m +++ b/scripts/strings/base2dec.m @@ -89,7 +89,7 @@ table = NaN (1, 256); table(toascii (symbols(1:base))) = 0 : base-1; table(toascii (" ")) = 0; - s = table(toascii (s)); + s = reshape (table(toascii (s)), size (s)); ## Multiply the resulting digits by the appropriate power ## and sum the rows. @@ -103,6 +103,9 @@ %!assert (base2dec ("-1", 2), NaN) %!assert (base2dec ({"A1", "1A"}, 16), [161; 26]) +%% Bug #35621 +%!assert (base2dec (["0"; "1"], 2), [0; 1]) + %%Test input validation %!error base2dec () %!error base2dec ("11120")
--- a/scripts/strings/bin2dec.m +++ b/scripts/strings/bin2dec.m @@ -24,7 +24,7 @@ ## @example ## @group ## bin2dec ("1110") -## @result{} 14 +## @result{} 14 ## @end group ## @end example ##
--- a/scripts/strings/blanks.m +++ b/scripts/strings/blanks.m @@ -23,7 +23,7 @@ ## @example ## @group ## blanks (10); -## whos ans; +## whos ans ## @result{} ## Attr Name Size Bytes Class ## ==== ==== ==== ===== =====
--- a/scripts/strings/cstrcat.m +++ b/scripts/strings/cstrcat.m @@ -32,8 +32,8 @@ ## @group ## s = [ "ab"; "cde" ]; ## cstrcat (s, s, s) -## @result{} "ab ab ab " -## "cdecdecde" +## @result{} "ab ab ab " +## "cdecdecde" ## @end group ## @end example ## @seealso{strcat, char, strvcat}
--- a/scripts/strings/hex2dec.m +++ b/scripts/strings/hex2dec.m @@ -24,9 +24,9 @@ ## @example ## @group ## hex2dec ("12B") -## @result{} 299 +## @result{} 299 ## hex2dec ("12b") -## @result{} 299 +## @result{} 299 ## @end group ## @end example ##
--- a/scripts/strings/index.m +++ b/scripts/strings/index.m @@ -28,7 +28,7 @@ ## @example ## @group ## index ("Teststring", "t") -## @result{} 4 +## @result{} 4 ## @end group ## @end example ##
--- a/src/DLD-FUNCTIONS/__init_fltk__.cc +++ b/src/DLD-FUNCTIONS/__init_fltk__.cc @@ -179,7 +179,7 @@ if (print_mode) { FILE *fp = octave_popen (print_cmd.c_str (), "w"); - glps_renderer rend (fileno (fp), print_term); + glps_renderer rend (fp, print_term); rend.draw (gh_manager::get_object (number)); @@ -668,6 +668,14 @@ callback (window_close, static_cast<void*> (this)); size_range (4*status_h, 2*status_h); + // FIXME: The function below is only available in FLTK >= 1.3 + // At some point support for FLTK 1.1 will be dropped in Octave. + // At that point this function should be uncommented. + // The current solution is to call xclass() before show() for each window. + // Set WM_CLASS which allows window managers to properly group related + // windows. Otherwise, the class is just "FLTK" + //default_xclass ("Octave"); + begin (); { @@ -722,6 +730,13 @@ canvas->mode (FL_DEPTH | FL_DOUBLE ); if (fp.is_visible ()) { + // FIXME: This code should be removed when Octave drops support + // for FLTK 1.1. Search for default_xclass in this file to find + // code that should be uncommented to take its place. + // + // Set WM_CLASS which allows window managers to properly group + // related windows. Otherwise, the class is just "FLTK" + xclass ("Octave"); show (); if (fp.get_currentaxes ().ok()) show_canvas ();
--- a/src/DLD-FUNCTIONS/besselj.cc +++ b/src/DLD-FUNCTIONS/besselj.cc @@ -531,10 +531,10 @@ @group\n\ K Function Scale factor (if 'opt' is supplied)\n\ --- -------- ---------------------------------------\n\ - 0 Ai (Z) exp (2/3 * Z * sqrt (Z))\n\ - 1 dAi(Z)/dZ exp (2/3 * Z * sqrt (Z))\n\ - 2 Bi (Z) exp (-abs (real (2/3 * Z *sqrt (Z))))\n\ - 3 dBi(Z)/dZ exp (-abs (real (2/3 * Z *sqrt (Z))))\n\ + 0 Ai (Z) exp ((2/3) * Z * sqrt (Z))\n\ + 1 dAi(Z)/dZ exp ((2/3) * Z * sqrt (Z))\n\ + 2 Bi (Z) exp (-abs (real ((2/3) * Z *sqrt (Z))))\n\ + 3 dBi(Z)/dZ exp (-abs (real ((2/3) * Z *sqrt (Z))))\n\ @end group\n\ @end example\n\ \n\ @@ -928,4 +928,323 @@ %!assert(besselk(-alpha,x,1), kx*exp(x), 100*eps) %!assert(besselh(-alpha,1,x,1), -I*(jx + I*yx)*exp(-I*x), 100*eps) %!assert(besselh(-alpha,2,x,1), I*(jx - I*yx)*exp(I*x), 100*eps) + + +Tests contributed by Robert T. Short. +Tests are based on the properties and tables in A&S: + Abramowitz and Stegun, "Handbook of Mathematical Functions", + 1972. + +For regular Bessel functions, there are 3 tests. These compare octave +results against Tables 9.1, 9.2, and 9.4 in A&S. Tables 9.1 and 9.2 +are good to only a few decimal places, so any failures should be +considered a broken implementation. Table 9.4 is an extended table +for larger orders and arguments. There are some differences between +Octave and Table 9.4, mostly in the last decimal place but in a very +few instances the errors are in the last two places. The comparison +tolerance has been changed to reflect this. + +Similarly for modifed Bessel functions, there are 3 tests. These +compare octave results against Tables 9.8, 9.9, and 9.11 in A&S. +Tables 9.8 and 9.9 are good to only a few decimal places, so any +failures should be considered a broken implementation. Table 9.11 is +an extended table for larger orders and arguments. There are some +differences between octave and Table 9.11, mostly in the last decimal +place but in a very few instances the errors are in the last two +places. The comparison tolerance has been changed to reflect this. + +For spherical Bessel functions, there are also three tests, comparing +octave results to Tables 10.1, 10.2, and 10.4 in A&S. Very similar +comments may be made here as in the previous lines. At this time, +modified spherical Bessel function tests are not included. + +% Table 9.1 - J and Y for integer orders 0, 1, 2. +% Compare against excerpts of Table 9.1, Abramowitz and Stegun. +%!test +%! n = 0:2; +%! z = (0:2.5:17.5)'; +%! +%! Jt = [[ 1.000000000000000, 0.0000000000, 0.0000000000]; +%! [-0.048383776468198, 0.4970941025, 0.4460590584]; +%! [-0.177596771314338, -0.3275791376, 0.0465651163]; +%! [ 0.266339657880378, 0.1352484276, -0.2302734105]; +%! [-0.245935764451348, 0.0434727462, 0.2546303137]; +%! [ 0.146884054700421, -0.1654838046, -0.1733614634]; +%! [-0.014224472826781, 0.2051040386, 0.0415716780]; +%! [-0.103110398228686, -0.1634199694, 0.0844338303]]; +%! +%! Yt = [[-Inf, -Inf, -Inf ]; +%! [ 0.4980703596, 0.1459181380, -0.38133585 ]; +%! [-0.3085176252, 0.1478631434, 0.36766288 ]; +%! [ 0.1173132861, -0.2591285105, -0.18641422 ]; +%! [ 0.0556711673, 0.2490154242, -0.00586808 ]; +%! [-0.1712143068, -0.1538382565, 0.14660019 ]; +%! [ 0.2054642960, 0.0210736280, -0.20265448 ]; +%! [-0.1604111925, 0.0985727987, 0.17167666 ]]; +%! +%! J = besselj(n,z); +%! Y = bessely(n,z); +%! assert(Jt(:,1), J(:,1), 0.5e-10); +%! assert(Yt(:,1), Y(:,1), 0.5e-10); +%! assert(Jt(:,2:3), J(:,2:3), 0.5e-10); + +Table 9.2 - J and Y for integer orders 3-9. + +%!test +%! n = (3:9); +%! z = (0:2:20).'; +%! +%! Jt = [[ 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00]; +%! [ 1.2894e-01, 3.3996e-02, 7.0396e-03, 1.2024e-03, 1.7494e-04, 2.2180e-05, 2.4923e-06]; +%! [ 4.3017e-01, 2.8113e-01, 1.3209e-01, 4.9088e-02, 1.5176e-02, 4.0287e-03, 9.3860e-04]; +%! [ 1.1477e-01, 3.5764e-01, 3.6209e-01, 2.4584e-01, 1.2959e-01, 5.6532e-02, 2.1165e-02]; +%! [-2.9113e-01,-1.0536e-01, 1.8577e-01, 3.3758e-01, 3.2059e-01, 2.2345e-01, 1.2632e-01]; +%! [ 5.8379e-02,-2.1960e-01,-2.3406e-01,-1.4459e-02, 2.1671e-01, 3.1785e-01, 2.9186e-01]; +%! [ 1.9514e-01, 1.8250e-01,-7.3471e-02,-2.4372e-01,-1.7025e-01, 4.5095e-02, 2.3038e-01]; +%! [-1.7681e-01, 7.6244e-02, 2.2038e-01, 8.1168e-02,-1.5080e-01,-2.3197e-01,-1.1431e-01]; +%! [-4.3847e-02,-2.0264e-01,-5.7473e-02, 1.6672e-01, 1.8251e-01,-7.0211e-03,-1.8953e-01]; +%! [ 1.8632e-01, 6.9640e-02,-1.5537e-01,-1.5596e-01, 5.1399e-02, 1.9593e-01, 1.2276e-01]; +%! [-9.8901e-02, 1.3067e-01, 1.5117e-01,-5.5086e-02,-1.8422e-01,-7.3869e-02, 1.2513e-01]]; +%! +%! Yt = [[ -Inf, -Inf, -Inf, -Inf, -Inf, -Inf, -Inf]; +%! [-1.1278e+00,-2.7659e+00,-9.9360e+00,-4.6914e+01,-2.7155e+02,-1.8539e+03,-1.4560e+04]; +%! [-1.8202e-01,-4.8894e-01,-7.9585e-01,-1.5007e+00,-3.7062e+00,-1.1471e+01,-4.2178e+01]; +%! [ 3.2825e-01, 9.8391e-02,-1.9706e-01,-4.2683e-01,-6.5659e-01,-1.1052e+00,-2.2907e+00]; +%! [ 2.6542e-02, 2.8294e-01, 2.5640e-01, 3.7558e-02,-2.0006e-01,-3.8767e-01,-5.7528e-01]; +%! [-2.5136e-01,-1.4495e-01, 1.3540e-01, 2.8035e-01, 2.0102e-01, 1.0755e-03,-1.9930e-01]; +%! [ 1.2901e-01,-1.5122e-01,-2.2982e-01,-4.0297e-02, 1.8952e-01, 2.6140e-01, 1.5902e-01]; +%! [ 1.2350e-01, 2.0393e-01,-6.9717e-03,-2.0891e-01,-1.7209e-01, 3.6816e-02, 2.1417e-01]; +%! [-1.9637e-01,-7.3222e-05, 1.9633e-01, 1.2278e-01,-1.0425e-01,-2.1399e-01,-1.0975e-01]; +%! [ 3.3724e-02,-1.7722e-01,-1.1249e-01, 1.1472e-01, 1.8897e-01, 3.2253e-02,-1.6030e-01]; +%! [ 1.4967e-01, 1.2409e-01,-1.0004e-01,-1.7411e-01,-4.4312e-03, 1.7101e-01, 1.4124e-01]]; +%! +%! n = (3:9); +%! z = (0:2:20).'; +%! J=besselj(n,z); +%! Y=bessely(n,z); +%! +%! assert(J(1,:), zeros (1, columns (J))); +%! assert(J(2:end,:), Jt(2:end,:), -5e-5); +%! assert(Yt(1,:), Y(1,:)); +%! assert(Y(2:end,:), Yt(2:end,:), -5e-5); + +Table 9.4 - J and Y for various integer orders and arguments. + +%!test +%! Jt = [[ 7.651976866e-01, 2.238907791e-01, -1.775967713e-01, -2.459357645e-01, 5.581232767e-02, 1.998585030e-02]; +%! [ 2.497577302e-04, 7.039629756e-03, 2.611405461e-01, -2.340615282e-01, -8.140024770e-02, -7.419573696e-02]; +%! [ 2.630615124e-10, 2.515386283e-07, 1.467802647e-03, 2.074861066e-01, -1.138478491e-01, -5.473217694e-02]; +%! [ 2.297531532e-17, 7.183016356e-13, 4.796743278e-07, 4.507973144e-03, -1.082255990e-01, 1.519812122e-02]; +%! [ 3.873503009e-25, 3.918972805e-19, 2.770330052e-11, 1.151336925e-05, -1.167043528e-01, 6.221745850e-02]; +%! [ 3.482869794e-42, 3.650256266e-33, 2.671177278e-21, 1.551096078e-12, 4.843425725e-02, 8.146012958e-02]; +%! [ 1.107915851e-60, 1.196077458e-48, 8.702241617e-33, 6.030895312e-21, -1.381762812e-01, 7.270175482e-02]; +%! [ 2.906004948e-80, 3.224095839e-65, 2.294247616e-45, 1.784513608e-30, 1.214090219e-01, -3.869833973e-02]; +%! [ 8.431828790e-189, 1.060953112e-158, 6.267789396e-119, 6.597316064e-89, 1.115927368e-21, 9.636667330e-02]]; +%! +%! Yt = [[ 8.825696420e-02, 5.103756726e-01, -3.085176252e-01, 5.567116730e-02, -9.806499547e-02, -7.724431337e-02] +%! [-2.604058666e+02, -9.935989128e+00, -4.536948225e-01, 1.354030477e-01, -7.854841391e-02, -2.948019628e-02] +%! [-1.216180143e+08, -1.291845422e+05, -2.512911010e+01, -3.598141522e-01, 5.723897182e-03, 5.833157424e-02] +%! [-9.256973276e+14, -2.981023646e+10, -4.694049564e+04, -6.364745877e+00, 4.041280205e-02, 7.879068695e-02] +%! [-4.113970315e+22, -4.081651389e+16, -5.933965297e+08, -1.597483848e+03, 1.644263395e-02, 5.124797308e-02] +%! [-3.048128783e+39, -2.913223848e+30, -4.028568418e+18, -7.256142316e+09, -1.164572349e-01, 6.138839212e-03] +%! [-7.184874797e+57, -6.661541235e+45, -9.216816571e+29, -1.362803297e+18, -4.530801120e-02, 4.074685217e-02] +%! [-2.191142813e+77, -1.976150576e+62, -2.788837017e+42, -3.641066502e+27, -2.103165546e-01, 7.650526394e-02] +%! [-3.775287810e+185, -3.000826049e+155, -5.084863915e+115, -4.849148271e+85, -3.293800188e+18, -1.669214114e-01]]; +%! +%! n = [(0:5:20).';30;40;50;100]; +%! z = [1,2,5,10,50,100]; +%! J = besselj(n.',z.').'; +%! Y = bessely(n.',z.').'; +%! assert(J, Jt, -1e-9); +%! assert(Y, Yt, -1e-9); + +Table 9.8 - I and K for integer orders 0, 1, 2. + +%!test +%! n = 0:2; +%! z1 = [0.1;2.5;5.0]; +%! z2 = [7.5;10.0;15.0;20.0]; +%! rtbl = [ [ 0.9071009258 0.0452984468 0.1251041992 2.6823261023 10.890182683 1.995039646 ]; +%! [ 0.2700464416 0.2065846495 0.2042345837 0.7595486903 0.9001744239 0.759126289 ]; +%! [ 0.1835408126 0.1639722669 0.7002245988 0.5478075643 0.6002738588 0.132723593 ]; +%! [ 0.1483158301 0.1380412115 0.111504840 0.4505236991 0.4796689336 0.57843541 ]; +%! [ 0.1278333372 0.1212626814 0.103580801 0.3916319344 0.4107665704 0.47378525 ]; +%! [ 0.1038995314 0.1003741751 0.090516308 0.3210023535 0.3315348950 0.36520701 ]; +%! [ 0.0897803119 0.0875062222 0.081029690 0.2785448768 0.2854254970 0.30708743 ]]; +%! +%! tbl = [besseli(n,z1,1), besselk(n,z1,1)]; +%! tbl(:,3) = tbl(:,3).*(exp(z1).*z1.^(-2)); +%! tbl(:,6) = tbl(:,6).*(exp(-z1).*z1.^(2)); +%! tbl = [tbl;[besseli(n,z2,1),besselk(n,z2,1)]]; +%! +%! assert(tbl, rtbl, -2e-8); + +Table 9.9 - I and K for orders 3-9. + +%!test +%! It = [[ 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00]; +%! [ 2.8791e-02 6.8654e-03 1.3298e-03 2.1656e-04 3.0402e-05 3.7487e-06 4.1199e-07]; +%! [ 6.1124e-02 2.5940e-02 9.2443e-03 2.8291e-03 7.5698e-04 1.7968e-04 3.8284e-05]; +%! [ 7.4736e-02 4.1238e-02 1.9752e-02 8.3181e-03 3.1156e-03 1.0484e-03 3.1978e-04]; +%! [ 7.9194e-02 5.0500e-02 2.8694e-02 1.4633e-02 6.7449e-03 2.8292e-03 1.0866e-03]; +%! [ 7.9830e-02 5.5683e-02 3.5284e-02 2.0398e-02 1.0806e-02 5.2694e-03 2.3753e-03]; +%! [ 7.8848e-02 5.8425e-02 3.9898e-02 2.5176e-02 1.4722e-02 8.0010e-03 4.0537e-03]; +%! [ 7.7183e-02 5.9723e-02 4.3056e-02 2.8969e-02 1.8225e-02 1.0744e-02 5.9469e-03]; +%! [ 7.5256e-02 6.0155e-02 4.5179e-02 3.1918e-02 2.1240e-02 1.3333e-02 7.9071e-03]; +%! [ 7.3263e-02 6.0059e-02 4.6571e-02 3.4186e-02 2.3780e-02 1.5691e-02 9.8324e-03]; +%! [ 7.1300e-02 5.9640e-02 4.7444e-02 3.5917e-02 2.5894e-02 1.7792e-02 1.1661e-02]]; +%! +%! Kt = [ +%! [ Inf Inf Inf Inf Inf Inf Inf]; +%! [ 4.7836e+00 1.6226e+01 6.9687e+01 3.6466e+02 2.2576e+03 1.6168e+04 1.3160e+05]; +%! [ 1.6317e+00 3.3976e+00 8.4268e+00 2.4465e+01 8.1821e+01 3.1084e+02 1.3252e+03]; +%! [ 9.9723e-01 1.6798e+00 3.2370e+00 7.0748e+00 1.7387e+01 4.7644e+01 1.4444e+02]; +%! [ 7.3935e-01 1.1069e+00 1.8463e+00 3.4148e+00 6.9684e+00 1.5610e+01 3.8188e+01]; +%! [ 6.0028e-01 8.3395e-01 1.2674e+00 2.1014e+00 3.7891e+00 7.4062e+00 1.5639e+01]; +%! [ 5.1294e-01 6.7680e-01 9.6415e-01 1.4803e+00 2.4444e+00 4.3321e+00 8.2205e+00]; +%! [ 4.5266e-01 5.7519e-01 7.8133e-01 1.1333e+00 1.7527e+00 2.8860e+00 5.0510e+00]; +%! [ 4.0829e-01 5.0414e-01 6.6036e-01 9.1686e-01 1.3480e+00 2.0964e+00 3.4444e+00]; +%! [ 3.7411e-01 4.5162e-01 5.7483e-01 7.7097e-01 1.0888e+00 1.6178e+00 2.5269e+00]; +%! [ 3.4684e-01 4.1114e-01 5.1130e-01 6.6679e-01 9.1137e-01 1.3048e+00 1.9552e+00]]; +%! +%! n = (3:9); +%! z = (0:2:20).'; +%! I=besseli(n,z,1); +%! K=besselk(n,z,1); +%! +%! assert(abs (I(1,:)), zeros(1, columns(I))); +%! assert(I(2:end,:), It(2:end,:), -5e-5); +%! assert(Kt(1,:), K(1,:)); +%! assert(K(2:end,:), Kt(2:end,:), -5e-5); + +Table 9.11 - I and K for various integer orders and arguments. + +%!test +%! It = [[ 1.266065878e+00 2.279585302e+00 2.723987182e+01 2.815716628e+03 2.93255378e+20 1.07375171e+42 ]; +%! [ 2.714631560e-04 9.825679323e-03 2.157974547e+00 7.771882864e+02 2.27854831e+20 9.47009387e+41 ]; +%! [ 2.752948040e-10 3.016963879e-07 4.580044419e-03 2.189170616e+01 1.07159716e+20 6.49897552e+41 ]; +%! [ 2.370463051e-17 8.139432531e-13 1.047977675e-06 1.043714907e-01 3.07376455e+19 3.47368638e+41 ]; +%! [ 3.966835986e-25 4.310560576e-19 5.024239358e-11 1.250799736e-04 5.44200840e+18 1.44834613e+41 ]; +%! [ 3.539500588e-42 3.893519664e-33 3.997844971e-21 7.787569783e-12 4.27499365e+16 1.20615487e+40 ]; +%! [ 1.121509741e-60 1.255869192e-48 1.180426980e-32 2.042123274e-20 6.00717897e+13 3.84170550e+38 ]; +%! [ 2.934635309e-80 3.353042830e-65 2.931469647e-45 4.756894561e-30 1.76508024e+10 4.82195809e+36 ]; +%! [ 8.473674008e-189 1.082171475e-158 7.093551489e-119 1.082344202e-88 2.72788795e-16 4.64153494e+21 ]]; +%! +%! Kt = [[ 4.210244382e-01 1.138938727e-01 3.691098334e-03 1.778006232e-05 3.41016774e-23 4.65662823e-45 ]; +%! [ 3.609605896e+02 9.431049101e+00 3.270627371e-02 5.754184999e-05 4.36718224e-23 5.27325611e-45 ]; +%! [ 1.807132899e+08 1.624824040e+05 9.758562829e+00 1.614255300e-03 9.15098819e-23 7.65542797e-45 ]; +%! [ 1.403066801e+15 4.059213332e+10 3.016976630e+04 2.656563849e-01 3.11621117e-22 1.42348325e-44 ]; +%! [ 6.294369360e+22 5.770856853e+16 4.827000521e+08 1.787442782e+02 1.70614838e-21 3.38520541e-44 ]; +%! [ 4.706145527e+39 4.271125755e+30 4.112132063e+18 2.030247813e+09 2.00581681e-19 3.97060205e-43 ]; +%! [ 1.114220651e+58 9.940839886e+45 1.050756722e+30 5.938224681e+17 1.29986971e-16 1.20842080e-41 ]; +%! [ 3.406896854e+77 2.979981740e+62 3.394322243e+42 2.061373775e+27 4.00601349e-13 9.27452265e-40 ]; +%! [ 5.900333184e+185 4.619415978e+155 7.039860193e+115 4.596674084e+85 1.63940352e+13 7.61712963e-25 ]]; +%! +%! n = [(0:5:20).';30;40;50;100]; +%! z = [1,2,5,10,50,100]; +%! I = besseli(n.',z.').'; +%! K = besselk(n.',z.').'; +%! assert(I, It, -5e-9); +%! assert(K, Kt, -5e-9); + +The next section checks that negative integer orders and positive +integer orders are appropriately related. + +%!test +%! n=(0:2:20); +%! assert(besselj(n,1), besselj(-n,1), 1e-8); +%! assert(-besselj(n+1,1), besselj(-n-1,1), 1e-8); + +besseli(n,z) = besseli(-n,z); + +%!test +%! n=(0:2:20); +%! assert(besseli(n,1), besseli(-n,1), 1e-8); + +Table 10.1 - j and y for integer orders 0, 1, 2. +Compare against excerpts of Table 10.1, Abramowitz and Stegun. + +%!test +%! n = (0:2); +%! z = [0.1;(2.5:2.5:10.0).']; +%! +%! jt = [[ 9.9833417e-01 3.33000119e-02 6.6619061e-04 ]; +%! [ 2.3938886e-01 4.16212989e-01 2.6006673e-01 ]; +%! [-1.9178485e-01 -9.50894081e-02 1.3473121e-01 ]; +%! [ 1.2507e-01 -2.9542e-02 -1.3688e-01 ]; +%! [ -5.4402e-02 7.8467e-02 7.7942e-02 ]]; +%! +%! yt = [[-9.9500417e+00 -1.0049875e+02 -3.0050125e+03 ]; +%! [ 3.2045745e-01 -1.1120588e-01 -4.5390450e-01 ]; +%! [-5.6732437e-02 1.8043837e-01 1.6499546e-01 ]; +%! [ -4.6218e-02 -1.3123e-01 -6.2736e-03 ]; +%! [ 8.3907e-02 6.2793e-02 -6.5069e-02 ]]; +%! +%! j = sqrt((pi/2)./z).*besselj(n+1/2,z); +%! y = sqrt((pi/2)./z).*bessely(n+1/2,z); +%! assert(jt, j, -5e-5); +%! assert(yt, y, -5e-5); + +Table 10.2 - j and y for orders 3-8. +Compare against excerpts of Table 10.2, Abramowitzh and Stegun. + + Important note: In A&S, y_4(0.1) = -1.0507e+7, but Octave returns + y_4(0.1) = -1.0508e+07 (-10507503.75). If I compute the same term using + a series, the difference is in the eighth significant digit so I left + the Octave results in place. + +%!test +%! n = (3:8); +%! z = (0:2.5:10).'; z(1)=0.1; +%! +%! jt = [[ 9.5185e-06 1.0577e-07 9.6163e-10 7.3975e-12 4.9319e-14 2.9012e-16]; +%! [ 1.0392e-01 3.0911e-02 7.3576e-03 1.4630e-03 2.5009e-04 3.7516e-05]; +%! [ 2.2982e-01 1.8702e-01 1.0681e-01 4.7967e-02 1.7903e-02 5.7414e-03]; +%! [-6.1713e-02 7.9285e-02 1.5685e-01 1.5077e-01 1.0448e-01 5.8188e-02]; +%! [-3.9496e-02 -1.0559e-01 -5.5535e-02 4.4501e-02 1.1339e-01 1.2558e-01]]; +%! +%! yt = [[-1.5015e+05 -1.0508e+07 -9.4553e+08 -1.0400e+11 -1.3519e+13 -2.0277e+15]; +%! [-7.9660e-01 -1.7766e+00 -5.5991e+00 -2.2859e+01 -1.1327e+02 -6.5676e+02]; +%! [-1.5443e-02 -1.8662e-01 -3.2047e-01 -5.1841e-01 -1.0274e+00 -2.5638e+00]; +%! [ 1.2705e-01 1.2485e-01 2.2774e-02 -9.1449e-02 -1.8129e-01 -2.7112e-01]; +%! [-9.5327e-02 -1.6599e-03 9.3834e-02 1.0488e-01 4.2506e-02 -4.1117e-02]]; +%! +%! j = sqrt((pi/2)./z).*besselj(n+1/2,z); +%! y = sqrt((pi/2)./z).*bessely(n+1/2,z); +%! +%! assert(jt, j, -5e-5); +%! assert(yt, y, -5e-5); + +Table 10.4 - j and y for various integer orders and arguments. + +%!test +%! jt = [[ 8.414709848e-01 4.546487134e-01 -1.917848549e-01 -5.440211109e-02 -5.247497074e-03 -5.063656411e-03]; +%! [ 9.256115861e-05 2.635169770e-03 1.068111615e-01 -5.553451162e-02 -2.004830056e-02 -9.290148935e-03]; +%! [ 7.116552640e-11 6.825300865e-08 4.073442442e-04 6.460515449e-02 -1.503922146e-02 -1.956578597e-04]; +%! [ 5.132686115e-18 1.606982166e-13 1.084280182e-07 1.063542715e-03 -1.129084539e-02 7.877261748e-03]; +%! [ 7.537795722e-26 7.632641101e-20 5.427726761e-12 2.308371961e-06 -1.578502990e-02 1.010767128e-02]; +%! [ 5.566831267e-43 5.836617888e-34 4.282730217e-22 2.512057385e-13 -1.494673454e-03 8.700628514e-03]; +%! [ 1.538210374e-61 1.660978779e-49 1.210347583e-33 8.435671634e-22 -2.606336952e-02 1.043410851e-02]; +%! [ 3.615274717e-81 4.011575290e-66 2.857479350e-46 2.230696023e-31 1.882910737e-02 5.797140882e-04]; +%! [7.444727742e-190 9.367832591e-160 5.535650303e-120 5.832040182e-90 1.019012263e-22 1.088047701e-02]]; +%! +%! yt = [[ -5.403023059e-01 2.080734183e-01 -5.673243709e-02 8.390715291e-02 -1.929932057e-02 -8.623188723e-03] +%! [ -9.994403434e+02 -1.859144531e+01 -3.204650467e-01 9.383354168e-02 -6.971131965e-04 3.720678486e-03] +%! [ -6.722150083e+08 -3.554147201e+05 -2.665611441e+01 -1.724536721e-01 1.352468751e-02 1.002577737e-02] +%! [ -6.298007233e+15 -1.012182944e+11 -6.288146513e+04 -3.992071745e+00 1.712319725e-02 6.258641510e-03] +%! [ -3.239592219e+23 -1.605436493e+17 -9.267951403e+08 -1.211210605e+03 1.375953130e-02 5.631729379e-05] +%! [ -2.946428547e+40 -1.407393871e+31 -7.760717570e+18 -6.908318646e+09 -2.241226812e-02 -5.412929349e-03] +%! [ -8.028450851e+58 -3.720929322e+46 -2.055758716e+30 -1.510304919e+18 4.978797221e-05 -7.048420407e-04] +%! [ -2.739192285e+78 -1.235021944e+63 -6.964109188e+42 -4.528227272e+27 -4.190000150e-02 1.074782297e-02] +%! [-6.683079463e+186 -2.655955830e+156 -1.799713983e+116 -8.573226309e+85 -1.125692891e+18 -2.298385049e-02]]; +%! +%! n = [(0:5:20).';30;40;50;100]; +%! z = [1,2,5,10,50,100]; +%! j = sqrt((pi/2)./z).*besselj((n+1/2).',z.').'; +%! y = sqrt((pi/2)./z).*bessely((n+1/2).',z.').'; +%! assert(j, jt, -1e-9); +%! assert(y, yt, -1e-9); + + + */
--- a/src/DLD-FUNCTIONS/betainc.cc +++ b/src/DLD-FUNCTIONS/betainc.cc @@ -46,12 +46,11 @@ \n\ @smallexample\n\ @group\n\ -@c spacing appears odd here, but is correct after Makeinfo\n\ - x\n\ - 1 /\n\ -betainc (x, a, b) = ----------- | t^(a-1) (1-t)^(b-1) dt.\n\ - beta (a, b) /\n\ - t=0\n\ + x\n\ + 1 /\n\ +betainc (x, a, b) = ----------- | t^(a-1) (1-t)^(b-1) dt.\n\ + beta (a, b) /\n\ + t=0\n\ @end group\n\ @end smallexample\n\ \n\
--- a/src/DLD-FUNCTIONS/gammainc.cc +++ b/src/DLD-FUNCTIONS/gammainc.cc @@ -47,8 +47,8 @@ \n\ @example\n\ @group\n\ - x\n\ - 1 /\n\ + x\n\ + 1 /\n\ gammainc (x, a) = --------- | exp (-t) t^(a-1) dt\n\ gamma (a) /\n\ t=0\n\
--- a/src/DLD-FUNCTIONS/regexp.cc +++ b/src/DLD-FUNCTIONS/regexp.cc @@ -641,7 +641,7 @@ if (nargin < 2) print_usage (); else if (args(0).is_cell () || args(1).is_cell ()) - retval = octcellregexp (args, nargout, "regexp"); + retval = octcellregexp (args, (nargout > 0 ? nargout : 1), "regexp"); else retval = octregexp (args, nargout, "regexp"); @@ -769,10 +769,20 @@ %! assert (nm.last{1},'Davis'); %! assert (nm.last{2},'Rogers'); +## Tests for named tokens %!test %! # Parenthesis in named token (ie (int)) causes a problem %! assert (regexp('qwe int asd', ['(?<typestr>(int))'], 'names'), struct ('typestr', 'int')); +%!test +%! ## Mix of named and unnamed tokens can cause segfault (bug #35683) +%! str = "abcde"; +%! ptn = '(?<T1>a)(\w+)(?<T2>d\w+)'; +%! tokens = regexp (str, ptn, "names"); +%! assert (isstruct (tokens) && numel (tokens) == 1); +%! assert (tokens.T1, "a"); +%! assert (tokens.T2, "de"); + %!assert(regexp("abc\nabc",'.'),[1:7]) %!assert(regexp("abc\nabc",'.','dotall'),[1:7]) %!test @@ -879,7 +889,7 @@ if (nargin < 2) print_usage (); else if (args(0).is_cell () || args(1).is_cell ()) - retval = octcellregexp (args, nargout, "regexpi", true); + retval = octcellregexp (args, (nargout > 0 ? nargout : 1), "regexpi", true); else retval = octregexp (args, nargout, "regexpi", true);
--- a/src/DLD-FUNCTIONS/schur.cc +++ b/src/DLD-FUNCTIONS/schur.cc @@ -376,4 +376,9 @@ %! assert (norm (tril (T, -1)), 0) %! assert (norm (U * U'), 1, 1e-14) +%!test +%! A = [0, 1;-1, 0]; +%! [u, t] = schur (A); +%! [U, T] = rsf2csf (u,t); +%! assert (U * T * U', A, 1e-14) */
--- a/src/DLD-FUNCTIONS/urlwrite.cc +++ b/src/DLD-FUNCTIONS/urlwrite.cc @@ -55,6 +55,11 @@ #include <curl/curlver.h> #include <curl/easy.h> +// Backwards compatibility for curl < 7.17.0 +#if LIBCURL_VERSION_NUM < 0x071100 +#define CURLOPT_DIRLISTONLY CURLOPT_FTPLISTONLY +#endif + static int write_data (void *buffer, size_t size, size_t nmemb, void *streamp) {
--- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,11 +20,13 @@ include $(top_srcdir)/build-aux/common.mk +## Search local directories before those specified by the user. AM_CPPFLAGS = \ - @CPPFLAGS@ -I../libgnu -I$(top_srcdir)/libgnu \ + -I../libgnu -I$(top_srcdir)/libgnu \ -I$(top_srcdir)/libcruft/misc \ -I../liboctave -I$(top_srcdir)/liboctave \ - -I. -I$(srcdir) + -I. -I$(srcdir) \ + @CPPFLAGS@ AUTOMAKE_OPTIONS = subdir-objects @@ -519,7 +521,7 @@ # Increment these as needed and according to the rules in the libtool manual: liboctinterp_current = 1 -liboctinterp_revision = 0 +liboctinterp_revision = 1 liboctinterp_age = 0 liboctinterp_version_info = $(liboctinterp_current):$(liboctinterp_revision):$(liboctinterp_age) @@ -659,6 +661,7 @@ __init_fltk__.lo __init_fltk__.o: \ AM_CXXFLAGS := $(filter-out $(DLL_CXXDEFS), $(AM_CXXFLAGS) $(GRAPHICS_CFLAGS)) +if AMCOND_BUILD_DOCS .DOCSTRINGS: gendoc$(BUILD_EXEEXT) if [ "x$(srcdir)" != "x." ] && [ -f $(srcdir)/DOCSTRINGS ] && [ ! -f DOCSTRINGS ]; then \ cp $(srcdir)/DOCSTRINGS DOCSTRINGS; \ @@ -681,6 +684,9 @@ $(BUILD_CXX) $(BUILD_CXXFLAGS) -o $@ $^ $(BUILD_LDFLAGS) all-local: $(OCT_STAMP_FILES) $(DLD_FUNCTIONS_PKG_ADD_FILE) .DOCSTRINGS +else +all-local: $(OCT_STAMP_FILES) $(DLD_FUNCTIONS_PKG_ADD_FILE) +endif if AMCOND_BUILD_COMPILED_AUX_PROGRAMS octave-config.cc: octave-config.cc.in Makefile
--- a/src/data.cc +++ b/src/data.cc @@ -132,27 +132,25 @@ } /* - %!test %! x = ones (3); %! x(1,1) = 0; -%! assert((all (all (rand (3) + 1) == [1, 1, 1]) == 1 -%! && all (all (x) == [0, 1, 1]) == 1 -%! && all (x, 1) == [0, 1, 1] -%! && all (x, 2) == [0; 1; 1])); +%! assert (all (all (rand (3) + 1) == [1, 1, 1]) == 1); +%! assert (all (all (x) == [0, 1, 1]) == 1); +%! assert (all (x, 1) == [0, 1, 1]); +%! assert (all (x, 2) == [0; 1; 1]); %!test -%! x = ones (3, 'single'); +%! x = ones (3, "single"); %! x(1,1) = 0; -%! assert((all (all (single (rand (3) + 1)) == [1, 1, 1]) == 1 -%! && all (all (x) == [0, 1, 1]) == 1 -%! && all (x, 1) == [0, 1, 1] -%! && all (x, 2) == [0; 1; 1])); - -%!error <Invalid call to all> all (); -%!error <Invalid call to all> all (1, 2, 3); - - */ +%! assert (all (all (single (rand (3) + 1)) == [1, 1, 1]) == 1); +%! assert (all (all (x) == [0, 1, 1]) == 1); +%! assert (all (x, 1) == [0, 1, 1]); +%! assert (all (x, 2) == [0; 1; 1]); + +%!error all () +%!error all (1, 2, 3) +*/ DEFUN (any, args, , "-*- texinfo -*-\n\ @@ -188,27 +186,25 @@ } /* - %!test %! x = zeros (3); %! x(3,3) = 1; -%! assert((all (any (x) == [0, 0, 1]) == 1 -%! && all (any (ones (3)) == [1, 1, 1]) == 1 -%! && any (x, 1) == [0, 0, 1] -%! && any (x, 2) == [0; 0; 1])); +%! assert (all (any (x) == [0, 0, 1]) == 1); +%! assert (all (any (ones (3)) == [1, 1, 1]) == 1); +%! assert (any (x, 1) == [0, 0, 1]); +%! assert (any (x, 2) == [0; 0; 1]); %!test -%! x = zeros (3,'single'); +%! x = zeros (3, "single"); %! x(3,3) = 1; -%! assert((all (any (x) == [0, 0, 1]) == 1 -%! && all (any (ones (3, 'single')) == [1, 1, 1]) == 1 -%! && any (x, 1) == [0, 0, 1] -%! && any (x, 2) == [0; 0; 1])); - -%!error <Invalid call to any> any (); -%!error <Invalid call to any> any (1, 2, 3); - - */ +%! assert (all (any (x) == [0, 0, 1]) == 1); +%! assert (all (any (ones (3, "single")) == [1, 1, 1]) == 1); +%! assert (any (x, 1) == [0, 0, 1]); +%! assert (any (x, 2) == [0; 0; 1]); + +%!error any () +%!error any (1, 2, 3) +*/ // These mapping functions may also be useful in other places, eh? @@ -283,19 +279,18 @@ %! v = [0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]; %! y = [0, rt3, 1, rt3, -rt3, -1, -rt3, 0]; %! x = [1, 3, 1, 1, 1, 1, 3, 1]; -%! assert(atan2 (y, x), v, sqrt (eps)); +%! assert (atan2 (y, x), v, sqrt (eps)); %!test %! rt2 = sqrt (2); %! rt3 = sqrt (3); -%! v = single([0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]); -%! y = single([0, rt3, 1, rt3, -rt3, -1, -rt3, 0]); -%! x = single([1, 3, 1, 1, 1, 1, 3, 1]); -%! assert(atan2 (y, x), v, sqrt (eps('single'))); - -%!error <Invalid call to atan2> atan2 (); -%!error <Invalid call to atan2> atan2 (1, 2, 3); - +%! v = single ([0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]); +%! y = single ([0, rt3, 1, rt3, -rt3, -1, -rt3, 0]); +%! x = single ([1, 3, 1, 1, 1, 1, 3, 1]); +%! assert (atan2 (y, x), v, sqrt (eps ("single"))); + +%!error atan2 () +%!error atan2 (1, 2, 3) */ @@ -397,8 +392,8 @@ %!assert (size (hypot (rand (2, 3, 4), 1)), [2, 3, 4]) %!assert (size (hypot (1, rand (2, 3, 4))), [2, 3, 4]) %!assert (size (hypot (1, 2)), [1, 1]) -%!assert (hypot (1:10, 1:10), sqrt(2) * [1:10], 16*eps) -%!assert (hypot (single(1:10), single(1:10)), single(sqrt(2) * [1:10])); +%!assert (hypot (1:10, 1:10), sqrt (2) * [1:10], 16*eps) +%!assert (hypot (single (1:10), single (1:10)), single (sqrt (2) * [1:10])) */ template<typename T, typename ET> @@ -498,16 +493,16 @@ } /* -%!assert(log2 ([1/4, 1/2, 1, 2, 4]), [-2, -1, 0, 1, 2]); -%!assert(log2(Inf), Inf); -%!assert(isnan(log2(NaN))); -%!assert(log2(4*i), 2 + log2(1*i)); -%!assert(log2(complex(0,Inf)), Inf + log2(i)); +%!assert (log2 ([1/4, 1/2, 1, 2, 4]), [-2, -1, 0, 1, 2]) +%!assert (log2 (Inf), Inf) +%!assert (isnan (log2 (NaN))) +%!assert (log2 (4*i), 2 + log2 (1*i)) +%!assert (log2 (complex (0,Inf)), Inf + log2 (i)) %!test %! [f, e] = log2 ([0,-1; 2,-4; Inf,-Inf]); %! assert (f, [0,-0.5; 0.5,-0.5; Inf,-Inf]); -%! assert (e(1:2,:), [0,1;2,3]) +%! assert (e(1:2,:), [0,1;2,3]); %!test %! [f, e] = log2 (complex (zeros (3, 2), [0,-1; 2,-4; Inf,-Inf])); @@ -620,21 +615,21 @@ } /* - -%!assert(rem ([1, 2, 3; -1, -2, -3], 2), [1, 0, 1; -1, 0, -1]); -%!assert(rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3)),[1, 0, 1; -1, 0, -1]); -%!error rem (); -%!error rem (1, 2, 3); -%!error rem ([1, 2], [3, 4, 5]); -%!error rem (i, 1); -%!assert(rem (uint8([1, 2, 3; -1, -2, -3]), uint8 (2)), uint8([1, 0, 1; -1, 0, -1])); -%!assert(uint8(rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3))),uint8([1, 0, 1; -1, 0, -1])); -%!error rem (uint(8),int8(5)); -%!error rem (uint8([1, 2]), uint8([3, 4, 5])); - +%!assert (rem ([1, 2, 3; -1, -2, -3], 2), [1, 0, 1; -1, 0, -1]) +%!assert (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3)),[1, 0, 1; -1, 0, -1]) +%!assert (rem (uint8 ([1, 2, 3; -1, -2, -3]), uint8 (2)), uint8 ([1, 0, 1; -1, 0, -1])) +%!assert (uint8 (rem ([1, 2, 3; -1, -2, -3], 2 * ones (2, 3))),uint8 ([1, 0, 1; -1, 0, -1])) + +%!error rem (uint (8), int8 (5)) +%!error rem (uint8 ([1, 2]), uint8 ([3, 4, 5])) +%!error rem () +%!error rem (1, 2, 3) +%!error rem ([1, 2], [3, 4, 5]) +%!error rem (i, 1) */ /* + %!assert (size (fmod (zeros (0, 2), zeros (0, 2))), [0, 2]) %!assert (size (fmod (rand (2, 3, 4), zeros (2, 3, 4))), [2, 3, 4]) %!assert (size (fmod (rand (2, 3, 4), 1)), [2, 3, 4]) @@ -754,48 +749,48 @@ /* ## empty input test -%!assert (isempty(mod([], []))); +%!assert (isempty (mod ([], []))) ## x mod y, y != 0 tests -%!assert (mod(5, 3), 2); -%!assert (mod(-5, 3), 1); -%!assert (mod(0, 3), 0); -%!assert (mod([-5, 5, 0], [3, 3, 3]), [1, 2, 0]); -%!assert (mod([-5; 5; 0], [3; 3; 3]), [1; 2; 0]); -%!assert (mod([-5, 5; 0, 3], [3, 3 ; 3, 1]), [1, 2 ; 0, 0]); +%!assert (mod (5, 3), 2) +%!assert (mod (-5, 3), 1) +%!assert (mod (0, 3), 0) +%!assert (mod ([-5, 5, 0], [3, 3, 3]), [1, 2, 0]) +%!assert (mod ([-5; 5; 0], [3; 3; 3]), [1; 2; 0]) +%!assert (mod ([-5, 5; 0, 3], [3, 3 ; 3, 1]), [1, 2 ; 0, 0]) ## x mod 0 tests -%!assert (mod(5, 0), 5); -%!assert (mod(-5, 0), -5); -%!assert (mod([-5, 5, 0], [3, 0, 3]), [1, 5, 0]); -%!assert (mod([-5; 5; 0], [3; 0; 3]), [1; 5; 0]); -%!assert (mod([-5, 5; 0, 3], [3, 0 ; 3, 1]), [1, 5 ; 0, 0]); -%!assert (mod([-5, 5; 0, 3], [0, 0 ; 0, 0]), [-5, 5; 0, 3]); +%!assert (mod (5, 0), 5) +%!assert (mod (-5, 0), -5) +%!assert (mod ([-5, 5, 0], [3, 0, 3]), [1, 5, 0]) +%!assert (mod ([-5; 5; 0], [3; 0; 3]), [1; 5; 0]) +%!assert (mod ([-5, 5; 0, 3], [3, 0 ; 3, 1]), [1, 5 ; 0, 0]) +%!assert (mod ([-5, 5; 0, 3], [0, 0 ; 0, 0]), [-5, 5; 0, 3]) ## mixed scalar/matrix tests -%!assert (mod([-5, 5; 0, 3], 0), [-5, 5; 0, 3]); -%!assert (mod([-5, 5; 0, 3], 3), [1, 2; 0, 0]); -%!assert (mod(-5,[0,0; 0,0]), [-5, -5; -5, -5]); -%!assert (mod(-5,[3,0; 3,1]), [1, -5; 1, 0]); -%!assert (mod(-5,[3,2; 3,1]), [1, 1; 1, 0]); +%!assert (mod ([-5, 5; 0, 3], 0), [-5, 5; 0, 3]) +%!assert (mod ([-5, 5; 0, 3], 3), [1, 2; 0, 0]) +%!assert (mod (-5, [0,0; 0,0]), [-5, -5; -5, -5]) +%!assert (mod (-5, [3,0; 3,1]), [1, -5; 1, 0]) +%!assert (mod (-5, [3,2; 3,1]), [1, 1; 1, 0]) ## integer types -%!assert (mod(uint8(5),uint8(4)),uint8(1)) -%!assert (mod(uint8([1:5]),uint8(4)),uint8([1,2,3,0,1])) -%!assert (mod(uint8([1:5]),uint8(0)),uint8([1:5])) -%!error (mod(uint8(5),int8(4))) +%!assert (mod (uint8 (5), uint8 (4)), uint8 (1)) +%!assert (mod (uint8 ([1:5]), uint8 (4)), uint8 ([1,2,3,0,1])) +%!assert (mod (uint8 ([1:5]), uint8 (0)), uint8 ([1:5])) +%!error (mod (uint8 (5), int8 (4))) ## mixed integer/real types -%!assert (mod(uint8(5),4),uint8(1)) -%!assert (mod(5,uint8(4)),uint8(1)) -%!assert (mod(uint8([1:5]),4),uint8([1,2,3,0,1])) +%!assert (mod (uint8 (5), 4), uint8 (1)) +%!assert (mod (5, uint8 (4)), uint8 (1)) +%!assert (mod (uint8 ([1:5]), 4), uint8 ([1,2,3,0,1])) ## non-integer real numbers %!assert (mod (2.1, 0.1), 0) %!assert (mod (2.1, 0.2), 0.1, eps) */ -// FIXME Need to convert the reduction functions of this file for single precision +// FIXME: Need to convert the reduction functions of this file for single precision #define NATIVE_REDUCTION_1(FCN, TYPE, DIM) \ (arg.is_ ## TYPE ## _type ()) \ @@ -1068,26 +1063,24 @@ } /* - -%!assert (cumprod ([1, 2, 3]), [1, 2, 6]); -%!assert (cumprod ([-1; -2; -3]), [-1; 2; -6]); -%!assert (cumprod ([i, 2+i, -3+2i, 4]), [i, -1+2i, -1-8i, -4-32i]); -%!assert (cumprod ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [1, 2, 3; i, 4i, 9i; -1+i, -8+8i, -27+27i]); - -%!assert (cumprod (single([1, 2, 3])), single([1, 2, 6])); -%!assert (cumprod (single([-1; -2; -3])), single([-1; 2; -6])); -%!assert (cumprod (single([i, 2+i, -3+2i, 4])), single([i, -1+2i, -1-8i, -4-32i])); -%!assert (cumprod (single([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single([1, 2, 3; i, 4i, 9i; -1+i, -8+8i, -27+27i])); - -%!error <Invalid call to cumprod> cumprod (); - -%!assert (cumprod ([2, 3; 4, 5], 1), [2, 3; 8, 15]); -%!assert (cumprod ([2, 3; 4, 5], 2), [2, 6; 4, 20]); - -%!assert (cumprod (single([2, 3; 4, 5]), 1), single([2, 3; 8, 15])); -%!assert (cumprod (single([2, 3; 4, 5]), 2), single([2, 6; 4, 20])); - - */ +%!assert (cumprod ([1, 2, 3]), [1, 2, 6]) +%!assert (cumprod ([-1; -2; -3]), [-1; 2; -6]) +%!assert (cumprod ([i, 2+i, -3+2i, 4]), [i, -1+2i, -1-8i, -4-32i]) +%!assert (cumprod ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [1, 2, 3; i, 4i, 9i; -1+i, -8+8i, -27+27i]) + +%!assert (cumprod (single ([1, 2, 3])), single ([1, 2, 6])) +%!assert (cumprod (single ([-1; -2; -3])), single ([-1; 2; -6])) +%!assert (cumprod (single ([i, 2+i, -3+2i, 4])), single ([i, -1+2i, -1-8i, -4-32i])) +%!assert (cumprod (single ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single ([1, 2, 3; i, 4i, 9i; -1+i, -8+8i, -27+27i])) + +%!assert (cumprod ([2, 3; 4, 5], 1), [2, 3; 8, 15]) +%!assert (cumprod ([2, 3; 4, 5], 2), [2, 6; 4, 20]) + +%!assert (cumprod (single ([2, 3; 4, 5]), 1), single ([2, 3; 8, 15])) +%!assert (cumprod (single ([2, 3; 4, 5]), 2), single ([2, 6; 4, 20])) + +%!error cumprod () +*/ DEFUN (cumsum, args, , "-*- texinfo -*-\n\ @@ -1219,26 +1212,24 @@ } /* - -%!assert (cumsum ([1, 2, 3]), [1, 3, 6]); -%!assert (cumsum ([-1; -2; -3]), [-1; -3; -6]); -%!assert (cumsum ([i, 2+i, -3+2i, 4]), [i, 2+2i, -1+4i, 3+4i]); -%!assert (cumsum ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [1, 2, 3; 1+i, 2+2i, 3+3i; 2+2i, 4+4i, 6+6i]); - -%!assert (cumsum (single([1, 2, 3])), single([1, 3, 6])); -%!assert (cumsum (single([-1; -2; -3])), single([-1; -3; -6])); -%!assert (cumsum (single([i, 2+i, -3+2i, 4])), single([i, 2+2i, -1+4i, 3+4i])); -%!assert (cumsum (single([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single([1, 2, 3; 1+i, 2+2i, 3+3i; 2+2i, 4+4i, 6+6i])); - -%!error <Invalid call to cumsum> cumsum (); - -%!assert (cumsum ([1, 2; 3, 4], 1), [1, 2; 4, 6]); -%!assert (cumsum ([1, 2; 3, 4], 2), [1, 3; 3, 7]); - -%!assert (cumsum (single([1, 2; 3, 4]), 1), single([1, 2; 4, 6])); -%!assert (cumsum (single([1, 2; 3, 4]), 2), single([1, 3; 3, 7])); - - */ +%!assert (cumsum ([1, 2, 3]), [1, 3, 6]) +%!assert (cumsum ([-1; -2; -3]), [-1; -3; -6]) +%!assert (cumsum ([i, 2+i, -3+2i, 4]), [i, 2+2i, -1+4i, 3+4i]) +%!assert (cumsum ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [1, 2, 3; 1+i, 2+2i, 3+3i; 2+2i, 4+4i, 6+6i]) + +%!assert (cumsum (single ([1, 2, 3])), single ([1, 3, 6])) +%!assert (cumsum (single ([-1; -2; -3])), single ([-1; -3; -6])) +%!assert (cumsum (single ([i, 2+i, -3+2i, 4])), single ([i, 2+2i, -1+4i, 3+4i])) +%!assert (cumsum (single ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single ([1, 2, 3; 1+i, 2+2i, 3+3i; 2+2i, 4+4i, 6+6i])) + +%!assert (cumsum ([1, 2; 3, 4], 1), [1, 2; 4, 6]) +%!assert (cumsum ([1, 2; 3, 4], 2), [1, 3; 3, 7]) + +%!assert (cumsum (single ([1, 2; 3, 4]), 1), single ([1, 2; 4, 6])) +%!assert (cumsum (single ([1, 2; 3, 4]), 2), single ([1, 3; 3, 7])) + +%!error cumsum () +*/ DEFUN (diag, args, , "-*- texinfo -*-\n\ @@ -1308,46 +1299,44 @@ } /* - -%!assert(full (diag ([1; 2; 3])), [1, 0, 0; 0, 2, 0; 0, 0, 3]); -%!assert(diag ([1; 2; 3], 1), [0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]); -%!assert(diag ([1; 2; 3], 2), [0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0]); -%!assert(diag ([1; 2; 3],-1), [0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]); -%!assert(diag ([1; 2; 3],-2), [0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0]); - -%!assert(diag ([1, 0, 0; 0, 2, 0; 0, 0, 3]), [1; 2; 3]); -%!assert(diag ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0], 1), [1; 2; 3]); -%!assert(diag ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0], -1), [1; 2; 3]); -%!assert(diag (ones(1, 0), 2), zeros (2)); -%!assert(diag (1:3, 4, 2), [1, 0; 0, 2; 0, 0; 0, 0]); - -%!assert(full (diag (single([1; 2; 3]))), single([1, 0, 0; 0, 2, 0; 0, 0, 3])); -%!assert(diag (single([1; 2; 3]), 1), single([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0])); -%!assert(diag (single([1; 2; 3]), 2), single([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0])); -%!assert(diag (single([1; 2; 3]),-1), single([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0])); -%!assert(diag (single([1; 2; 3]),-2), single([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0])); - -%!assert(diag (single([1, 0, 0; 0, 2, 0; 0, 0, 3])), single([1; 2; 3])); -%!assert(diag (single([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), single([1; 2; 3])); -%!assert(diag (single([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), single([1; 2; 3])); - -%!assert(diag (int8([1; 2; 3])), int8([1, 0, 0; 0, 2, 0; 0, 0, 3])); -%!assert(diag (int8([1; 2; 3]), 1), int8([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0])); -%!assert(diag (int8([1; 2; 3]), 2), int8([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0])); -%!assert(diag (int8([1; 2; 3]),-1), int8([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0])); -%!assert(diag (int8([1; 2; 3]),-2), int8([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0])); - -%!assert(diag (int8([1, 0, 0; 0, 2, 0; 0, 0, 3])), int8([1; 2; 3])); -%!assert(diag (int8([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), int8([1; 2; 3])); -%!assert(diag (int8([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), int8([1; 2; 3])); - -%% Test input validation -%!error <Invalid call to diag> diag (); -%!error <Invalid call to diag> diag (1,2,3,4); -%!error diag (ones (2), 3, 3); -%!error diag (1:3, -4, 3); - - */ +%!assert (full (diag ([1; 2; 3])), [1, 0, 0; 0, 2, 0; 0, 0, 3]) +%!assert (diag ([1; 2; 3], 1), [0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]) +%!assert (diag ([1; 2; 3], 2), [0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0]) +%!assert (diag ([1; 2; 3],-1), [0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]) +%!assert (diag ([1; 2; 3],-2), [0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0]) + +%!assert (diag ([1, 0, 0; 0, 2, 0; 0, 0, 3]), [1; 2; 3]) +%!assert (diag ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0], 1), [1; 2; 3]) +%!assert (diag ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0], -1), [1; 2; 3]) +%!assert (diag (ones (1, 0), 2), zeros (2)) +%!assert (diag (1:3, 4, 2), [1, 0; 0, 2; 0, 0; 0, 0]) + +%!assert (full (diag (single ([1; 2; 3]))), single ([1, 0, 0; 0, 2, 0; 0, 0, 3])) +%!assert (diag (single ([1; 2; 3]), 1), single ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0])) +%!assert (diag (single ([1; 2; 3]), 2), single ([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0])) +%!assert (diag (single ([1; 2; 3]),-1), single ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0])) +%!assert (diag (single ([1; 2; 3]),-2), single ([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0])) + +%!assert (diag (single ([1, 0, 0; 0, 2, 0; 0, 0, 3])), single ([1; 2; 3])) +%!assert (diag (single ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), single ([1; 2; 3])) +%!assert (diag (single ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), single ([1; 2; 3])) + +%!assert (diag (int8 ([1; 2; 3])), int8 ([1, 0, 0; 0, 2, 0; 0, 0, 3])) +%!assert (diag (int8 ([1; 2; 3]), 1), int8 ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0])) +%!assert (diag (int8 ([1; 2; 3]), 2), int8 ([0, 0, 1, 0, 0; 0, 0, 0, 2, 0; 0, 0, 0, 0, 3; 0, 0, 0, 0, 0; 0, 0, 0, 0, 0])) +%!assert (diag (int8 ([1; 2; 3]),-1), int8 ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0])) +%!assert (diag (int8 ([1; 2; 3]),-2), int8 ([0, 0, 0, 0, 0; 0, 0, 0, 0, 0; 1, 0, 0, 0, 0; 0, 2, 0, 0, 0; 0, 0, 3, 0, 0])) + +%!assert (diag (int8 ([1, 0, 0; 0, 2, 0; 0, 0, 3])), int8 ([1; 2; 3])) +%!assert (diag (int8 ([0, 1, 0, 0; 0, 0, 2, 0; 0, 0, 0, 3; 0, 0, 0, 0]), 1), int8 ([1; 2; 3])) +%!assert (diag (int8 ([0, 0, 0, 0; 1, 0, 0, 0; 0, 2, 0, 0; 0, 0, 3, 0]), -1), int8 ([1; 2; 3])) + +## Test input validation +%!error diag () +%!error diag (1,2,3,4) +%!error diag (ones (2), 3, 3) +%!error diag (1:3, -4, 3) +*/ DEFUN (prod, args, , "-*- texinfo -*-\n\ @@ -1362,50 +1351,48 @@ } /* - -%!assert (prod ([1, 2, 3]), 6); -%!assert (prod ([-1; -2; -3]), -6); -%!assert (prod ([i, 2+i, -3+2i, 4]), -4 - 32i); -%!assert (prod ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [-1+i, -8+8i, -27+27i]); - -%!assert (prod (single([1, 2, 3])), single(6)); -%!assert (prod (single([-1; -2; -3])), single(-6)); -%!assert (prod (single([i, 2+i, -3+2i, 4])), single(-4 - 32i)); -%!assert (prod (single([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single([-1+i, -8+8i, -27+27i])); - -%!error <Invalid call to prod> prod (); - -%!assert (prod ([1, 2; 3, 4], 1), [3, 8]); -%!assert (prod ([1, 2; 3, 4], 2), [2; 12]); -%!assert (prod (zeros (1, 0)), 1); -%!assert (prod (zeros (1, 0), 1), zeros (1, 0)); -%!assert (prod (zeros (1, 0), 2), 1); -%!assert (prod (zeros (0, 1)), 1); -%!assert (prod (zeros (0, 1), 1), 1); -%!assert (prod (zeros (0, 1), 2), zeros (0, 1)); -%!assert (prod (zeros (2, 0)), zeros (1, 0)); -%!assert (prod (zeros (2, 0), 1), zeros (1, 0)); -%!assert (prod (zeros (2, 0), 2), [1; 1]); -%!assert (prod (zeros (0, 2)), [1, 1]); -%!assert (prod (zeros (0, 2), 1), [1, 1]); -%!assert (prod (zeros (0, 2), 2), zeros(0, 1)); - -%!assert (prod (single([1, 2; 3, 4]), 1), single([3, 8])); -%!assert (prod (single([1, 2; 3, 4]), 2), single([2; 12])); -%!assert (prod (zeros (1, 0, 'single')), single(1)); -%!assert (prod (zeros (1, 0, 'single'), 1), zeros (1, 0, 'single')); -%!assert (prod (zeros (1, 0, 'single'), 2), single(1)); -%!assert (prod (zeros (0, 1, 'single')), single(1)); -%!assert (prod (zeros (0, 1, 'single'), 1), single(1)); -%!assert (prod (zeros (0, 1, 'single'), 2), zeros (0, 1, 'single')); -%!assert (prod (zeros (2, 0, 'single')), zeros (1, 0, 'single')); -%!assert (prod (zeros (2, 0, 'single'), 1), zeros (1, 0, 'single')); -%!assert (prod (zeros (2, 0, 'single'), 2), single([1; 1])); -%!assert (prod (zeros (0, 2, 'single')), single([1, 1])); -%!assert (prod (zeros (0, 2, 'single'), 1), single([1, 1])); -%!assert (prod (zeros (0, 2, 'single'), 2), zeros(0, 1, 'single')); - - */ +%!assert (prod ([1, 2, 3]), 6) +%!assert (prod ([-1; -2; -3]), -6) +%!assert (prod ([i, 2+i, -3+2i, 4]), -4 - 32i) +%!assert (prod ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [-1+i, -8+8i, -27+27i]) + +%!assert (prod (single ([1, 2, 3])), single (6)) +%!assert (prod (single ([-1; -2; -3])), single (-6)) +%!assert (prod (single ([i, 2+i, -3+2i, 4])), single (-4 - 32i)) +%!assert (prod (single ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single ([-1+i, -8+8i, -27+27i])) + +%!assert (prod ([1, 2; 3, 4], 1), [3, 8]) +%!assert (prod ([1, 2; 3, 4], 2), [2; 12]) +%!assert (prod (zeros (1, 0)), 1) +%!assert (prod (zeros (1, 0), 1), zeros (1, 0)) +%!assert (prod (zeros (1, 0), 2), 1) +%!assert (prod (zeros (0, 1)), 1) +%!assert (prod (zeros (0, 1), 1), 1) +%!assert (prod (zeros (0, 1), 2), zeros (0, 1)) +%!assert (prod (zeros (2, 0)), zeros (1, 0)) +%!assert (prod (zeros (2, 0), 1), zeros (1, 0)) +%!assert (prod (zeros (2, 0), 2), [1; 1]) +%!assert (prod (zeros (0, 2)), [1, 1]) +%!assert (prod (zeros (0, 2), 1), [1, 1]) +%!assert (prod (zeros (0, 2), 2), zeros (0, 1)) + +%!assert (prod (single ([1, 2; 3, 4]), 1), single ([3, 8])) +%!assert (prod (single ([1, 2; 3, 4]), 2), single ([2; 12])) +%!assert (prod (zeros (1, 0, "single")), single (1)) +%!assert (prod (zeros (1, 0, "single"), 1), zeros (1, 0, "single")) +%!assert (prod (zeros (1, 0, "single"), 2), single (1)) +%!assert (prod (zeros (0, 1, "single")), single (1)) +%!assert (prod (zeros (0, 1, "single"), 1), single (1)) +%!assert (prod (zeros (0, 1, "single"), 2), zeros (0, 1, "single")) +%!assert (prod (zeros (2, 0, "single")), zeros (1, 0, "single")) +%!assert (prod (zeros (2, 0, "single"), 1), zeros (1, 0, "single")) +%!assert (prod (zeros (2, 0, "single"), 2), single ([1; 1])) +%!assert (prod (zeros (0, 2, "single")), single ([1, 1])) +%!assert (prod (zeros (0, 2, "single"), 1), single ([1, 1])) +%!assert (prod (zeros (0, 2, "single"), 2), zeros (0, 1, "single")) + +%!error prod () +*/ static bool all_scalar_1x1 (const octave_value_list& args) @@ -1875,194 +1862,195 @@ } /* -%% test concatenation with all zero matrices -%!assert(horzcat ('', 65*ones(1,10)), 'AAAAAAAAAA'); -%!assert(horzcat (65*ones(1,10), ''), 'AAAAAAAAAA'); - -%!assert (class (horzcat (int64(1), int64(1))), 'int64') -%!assert (class (horzcat (int64(1), int32(1))), 'int64') -%!assert (class (horzcat (int64(1), int16(1))), 'int64') -%!assert (class (horzcat (int64(1), int8(1))), 'int64') -%!assert (class (horzcat (int64(1), uint64(1))), 'int64') -%!assert (class (horzcat (int64(1), uint32(1))), 'int64') -%!assert (class (horzcat (int64(1), uint16(1))), 'int64') -%!assert (class (horzcat (int64(1), uint8(1))), 'int64') -%!assert (class (horzcat (int64(1), single(1))), 'int64') -%!assert (class (horzcat (int64(1), double(1))), 'int64') -%!assert (class (horzcat (int64(1), cell(1))), 'cell') -%!assert (class (horzcat (int64(1), true)), 'int64') -%!assert (class (horzcat (int64(1), 'a')), 'char') - -%!assert (class (horzcat (int32(1), int64(1))), 'int32') -%!assert (class (horzcat (int32(1), int32(1))), 'int32') -%!assert (class (horzcat (int32(1), int16(1))), 'int32') -%!assert (class (horzcat (int32(1), int8(1))), 'int32') -%!assert (class (horzcat (int32(1), uint64(1))), 'int32') -%!assert (class (horzcat (int32(1), uint32(1))), 'int32') -%!assert (class (horzcat (int32(1), uint16(1))), 'int32') -%!assert (class (horzcat (int32(1), uint8(1))), 'int32') -%!assert (class (horzcat (int32(1), single(1))), 'int32') -%!assert (class (horzcat (int32(1), double(1))), 'int32') -%!assert (class (horzcat (int32(1), cell(1))), 'cell') -%!assert (class (horzcat (int32(1), true)), 'int32') -%!assert (class (horzcat (int32(1), 'a')), 'char') - -%!assert (class (horzcat (int16(1), int64(1))), 'int16') -%!assert (class (horzcat (int16(1), int32(1))), 'int16') -%!assert (class (horzcat (int16(1), int16(1))), 'int16') -%!assert (class (horzcat (int16(1), int8(1))), 'int16') -%!assert (class (horzcat (int16(1), uint64(1))), 'int16') -%!assert (class (horzcat (int16(1), uint32(1))), 'int16') -%!assert (class (horzcat (int16(1), uint16(1))), 'int16') -%!assert (class (horzcat (int16(1), uint8(1))), 'int16') -%!assert (class (horzcat (int16(1), single(1))), 'int16') -%!assert (class (horzcat (int16(1), double(1))), 'int16') -%!assert (class (horzcat (int16(1), cell(1))), 'cell') -%!assert (class (horzcat (int16(1), true)), 'int16') -%!assert (class (horzcat (int16(1), 'a')), 'char') - -%!assert (class (horzcat (int8(1), int64(1))), 'int8') -%!assert (class (horzcat (int8(1), int32(1))), 'int8') -%!assert (class (horzcat (int8(1), int16(1))), 'int8') -%!assert (class (horzcat (int8(1), int8(1))), 'int8') -%!assert (class (horzcat (int8(1), uint64(1))), 'int8') -%!assert (class (horzcat (int8(1), uint32(1))), 'int8') -%!assert (class (horzcat (int8(1), uint16(1))), 'int8') -%!assert (class (horzcat (int8(1), uint8(1))), 'int8') -%!assert (class (horzcat (int8(1), single(1))), 'int8') -%!assert (class (horzcat (int8(1), double(1))), 'int8') -%!assert (class (horzcat (int8(1), cell(1))), 'cell') -%!assert (class (horzcat (int8(1), true)), 'int8') -%!assert (class (horzcat (int8(1), 'a')), 'char') - -%!assert (class (horzcat (uint64(1), int64(1))), 'uint64') -%!assert (class (horzcat (uint64(1), int32(1))), 'uint64') -%!assert (class (horzcat (uint64(1), int16(1))), 'uint64') -%!assert (class (horzcat (uint64(1), int8(1))), 'uint64') -%!assert (class (horzcat (uint64(1), uint64(1))), 'uint64') -%!assert (class (horzcat (uint64(1), uint32(1))), 'uint64') -%!assert (class (horzcat (uint64(1), uint16(1))), 'uint64') -%!assert (class (horzcat (uint64(1), uint8(1))), 'uint64') -%!assert (class (horzcat (uint64(1), single(1))), 'uint64') -%!assert (class (horzcat (uint64(1), double(1))), 'uint64') -%!assert (class (horzcat (uint64(1), cell(1))), 'cell') -%!assert (class (horzcat (uint64(1), true)), 'uint64') -%!assert (class (horzcat (uint64(1), 'a')), 'char') - -%!assert (class (horzcat (uint32(1), int64(1))), 'uint32') -%!assert (class (horzcat (uint32(1), int32(1))), 'uint32') -%!assert (class (horzcat (uint32(1), int16(1))), 'uint32') -%!assert (class (horzcat (uint32(1), int8(1))), 'uint32') -%!assert (class (horzcat (uint32(1), uint64(1))), 'uint32') -%!assert (class (horzcat (uint32(1), uint32(1))), 'uint32') -%!assert (class (horzcat (uint32(1), uint16(1))), 'uint32') -%!assert (class (horzcat (uint32(1), uint8(1))), 'uint32') -%!assert (class (horzcat (uint32(1), single(1))), 'uint32') -%!assert (class (horzcat (uint32(1), double(1))), 'uint32') -%!assert (class (horzcat (uint32(1), cell(1))), 'cell') -%!assert (class (horzcat (uint32(1), true)), 'uint32') -%!assert (class (horzcat (uint32(1), 'a')), 'char') - -%!assert (class (horzcat (uint16(1), int64(1))), 'uint16') -%!assert (class (horzcat (uint16(1), int32(1))), 'uint16') -%!assert (class (horzcat (uint16(1), int16(1))), 'uint16') -%!assert (class (horzcat (uint16(1), int8(1))), 'uint16') -%!assert (class (horzcat (uint16(1), uint64(1))), 'uint16') -%!assert (class (horzcat (uint16(1), uint32(1))), 'uint16') -%!assert (class (horzcat (uint16(1), uint16(1))), 'uint16') -%!assert (class (horzcat (uint16(1), uint8(1))), 'uint16') -%!assert (class (horzcat (uint16(1), single(1))), 'uint16') -%!assert (class (horzcat (uint16(1), double(1))), 'uint16') -%!assert (class (horzcat (uint16(1), cell(1))), 'cell') -%!assert (class (horzcat (uint16(1), true)), 'uint16') -%!assert (class (horzcat (uint16(1), 'a')), 'char') - -%!assert (class (horzcat (uint8(1), int64(1))), 'uint8') -%!assert (class (horzcat (uint8(1), int32(1))), 'uint8') -%!assert (class (horzcat (uint8(1), int16(1))), 'uint8') -%!assert (class (horzcat (uint8(1), int8(1))), 'uint8') -%!assert (class (horzcat (uint8(1), uint64(1))), 'uint8') -%!assert (class (horzcat (uint8(1), uint32(1))), 'uint8') -%!assert (class (horzcat (uint8(1), uint16(1))), 'uint8') -%!assert (class (horzcat (uint8(1), uint8(1))), 'uint8') -%!assert (class (horzcat (uint8(1), single(1))), 'uint8') -%!assert (class (horzcat (uint8(1), double(1))), 'uint8') -%!assert (class (horzcat (uint8(1), cell(1))), 'cell') -%!assert (class (horzcat (uint8(1), true)), 'uint8') -%!assert (class (horzcat (uint8(1), 'a')), 'char') - -%!assert (class (horzcat (single(1), int64(1))), 'int64') -%!assert (class (horzcat (single(1), int32(1))), 'int32') -%!assert (class (horzcat (single(1), int16(1))), 'int16') -%!assert (class (horzcat (single(1), int8(1))), 'int8') -%!assert (class (horzcat (single(1), uint64(1))), 'uint64') -%!assert (class (horzcat (single(1), uint32(1))), 'uint32') -%!assert (class (horzcat (single(1), uint16(1))), 'uint16') -%!assert (class (horzcat (single(1), uint8(1))), 'uint8') -%!assert (class (horzcat (single(1), single(1))), 'single') -%!assert (class (horzcat (single(1), double(1))), 'single') -%!assert (class (horzcat (single(1), cell(1))), 'cell') -%!assert (class (horzcat (single(1), true)), 'single') -%!assert (class (horzcat (single(1), 'a')), 'char') - -%!assert (class (horzcat (double(1), int64(1))), 'int64') -%!assert (class (horzcat (double(1), int32(1))), 'int32') -%!assert (class (horzcat (double(1), int16(1))), 'int16') -%!assert (class (horzcat (double(1), int8(1))), 'int8') -%!assert (class (horzcat (double(1), uint64(1))), 'uint64') -%!assert (class (horzcat (double(1), uint32(1))), 'uint32') -%!assert (class (horzcat (double(1), uint16(1))), 'uint16') -%!assert (class (horzcat (double(1), uint8(1))), 'uint8') -%!assert (class (horzcat (double(1), single(1))), 'single') -%!assert (class (horzcat (double(1), double(1))), 'double') -%!assert (class (horzcat (double(1), cell(1))), 'cell') -%!assert (class (horzcat (double(1), true)), 'double') -%!assert (class (horzcat (double(1), 'a')), 'char') - -%!assert (class (horzcat (cell(1), int64(1))), 'cell') -%!assert (class (horzcat (cell(1), int32(1))), 'cell') -%!assert (class (horzcat (cell(1), int16(1))), 'cell') -%!assert (class (horzcat (cell(1), int8(1))), 'cell') -%!assert (class (horzcat (cell(1), uint64(1))), 'cell') -%!assert (class (horzcat (cell(1), uint32(1))), 'cell') -%!assert (class (horzcat (cell(1), uint16(1))), 'cell') -%!assert (class (horzcat (cell(1), uint8(1))), 'cell') -%!assert (class (horzcat (cell(1), single(1))), 'cell') -%!assert (class (horzcat (cell(1), double(1))), 'cell') -%!assert (class (horzcat (cell(1), cell(1))), 'cell') -%!assert (class (horzcat (cell(1), true)), 'cell') -%!assert (class (horzcat (cell(1), 'a')), 'cell') - -%!assert (class (horzcat (true, int64(1))), 'int64') -%!assert (class (horzcat (true, int32(1))), 'int32') -%!assert (class (horzcat (true, int16(1))), 'int16') -%!assert (class (horzcat (true, int8(1))), 'int8') -%!assert (class (horzcat (true, uint64(1))), 'uint64') -%!assert (class (horzcat (true, uint32(1))), 'uint32') -%!assert (class (horzcat (true, uint16(1))), 'uint16') -%!assert (class (horzcat (true, uint8(1))), 'uint8') -%!assert (class (horzcat (true, single(1))), 'single') -%!assert (class (horzcat (true, double(1))), 'double') -%!assert (class (horzcat (true, cell(1))), 'cell') -%!assert (class (horzcat (true, true)), 'logical') -%!assert (class (horzcat (true, 'a')), 'char') - -%!assert (class (horzcat ('a', int64(1))), 'char') -%!assert (class (horzcat ('a', int32(1))), 'char') -%!assert (class (horzcat ('a', int16(1))), 'char') -%!assert (class (horzcat ('a', int8(1))), 'char') -%!assert (class (horzcat ('a', int64(1))), 'char') -%!assert (class (horzcat ('a', int32(1))), 'char') -%!assert (class (horzcat ('a', int16(1))), 'char') -%!assert (class (horzcat ('a', int8(1))), 'char') -%!assert (class (horzcat ('a', single(1))), 'char') -%!assert (class (horzcat ('a', double(1))), 'char') -%!assert (class (horzcat ('a', cell(1))), 'cell') -%!assert (class (horzcat ('a', true)), 'char') -%!assert (class (horzcat ('a', 'a')), 'char') - -%!assert (class (horzcat (cell(1), struct('foo', 'bar'))), 'cell') -%!error horzcat (struct('foo', 'bar'), cell(1)); +## Test concatenation with all zero matrices +%!assert (horzcat ("", 65*ones (1,10)), "AAAAAAAAAA"); +%!assert (horzcat (65*ones (1,10), ""), "AAAAAAAAAA"); + +%!assert (class (horzcat (int64 (1), int64 (1))), "int64") +%!assert (class (horzcat (int64 (1), int32 (1))), "int64") +%!assert (class (horzcat (int64 (1), int16 (1))), "int64") +%!assert (class (horzcat (int64 (1), int8 (1))), "int64") +%!assert (class (horzcat (int64 (1), uint64 (1))), "int64") +%!assert (class (horzcat (int64 (1), uint32 (1))), "int64") +%!assert (class (horzcat (int64 (1), uint16 (1))), "int64") +%!assert (class (horzcat (int64 (1), uint8 (1))), "int64") +%!assert (class (horzcat (int64 (1), single (1))), "int64") +%!assert (class (horzcat (int64 (1), double (1))), "int64") +%!assert (class (horzcat (int64 (1), cell (1))), "cell") +%!assert (class (horzcat (int64 (1), true)), "int64") +%!assert (class (horzcat (int64 (1), "a")), "char") + +%!assert (class (horzcat (int32 (1), int64 (1))), "int32") +%!assert (class (horzcat (int32 (1), int32 (1))), "int32") +%!assert (class (horzcat (int32 (1), int16 (1))), "int32") +%!assert (class (horzcat (int32 (1), int8 (1))), "int32") +%!assert (class (horzcat (int32 (1), uint64 (1))), "int32") +%!assert (class (horzcat (int32 (1), uint32 (1))), "int32") +%!assert (class (horzcat (int32 (1), uint16 (1))), "int32") +%!assert (class (horzcat (int32 (1), uint8 (1))), "int32") +%!assert (class (horzcat (int32 (1), single (1))), "int32") +%!assert (class (horzcat (int32 (1), double (1))), "int32") +%!assert (class (horzcat (int32 (1), cell (1))), "cell") +%!assert (class (horzcat (int32 (1), true)), "int32") +%!assert (class (horzcat (int32 (1), "a")), "char") + +%!assert (class (horzcat (int16 (1), int64 (1))), "int16") +%!assert (class (horzcat (int16 (1), int32 (1))), "int16") +%!assert (class (horzcat (int16 (1), int16 (1))), "int16") +%!assert (class (horzcat (int16 (1), int8 (1))), "int16") +%!assert (class (horzcat (int16 (1), uint64 (1))), "int16") +%!assert (class (horzcat (int16 (1), uint32 (1))), "int16") +%!assert (class (horzcat (int16 (1), uint16 (1))), "int16") +%!assert (class (horzcat (int16 (1), uint8 (1))), "int16") +%!assert (class (horzcat (int16 (1), single (1))), "int16") +%!assert (class (horzcat (int16 (1), double (1))), "int16") +%!assert (class (horzcat (int16 (1), cell (1))), "cell") +%!assert (class (horzcat (int16 (1), true)), "int16") +%!assert (class (horzcat (int16 (1), "a")), "char") + +%!assert (class (horzcat (int8 (1), int64 (1))), "int8") +%!assert (class (horzcat (int8 (1), int32 (1))), "int8") +%!assert (class (horzcat (int8 (1), int16 (1))), "int8") +%!assert (class (horzcat (int8 (1), int8 (1))), "int8") +%!assert (class (horzcat (int8 (1), uint64 (1))), "int8") +%!assert (class (horzcat (int8 (1), uint32 (1))), "int8") +%!assert (class (horzcat (int8 (1), uint16 (1))), "int8") +%!assert (class (horzcat (int8 (1), uint8 (1))), "int8") +%!assert (class (horzcat (int8 (1), single (1))), "int8") +%!assert (class (horzcat (int8 (1), double (1))), "int8") +%!assert (class (horzcat (int8 (1), cell (1))), "cell") +%!assert (class (horzcat (int8 (1), true)), "int8") +%!assert (class (horzcat (int8 (1), "a")), "char") + +%!assert (class (horzcat (uint64 (1), int64 (1))), "uint64") +%!assert (class (horzcat (uint64 (1), int32 (1))), "uint64") +%!assert (class (horzcat (uint64 (1), int16 (1))), "uint64") +%!assert (class (horzcat (uint64 (1), int8 (1))), "uint64") +%!assert (class (horzcat (uint64 (1), uint64 (1))), "uint64") +%!assert (class (horzcat (uint64 (1), uint32 (1))), "uint64") +%!assert (class (horzcat (uint64 (1), uint16 (1))), "uint64") +%!assert (class (horzcat (uint64 (1), uint8 (1))), "uint64") +%!assert (class (horzcat (uint64 (1), single (1))), "uint64") +%!assert (class (horzcat (uint64 (1), double (1))), "uint64") +%!assert (class (horzcat (uint64 (1), cell (1))), "cell") +%!assert (class (horzcat (uint64 (1), true)), "uint64") +%!assert (class (horzcat (uint64 (1), "a")), "char") + +%!assert (class (horzcat (uint32 (1), int64 (1))), "uint32") +%!assert (class (horzcat (uint32 (1), int32 (1))), "uint32") +%!assert (class (horzcat (uint32 (1), int16 (1))), "uint32") +%!assert (class (horzcat (uint32 (1), int8 (1))), "uint32") +%!assert (class (horzcat (uint32 (1), uint64 (1))), "uint32") +%!assert (class (horzcat (uint32 (1), uint32 (1))), "uint32") +%!assert (class (horzcat (uint32 (1), uint16 (1))), "uint32") +%!assert (class (horzcat (uint32 (1), uint8 (1))), "uint32") +%!assert (class (horzcat (uint32 (1), single (1))), "uint32") +%!assert (class (horzcat (uint32 (1), double (1))), "uint32") +%!assert (class (horzcat (uint32 (1), cell (1))), "cell") +%!assert (class (horzcat (uint32 (1), true)), "uint32") +%!assert (class (horzcat (uint32 (1), "a")), "char") + +%!assert (class (horzcat (uint16 (1), int64 (1))), "uint16") +%!assert (class (horzcat (uint16 (1), int32 (1))), "uint16") +%!assert (class (horzcat (uint16 (1), int16 (1))), "uint16") +%!assert (class (horzcat (uint16 (1), int8 (1))), "uint16") +%!assert (class (horzcat (uint16 (1), uint64 (1))), "uint16") +%!assert (class (horzcat (uint16 (1), uint32 (1))), "uint16") +%!assert (class (horzcat (uint16 (1), uint16 (1))), "uint16") +%!assert (class (horzcat (uint16 (1), uint8 (1))), "uint16") +%!assert (class (horzcat (uint16 (1), single (1))), "uint16") +%!assert (class (horzcat (uint16 (1), double (1))), "uint16") +%!assert (class (horzcat (uint16 (1), cell (1))), "cell") +%!assert (class (horzcat (uint16 (1), true)), "uint16") +%!assert (class (horzcat (uint16 (1), "a")), "char") + +%!assert (class (horzcat (uint8 (1), int64 (1))), "uint8") +%!assert (class (horzcat (uint8 (1), int32 (1))), "uint8") +%!assert (class (horzcat (uint8 (1), int16 (1))), "uint8") +%!assert (class (horzcat (uint8 (1), int8 (1))), "uint8") +%!assert (class (horzcat (uint8 (1), uint64 (1))), "uint8") +%!assert (class (horzcat (uint8 (1), uint32 (1))), "uint8") +%!assert (class (horzcat (uint8 (1), uint16 (1))), "uint8") +%!assert (class (horzcat (uint8 (1), uint8 (1))), "uint8") +%!assert (class (horzcat (uint8 (1), single (1))), "uint8") +%!assert (class (horzcat (uint8 (1), double (1))), "uint8") +%!assert (class (horzcat (uint8 (1), cell (1))), "cell") +%!assert (class (horzcat (uint8 (1), true)), "uint8") +%!assert (class (horzcat (uint8 (1), "a")), "char") + +%!assert (class (horzcat (single (1), int64 (1))), "int64") +%!assert (class (horzcat (single (1), int32 (1))), "int32") +%!assert (class (horzcat (single (1), int16 (1))), "int16") +%!assert (class (horzcat (single (1), int8 (1))), "int8") +%!assert (class (horzcat (single (1), uint64 (1))), "uint64") +%!assert (class (horzcat (single (1), uint32 (1))), "uint32") +%!assert (class (horzcat (single (1), uint16 (1))), "uint16") +%!assert (class (horzcat (single (1), uint8 (1))), "uint8") +%!assert (class (horzcat (single (1), single (1))), "single") +%!assert (class (horzcat (single (1), double (1))), "single") +%!assert (class (horzcat (single (1), cell (1))), "cell") +%!assert (class (horzcat (single (1), true)), "single") +%!assert (class (horzcat (single (1), "a")), "char") + +%!assert (class (horzcat (double (1), int64 (1))), "int64") +%!assert (class (horzcat (double (1), int32 (1))), "int32") +%!assert (class (horzcat (double (1), int16 (1))), "int16") +%!assert (class (horzcat (double (1), int8 (1))), "int8") +%!assert (class (horzcat (double (1), uint64 (1))), "uint64") +%!assert (class (horzcat (double (1), uint32 (1))), "uint32") +%!assert (class (horzcat (double (1), uint16 (1))), "uint16") +%!assert (class (horzcat (double (1), uint8 (1))), "uint8") +%!assert (class (horzcat (double (1), single (1))), "single") +%!assert (class (horzcat (double (1), double (1))), "double") +%!assert (class (horzcat (double (1), cell (1))), "cell") +%!assert (class (horzcat (double (1), true)), "double") +%!assert (class (horzcat (double (1), "a")), "char") + +%!assert (class (horzcat (cell (1), int64 (1))), "cell") +%!assert (class (horzcat (cell (1), int32 (1))), "cell") +%!assert (class (horzcat (cell (1), int16 (1))), "cell") +%!assert (class (horzcat (cell (1), int8 (1))), "cell") +%!assert (class (horzcat (cell (1), uint64 (1))), "cell") +%!assert (class (horzcat (cell (1), uint32 (1))), "cell") +%!assert (class (horzcat (cell (1), uint16 (1))), "cell") +%!assert (class (horzcat (cell (1), uint8 (1))), "cell") +%!assert (class (horzcat (cell (1), single (1))), "cell") +%!assert (class (horzcat (cell (1), double (1))), "cell") +%!assert (class (horzcat (cell (1), cell (1))), "cell") +%!assert (class (horzcat (cell (1), true)), "cell") +%!assert (class (horzcat (cell (1), "a")), "cell") + +%!assert (class (horzcat (true, int64 (1))), "int64") +%!assert (class (horzcat (true, int32 (1))), "int32") +%!assert (class (horzcat (true, int16 (1))), "int16") +%!assert (class (horzcat (true, int8 (1))), "int8") +%!assert (class (horzcat (true, uint64 (1))), "uint64") +%!assert (class (horzcat (true, uint32 (1))), "uint32") +%!assert (class (horzcat (true, uint16 (1))), "uint16") +%!assert (class (horzcat (true, uint8 (1))), "uint8") +%!assert (class (horzcat (true, single (1))), "single") +%!assert (class (horzcat (true, double (1))), "double") +%!assert (class (horzcat (true, cell (1))), "cell") +%!assert (class (horzcat (true, true)), "logical") +%!assert (class (horzcat (true, "a")), "char") + +%!assert (class (horzcat ("a", int64 (1))), "char") +%!assert (class (horzcat ("a", int32 (1))), "char") +%!assert (class (horzcat ("a", int16 (1))), "char") +%!assert (class (horzcat ("a", int8 (1))), "char") +%!assert (class (horzcat ("a", int64 (1))), "char") +%!assert (class (horzcat ("a", int32 (1))), "char") +%!assert (class (horzcat ("a", int16 (1))), "char") +%!assert (class (horzcat ("a", int8 (1))), "char") +%!assert (class (horzcat ("a", single (1))), "char") +%!assert (class (horzcat ("a", double (1))), "char") +%!assert (class (horzcat ("a", cell (1))), "cell") +%!assert (class (horzcat ("a", true)), "char") +%!assert (class (horzcat ("a", "a")), "char") + +%!assert (class (horzcat (cell (1), struct ("foo", "bar"))), "cell") + +%!error horzcat (struct ("foo", "bar"), cell (1)) */ DEFUN (vertcat, args, , @@ -2085,8 +2073,8 @@ /* %!test -%! c = {'foo'; 'bar'; 'bazoloa'}; -%! assert (vertcat (c, 'a', 'bc', 'def'), {'foo'; 'bar'; 'bazoloa'; 'a'; 'bc'; 'def'}); +%! c = {"foo"; "bar"; "bazoloa"}; +%! assert (vertcat (c, "a", "bc", "def"), {"foo"; "bar"; "bazoloa"; "a"; "bc"; "def"}); */ DEFUN (cat, args, , @@ -2158,132 +2146,131 @@ } /* - %!function ret = __testcat (t1, t2, tr, cmplx) -%! assert (cat (1, cast ([], t1), cast([], t2)), cast ([], tr)); -%! -%! assert (cat (1, cast (1, t1), cast (2, t2)), cast ([1; 2], tr)); -%! assert (cat (1, cast (1, t1), cast ([2; 3], t2)), cast ([1; 2; 3], tr)); -%! assert (cat (1, cast ([1; 2], t1), cast (3, t2)), cast ([1; 2; 3], tr)); -%! assert (cat (1, cast ([1; 2], t1), cast ([3; 4], t2)), cast ([1; 2; 3; 4], tr)); -%! assert (cat (2, cast (1, t1), cast (2, t2)), cast ([1, 2], tr)); -%! assert (cat (2, cast (1, t1), cast ([2, 3], t2)), cast ([1, 2, 3], tr)); -%! assert (cat (2, cast ([1, 2], t1), cast (3, t2)), cast ([1, 2, 3], tr)); -%! assert (cat (2, cast ([1, 2], t1), cast ([3, 4], t2)), cast ([1, 2, 3, 4], tr)); -%! -%! assert ([cast(1, t1); cast(2, t2)], cast ([1; 2], tr)); -%! assert ([cast(1, t1); cast([2; 3], t2)], cast ([1; 2; 3], tr)); -%! assert ([cast([1; 2], t1); cast(3, t2)], cast ([1; 2; 3], tr)); -%! assert ([cast([1; 2], t1); cast([3; 4], t2)], cast ([1; 2; 3; 4], tr)); -%! assert ([cast(1, t1), cast(2, t2)], cast ([1, 2], tr)); -%! assert ([cast(1, t1), cast([2, 3], t2)], cast ([1, 2, 3], tr)); -%! assert ([cast([1, 2], t1), cast(3, t2)], cast ([1, 2, 3], tr)); -%! assert ([cast([1, 2], t1), cast([3, 4], t2)], cast ([1, 2, 3, 4], tr)); -%! -%! if (nargin == 3 || cmplx) -%! assert (cat (1, cast (1i, t1), cast (2, t2)), cast ([1i; 2], tr)); -%! assert (cat (1, cast (1i, t1), cast ([2; 3], t2)), cast ([1i; 2; 3], tr)); -%! assert (cat (1, cast ([1i; 2], t1), cast (3, t2)), cast ([1i; 2; 3], tr)); -%! assert (cat (1, cast ([1i; 2], t1), cast ([3; 4], t2)), cast ([1i; 2; 3; 4], tr)); -%! assert (cat (2, cast (1i, t1), cast (2, t2)), cast ([1i, 2], tr)); -%! assert (cat (2, cast (1i, t1), cast ([2, 3], t2)), cast ([1i, 2, 3], tr)); -%! assert (cat (2, cast ([1i, 2], t1), cast (3, t2)), cast ([1i, 2, 3], tr)); -%! assert (cat (2, cast ([1i, 2], t1), cast ([3, 4], t2)), cast ([1i, 2, 3, 4], tr)); -%! -%! assert ([cast(1i, t1); cast(2, t2)], cast ([1i; 2], tr)); -%! assert ([cast(1i, t1); cast([2; 3], t2)], cast ([1i; 2; 3], tr)); -%! assert ([cast([1i; 2], t1); cast(3, t2)], cast ([1i; 2; 3], tr)); -%! assert ([cast([1i; 2], t1); cast([3; 4], t2)], cast ([1i; 2; 3; 4], tr)); -%! assert ([cast(1i, t1), cast(2, t2)], cast ([1i, 2], tr)); -%! assert ([cast(1i, t1), cast([2, 3], t2)], cast ([1i, 2, 3], tr)); -%! assert ([cast([1i, 2], t1), cast(3, t2)], cast ([1i, 2, 3], tr)); -%! assert ([cast([1i, 2], t1), cast([3, 4], t2)], cast ([1i, 2, 3, 4], tr)); -%! -%! assert (cat (1, cast (1, t1), cast (2i, t2)), cast ([1; 2i], tr)); -%! assert (cat (1, cast (1, t1), cast ([2i; 3], t2)), cast ([1; 2i; 3], tr)); -%! assert (cat (1, cast ([1; 2], t1), cast (3i, t2)), cast ([1; 2; 3i], tr)); -%! assert (cat (1, cast ([1; 2], t1), cast ([3i; 4], t2)), cast ([1; 2; 3i; 4], tr)); -%! assert (cat (2, cast (1, t1), cast (2i, t2)), cast ([1, 2i], tr)); -%! assert (cat (2, cast (1, t1), cast ([2i, 3], t2)), cast ([1, 2i, 3], tr)); -%! assert (cat (2, cast ([1, 2], t1), cast (3i, t2)), cast ([1, 2, 3i], tr)); -%! assert (cat (2, cast ([1, 2], t1), cast ([3i, 4], t2)), cast ([1, 2, 3i, 4], tr)); -%! -%! assert ([cast(1, t1); cast(2i, t2)], cast ([1; 2i], tr)); -%! assert ([cast(1, t1); cast([2i; 3], t2)], cast ([1; 2i; 3], tr)); -%! assert ([cast([1; 2], t1); cast(3i, t2)], cast ([1; 2; 3i], tr)); -%! assert ([cast([1; 2], t1); cast([3i; 4], t2)], cast ([1; 2; 3i; 4], tr)); -%! assert ([cast(1, t1), cast(2i, t2)], cast ([1, 2i], tr)); -%! assert ([cast(1, t1), cast([2i, 3], t2)], cast ([1, 2i, 3], tr)); -%! assert ([cast([1, 2], t1), cast(3i, t2)], cast ([1, 2, 3i], tr)); -%! assert ([cast([1, 2], t1), cast([3i, 4], t2)], cast ([1, 2, 3i, 4], tr)); -%! -%! assert (cat (1, cast (1i, t1), cast (2i, t2)), cast ([1i; 2i], tr)); -%! assert (cat (1, cast (1i, t1), cast ([2i; 3], t2)), cast ([1i; 2i; 3], tr)); -%! assert (cat (1, cast ([1i; 2], t1), cast (3i, t2)), cast ([1i; 2; 3i], tr)); -%! assert (cat (1, cast ([1i; 2], t1), cast ([3i; 4], t2)), cast ([1i; 2; 3i; 4], tr)); -%! assert (cat (2, cast (1i, t1), cast (2i, t2)), cast ([1i, 2i], tr)); -%! assert (cat (2, cast (1i, t1), cast ([2i, 3], t2)), cast ([1i, 2i, 3], tr)); -%! assert (cat (2, cast ([1i, 2], t1), cast (3i, t2)), cast ([1i, 2, 3i], tr)); -%! assert (cat (2, cast ([1i, 2], t1), cast ([3i, 4], t2)), cast ([1i, 2, 3i, 4], tr)); -%! -%! assert ([cast(1i, t1); cast(2i, t2)], cast ([1i; 2i], tr)); -%! assert ([cast(1i, t1); cast([2i; 3], t2)], cast ([1i; 2i; 3], tr)); -%! assert ([cast([1i; 2], t1); cast(3i, t2)], cast ([1i; 2; 3i], tr)); -%! assert ([cast([1i; 2], t1); cast([3i; 4], t2)], cast ([1i; 2; 3i; 4], tr)); -%! assert ([cast(1i, t1), cast(2i, t2)], cast ([1i, 2i], tr)); -%! assert ([cast(1i, t1), cast([2i, 3], t2)], cast ([1i, 2i, 3], tr)); -%! assert ([cast([1i, 2], t1), cast(3i, t2)], cast ([1i, 2, 3i], tr)); -%! assert ([cast([1i, 2], t1), cast([3i, 4], t2)], cast ([1i, 2, 3i, 4], tr)); -%! endif -%! ret = true; +%! assert (cat (1, cast ([], t1), cast([], t2)), cast ([], tr)); +%! +%! assert (cat (1, cast (1, t1), cast (2, t2)), cast ([1; 2], tr)); +%! assert (cat (1, cast (1, t1), cast ([2; 3], t2)), cast ([1; 2; 3], tr)); +%! assert (cat (1, cast ([1; 2], t1), cast (3, t2)), cast ([1; 2; 3], tr)); +%! assert (cat (1, cast ([1; 2], t1), cast ([3; 4], t2)), cast ([1; 2; 3; 4], tr)); +%! assert (cat (2, cast (1, t1), cast (2, t2)), cast ([1, 2], tr)); +%! assert (cat (2, cast (1, t1), cast ([2, 3], t2)), cast ([1, 2, 3], tr)); +%! assert (cat (2, cast ([1, 2], t1), cast (3, t2)), cast ([1, 2, 3], tr)); +%! assert (cat (2, cast ([1, 2], t1), cast ([3, 4], t2)), cast ([1, 2, 3, 4], tr)); +%! +%! assert ([cast(1, t1); cast(2, t2)], cast ([1; 2], tr)); +%! assert ([cast(1, t1); cast([2; 3], t2)], cast ([1; 2; 3], tr)); +%! assert ([cast([1; 2], t1); cast(3, t2)], cast ([1; 2; 3], tr)); +%! assert ([cast([1; 2], t1); cast([3; 4], t2)], cast ([1; 2; 3; 4], tr)); +%! assert ([cast(1, t1), cast(2, t2)], cast ([1, 2], tr)); +%! assert ([cast(1, t1), cast([2, 3], t2)], cast ([1, 2, 3], tr)); +%! assert ([cast([1, 2], t1), cast(3, t2)], cast ([1, 2, 3], tr)); +%! assert ([cast([1, 2], t1), cast([3, 4], t2)], cast ([1, 2, 3, 4], tr)); +%! +%! if (nargin == 3 || cmplx) +%! assert (cat (1, cast (1i, t1), cast (2, t2)), cast ([1i; 2], tr)); +%! assert (cat (1, cast (1i, t1), cast ([2; 3], t2)), cast ([1i; 2; 3], tr)); +%! assert (cat (1, cast ([1i; 2], t1), cast (3, t2)), cast ([1i; 2; 3], tr)); +%! assert (cat (1, cast ([1i; 2], t1), cast ([3; 4], t2)), cast ([1i; 2; 3; 4], tr)); +%! assert (cat (2, cast (1i, t1), cast (2, t2)), cast ([1i, 2], tr)); +%! assert (cat (2, cast (1i, t1), cast ([2, 3], t2)), cast ([1i, 2, 3], tr)); +%! assert (cat (2, cast ([1i, 2], t1), cast (3, t2)), cast ([1i, 2, 3], tr)); +%! assert (cat (2, cast ([1i, 2], t1), cast ([3, 4], t2)), cast ([1i, 2, 3, 4], tr)); +%! +%! assert ([cast(1i, t1); cast(2, t2)], cast ([1i; 2], tr)); +%! assert ([cast(1i, t1); cast([2; 3], t2)], cast ([1i; 2; 3], tr)); +%! assert ([cast([1i; 2], t1); cast(3, t2)], cast ([1i; 2; 3], tr)); +%! assert ([cast([1i; 2], t1); cast([3; 4], t2)], cast ([1i; 2; 3; 4], tr)); +%! assert ([cast(1i, t1), cast(2, t2)], cast ([1i, 2], tr)); +%! assert ([cast(1i, t1), cast([2, 3], t2)], cast ([1i, 2, 3], tr)); +%! assert ([cast([1i, 2], t1), cast(3, t2)], cast ([1i, 2, 3], tr)); +%! assert ([cast([1i, 2], t1), cast([3, 4], t2)], cast ([1i, 2, 3, 4], tr)); +%! +%! assert (cat (1, cast (1, t1), cast (2i, t2)), cast ([1; 2i], tr)); +%! assert (cat (1, cast (1, t1), cast ([2i; 3], t2)), cast ([1; 2i; 3], tr)); +%! assert (cat (1, cast ([1; 2], t1), cast (3i, t2)), cast ([1; 2; 3i], tr)); +%! assert (cat (1, cast ([1; 2], t1), cast ([3i; 4], t2)), cast ([1; 2; 3i; 4], tr)); +%! assert (cat (2, cast (1, t1), cast (2i, t2)), cast ([1, 2i], tr)); +%! assert (cat (2, cast (1, t1), cast ([2i, 3], t2)), cast ([1, 2i, 3], tr)); +%! assert (cat (2, cast ([1, 2], t1), cast (3i, t2)), cast ([1, 2, 3i], tr)); +%! assert (cat (2, cast ([1, 2], t1), cast ([3i, 4], t2)), cast ([1, 2, 3i, 4], tr)); +%! +%! assert ([cast(1, t1); cast(2i, t2)], cast ([1; 2i], tr)); +%! assert ([cast(1, t1); cast([2i; 3], t2)], cast ([1; 2i; 3], tr)); +%! assert ([cast([1; 2], t1); cast(3i, t2)], cast ([1; 2; 3i], tr)); +%! assert ([cast([1; 2], t1); cast([3i; 4], t2)], cast ([1; 2; 3i; 4], tr)); +%! assert ([cast(1, t1), cast(2i, t2)], cast ([1, 2i], tr)); +%! assert ([cast(1, t1), cast([2i, 3], t2)], cast ([1, 2i, 3], tr)); +%! assert ([cast([1, 2], t1), cast(3i, t2)], cast ([1, 2, 3i], tr)); +%! assert ([cast([1, 2], t1), cast([3i, 4], t2)], cast ([1, 2, 3i, 4], tr)); +%! +%! assert (cat (1, cast (1i, t1), cast (2i, t2)), cast ([1i; 2i], tr)); +%! assert (cat (1, cast (1i, t1), cast ([2i; 3], t2)), cast ([1i; 2i; 3], tr)); +%! assert (cat (1, cast ([1i; 2], t1), cast (3i, t2)), cast ([1i; 2; 3i], tr)); +%! assert (cat (1, cast ([1i; 2], t1), cast ([3i; 4], t2)), cast ([1i; 2; 3i; 4], tr)); +%! assert (cat (2, cast (1i, t1), cast (2i, t2)), cast ([1i, 2i], tr)); +%! assert (cat (2, cast (1i, t1), cast ([2i, 3], t2)), cast ([1i, 2i, 3], tr)); +%! assert (cat (2, cast ([1i, 2], t1), cast (3i, t2)), cast ([1i, 2, 3i], tr)); +%! assert (cat (2, cast ([1i, 2], t1), cast ([3i, 4], t2)), cast ([1i, 2, 3i, 4], tr)); +%! +%! assert ([cast(1i, t1); cast(2i, t2)], cast ([1i; 2i], tr)); +%! assert ([cast(1i, t1); cast([2i; 3], t2)], cast ([1i; 2i; 3], tr)); +%! assert ([cast([1i; 2], t1); cast(3i, t2)], cast ([1i; 2; 3i], tr)); +%! assert ([cast([1i; 2], t1); cast([3i; 4], t2)], cast ([1i; 2; 3i; 4], tr)); +%! assert ([cast(1i, t1), cast(2i, t2)], cast ([1i, 2i], tr)); +%! assert ([cast(1i, t1), cast([2i, 3], t2)], cast ([1i, 2i, 3], tr)); +%! assert ([cast([1i, 2], t1), cast(3i, t2)], cast ([1i, 2, 3i], tr)); +%! assert ([cast([1i, 2], t1), cast([3i, 4], t2)], cast ([1i, 2, 3i, 4], tr)); +%! endif +%! ret = true; %!endfunction -%!assert (__testcat('double', 'double', 'double')) -%!assert (__testcat('single', 'double', 'single')) -%!assert (__testcat('double', 'single', 'single')) -%!assert (__testcat('single', 'single', 'single')) - -%!assert (__testcat('double', 'int8', 'int8', false)) -%!assert (__testcat('int8', 'double', 'int8', false)) -%!assert (__testcat('single', 'int8', 'int8', false)) -%!assert (__testcat('int8', 'single', 'int8', false)) -%!assert (__testcat('int8', 'int8', 'int8', false)) -%!assert (__testcat('double', 'int16', 'int16', false)) -%!assert (__testcat('int16', 'double', 'int16', false)) -%!assert (__testcat('single', 'int16', 'int16', false)) -%!assert (__testcat('int16', 'single', 'int16', false)) -%!assert (__testcat('int16', 'int16', 'int16', false)) -%!assert (__testcat('double', 'int32', 'int32', false)) -%!assert (__testcat('int32', 'double', 'int32', false)) -%!assert (__testcat('single', 'int32', 'int32', false)) -%!assert (__testcat('int32', 'single', 'int32', false)) -%!assert (__testcat('int32', 'int32', 'int32', false)) -%!assert (__testcat('double', 'int64', 'int64', false)) -%!assert (__testcat('int64', 'double', 'int64', false)) -%!assert (__testcat('single', 'int64', 'int64', false)) -%!assert (__testcat('int64', 'single', 'int64', false)) -%!assert (__testcat('int64', 'int64', 'int64', false)) - -%!assert (__testcat('double', 'uint8', 'uint8', false)) -%!assert (__testcat('uint8', 'double', 'uint8', false)) -%!assert (__testcat('single', 'uint8', 'uint8', false)) -%!assert (__testcat('uint8', 'single', 'uint8', false)) -%!assert (__testcat('uint8', 'uint8', 'uint8', false)) -%!assert (__testcat('double', 'uint16', 'uint16', false)) -%!assert (__testcat('uint16', 'double', 'uint16', false)) -%!assert (__testcat('single', 'uint16', 'uint16', false)) -%!assert (__testcat('uint16', 'single', 'uint16', false)) -%!assert (__testcat('uint16', 'uint16', 'uint16', false)) -%!assert (__testcat('double', 'uint32', 'uint32', false)) -%!assert (__testcat('uint32', 'double', 'uint32', false)) -%!assert (__testcat('single', 'uint32', 'uint32', false)) -%!assert (__testcat('uint32', 'single', 'uint32', false)) -%!assert (__testcat('uint32', 'uint32', 'uint32', false)) -%!assert (__testcat('double', 'uint64', 'uint64', false)) -%!assert (__testcat('uint64', 'double', 'uint64', false)) -%!assert (__testcat('single', 'uint64', 'uint64', false)) -%!assert (__testcat('uint64', 'single', 'uint64', false)) -%!assert (__testcat('uint64', 'uint64', 'uint64', false)) +%!assert (__testcat ("double", "double", "double")) +%!assert (__testcat ("single", "double", "single")) +%!assert (__testcat ("double", "single", "single")) +%!assert (__testcat ("single", "single", "single")) + +%!assert (__testcat ("double", "int8", "int8", false)) +%!assert (__testcat ("int8", "double", "int8", false)) +%!assert (__testcat ("single", "int8", "int8", false)) +%!assert (__testcat ("int8", "single", "int8", false)) +%!assert (__testcat ("int8", "int8", "int8", false)) +%!assert (__testcat ("double", "int16", "int16", false)) +%!assert (__testcat ("int16", "double", "int16", false)) +%!assert (__testcat ("single", "int16", "int16", false)) +%!assert (__testcat ("int16", "single", "int16", false)) +%!assert (__testcat ("int16", "int16", "int16", false)) +%!assert (__testcat ("double", "int32", "int32", false)) +%!assert (__testcat ("int32", "double", "int32", false)) +%!assert (__testcat ("single", "int32", "int32", false)) +%!assert (__testcat ("int32", "single", "int32", false)) +%!assert (__testcat ("int32", "int32", "int32", false)) +%!assert (__testcat ("double", "int64", "int64", false)) +%!assert (__testcat ("int64", "double", "int64", false)) +%!assert (__testcat ("single", "int64", "int64", false)) +%!assert (__testcat ("int64", "single", "int64", false)) +%!assert (__testcat ("int64", "int64", "int64", false)) + +%!assert (__testcat ("double", "uint8", "uint8", false)) +%!assert (__testcat ("uint8", "double", "uint8", false)) +%!assert (__testcat ("single", "uint8", "uint8", false)) +%!assert (__testcat ("uint8", "single", "uint8", false)) +%!assert (__testcat ("uint8", "uint8", "uint8", false)) +%!assert (__testcat ("double", "uint16", "uint16", false)) +%!assert (__testcat ("uint16", "double", "uint16", false)) +%!assert (__testcat ("single", "uint16", "uint16", false)) +%!assert (__testcat ("uint16", "single", "uint16", false)) +%!assert (__testcat ("uint16", "uint16", "uint16", false)) +%!assert (__testcat ("double", "uint32", "uint32", false)) +%!assert (__testcat ("uint32", "double", "uint32", false)) +%!assert (__testcat ("single", "uint32", "uint32", false)) +%!assert (__testcat ("uint32", "single", "uint32", false)) +%!assert (__testcat ("uint32", "uint32", "uint32", false)) +%!assert (__testcat ("double", "uint64", "uint64", false)) +%!assert (__testcat ("uint64", "double", "uint64", false)) +%!assert (__testcat ("single", "uint64", "uint64", false)) +%!assert (__testcat ("uint64", "single", "uint64", false)) +%!assert (__testcat ("uint64", "uint64", "uint64", false)) %!assert (cat (3, [], [1,2;3,4]), [1,2;3,4]) %!assert (cat (3, [1,2;3,4], []), [1,2;3,4]) @@ -2293,12 +2280,12 @@ %!assert (cat (3, [], [], 1, 2), cat (3, 1, 2)) %!assert (cat (3, [], [], [1,2;3,4]), [1,2;3,4]) %!assert (cat (4, [], [], [1,2;3,4]), [1,2;3,4]) + +%!assert ([zeros(3,2,2); ones(1,2,2)], repmat ([0;0;0;1],[1,2,2]) ) +%!assert ([zeros(3,2,2); ones(1,2,2)], vertcat (zeros (3,2,2), ones (1,2,2)) ) + %!error <dimension mismatch> cat (3, cat (3, [], []), [1,2;3,4]) %!error <dimension mismatch> cat (3, zeros (0, 0, 2), [1,2;3,4]) - -%!assert ([zeros(3,2,2); ones(1,2,2)], repmat([0;0;0;1],[1,2,2]) ) -%!assert ([zeros(3,2,2); ones(1,2,2)], vertcat(zeros(3,2,2), ones(1,2,2)) ) - */ static octave_value @@ -2803,64 +2790,62 @@ } /* - -%!assert (sum([true,true]), 2) -%!assert (sum([true,true],'native'), true) -%!assert (sum(int8([127,10,-20])), 117); -%!assert (sum(int8([127,10,-20]),'native'), int8(107)); - -%!assert(sum ([1, 2, 3]), 6) -%!assert(sum ([-1; -2; -3]), -6); -%!assert(sum ([i, 2+i, -3+2i, 4]), 3+4i); -%!assert(sum ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [2+2i, 4+4i, 6+6i]); - -%!assert(sum (single([1, 2, 3])), single(6)) -%!assert(sum (single([-1; -2; -3])), single(-6)); -%!assert(sum (single([i, 2+i, -3+2i, 4])), single(3+4i)); -%!assert(sum (single([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single([2+2i, 4+4i, 6+6i])); - -%!error <Invalid call to sum> sum (); - -%!assert (sum ([1, 2; 3, 4], 1), [4, 6]); -%!assert (sum ([1, 2; 3, 4], 2), [3; 7]); -%!assert (sum (zeros (1, 0)), 0); -%!assert (sum (zeros (1, 0), 1), zeros(1, 0)); -%!assert (sum (zeros (1, 0), 2), 0); -%!assert (sum (zeros (0, 1)), 0); -%!assert (sum (zeros (0, 1), 1), 0); -%!assert (sum (zeros (0, 1), 2), zeros(0, 1)); -%!assert (sum (zeros (2, 0)), zeros(1, 0)); -%!assert (sum (zeros (2, 0), 1), zeros(1, 0)); -%!assert (sum (zeros (2, 0), 2), [0; 0]); -%!assert (sum (zeros (0, 2)), [0, 0]); -%!assert (sum (zeros (0, 2), 1), [0, 0]); -%!assert (sum (zeros (0, 2), 2), zeros(0, 1)); -%!assert (sum (zeros (2, 2, 0, 3)), zeros(1, 2, 0, 3)); -%!assert (sum (zeros (2, 2, 0, 3), 2), zeros(2, 1, 0, 3)); -%!assert (sum (zeros (2, 2, 0, 3), 3), zeros(2, 2, 1, 3)); -%!assert (sum (zeros (2, 2, 0, 3), 4), zeros(2, 2, 0)); -%!assert (sum (zeros (2, 2, 0, 3), 7), zeros(2, 2, 0, 3)); - -%!assert (sum (single([1, 2; 3, 4]), 1), single([4, 6])); -%!assert (sum (single([1, 2; 3, 4]), 2), single([3; 7])); -%!assert (sum (zeros (1, 0, 'single')), single(0)); -%!assert (sum (zeros (1, 0, 'single'), 1), zeros(1, 0, 'single')); -%!assert (sum (zeros (1, 0, 'single'), 2), single(0)); -%!assert (sum (zeros (0, 1, 'single')), single(0)); -%!assert (sum (zeros (0, 1, 'single'), 1), single(0)); -%!assert (sum (zeros (0, 1, 'single'), 2), zeros(0, 1, 'single')); -%!assert (sum (zeros (2, 0, 'single')), zeros(1, 0, 'single')); -%!assert (sum (zeros (2, 0, 'single'), 1), zeros(1, 0, 'single')); -%!assert (sum (zeros (2, 0, 'single'), 2), single([0; 0])); -%!assert (sum (zeros (0, 2, 'single')), single([0, 0])); -%!assert (sum (zeros (0, 2, 'single'), 1), single([0, 0])); -%!assert (sum (zeros (0, 2, 'single'), 2), zeros(0, 1, 'single')); -%!assert (sum (zeros (2, 2, 0, 3, 'single')), zeros(1, 2, 0, 3, 'single')); -%!assert (sum (zeros (2, 2, 0, 3, 'single'), 2), zeros(2, 1, 0, 3, 'single')); -%!assert (sum (zeros (2, 2, 0, 3, 'single'), 3), zeros(2, 2, 1, 3, 'single')); -%!assert (sum (zeros (2, 2, 0, 3, 'single'), 4), zeros(2, 2, 0, 'single')); -%!assert (sum (zeros (2, 2, 0, 3, 'single'), 7), zeros(2, 2, 0, 3, 'single')); - +%!assert (sum ([true,true]), 2) +%!assert (sum ([true,true],"native"), true) +%!assert (sum (int8 ([127,10,-20])), 117) +%!assert (sum (int8 ([127,10,-20]),'native'), int8 (107)) + +%!assert (sum ([1, 2, 3]), 6) +%!assert (sum ([-1; -2; -3]), -6) +%!assert (sum ([i, 2+i, -3+2i, 4]), 3+4i) +%!assert (sum ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i]), [2+2i, 4+4i, 6+6i]) + +%!assert (sum (single ([1, 2, 3])), single (6)) +%!assert (sum (single ([-1; -2; -3])), single (-6)) +%!assert (sum (single ([i, 2+i, -3+2i, 4])), single (3+4i)) +%!assert (sum (single ([1, 2, 3; i, 2i, 3i; 1+i, 2+2i, 3+3i])), single ([2+2i, 4+4i, 6+6i])) + +%!assert (sum ([1, 2; 3, 4], 1), [4, 6]) +%!assert (sum ([1, 2; 3, 4], 2), [3; 7]) +%!assert (sum (zeros (1, 0)), 0) +%!assert (sum (zeros (1, 0), 1), zeros (1, 0)) +%!assert (sum (zeros (1, 0), 2), 0) +%!assert (sum (zeros (0, 1)), 0) +%!assert (sum (zeros (0, 1), 1), 0) +%!assert (sum (zeros (0, 1), 2), zeros (0, 1)) +%!assert (sum (zeros (2, 0)), zeros (1, 0)) +%!assert (sum (zeros (2, 0), 1), zeros (1, 0)) +%!assert (sum (zeros (2, 0), 2), [0; 0]) +%!assert (sum (zeros (0, 2)), [0, 0]) +%!assert (sum (zeros (0, 2), 1), [0, 0]) +%!assert (sum (zeros (0, 2), 2), zeros (0, 1)) +%!assert (sum (zeros (2, 2, 0, 3)), zeros (1, 2, 0, 3)) +%!assert (sum (zeros (2, 2, 0, 3), 2), zeros (2, 1, 0, 3)) +%!assert (sum (zeros (2, 2, 0, 3), 3), zeros (2, 2, 1, 3)) +%!assert (sum (zeros (2, 2, 0, 3), 4), zeros (2, 2, 0)) +%!assert (sum (zeros (2, 2, 0, 3), 7), zeros (2, 2, 0, 3)) + +%!assert (sum (single ([1, 2; 3, 4]), 1), single ([4, 6])) +%!assert (sum (single ([1, 2; 3, 4]), 2), single ([3; 7])) +%!assert (sum (zeros (1, 0, "single")), single (0)) +%!assert (sum (zeros (1, 0, "single"), 1), zeros (1, 0, "single")) +%!assert (sum (zeros (1, 0, "single"), 2), single (0)) +%!assert (sum (zeros (0, 1, "single")), single (0)) +%!assert (sum (zeros (0, 1, "single"), 1), single (0)) +%!assert (sum (zeros (0, 1, "single"), 2), zeros (0, 1, "single")) +%!assert (sum (zeros (2, 0, "single")), zeros (1, 0, "single")) +%!assert (sum (zeros (2, 0, "single"), 1), zeros (1, 0, "single")) +%!assert (sum (zeros (2, 0, "single"), 2), single ([0; 0])) +%!assert (sum (zeros (0, 2, "single")), single ([0, 0])) +%!assert (sum (zeros (0, 2, "single"), 1), single ([0, 0])) +%!assert (sum (zeros (0, 2, "single"), 2), zeros (0, 1, "single")) +%!assert (sum (zeros (2, 2, 0, 3, "single")), zeros (1, 2, 0, 3, "single")) +%!assert (sum (zeros (2, 2, 0, 3, "single"), 2), zeros (2, 1, 0, 3, "single")) +%!assert (sum (zeros (2, 2, 0, 3, "single"), 3), zeros (2, 2, 1, 3, "single")) +%!assert (sum (zeros (2, 2, 0, 3, "single"), 4), zeros (2, 2, 0, "single")) +%!assert (sum (zeros (2, 2, 0, 3, "single"), 7), zeros (2, 2, 0, 3, "single")) + +%!error sum () */ DEFUN (sumsq, args, , @@ -2885,24 +2870,22 @@ } /* - -%!assert(sumsq ([1, 2, 3]), 14) -%!assert(sumsq ([-1; -2; 4i]), 21); -%!assert(sumsq ([1, 2, 3; 2, 3, 4; 4i, 6i, 2]), [21, 49, 29]); - -%!assert(sumsq (single([1, 2, 3])), single(14)) -%!assert(sumsq (single([-1; -2; 4i])), single(21)); -%!assert(sumsq (single([1, 2, 3; 2, 3, 4; 4i, 6i, 2])), single([21, 49, 29])); - -%!error <Invalid call to sumsq> sumsq (); - -%!assert (sumsq ([1, 2; 3, 4], 1), [10, 20]); -%!assert (sumsq ([1, 2; 3, 4], 2), [5; 25]); - -%!assert (sumsq (single([1, 2; 3, 4]), 1), single([10, 20])); -%!assert (sumsq (single([1, 2; 3, 4]), 2), single([5; 25])); - - */ +%!assert (sumsq ([1, 2, 3]), 14) +%!assert (sumsq ([-1; -2; 4i]), 21) +%!assert (sumsq ([1, 2, 3; 2, 3, 4; 4i, 6i, 2]), [21, 49, 29]) + +%!assert (sumsq (single ([1, 2, 3])), single (14)) +%!assert (sumsq (single ([-1; -2; 4i])), single (21)) +%!assert (sumsq (single ([1, 2, 3; 2, 3, 4; 4i, 6i, 2])), single ([21, 49, 29])) + +%!assert (sumsq ([1, 2; 3, 4], 1), [10, 20]) +%!assert (sumsq ([1, 2; 3, 4], 2), [5; 25]) + +%!assert (sumsq (single ([1, 2; 3, 4]), 1), single ([10, 20])) +%!assert (sumsq (single ([1, 2; 3, 4]), 2), single ([5; 25])) + +%!error sumsq () +*/ DEFUN (islogical, args, , "-*- texinfo -*-\n\ @@ -2925,20 +2908,18 @@ DEFALIAS (isbool, islogical); /* - -%!assert (islogical(true), true) -%!assert (islogical(false), true) -%!assert (islogical([true, false]), true) -%!assert (islogical(1), false) -%!assert (islogical(1i), false) -%!assert (islogical([1,1]), false) -%!assert (islogical(single(1)), false) -%!assert (islogical(single(1i)), false) -%!assert (islogical(single([1,1])), false) -%!assert (islogical(sparse ([true, false])), true) -%!assert (islogical(sparse ([1, 0])), false) - - */ +%!assert (islogical (true), true) +%!assert (islogical (false), true) +%!assert (islogical ([true, false]), true) +%!assert (islogical (1), false) +%!assert (islogical (1i), false) +%!assert (islogical ([1,1]), false) +%!assert (islogical (single (1)), false) +%!assert (islogical (single (1i)), false) +%!assert (islogical (single ([1,1])), false) +%!assert (islogical (sparse ([true, false])), true) +%!assert (islogical (sparse ([1, 0])), false) +*/ DEFUN (isinteger, args, , "-*- texinfo -*-\n\ @@ -3343,21 +3324,19 @@ } /* - -%!assert (isnumeric(1), true) -%!assert (isnumeric(1i), true) -%!assert (isnumeric([1,1]), true) -%!assert (isnumeric(single(1)), true) -%!assert (isnumeric(single(1i)), true) -%!assert (isnumeric(single([1,1])), true) -%!assert (isnumeric(int8(1)), true) -%!assert (isnumeric(uint8([1,1])), true) -%!assert (isnumeric("Hello World"), false) -%!assert (isnumeric(true), false) -%!assert (isnumeric(false), false) -%!assert (isnumeric([true, false]), false) -%!assert (isnumeric(sparse ([true, false])), false) - +%!assert (isnumeric (1), true) +%!assert (isnumeric (1i), true) +%!assert (isnumeric ([1,1]), true) +%!assert (isnumeric (single (1)), true) +%!assert (isnumeric (single (1i)), true) +%!assert (isnumeric (single ([1,1])), true) +%!assert (isnumeric (int8 (1)), true) +%!assert (isnumeric (uint8 ([1,1])), true) +%!assert (isnumeric ("Hello World"), false) +%!assert (isnumeric (true), false) +%!assert (isnumeric (false), false) +%!assert (isnumeric ([true, false]), false) +%!assert (isnumeric (sparse ([true, false])), false) */ DEFUN (ismatrix, args, , @@ -3385,30 +3364,28 @@ } /* - -%!assert(ismatrix ([])); -%!assert(ismatrix (1)); -%!assert(ismatrix ([1, 2, 3])); -%!assert(ismatrix ([1, 2; 3, 4])); -%!assert(ismatrix (zeros (3, 2, 4))); - -%!assert(ismatrix (single([]))); -%!assert(ismatrix (single(1))); -%!assert(ismatrix (single([1, 2, 3]))); -%!assert(ismatrix (single([1, 2; 3, 4]))); - -%!assert(ismatrix ("t")); -%!assert(ismatrix ("test")); -%!assert(ismatrix (["test"; "ing"])); +%!assert (ismatrix ([])) +%!assert (ismatrix (1)) +%!assert (ismatrix ([1, 2, 3])) +%!assert (ismatrix ([1, 2; 3, 4])) +%!assert (ismatrix (zeros (3, 2, 4))) + +%!assert (ismatrix (single ([]))) +%!assert (ismatrix (single (1))) +%!assert (ismatrix (single ([1, 2, 3]))) +%!assert (ismatrix (single ([1, 2; 3, 4]))) + +%!assert (ismatrix ("t")) +%!assert (ismatrix ("test")) +%!assert (ismatrix (["test"; "ing"])) %!test %! s.a = 1; -%! assert(ismatrix (s), false); - -%!error <Invalid call to ismatrix> ismatrix (); -%!error <Invalid call to ismatrix> ismatrix ([1, 2; 3, 4], 2); - - */ +%! assert (ismatrix (s), false); + +%!error ismatrix () +%!error ismatrix ([1, 2; 3, 4], 2) +*/ static octave_value fill_matrix (const octave_value_list& args, int val, const char *fcn) @@ -3862,23 +3839,21 @@ } /* - -%!assert(ones (3), [1, 1, 1; 1, 1, 1; 1, 1, 1]); -%!assert(ones (2, 3), [1, 1, 1; 1, 1, 1]); -%!assert(ones (3, 2), [1, 1; 1, 1; 1, 1]); -%!assert(size (ones (3, 4, 5)), [3, 4, 5]); - -%!assert(ones (3,'single'), single([1, 1, 1; 1, 1, 1; 1, 1, 1])); -%!assert(ones (2, 3,'single'), single([1, 1, 1; 1, 1, 1])); -%!assert(ones (3, 2,'single'), single([1, 1; 1, 1; 1, 1])); -%!assert(size (ones (3, 4, 5, 'single')), [3, 4, 5]); - -%!assert(ones (3,'int8'), int8([1, 1, 1; 1, 1, 1; 1, 1, 1])); -%!assert(ones (2, 3,'int8'), int8([1, 1, 1; 1, 1, 1])); -%!assert(ones (3, 2,'int8'), int8([1, 1; 1, 1; 1, 1])); -%!assert(size (ones (3, 4, 5, 'int8')), [3, 4, 5]); - - */ +%!assert (ones (3), [1, 1, 1; 1, 1, 1; 1, 1, 1]) +%!assert (ones (2, 3), [1, 1, 1; 1, 1, 1]) +%!assert (ones (3, 2), [1, 1; 1, 1; 1, 1]) +%!assert (size (ones (3, 4, 5)), [3, 4, 5]) + +%!assert (ones (3, "single"), single ([1, 1, 1; 1, 1, 1; 1, 1, 1])) +%!assert (ones (2, 3, "single"), single ([1, 1, 1; 1, 1, 1])) +%!assert (ones (3, 2, "single"), single ([1, 1; 1, 1; 1, 1])) +%!assert (size (ones (3, 4, 5, "single")), [3, 4, 5]) + +%!assert (ones (3, "int8"), int8 ([1, 1, 1; 1, 1, 1; 1, 1, 1])) +%!assert (ones (2, 3, "int8"), int8 ([1, 1, 1; 1, 1, 1])) +%!assert (ones (3, 2, "int8"), int8 ([1, 1; 1, 1; 1, 1])) +%!assert (size (ones (3, 4, 5, "int8")), [3, 4, 5]) +*/ DEFUN (zeros, args, , "-*- texinfo -*-\n\ @@ -3906,23 +3881,21 @@ } /* - -%!assert(zeros (3), [0, 0, 0; 0, 0, 0; 0, 0, 0]); -%!assert(zeros (2, 3), [0, 0, 0; 0, 0, 0]); -%!assert(zeros (3, 2), [0, 0; 0, 0; 0, 0]); -%!assert(size (zeros (3, 4, 5)), [3, 4, 5]); - -%!assert(zeros (3,'single'), single([0, 0, 0; 0, 0, 0; 0, 0, 0])); -%!assert(zeros (2, 3,'single'), single([0, 0, 0; 0, 0, 0])); -%!assert(zeros (3, 2,'single'), single([0, 0; 0, 0; 0, 0])); -%!assert(size (zeros (3, 4, 5, 'single')), [3, 4, 5]); - -%!assert(zeros (3,'int8'), int8([0, 0, 0; 0, 0, 0; 0, 0, 0])); -%!assert(zeros (2, 3,'int8'), int8([0, 0, 0; 0, 0, 0])); -%!assert(zeros (3, 2,'int8'), int8([0, 0; 0, 0; 0, 0])); -%!assert(size (zeros (3, 4, 5, 'int8')), [3, 4, 5]); - - */ +%!assert (zeros (3), [0, 0, 0; 0, 0, 0; 0, 0, 0]) +%!assert (zeros (2, 3), [0, 0, 0; 0, 0, 0]) +%!assert (zeros (3, 2), [0, 0; 0, 0; 0, 0]) +%!assert (size (zeros (3, 4, 5)), [3, 4, 5]) + +%!assert (zeros (3, "single"), single ([0, 0, 0; 0, 0, 0; 0, 0, 0])) +%!assert (zeros (2, 3, "single"), single ([0, 0, 0; 0, 0, 0])) +%!assert (zeros (3, 2, "single"), single ([0, 0; 0, 0; 0, 0])) +%!assert (size (zeros (3, 4, 5, "single")), [3, 4, 5]) + +%!assert (zeros (3, "int8"), int8 ([0, 0, 0; 0, 0, 0; 0, 0, 0])) +%!assert (zeros (2, 3, "int8"), int8 ([0, 0, 0; 0, 0, 0])) +%!assert (zeros (3, 2, "int8"), int8 ([0, 0; 0, 0; 0, 0])) +%!assert (size (zeros (3, 4, 5, "int8")), [3, 4, 5]) +*/ DEFUN (Inf, args, , "-*- texinfo -*-\n\ @@ -3965,23 +3938,21 @@ DEFALIAS (inf, Inf); /* - -%!assert(inf (3), [Inf, Inf, Inf; Inf, Inf, Inf; Inf, Inf, Inf]); -%!assert(inf (2, 3), [Inf, Inf, Inf; Inf, Inf, Inf]); -%!assert(inf (3, 2), [Inf, Inf; Inf, Inf; Inf, Inf]); -%!assert(size (inf (3, 4, 5)), [3, 4, 5]); - -%!assert(inf (3,'single'), single([Inf, Inf, Inf; Inf, Inf, Inf; Inf, Inf, Inf])); -%!assert(inf (2, 3,'single'), single([Inf, Inf, Inf; Inf, Inf, Inf])); -%!assert(inf (3, 2,'single'), single([Inf, Inf; Inf, Inf; Inf, Inf])); -%!assert(size (inf (3, 4, 5, 'single')), [3, 4, 5]); - -%!error(inf (3,'int8')); -%!error(inf (2, 3,'int8')); -%!error(inf (3, 2,'int8')); -%!error(inf (3, 4, 5, 'int8')); - - */ +%!assert (inf (3), [Inf, Inf, Inf; Inf, Inf, Inf; Inf, Inf, Inf]) +%!assert (inf (2, 3), [Inf, Inf, Inf; Inf, Inf, Inf]) +%!assert (inf (3, 2), [Inf, Inf; Inf, Inf; Inf, Inf]) +%!assert (size (inf (3, 4, 5)), [3, 4, 5]) + +%!assert (inf (3, "single"), single ([Inf, Inf, Inf; Inf, Inf, Inf; Inf, Inf, Inf])) +%!assert (inf (2, 3, "single"), single ([Inf, Inf, Inf; Inf, Inf, Inf])) +%!assert (inf (3, 2, "single"), single ([Inf, Inf; Inf, Inf; Inf, Inf])) +%!assert (size (inf (3, 4, 5, "single")), [3, 4, 5]) + +%!error (inf (3, "int8")) +%!error (inf (2, 3, "int8")) +%!error (inf (3, 2, "int8")) +%!error (inf (3, 4, 5, "int8")) +*/ DEFUN (NaN, args, , "-*- texinfo -*-\n\ @@ -4026,22 +3997,21 @@ DEFALIAS (nan, NaN); /* -%!assert(NaN (3), [NaN, NaN, NaN; NaN, NaN, NaN; NaN, NaN, NaN]); -%!assert(NaN (2, 3), [NaN, NaN, NaN; NaN, NaN, NaN]); -%!assert(NaN (3, 2), [NaN, NaN; NaN, NaN; NaN, NaN]); -%!assert(size (NaN (3, 4, 5)), [3, 4, 5]); - -%!assert(NaN (3,'single'), single([NaN, NaN, NaN; NaN, NaN, NaN; NaN, NaN, NaN])); -%!assert(NaN (2, 3,'single'), single([NaN, NaN, NaN; NaN, NaN, NaN])); -%!assert(NaN (3, 2,'single'), single([NaN, NaN; NaN, NaN; NaN, NaN])); -%!assert(size (NaN (3, 4, 5, 'single')), [3, 4, 5]); - -%!error(NaN (3,'int8')); -%!error(NaN (2, 3,'int8')); -%!error(NaN (3, 2,'int8')); -%!error(NaN (3, 4, 5, 'int8')); - - */ +%!assert (NaN (3), [NaN, NaN, NaN; NaN, NaN, NaN; NaN, NaN, NaN]) +%!assert (NaN (2, 3), [NaN, NaN, NaN; NaN, NaN, NaN]) +%!assert (NaN (3, 2), [NaN, NaN; NaN, NaN; NaN, NaN]) +%!assert (size (NaN (3, 4, 5)), [3, 4, 5]) + +%!assert (NaN (3, "single"), single ([NaN, NaN, NaN; NaN, NaN, NaN; NaN, NaN, NaN])) +%!assert (NaN (2, 3, "single"), single ([NaN, NaN, NaN; NaN, NaN, NaN])) +%!assert (NaN (3, 2, "single"), single ([NaN, NaN; NaN, NaN; NaN, NaN])) +%!assert (size (NaN (3, 4, 5, "single")), [3, 4, 5]) + +%!error (NaN (3, "int8")) +%!error (NaN (2, 3, "int8")) +%!error (NaN (3, 2, "int8")) +%!error (NaN (3, 4, 5, "int8")) +*/ DEFUN (e, args, , "-*- texinfo -*-\n\ @@ -4171,29 +4141,26 @@ } /* - -%!assert(eps(1/2),2^(-53)) -%!assert(eps(1),2^(-52)) -%!assert(eps(2),2^(-51)) -%!assert(eps(realmax),2^971) -%!assert(eps(0),2^(-1074)) -%!assert(eps(realmin/2),2^(-1074)) -%!assert(eps(realmin/16),2^(-1074)) -%!assert(eps(Inf),NaN) -%!assert(eps(NaN),NaN) -%!assert(eps(single(1/2)),single(2^(-24))) -%!assert(eps(single(1)),single(2^(-23))) -%!assert(eps(single(2)),single(2^(-22))) -%!assert(eps(realmax('single')),single(2^104)) -%!assert(eps(single(0)),single(2^(-149))) -%!assert(eps(realmin('single')/2),single(2^(-149))) -%!assert(eps(realmin('single')/16),single(2^(-149))) -%!assert(eps(single(Inf)),single(NaN)) -%!assert(eps(single(NaN)),single(NaN)) - +%!assert (eps (1/2), 2^(-53)) +%!assert (eps (1), 2^(-52)) +%!assert (eps (2), 2^(-51)) +%!assert (eps (realmax), 2^971) +%!assert (eps (0), 2^(-1074)) +%!assert (eps (realmin/2), 2^(-1074)) +%!assert (eps (realmin/16), 2^(-1074)) +%!assert (eps (Inf), NaN) +%!assert (eps (NaN), NaN) +%!assert (eps (single (1/2)), single (2^(-24))) +%!assert (eps (single (1)), single (2^(-23))) +%!assert (eps (single (2)), single (2^(-22))) +%!assert (eps (realmax ("single")), single (2^104)) +%!assert (eps (single (0)), single (2^(-149))) +%!assert (eps (realmin ("single")/2), single (2^(-149))) +%!assert (eps (realmin ("single")/16), single (2^(-149))) +%!assert (eps (single (Inf)), single (NaN)) +%!assert (eps (single (NaN)), single (NaN)) */ - DEFUN (pi, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} pi\n\ @@ -4368,11 +4335,9 @@ } /* - -%!assert(single(NA('double')),NA('single')) -%!assert(double(NA('single')),NA('double')) - - */ +%!assert (single (NA ("double")), NA ("single")) +%!assert (double (NA ("single")), NA ("double")) +*/ DEFUN (false, args, , "-*- texinfo -*-\n\ @@ -4621,21 +4586,18 @@ return retval; } - /* - -%!assert (full (eye(3)), [1, 0, 0; 0, 1, 0; 0, 0, 1]); -%!assert (full (eye(2, 3)), [1, 0, 0; 0, 1, 0]); - -%!assert (full (eye(3,'single')), single([1, 0, 0; 0, 1, 0; 0, 0, 1])); -%!assert (full (eye(2, 3,'single')), single([1, 0, 0; 0, 1, 0])); - -%!assert (eye(3,'int8'), int8([1, 0, 0; 0, 1, 0; 0, 0, 1])); -%!assert (eye(2, 3,'int8'), int8([1, 0, 0; 0, 1, 0])); - -%!error <Invalid call to eye> eye (1, 2, 3); - - */ +%!assert (full (eye (3)), [1, 0, 0; 0, 1, 0; 0, 0, 1]) +%!assert (full (eye (2, 3)), [1, 0, 0; 0, 1, 0]) + +%!assert (full (eye (3,"single")), single ([1, 0, 0; 0, 1, 0; 0, 0, 1])) +%!assert (full (eye (2, 3,"single")), single ([1, 0, 0; 0, 1, 0])) + +%!assert (eye (3, "int8"), int8 ([1, 0, 0; 0, 1, 0; 0, 0, 1])) +%!assert (eye (2, 3, "int8"), int8 ([1, 0, 0; 0, 1, 0])) + +%!error eye (1, 2, 3) +*/ template <class MT> static octave_value @@ -4744,24 +4706,20 @@ /* - %!test %! x1 = linspace (1, 2); %! x2 = linspace (1, 2, 10); %! x3 = linspace (1, -2, 10); -%! assert((size (x1) == [1, 100] && x1(1) == 1 && x1(100) == 2 -%! && size (x2) == [1, 10] && x2(1) == 1 && x2(10) == 2 -%! && size (x3) == [1, 10] && x3(1) == 1 && x3(10) == -2)); - - -% assert(linspace ([1, 2; 3, 4], 5, 6), linspace (1, 5, 6)); - -%!error <Invalid call to linspace> linspace (); -%!error <Invalid call to linspace> linspace (1, 2, 3, 4); - -%!test -%! fail("linspace ([1, 2; 3, 4], 5, 6)","warning"); - +%! assert (size (x1) == [1, 100] && x1(1) == 1 && x1(100) == 2); +%! assert (size (x2) == [1, 10] && x2(1) == 1 && x2(10) == 2); +%! assert (size (x3) == [1, 10] && x3(1) == 1 && x3(10) == -2); + +%#assert (linspace ([1, 2; 3, 4], 5, 6), linspace (1, 5, 6)) + +%!fail ("linspace ([1, 2; 3, 4], 5, 6)", "warning") + +%!error linspace () +%!error linspace (1, 2, 3, 4) */ // FIXME -- should accept dimensions as separate args for N-d @@ -4977,25 +4935,23 @@ } /* - -%!assert(size (reshape (ones (4, 4), 2, 8)), [2, 8]) -%!assert(size (reshape (ones (4, 4), 8, 2)), [8, 2]) -%!assert(size (reshape (ones (15, 4), 1, 60)), [1, 60]) -%!assert(size (reshape (ones (15, 4), 60, 1)), [60, 1]) - -%!assert(size (reshape (ones (4, 4, 'single'), 2, 8)), [2, 8]) -%!assert(size (reshape (ones (4, 4, 'single'), 8, 2)), [8, 2]) -%!assert(size (reshape (ones (15, 4, 'single'), 1, 60)), [1, 60]) -%!assert(size (reshape (ones (15, 4, 'single'), 60, 1)), [60, 1]) +%!assert (size (reshape (ones (4, 4), 2, 8)), [2, 8]) +%!assert (size (reshape (ones (4, 4), 8, 2)), [8, 2]) +%!assert (size (reshape (ones (15, 4), 1, 60)), [1, 60]) +%!assert (size (reshape (ones (15, 4), 60, 1)), [60, 1]) + +%!assert (size (reshape (ones (4, 4, "single"), 2, 8)), [2, 8]) +%!assert (size (reshape (ones (4, 4, "single"), 8, 2)), [8, 2]) +%!assert (size (reshape (ones (15, 4, "single"), 1, 60)), [1, 60]) +%!assert (size (reshape (ones (15, 4, "single"), 60, 1)), [60, 1]) %!test %! s.a = 1; -%! fail("reshape (s, 2, 3)"); - -%!error <Invalid call to reshape> reshape (); -%!error reshape (1, 2, 3, 4); - - */ +%! fail ("reshape (s, 2, 3)"); + +%!error reshape () +%!error reshape (1, 2, 3, 4) +*/ DEFUN (vec, args, , "-*- texinfo -*-\n\ @@ -5049,20 +5005,18 @@ } /* - -%!assert(vec ([1, 2; 3, 4]), [1; 3; 2; 4]) -%!assert(vec ([1, 3, 2, 4]), [1; 3; 2; 4]); -%!assert(vec ([1, 2, 3, 4], 2), [1, 2, 3, 4]); -%!assert(vec ([1, 2; 3, 4]), vec ([1, 2; 3, 4], 1)); -%!assert(vec ([1, 2; 3, 4], 1), [1; 3; 2; 4]); -%!assert(vec ([1, 2; 3, 4], 2), [1, 3, 2, 4]); -%!assert(vec ([1, 3; 2, 4], 3), reshape ([1, 2, 3, 4], 1, 1, 4)); -%!assert(vec ([1, 3; 2, 4], 3), shiftdim (vec ([1, 3; 2, 4]), -2)); - -%!error vec (); -%!error vec (1, 2, 3); -%!error vec ([1, 2; 3, 4], 0); - +%!assert (vec ([1, 2; 3, 4]), [1; 3; 2; 4]) +%!assert (vec ([1, 3, 2, 4]), [1; 3; 2; 4]) +%!assert (vec ([1, 2, 3, 4], 2), [1, 2, 3, 4]) +%!assert (vec ([1, 2; 3, 4]), vec ([1, 2; 3, 4], 1)) +%!assert (vec ([1, 2; 3, 4], 1), [1; 3; 2; 4]) +%!assert (vec ([1, 2; 3, 4], 2), [1, 3, 2, 4]) +%!assert (vec ([1, 3; 2, 4], 3), reshape ([1, 2, 3, 4], 1, 1, 4)) +%!assert (vec ([1, 3; 2, 4], 3), shiftdim (vec ([1, 3; 2, 4]), -2)) + +%!error vec () +%!error vec (1, 2, 3) +%!error vec ([1, 2; 3, 4], 0) */ DEFUN (squeeze, args, , @@ -5227,53 +5181,53 @@ /* %!shared x %! x = [1, -3, 4, 5, -7]; -%!assert(norm(x,1), 20); -%!assert(norm(x,2), 10); -%!assert(norm(x,3), 8.24257059961711, -4*eps); -%!assert(norm(x,Inf), 7); -%!assert(norm(x,-Inf), 1); -%!assert(norm(x,"inf"), 7); -%!assert(norm(x,"fro"), 10, -eps); -%!assert(norm(x), 10); -%!assert(norm([1e200, 1]), 1e200); -%!assert(norm([3+4i, 3-4i, sqrt(31)]), 9, -4*eps); +%!assert (norm (x,1), 20) +%!assert (norm (x,2), 10) +%!assert (norm (x,3), 8.24257059961711, -4*eps) +%!assert (norm (x,Inf), 7) +%!assert (norm (x,-Inf), 1) +%!assert (norm (x,"inf"), 7) +%!assert (norm (x,"fro"), 10, -eps) +%!assert (norm (x), 10) +%!assert (norm ([1e200, 1]), 1e200) +%!assert (norm ([3+4i, 3-4i, sqrt(31)]), 9, -4*eps) %!shared m %! m = magic (4); -%!assert(norm(m,1), 34); -%!assert(norm(m,2), 34, -eps); -%!assert(norm(m,Inf), 34); -%!assert(norm(m,"inf"), 34); +%!assert (norm (m,1), 34) +%!assert (norm (m,2), 34, -eps) +%!assert (norm (m,Inf), 34) +%!assert (norm (m,"inf"), 34) %!shared m2, flo, fhi %! m2 = [1,2;3,4]; %! flo = 1e-300; %! fhi = 1e+300; -%!assert (norm(flo*m2,"fro"), sqrt(30)*flo, -eps) -%!assert (norm(fhi*m2,"fro"), sqrt(30)*fhi, -eps) +%!assert (norm (flo*m2,"fro"), sqrt (30)*flo, -eps) +%!assert (norm (fhi*m2,"fro"), sqrt (30)*fhi, -eps) %!shared x -%! x = single([1, -3, 4, 5, -7]); -%!assert(norm(x,1), single(20)); -%!assert(norm(x,2), single(10)); -%!assert(norm(x,3), single(8.24257059961711), -4*eps('single')); -%!assert(norm(x,Inf), single(7)); -%!assert(norm(x,-Inf), single(1)); -%!assert(norm(x,"inf"), single(7)); -%!assert(norm(x,"fro"), single(10), -eps('single')); -%!assert(norm(x), single(10)); -%!assert(norm(single([1e200, 1])), single(1e200)); -%!assert(norm(single([3+4i, 3-4i, sqrt(31)])), single(9), -4*eps('single')); +%! x = single ([1, -3, 4, 5, -7]); +%!assert (norm (x,1), single (20)) +%!assert (norm (x,2), single (10)) +%!assert (norm (x,3), single (8.24257059961711), -4*eps ("single")) +%!assert (norm (x,Inf), single (7)) +%!assert (norm (x,-Inf), single (1)) +%!assert (norm (x,"inf"), single (7)) +%!assert (norm (x,"fro"), single (10), -eps ("single")) +%!assert (norm (x), single (10)) +%!assert (norm (single ([1e200, 1])), single (1e200)) +%!assert (norm (single ([3+4i, 3-4i, sqrt(31)])), single (9), -4*eps ("single")) %!shared m -%! m = single(magic (4)); -%!assert(norm(m,1), single(34)); -%!assert(norm(m,2), single(34), -eps('single')); -%!assert(norm(m,Inf), single(34)); -%!assert(norm(m,"inf"), single(34)); +%! m = single (magic (4)); +%!assert (norm (m,1), single (34)) +%!assert (norm (m,2), single (34), -eps ("single")) +%!assert (norm (m,Inf), single (34)) +%!assert (norm (m,"inf"), single (34)) %!shared m2, flo, fhi -%! m2 = single([1,2;3,4]); -%! flo = single(1e-300); -%! fhi = single(1e+300); -%!assert (norm(flo*m2,"fro"), single(sqrt(30)*flo), -eps('single')) -%!assert (norm(fhi*m2,"fro"), single(sqrt(30)*fhi), -eps('single')) +%! m2 = single ([1,2;3,4]); +%! flo = single (1e-300); +%! fhi = single (1e+300); +%!assert (norm (flo*m2,"fro"), single (sqrt (30)*flo), -eps ("single")) +%!assert (norm (fhi*m2,"fro"), single (sqrt (30)*fhi), -eps ("single")) */ static octave_value @@ -5330,25 +5284,23 @@ } /* - -%!assert (2.', 2); -%!assert (2i.',2i); -%!assert ([1:4].',[1;2;3;4]); -%!assert ([1;2;3;4].',[1:4]); -%!assert ([1,2;3,4].',[1,3;2,4]); -%!assert ([1,2i;3,4].',[1,3;2i,4]); - -%!assert (transpose ([1,2;3,4]),[1,3;2,4]); - -%!assert (single(2).', single(2)); -%!assert (single(2i).',single(2i)); -%!assert (single([1:4]).',single([1;2;3;4])); -%!assert (single([1;2;3;4]).',single([1:4])); -%!assert (single([1,2;3,4]).',single([1,3;2,4])); -%!assert (single([1,2i;3,4]).',single([1,3;2i,4])); - -%!assert (transpose (single([1,2;3,4])),single([1,3;2,4])); - +%!assert (2.', 2) +%!assert (2i.', 2i) +%!assert ([1:4].', [1;2;3;4]) +%!assert ([1;2;3;4].', [1:4]) +%!assert ([1,2;3,4].', [1,3;2,4]) +%!assert ([1,2i;3,4].', [1,3;2i,4]) + +%!assert (transpose ([1,2;3,4]), [1,3;2,4]) + +%!assert (single (2).', single (2)) +%!assert (single (2i).', single (2i)) +%!assert (single ([1:4]).', single ([1;2;3;4])) +%!assert (single ([1;2;3;4]).', single ([1:4])) +%!assert (single ([1,2;3,4]).', single ([1,3;2,4])) +%!assert (single ([1,2i;3,4]).', single ([1,3;2i,4])) + +%!assert (transpose (single ([1,2;3,4])), single ([1,3;2,4])) */ DEFUN (ctranspose, args, , @@ -5363,25 +5315,23 @@ } /* - -%!assert (2', 2); -%!assert (2i',-2i); -%!assert ([1:4]',[1;2;3;4]); -%!assert ([1;2;3;4]',[1:4]); -%!assert ([1,2;3,4]',[1,3;2,4]); -%!assert ([1,2i;3,4]',[1,3;-2i,4]); - -%!assert (ctranspose ([1,2i;3,4]),[1,3;-2i,4]); - -%!assert (single(2)', single(2)); -%!assert (single(2i)',single(-2i)); -%!assert (single([1:4])',single([1;2;3;4])); -%!assert (single([1;2;3;4])',single([1:4])); -%!assert (single([1,2;3,4])',single([1,3;2,4])); -%!assert (single([1,2i;3,4])',single([1,3;-2i,4])); - -%!assert (ctranspose (single([1,2i;3,4])),single([1,3;-2i,4])); - +%!assert (2', 2) +%!assert (2i', -2i) +%!assert ([1:4]', [1;2;3;4]) +%!assert ([1;2;3;4]', [1:4]) +%!assert ([1,2;3,4]', [1,3;2,4]) +%!assert ([1,2i;3,4]', [1,3;-2i,4]) + +%!assert (ctranspose ([1,2i;3,4]), [1,3;-2i,4]) + +%!assert (single (2)', single (2)) +%!assert (single (2i)', single (-2i)) +%!assert (single ([1:4])', single ([1;2;3;4])) +%!assert (single ([1;2;3;4])', single ([1:4])) +%!assert (single ([1,2;3,4])', single ([1,3;2,4])) +%!assert (single ([1,2i;3,4])', single ([1,3;-2i,4])) + +%!assert (ctranspose (single ([1,2i;3,4])), single ([1,3;-2i,4])) */ static octave_value @@ -6004,8 +5954,7 @@ } /* - -%% Double +## Double %!assert (sort ([NaN, 1, -1, 2, Inf]), [-1, 1, 2, Inf, NaN]) %!assert (sort ([NaN, 1, -1, 2, Inf], 1), [NaN, 1, -1, 2, Inf]) %!assert (sort ([NaN, 1, -1, 2, Inf], 2), [-1, 1, 2, Inf, NaN]) @@ -6021,10 +5970,10 @@ %!test %! [v, i] = sort ([NaN, 1, -1, Inf, 1]); -%! assert (v, [-1, 1, 1, Inf, NaN]) -%! assert (i, [3, 2, 5, 4, 1]) - -%% Complex +%! assert (v, [-1, 1, 1, Inf, NaN]); +%! assert (i, [3, 2, 5, 4, 1]); + +## Complex %!assert (sort ([NaN, 1i, -1, 2, Inf]), [1i, -1, 2, Inf, NaN]) %!assert (sort ([NaN, 1i, -1, 2, Inf], 1), [NaN, 1i, -1, 2, Inf]) %!assert (sort ([NaN, 1i, -1, 2, Inf], 2), [1i, -1, 2, Inf, NaN]) @@ -6040,48 +5989,48 @@ %!test %! [v, i] = sort ([NaN, 1i, -1, Inf, 1, 1i]); -%! assert (v, [1, 1i, 1i, -1, Inf, NaN]) -%! assert (i, [5, 2, 6, 3, 4, 1]) - -%% Single -%!assert (sort (single([NaN, 1, -1, 2, Inf])), single([-1, 1, 2, Inf, NaN])) -%!assert (sort (single([NaN, 1, -1, 2, Inf]), 1), single([NaN, 1, -1, 2, Inf])) -%!assert (sort (single([NaN, 1, -1, 2, Inf]), 2), single([-1, 1, 2, Inf, NaN])) -%!assert (sort (single([NaN, 1, -1, 2, Inf]), 3), single([NaN, 1, -1, 2, Inf])) -%!assert (sort (single([NaN, 1, -1, 2, Inf]), "ascend"), single([-1, 1, 2, Inf, NaN])) -%!assert (sort (single([NaN, 1, -1, 2, Inf]), 2, "ascend"), single([-1, 1, 2, Inf, NaN])) -%!assert (sort (single([NaN, 1, -1, 2, Inf]), "descend"), single([NaN, Inf, 2, 1, -1])) -%!assert (sort (single([NaN, 1, -1, 2, Inf]), 2, "descend"), single([NaN, Inf, 2, 1, -1])) -%!assert (sort (single([3, 1, 7, 5; 8, 2, 6, 4])), single([3, 1, 6, 4; 8, 2, 7, 5])) -%!assert (sort (single([3, 1, 7, 5; 8, 2, 6, 4]), 1), single([3, 1, 6, 4; 8, 2, 7, 5])) -%!assert (sort (single([3, 1, 7, 5; 8, 2, 6, 4]), 2), single([1, 3, 5, 7; 2, 4, 6, 8])) -%!assert (sort (single(1)), single(1)) +%! assert (v, [1, 1i, 1i, -1, Inf, NaN]); +%! assert (i, [5, 2, 6, 3, 4, 1]); + +## Single +%!assert (sort (single ([NaN, 1, -1, 2, Inf])), single ([-1, 1, 2, Inf, NaN])) +%!assert (sort (single ([NaN, 1, -1, 2, Inf]), 1), single ([NaN, 1, -1, 2, Inf])) +%!assert (sort (single ([NaN, 1, -1, 2, Inf]), 2), single ([-1, 1, 2, Inf, NaN])) +%!assert (sort (single ([NaN, 1, -1, 2, Inf]), 3), single ([NaN, 1, -1, 2, Inf])) +%!assert (sort (single ([NaN, 1, -1, 2, Inf]), "ascend"), single ([-1, 1, 2, Inf, NaN])) +%!assert (sort (single ([NaN, 1, -1, 2, Inf]), 2, "ascend"), single ([-1, 1, 2, Inf, NaN])) +%!assert (sort (single ([NaN, 1, -1, 2, Inf]), "descend"), single ([NaN, Inf, 2, 1, -1])) +%!assert (sort (single ([NaN, 1, -1, 2, Inf]), 2, "descend"), single ([NaN, Inf, 2, 1, -1])) +%!assert (sort (single ([3, 1, 7, 5; 8, 2, 6, 4])), single ([3, 1, 6, 4; 8, 2, 7, 5])) +%!assert (sort (single ([3, 1, 7, 5; 8, 2, 6, 4]), 1), single ([3, 1, 6, 4; 8, 2, 7, 5])) +%!assert (sort (single ([3, 1, 7, 5; 8, 2, 6, 4]), 2), single ([1, 3, 5, 7; 2, 4, 6, 8])) +%!assert (sort (single (1)), single (1)) %!test -%! [v, i] = sort (single([NaN, 1, -1, Inf, 1])); -%! assert (v, single([-1, 1, 1, Inf, NaN])) -%! assert (i, [3, 2, 5, 4, 1]) - -%% Single Complex -%!assert (sort (single([NaN, 1i, -1, 2, Inf])), single([1i, -1, 2, Inf, NaN])) -%!assert (sort (single([NaN, 1i, -1, 2, Inf]), 1), single([NaN, 1i, -1, 2, Inf])) -%!assert (sort (single([NaN, 1i, -1, 2, Inf]), 2), single([1i, -1, 2, Inf, NaN])) -%!assert (sort (single([NaN, 1i, -1, 2, Inf]), 3), single([NaN, 1i, -1, 2, Inf])) -%!assert (sort (single([NaN, 1i, -1, 2, Inf]), "ascend"), single([1i, -1, 2, Inf, NaN])) -%!assert (sort (single([NaN, 1i, -1, 2, Inf]), 2, "ascend"), single([1i, -1, 2, Inf, NaN])) -%!assert (sort (single([NaN, 1i, -1, 2, Inf]), "descend"), single([NaN, Inf, 2, -1, 1i])) -%!assert (sort (single([NaN, 1i, -1, 2, Inf]), 2, "descend"), single([NaN, Inf, 2, -1, 1i])) -%!assert (sort (single([3, 1i, 7, 5; 8, 2, 6, 4])), single([3, 1i, 6, 4; 8, 2, 7, 5])) -%!assert (sort (single([3, 1i, 7, 5; 8, 2, 6, 4]), 1), single([3, 1i, 6, 4; 8, 2, 7, 5])) -%!assert (sort (single([3, 1i, 7, 5; 8, 2, 6, 4]), 2), single([1i, 3, 5, 7; 2, 4, 6, 8])) -%!assert (sort (single(1i)),single( 1i)) +%! [v, i] = sort (single ([NaN, 1, -1, Inf, 1])); +%! assert (v, single ([-1, 1, 1, Inf, NaN])); +%! assert (i, [3, 2, 5, 4, 1]); + +## Single Complex +%!assert (sort (single ([NaN, 1i, -1, 2, Inf])), single ([1i, -1, 2, Inf, NaN])) +%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), 1), single ([NaN, 1i, -1, 2, Inf])) +%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), 2), single ([1i, -1, 2, Inf, NaN])) +%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), 3), single ([NaN, 1i, -1, 2, Inf])) +%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), "ascend"), single ([1i, -1, 2, Inf, NaN])) +%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), 2, "ascend"), single ([1i, -1, 2, Inf, NaN])) +%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), "descend"), single ([NaN, Inf, 2, -1, 1i])) +%!assert (sort (single ([NaN, 1i, -1, 2, Inf]), 2, "descend"), single ([NaN, Inf, 2, -1, 1i])) +%!assert (sort (single ([3, 1i, 7, 5; 8, 2, 6, 4])), single ([3, 1i, 6, 4; 8, 2, 7, 5])) +%!assert (sort (single ([3, 1i, 7, 5; 8, 2, 6, 4]), 1), single ([3, 1i, 6, 4; 8, 2, 7, 5])) +%!assert (sort (single ([3, 1i, 7, 5; 8, 2, 6, 4]), 2), single ([1i, 3, 5, 7; 2, 4, 6, 8])) +%!assert (sort (single (1i)), single (1i)) %!test -%! [v, i] = sort (single([NaN, 1i, -1, Inf, 1, 1i])); -%! assert (v, single([1, 1i, 1i, -1, Inf, NaN])) -%! assert (i, [5, 2, 6, 3, 4, 1]) - -%% Bool +%! [v, i] = sort (single ([NaN, 1i, -1, Inf, 1, 1i])); +%! assert (v, single ([1, 1i, 1i, -1, Inf, NaN])); +%! assert (i, [5, 2, 6, 3, 4, 1]); + +## Bool %!assert (sort ([true, false, true, false]), [false, false, true, true]) %!assert (sort ([true, false, true, false], 1), [true, false, true, false]) %!assert (sort ([true, false, true, false], 2), [false, false, true, true]) @@ -6094,10 +6043,10 @@ %!test %! [v, i] = sort ([true, false, true, false]); -%! assert (v, [false, false, true, true]) -%! assert (i, [2, 4, 1, 3]) - -%% Sparse Double +%! assert (v, [false, false, true, true]); +%! assert (i, [2, 4, 1, 3]); + +## Sparse Double %!assert (sort (sparse ([0, NaN, 1, 0, -1, 2, Inf])), sparse ([-1, 0, 0, 1, 2, Inf, NaN])) %!assert (sort (sparse ([0, NaN, 1, 0, -1, 2, Inf]), 1), sparse ([0, NaN, 1, 0, -1, 2, Inf])) %!assert (sort (sparse ([0, NaN, 1, 0, -1, 2, Inf]), 2), sparse ([-1, 0, 0, 1, 2, Inf, NaN])) @@ -6109,17 +6058,17 @@ %!shared a %! a = randn (10, 10); -%! a (a < 0) = 0; +%! a(a < 0) = 0; %!assert (sort (sparse (a)), sparse (sort (a))) %!assert (sort (sparse (a), 1), sparse (sort (a, 1))) %!assert (sort (sparse (a), 2), sparse (sort (a, 2))) %!test %! [v, i] = sort (a); %! [vs, is] = sort (sparse (a)); -%! assert (vs, sparse (v)) -%! assert (is, i) - -%% Sparse Complex +%! assert (vs, sparse (v)); +%! assert (is, i); + +## Sparse Complex %!assert (sort (sparse ([0, NaN, 1i, 0, -1, 2, Inf])), sparse ([0, 0, 1i, -1, 2, Inf, NaN])) %!assert (sort (sparse ([0, NaN, 1i, 0, -1, 2, Inf]), 1), sparse ([0, NaN, 1i, 0, -1, 2, Inf])) %!assert (sort (sparse ([0, NaN, 1i, 0, -1, 2, Inf]), 2), sparse ([0, 0, 1i, -1, 2, Inf, NaN])) @@ -6131,7 +6080,7 @@ %!shared a %! a = randn (10, 10); -%! a (a < 0) = 0; +%! a(a < 0) = 0; %! a = 1i * a; %!assert (sort (sparse (a)), sparse (sort (a))) %!assert (sort (sparse (a), 1), sparse (sort (a, 1))) @@ -6139,30 +6088,30 @@ %!test %! [v, i] = sort (a); %! [vs, is] = sort (sparse (a)); -%! assert (vs, sparse (v)) -%! assert (is, i) - -%% Sparse Bool +%! assert (vs, sparse (v)); +%! assert (is, i); + +## Sparse Bool %!assert (sort (sparse ([true, false, true, false])), sparse ([false, false, true, true])) -%!assert (sort (sparse([true, false, true, false]), 1), sparse ([true, false, true, false])) +%!assert (sort (sparse ([true, false, true, false]), 1), sparse ([true, false, true, false])) %!assert (sort (sparse ([true, false, true, false]), 2), sparse ([false, false, true, true])) %!assert (sort (sparse ([true, false, true, false]), 3), sparse ([true, false, true, false])) -%!assert (sort (sparse ([true, false, true, false]), "ascend"), sparse([false, false, true, true])) -%!assert (sort (sparse ([true, false, true, false]), 2, "ascend"), sparse([false, false, true, true])) +%!assert (sort (sparse ([true, false, true, false]), "ascend"), sparse ([false, false, true, true])) +%!assert (sort (sparse ([true, false, true, false]), 2, "ascend"), sparse ([false, false, true, true])) %!assert (sort (sparse ([true, false, true, false]), "descend"), sparse ([true, true, false, false])) -%!assert (sort (sparse ([true, false, true, false]), 2, "descend"), sparse([true, true, false, false])) +%!assert (sort (sparse ([true, false, true, false]), 2, "descend"), sparse ([true, true, false, false])) %!test -%! [v, i] = sort (sparse([true, false, true, false])); -%! assert (v, sparse([false, false, true, true])) -%! assert (i, [2, 4, 1, 3]) - -%% Cell string array +%! [v, i] = sort (sparse ([true, false, true, false])); +%! assert (v, sparse ([false, false, true, true])); +%! assert (i, [2, 4, 1, 3]); + +## Cell string array %!shared a, b, c %! a = {"Alice", "Cecile", "Eric", "Barry", "David"}; %! b = {"Alice", "Barry", "Cecile", "David", "Eric"}; %! c = {"Eric", "David", "Cecile", "Barry", "Alice"}; -%!assert (sort (a), b); +%!assert (sort (a), b) %!assert (sort (a, 1), a) %!assert (sort (a, 2), b) %!assert (sort (a, 3), a) @@ -6173,11 +6122,10 @@ %!test %! [v, i] = sort (a); -%! assert (i, [1, 4, 2, 5, 3]) - -%!error <Invalid call to sort> sort (); -%!error <Invalid call to sort> sort (1, 2, 3, 4); - +%! assert (i, [1, 4, 2, 5, 3]); + +%!error sort () +%!error sort (1, 2, 3, 4) */ // Sort the rows of the matrix @var{a} according to the order @@ -6340,32 +6288,32 @@ %! um = [3, 1; 2, 4]; %! sv = [1, 2, 3, 4]; %! uv = [2, 1, 4, 3]; -%!assert(issorted (sm, "rows")); -%!assert(!issorted (um, "rows")); -%!assert(issorted (sv)); -%!assert(!issorted (uv)); -%!assert(issorted (sv')); -%!assert(!issorted (uv')); -%!assert(issorted (sm, "rows", "ascending")); -%!assert(!issorted (um, "rows", "ascending")); -%!assert(issorted (sv, "ascending")); -%!assert(!issorted (uv, "ascending")); -%!assert(issorted (sv', "ascending")); -%!assert(!issorted (uv', "ascending")); -%!assert(!issorted (sm, "rows", "descending")); -%!assert(issorted (flipud (sm), "rows", "descending")); -%!assert(!issorted (sv, "descending")); -%!assert(issorted (fliplr (sv), "descending")); -%!assert(!issorted (sv', "descending")); -%!assert(issorted (fliplr (sv)', "descending")); -%!assert(!issorted (um, "rows", "either")); -%!assert(!issorted (uv, "either")); -%!assert(issorted (sm, "rows", "either")); -%!assert(issorted (flipud (sm), "rows", "either")); -%!assert(issorted (sv, "either")); -%!assert(issorted (fliplr (sv), "either")); -%!assert(issorted (sv', "either")); -%!assert(issorted (fliplr (sv)', "either")); +%!assert (issorted (sm, "rows")) +%!assert (!issorted (um, "rows")) +%!assert (issorted (sv)) +%!assert (!issorted (uv)) +%!assert (issorted (sv')) +%!assert (!issorted (uv')) +%!assert (issorted (sm, "rows", "ascending")) +%!assert (!issorted (um, "rows", "ascending")) +%!assert (issorted (sv, "ascending")) +%!assert (!issorted (uv, "ascending")) +%!assert (issorted (sv', "ascending")) +%!assert (!issorted (uv', "ascending")) +%!assert (!issorted (sm, "rows", "descending")) +%!assert (issorted (flipud (sm), "rows", "descending")) +%!assert (!issorted (sv, "descending")) +%!assert (issorted (fliplr (sv), "descending")) +%!assert (!issorted (sv', "descending")) +%!assert (issorted (fliplr (sv)', "descending")) +%!assert (!issorted (um, "rows", "either")) +%!assert (!issorted (uv, "either")) +%!assert (issorted (sm, "rows", "either")) +%!assert (issorted (flipud (sm), "rows", "either")) +%!assert (issorted (sv, "either")) +%!assert (issorted (fliplr (sv), "either")) +%!assert (issorted (sv', "either")) +%!assert (issorted (fliplr (sv)', "either")) */ DEFUN (nth_element, args, , @@ -7071,21 +7019,16 @@ } /* - %!assert (diff ([1, 2, 3, 4]), [1, 1, 1]) %!assert (diff ([1, 3, 7, 19], 2), [2, 8]) %!assert (diff ([1, 2; 5, 4; 8, 7; 9, 6; 3, 1]), [4, 2; 3, 3; 1, -1; -6, -5]) %!assert (diff ([1, 2; 5, 4; 8, 7; 9, 6; 3, 1], 3), [-1, -5; -5, 0]) -%!assert (isempty (diff (1))); - -%!error diff ([1, 2; 3, 4], -1); - -%!error diff ("foo"); - -%!error diff (); - -%!error diff (1, 2, 3, 4); - +%!assert (isempty (diff (1))) + +%!error diff () +%!error diff (1, 2, 3, 4) +%!error diff ("foo") +%!error diff ([1, 2; 3, 4], -1) */ template <class T>
--- a/src/defaults.cc +++ b/src/defaults.cc @@ -425,7 +425,6 @@ } /* -%!error (EDITOR (1, 2)); %!test %! orig_val = EDITOR (); %! old_val = EDITOR ("X"); @@ -433,6 +432,8 @@ %! assert (EDITOR (), "X"); %! EDITOR (orig_val); %! assert (EDITOR (), orig_val); + +%!error (EDITOR (1, 2)) */ DEFUN (EXEC_PATH, args, nargout, @@ -460,7 +461,6 @@ } /* -%!error (EXEC_PATH (1, 2)); %!test %! orig_val = EXEC_PATH (); %! old_val = EXEC_PATH ("X"); @@ -468,6 +468,8 @@ %! assert (EXEC_PATH (), "X"); %! EXEC_PATH (orig_val); %! assert (EXEC_PATH (), orig_val); + +%!error (EXEC_PATH (1, 2)) */ DEFUN (IMAGE_PATH, args, nargout, @@ -487,7 +489,6 @@ } /* -%!error (IMAGE_PATH (1, 2)); %!test %! orig_val = IMAGE_PATH (); %! old_val = IMAGE_PATH ("X"); @@ -495,6 +496,8 @@ %! assert (IMAGE_PATH (), "X"); %! IMAGE_PATH (orig_val); %! assert (IMAGE_PATH (), orig_val); + +%!error (IMAGE_PATH (1, 2)) */ DEFUN (OCTAVE_HOME, args, , @@ -514,8 +517,8 @@ } /* -%!error OCTAVE_HOME (1); -%!assert (ischar (OCTAVE_HOME ())); +%!assert (ischar (OCTAVE_HOME ())) +%!error OCTAVE_HOME (1) */ DEFUNX ("OCTAVE_VERSION", FOCTAVE_VERSION, args, , @@ -537,6 +540,6 @@ } /* -%!error OCTAVE_VERSION (1); -%!assert (ischar (OCTAVE_VERSION ())); +%!assert (ischar (OCTAVE_VERSION ())) +%!error OCTAVE_VERSION (1) */
--- a/src/dirfns.cc +++ b/src/dirfns.cc @@ -617,35 +617,34 @@ /* %!test -%! tmpdir = tmpnam; -%! filename = {"file1", "file2", "file3", "myfile1", "myfile1b"}; -%! if (mkdir (tmpdir)) -%! cwd = pwd; -%! cd (tmpdir); -%! if strcmp (canonicalize_file_name (pwd), ... -%! canonicalize_file_name (tmpdir)) -%! a = 0; -%! for n = 1:5 -%! save (filename{n}, "a"); -%! endfor -%! else -%! rmdir (tmpdir); -%! error ("Couldn't change to temporary dir"); -%! endif -%! else -%! error ("Couldn't create temporary directory"); -%! endif -%! result1 = glob ("*file1"); -%! result2 = glob ("myfile?"); -%! result3 = glob ("file[12]"); -%! for n = 1:5 -%! delete (filename{n}); -%! endfor -%! cd (cwd); -%! rmdir (tmpdir); -%! assert (result1, {"file1"; "myfile1"}); -%! assert (result2, {"myfile1"}); -%! assert (result3, {"file1"; "file2"}); +%! tmpdir = tmpnam; +%! filename = {"file1", "file2", "file3", "myfile1", "myfile1b"}; +%! if (mkdir (tmpdir)) +%! cwd = pwd; +%! cd (tmpdir); +%! if strcmp (canonicalize_file_name (pwd), canonicalize_file_name (tmpdir)) +%! a = 0; +%! for n = 1:5 +%! save (filename{n}, "a"); +%! endfor +%! else +%! rmdir (tmpdir); +%! error ("Couldn't change to temporary dir"); +%! endif +%! else +%! error ("Couldn't create temporary directory"); +%! endif +%! result1 = glob ("*file1"); +%! result2 = glob ("myfile?"); +%! result3 = glob ("file[12]"); +%! for n = 1:5 +%! delete (filename{n}); +%! endfor +%! cd (cwd); +%! rmdir (tmpdir); +%! assert (result1, {"file1"; "myfile1"}); +%! assert (result2, {"myfile1"}); +%! assert (result3, {"file1"; "file2"}); */ DEFUNX ("fnmatch", Ffnmatch, args, ,
--- a/src/file-io.cc +++ b/src/file-io.cc @@ -217,7 +217,7 @@ Close the specified file. If successful, @code{fclose} returns 0,\n\ otherwise, it returns -1. The second form of the @code{fclose} call closes\n\ all open files except @code{stdout}, @code{stderr}, and @code{stdin}.\n\ -@seealso{fopen, fseek, ftell}\n\ +@seealso{fopen, freport}\n\ @end deftypefn") { octave_value retval = -1; @@ -236,6 +236,7 @@ "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} fclear (@var{fid})\n\ Clear the stream state for the specified file.\n\ +@seealso{fopen}\n\ @end deftypefn") { octave_value retval; @@ -302,7 +303,8 @@ DEFUN (fgetl, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} fgetl (@var{fid}, @var{len})\n\ +@deftypefn {Built-in Function} {@var{str} =} fgetl (@var{fid})\n\ +@deftypefnx {Built-in Function} {@var{str} =} fgetl (@var{fid}, @var{len})\n\ Read characters from a file, stopping after a newline, or EOF,\n\ or @var{len} characters have been read. The characters read, excluding\n\ the possible trailing newline, are returned as a string.\n\ @@ -311,7 +313,9 @@ character.\n\ \n\ If there are no more characters to read, @code{fgetl} returns @minus{}1.\n\ -@seealso{fread, fscanf}\n\ +\n\ +To read a line and return the terminating newline see @code{fgets}.\n\ +@seealso{fgets, fscanf, fread, fopen}\n\ @end deftypefn") { static std::string who = "fgetl"; @@ -350,8 +354,8 @@ DEFUN (fgets, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} fgets (@var{fid})\n\ -@deftypefnx {Built-in Function} {} fgets (@var{fid}, @var{len})\n\ +@deftypefn {Built-in Function} {@var{str} =} fgets (@var{fid})\n\ +@deftypefnx {Built-in Function} {@var{str} =} fgets (@var{fid}, @var{len})\n\ Read characters from a file, stopping after a newline, or EOF,\n\ or @var{len} characters have been read. The characters read, including\n\ the possible trailing newline, are returned as a string.\n\ @@ -360,7 +364,9 @@ character.\n\ \n\ If there are no more characters to read, @code{fgets} returns @minus{}1.\n\ -@seealso{fputs, fopen, fread, fscanf}\n\ +\n\ +To read a line and discard the terminating newline see @code{fgetl}.\n\ +@seealso{fputs, fgetl, fscanf, fread, fopen}\n\ @end deftypefn") { static std::string who = "fgets"; @@ -399,14 +405,19 @@ DEFUN (fskipl, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} fskipl (@var{fid}, @var{count})\n\ -Skip a given number of lines, i.e., discards characters until an end-of-line\n\ -is met exactly @var{count}-times, or end-of-file occurs.\n\ +@deftypefn {Built-in Function} {@var{nlines} =} fskipl (@var{fid})\n\ +@deftypefnx {Built-in Function} {@var{nlines} =} fskipl (@var{fid}, @var{count})\n\ +@deftypefnx {Built-in Function} {@var{nlines} =} fskipl (@var{fid}, Inf)\n\ +Read and skip @var{count} lines from the file descriptor @var{fid}.\n\ +@code{fskipl} discards characters until an end-of-line is encountered exactly\n\ +@var{count}-times, or until the end-of-file marker is found.\n\ +\n\ +If @var{count} is omitted, it defaults to 1. @var{count} may also be\n\ +@code{Inf}, in which case lines are skipped until the end of the file.\n\ +This form is suitable for counting the number of lines in a file.\n\ +\n\ Returns the number of lines skipped (end-of-line sequences encountered).\n\ -If @var{count} is omitted, it defaults to 1. @var{count} may also be\n\ -@code{Inf}, in which case lines are skipped to the end of file.\n\ -This form is suitable for counting lines in a file.\n\ -@seealso{fgetl, fgets}\n\ +@seealso{fgetl, fgets, fscanf, fopen}\n\ @end deftypefn") { static std::string who = "fskipl"; @@ -658,7 +669,7 @@ @noindent\n\ however, conversions are currently only supported for @samp{native}\n\ @samp{ieee-be}, and @samp{ieee-le} formats.\n\ -@seealso{fclose, fgets, fputs, fread, fseek, ferror, fprintf, fscanf, ftell, fwrite}\n\ +@seealso{fclose, fgets, fgetl, fscanf, fread, fputs, fdisp, fprintf, fwrite, fskipl, fseek, frewind, ftell, feof, ferror, fclear, fflush, freport}\n\ @end deftypefn") { octave_value_list retval; @@ -743,6 +754,7 @@ @print{} 3 r myfile\n\ @end group\n\ @end example\n\ +@seealso{fopen, fclose}\n\ @end deftypefn") { octave_value_list retval; @@ -763,6 +775,7 @@ Move the file pointer to the beginning of the file @var{fid}, returning\n\ 0 for success, and -1 if an error was encountered. It is equivalent to\n\ @code{fseek (@var{fid}, 0, SEEK_SET)}.\n\ +@seealso{fseek, ftell, fopen}\n\ @end deftypefn") { octave_value retval; @@ -789,18 +802,19 @@ DEFUN (fseek, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} fseek (@var{fid}, @var{offset}, @var{origin})\n\ +@deftypefn {Built-in Function} {} fseek (@var{fid}, @var{offset})\n\ +@deftypefnx {Built-in Function} {} fseek (@var{fid}, @var{offset}, @var{origin})\n\ +@deftypefnx {Built-in Function} {@var{status} =} fseek (@dots{})\n\ Set the file pointer to any location within the file @var{fid}.\n\ \n\ The pointer is positioned @var{offset} characters from the @var{origin},\n\ which may be one of the predefined variables @w{@code{SEEK_CUR}} (current\n\ position), @w{@code{SEEK_SET}} (beginning), or @w{@code{SEEK_END}} (end of\n\ file) or strings \"cof\", \"bof\" or \"eof\". If @var{origin} is omitted,\n\ -@w{@code{SEEK_SET}} is assumed. The offset must be zero, or a value returned\n\ -by @code{ftell} (in which case @var{origin} must be @w{@code{SEEK_SET}}).\n\ +@w{@code{SEEK_SET}} is assumed. @var{offset} may be positive, negative, or zero but not all combinations of @var{origin} and @var{offset} can be realized.\n\ \n\ Return 0 on success and -1 on error.\n\ -@seealso{ftell, fopen, fclose}\n\ +@seealso{fskipl, frewind, ftell, fopen}\n\ @end deftypefn") { octave_value retval = -1; @@ -830,7 +844,7 @@ @deftypefn {Built-in Function} {} ftell (@var{fid})\n\ Return the position of the file pointer as the number of characters\n\ from the beginning of the file @var{fid}.\n\ -@seealso{fseek, fopen, fclose}\n\ +@seealso{fseek, feof, fopen}\n\ @end deftypefn") { octave_value retval = -1; @@ -856,7 +870,7 @@ This function is just like @code{printf}, except that the output is\n\ written to the stream @var{fid} instead of @code{stdout}.\n\ If @var{fid} is omitted, the output is written to @code{stdout}.\n\ -@seealso{printf, sprintf, fread, fscanf, fopen, fclose}\n\ +@seealso{fputs, fdisp, fwrite, fscanf, printf, sprintf, fopen}\n\ @end deftypefn") { static std::string who = "fprintf"; @@ -967,7 +981,7 @@ Write a string to a file with no formatting.\n\ \n\ Return a non-negative number on success and EOF on error.\n\ -@seealso{scanf, sscanf, fread, fprintf, fgets, fscanf}\n\ +@seealso{fdisp, fprintf, fwrite, fopen}\n\ @end deftypefn") { static std::string who = "fputs"; @@ -995,6 +1009,7 @@ Write a string to the standard output with no formatting.\n\ \n\ Return a non-negative number on success and EOF on error.\n\ +@seealso{fputs, disp}\n\ @end deftypefn") { static std::string who = "puts"; @@ -1120,7 +1135,7 @@ See the Formatted Input section of the GNU Octave manual for a\n\ complete description of the syntax of the template string.\n\ @end ifclear\n\ -@seealso{scanf, sscanf, fread, fprintf, fgets, fputs}\n\ +@seealso{fgets, fgetl, fread, scanf, sscanf, fopen}\n\ @end deftypefn") { static std::string who = "fscanf"; @@ -1144,7 +1159,7 @@ // old val for restoring afterwards. oldloc = os.imbue (std::locale (args(2).string_value ().c_str ())); - + } catch (std::runtime_error) { @@ -1332,8 +1347,8 @@ /* %!test -%! assert(sscanf('1,2', '%f', 'C'), 1) -%! assert(sscanf('1,2', '%f', 'fr_FR'), 1.2) +%! assert (sscanf ("1,2", "%f", "C"), 1) +%! assert (sscanf ("1,2", "%f", "fr_FR"), 1.2) */ DEFUN (scanf, args, nargout, @@ -1589,7 +1604,7 @@ \n\ The data read from the file is returned in @var{val}, and the number of\n\ values read is returned in @code{count}\n\ -@seealso{fwrite, fopen, fclose}\n\ +@seealso{fwrite, fgets, fgetl, fscanf, fopen}\n\ @end deftypefn") { octave_value_list retval; @@ -1706,7 +1721,7 @@ \n\ The behavior of @code{fwrite} is undefined if the values in @var{data}\n\ are too large to fit in the specified precision.\n\ -@seealso{fread, fopen, fclose}\n\ +@seealso{fread, fputs, fprintf, fopen}\n\ @end deftypefn") { octave_value retval = -1; @@ -1759,7 +1774,7 @@ file and 0 otherwise. Note that it will only return 1 if the end of the\n\ file has already been encountered, not if the next read operation will\n\ result in an end-of-file condition.\n\ -@seealso{fread, fopen, fclose}\n\ +@seealso{fread, fopen}\n\ @end deftypefn") { octave_value retval = -1; @@ -1781,7 +1796,8 @@ DEFUNX ("ferror", Fferror, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} ferror (@var{fid}, \"clear\")\n\ +@deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} ferror (@var{fid})\n\ +@deftypefnx {Built-in Function} {[@var{err}, @var{msg}] =} ferror (@var{fid}, \"clear\")\n\ Return 1 if an error condition has been encountered for the file ID\n\ @var{fid} and 0 otherwise. Note that it will only return 1 if an error\n\ has already been encountered, not if the next operation will result in\n\ @@ -1789,6 +1805,7 @@ \n\ The second argument is optional. If it is supplied, also clear the\n\ error condition.\n\ +@seealso{fclear, fopen}\n\ @end deftypefn") { octave_value_list retval;
--- a/src/gl2ps-renderer.cc +++ b/src/gl2ps-renderer.cc @@ -43,14 +43,6 @@ { in_draw = true; - FILE *fp = fdopen (fid, "wb"); - - if (! fp) - { - error ("gl2ps-renderer: fdopen failed"); - return; - } - GLint buffsize = 0, state = GL2PS_OVERFLOW; GLint viewport[4]; @@ -72,11 +64,15 @@ GLint gl2ps_text = 0; if (term.find ("notxt") != std::string::npos) gl2ps_text = GL2PS_NO_TEXT; + // Default sort order optimizes for 3D plots + GLint gl2ps_sort = GL2PS_BSP_SORT; + if (term.find ("is2D") != std::string::npos) gl2ps_sort = GL2PS_NO_SORT; + while (state == GL2PS_OVERFLOW) { buffsize += 1024*1024; gl2psBeginPage ("glps_renderer figure", "Octave", viewport, - gl2ps_term, GL2PS_BSP_SORT, + gl2ps_term, gl2ps_sort, (GL2PS_SILENT | GL2PS_SIMPLE_LINE_OFFSET | GL2PS_NO_BLENDING | GL2PS_OCCLUSION_CULL | GL2PS_BEST_ROOT | gl2ps_text @@ -88,8 +84,6 @@ state = gl2psEndPage (); } - gnulib::fclose (fp); - in_draw = 0; } else
--- a/src/gl2ps-renderer.h +++ b/src/gl2ps-renderer.h @@ -31,8 +31,8 @@ glps_renderer : public opengl_renderer { public: - glps_renderer (const int _fid, const std::string& _term) - : opengl_renderer () , fid (_fid), term (_term), + glps_renderer (FILE *_fp, const std::string& _term) + : opengl_renderer () , fp (_fp), term (_term), fontsize (), fontname () { } ~glps_renderer (void) { } @@ -52,13 +52,14 @@ void draw_pixels (GLsizei w, GLsizei h, GLenum format, GLenum type, const GLvoid *data); - void set_linestyle (const std::string& s, bool use_stipple) + void set_linestyle (const std::string& s, bool use_stipple = false) { opengl_renderer::set_linestyle (s, use_stipple); - if (use_stipple) + + if (s == "-" && ! use_stipple) + gl2psDisable (GL2PS_LINE_STIPPLE); + else gl2psEnable (GL2PS_LINE_STIPPLE); - else - gl2psDisable (GL2PS_LINE_STIPPLE); } void set_polygon_offset (bool on, double offset = 0.0) @@ -77,7 +78,7 @@ private: int alignment_to_mode (int ha, int va) const; - int fid; + FILE *fp; caseless_str term; double fontsize; std::string fontname;
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -1967,13 +1967,13 @@ } /* -%!# test set with name, value pairs +## test set with name, value pairs %!test -%! set(gcf, "visible", "off"); -%! h = plot (1:10, 10:-1:1); -%! set (h, "linewidth", 10, "marker", "x"); -%! assert (get (h, "linewidth"), 10); -%! assert (get (h, "marker"), "x"); +%! set (gcf, "visible", "off"); +%! h = plot (1:10, 10:-1:1); +%! set (h, "linewidth", 10, "marker", "x"); +%! assert (get (h, "linewidth"), 10); +%! assert (get (h, "marker"), "x"); */ // Set properties given in two cell arrays containing names and values. @@ -2002,34 +2002,34 @@ } /* -%!# test set with cell array arguments +## test set with cell array arguments %!test -%! set (gcf, "visible", "off"); -%! h = plot (1:10, 10:-1:1); -%! set (h, {"linewidth", "marker"}, {10, "x"}); -%! assert (get(h, "linewidth"), 10); -%! assert (get(h, "marker"), "x"); - -%!# test set with multiple handles and cell array arguments +%! set (gcf, "visible", "off"); +%! h = plot (1:10, 10:-1:1); +%! set (h, {"linewidth", "marker"}, {10, "x"}); +%! assert (get (h, "linewidth"), 10); +%! assert (get (h, "marker"), "x"); + +## test set with multiple handles and cell array arguments %!test -%! set (gcf, "visible", "off"); -%! h = plot (1:10, 10:-1:1, 1:10, 1:10); -%! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"}); -%! assert (get (h, "linewidth"), {10; 5}); -%! assert (get (h, "marker"), {"x"; "o"}); -%! set (h, {"linewidth", "marker"}, {10, "x"}); -%! assert (get (h, "linewidth"), {10; 10}); -%! assert (get (h, "marker"), {"x"; "x"}); +%! set (gcf, "visible", "off"); +%! h = plot (1:10, 10:-1:1, 1:10, 1:10); +%! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"}); +%! assert (get (h, "linewidth"), {10; 5}); +%! assert (get (h, "marker"), {"x"; "o"}); +%! set (h, {"linewidth", "marker"}, {10, "x"}); +%! assert (get (h, "linewidth"), {10; 10}); +%! assert (get (h, "marker"), {"x"; "x"}); %!error <set: number of graphics handles must match number of value rows> -%! set (gcf, "visible", "off"); -%! h = plot (1:10, 10:-1:1, 1:10, 1:10); -%! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"; 7, "."}); +%! set (gcf, "visible", "off"); +%! h = plot (1:10, 10:-1:1, 1:10, 1:10); +%! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"; 7, "."}); %!error <set: number of names must match number of value columns> -%! set (gcf, "visible", "off"); -%! h = plot (1:10, 10:-1:1, 1:10, 1:10); -%! set (h, {"linewidth"}, {10, "x"; 5, "o"}); +%! set (gcf, "visible", "off"); +%! h = plot (1:10, 10:-1:1, 1:10, 1:10); +%! set (h, {"linewidth"}, {10, "x"; 5, "o"}); */ // Set properties given in a struct array @@ -2051,16 +2051,16 @@ } /* -%!# test set with struct arguments +## test set with struct arguments %!test -%! set (gcf, "visible", "off"); -%! h = plot (1:10, 10:-1:1); -%! set (h, struct ("linewidth", 10, "marker", "x")); -%! assert (get (h, "linewidth"), 10); -%! assert (get (h, "marker"), "x"); -%! h = plot (1:10, 10:-1:1, 1:10, 1:10); -%! set (h, struct ("linewidth", {5, 10})); -%! assert (get(h, "linewidth"), {10; 10}); +%! set (gcf, "visible", "off"); +%! h = plot (1:10, 10:-1:1); +%! set (h, struct ("linewidth", 10, "marker", "x")); +%! assert (get (h, "linewidth"), 10); +%! assert (get (h, "marker"), "x"); +%! h = plot (1:10, 10:-1:1, 1:10, 1:10); +%! set (h, struct ("linewidth", {5, 10})); +%! assert (get (h, "linewidth"), {10; 10}); */ // Set a property to a value or to its (factory) default value. @@ -2101,15 +2101,15 @@ } /* -%!# test setting of default values +## test setting of default values %!test -%! set (gcf, "visible", "off"); -%! h = plot (1:10, 10:-1:1); -%! set (0, "defaultlinelinewidth", 20); -%! set (h, "linewidth", "default"); -%! assert (get (h, "linewidth"), 20); -%! set (h, "linewidth", "factory"); -%! assert (get (h, "linewidth"), 0.5); +%! set (gcf, "visible", "off"); +%! h = plot (1:10, 10:-1:1); +%! set (0, "defaultlinelinewidth", 20); +%! set (h, "linewidth", "default"); +%! assert (get (h, "linewidth"), 20); +%! set (h, "linewidth", "factory"); +%! assert (get (h, "linewidth"), 0.5); */ static double @@ -3055,19 +3055,19 @@ /* %!test -%! set (0, "units", "pixels") +%! set (0, "units", "pixels"); %! sz = get (0, "screensize") - [1, 1, 0, 0]; %! dpi = get (0, "screenpixelsperinch"); -%! set (0, "units", "inches") -%! assert (get (0, "screensize"), sz / dpi, 0.5 / dpi) -%! set (0, "units", "centimeters") -%! assert (get (0, "screensize"), sz / dpi * 2.54, 0.5 / dpi * 2.54) -%! set (0, "units", "points") -%! assert (get (0, "screensize"), sz / dpi * 72, 0.5 / dpi * 72) -%! set (0, "units", "normalized") -%! assert (get (0, "screensize"), [0.0, 0.0, 1.0, 1.0]) -%! set (0, "units", "pixels") -%! assert (get (0, "screensize"), sz + [1, 1, 0, 0]) +%! set (0, "units", "inches"); +%! assert (get (0, "screensize"), sz / dpi, 0.5 / dpi); +%! set (0, "units", "centimeters"); +%! assert (get (0, "screensize"), sz / dpi * 2.54, 0.5 / dpi * 2.54); +%! set (0, "units", "points"); +%! assert (get (0, "screensize"), sz / dpi * 72, 0.5 / dpi * 72); +%! set (0, "units", "normalized"); +%! assert (get (0, "screensize"), [0.0, 0.0, 1.0, 1.0]); +%! set (0, "units", "pixels"); +%! assert (get (0, "screensize"), sz + [1, 1, 0, 0]); */ void @@ -3656,6 +3656,11 @@ // update_papersize and update_papertype papertype.set (typ); } + if (get_paperorientation () == "landscape") + { + std::swap (sz(0), sz(1)); + papersize.set (octave_value (sz)); + } } void @@ -3681,22 +3686,23 @@ %!test %! figure (1, "visible", false); %! tol = 100 * eps (); -%! set (gcf (), "paperorientation", "PORTRAIT") -%! set (gcf (), "paperunits", "inches") -%! set (gcf (), "papertype", "USletter") -%! assert (get (gcf (), "papersize"), [8.5, 11.0], tol) -%! set (gcf (), "paperorientation", "Landscape") -%! assert (get (gcf (), "papersize"), [11.0, 8.5], tol) -%! set (gcf (), "paperunits", "centimeters") -%! assert (get (gcf (), "papersize"), [11.0, 8.5] * 2.54, tol) +%! ## UPPER case and MiXed case is part of test and should not be changed. +%! set (gcf (), "paperorientation", "PORTRAIT"); +%! set (gcf (), "paperunits", "inches"); +%! set (gcf (), "papertype", "USletter"); +%! assert (get (gcf (), "papersize"), [8.5, 11.0], tol); +%! set (gcf (), "paperorientation", "Landscape"); +%! assert (get (gcf (), "papersize"), [11.0, 8.5], tol); +%! set (gcf (), "paperunits", "centimeters"); +%! assert (get (gcf (), "papersize"), [11.0, 8.5] * 2.54, tol); %! set (gcf (), "papertype", "a4"); -%! assert (get (gcf (), "papersize"), [29.7, 21.0], tol) -%! set (gcf (), "paperunits", "inches", "papersize", [8.5, 11.0]) -%! assert (get (gcf (), "papertype"), "usletter") -%! assert (get (gcf (), "paperorientation"), "portrait") -%! set (gcf (), "papersize", [11.0, 8.5]) -%! assert (get (gcf (), "papertype"), "usletter") -%! assert (get (gcf (), "paperorientation"), "landscape") +%! assert (get (gcf (), "papersize"), [29.7, 21.0], tol); +%! set (gcf (), "paperunits", "inches", "papersize", [8.5, 11.0]); +%! assert (get (gcf (), "papertype"), "usletter"); +%! assert (get (gcf (), "paperorientation"), "portrait"); +%! set (gcf (), "papersize", [11.0, 8.5]); +%! assert (get (gcf (), "papertype"), "usletter"); +%! assert (get (gcf (), "paperorientation"), "landscape"); */ void @@ -3722,13 +3728,13 @@ /* %!test -%! figure (1, "visible", false) -%! set (0, "units", "pixels") +%! figure (1, "visible", false); +%! set (0, "units", "pixels"); %! rsz = get (0, "screensize"); -%! set (gcf (), "units", "pixels") +%! set (gcf (), "units", "pixels"); %! fsz = get (gcf (), "position"); -%! set (gcf (), "units", "normalized") -%! assert (get (gcf (), "position"), (fsz - [1, 1, 0, 0]) ./ rsz([3, 4, 3, 4])) +%! set (gcf (), "units", "normalized"); +%! assert (get (gcf (), "position"), (fsz - [1, 1, 0, 0]) ./ rsz([3, 4, 3, 4])); */ std::string @@ -4933,32 +4939,29 @@ Matrix viewmat = get_view ().matrix_value (); nearhoriz = std::abs(viewmat(1)) <= 5; - update_ticklengths (); -} - -void -axes::properties::update_ticklengths (void) + update_ticklength (); +} + +void +axes::properties::update_ticklength (void) { bool mode2d = (((xstate > AXE_DEPTH_DIR ? 1 : 0) + (ystate > AXE_DEPTH_DIR ? 1 : 0) + (zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2); + if (tickdirmode_is ("auto")) - { - // FIXME: tickdir should be updated (code below comes - // from JHandles) - //autoMode++; - //TickDir.set(mode2d ? "in" : "out", true); - //autoMode--; - } - - //double ticksign = (tickdir_is ("in") ? -1 : 1); - double ticksign = (tickdirmode_is ("auto") ? - (mode2d ? -1 : 1) : - (tickdir_is ("in") ? -1 : 1)); - // FIXME: use ticklength property - xticklen = ticksign*7; - yticklen = ticksign*7; - zticklen = ticksign*7; + tickdir.set (mode2d ? "in" : "out", true); + + double ticksign = (tickdir_is ("in") ? -1 : 1); + + Matrix bbox = get_boundingbox (true); + Matrix ticklen = get_ticklength ().matrix_value (); + ticklen(0) = ticklen(0) * std::max (bbox(2), bbox(3)); + ticklen(1) = ticklen(1) * std::max (bbox(2), bbox(3)); + + xticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1)); + yticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1)); + zticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1)); xtickoffset = (mode2d ? std::max (0., xticklen) : std::abs (xticklen)) + 5; ytickoffset = (mode2d ? std::max (0., yticklen) : std::abs (yticklen)) + 5; @@ -4970,6 +4973,24 @@ update_title_position (); } +/* +## FIXME: A demo can't be called in a C++ file. This should be made a test +## or moved to a .m file where it can be called. +%!demo +%! clf; +%! subplot (2,1,1); +%! plot (rand (3)); +%! xlabel xlabel; +%! ylabel ylabel; +%! title title; +%! subplot (2,1,2); +%! plot (rand (3)); +%! set (gca, "ticklength", get (gca, "ticklength") * 2, "tickdir", "out"); +%! xlabel xlabel; +%! ylabel ylabel; +%! title title; +*/ + static bool updating_xlabel_position = false; void @@ -6869,13 +6890,21 @@ Matrix text::properties::get_extent_matrix (void) const { + // FIXME: Should this function also add the (x,y) base position? return extent.get ().matrix_value (); } octave_value text::properties::get_extent (void) const { + // FIXME: This doesn't work right for 3D plots. + // (It doesn't in Matlab either, at least not in version 6.5.) Matrix m = extent.get ().matrix_value (); + Matrix pos = get_position ().matrix_value (); + Matrix p = convert_text_position (pos, *this, get_units (), "pixels"); + + m(0) += p(0); + m(1) += p(1); return convert_text_position (m, *this, "pixels", get_units ()); } @@ -6923,6 +6952,10 @@ renderer.text_to_pixels (sv.join ("\n"), pixels, bbox, halign, valign, get_rotation ()); + /* The bbox is relative to the text's position. + We'll leave it that way, because get_position() does not return + valid results when the text is first constructed. + Conversion to proper coordinates is performed in get_extent. */ set_extent (bbox); #endif @@ -8583,7 +8616,7 @@ } /* -%!assert (get (findobj (0, 'Tag', 'nonexistenttag'), 'nonexistentproperty'), []) +%!assert (get (findobj (0, "Tag", "nonexistenttag"), "nonexistentproperty"), []) */ // Return all properties from the graphics handle @var{h}.
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -3824,7 +3824,7 @@ radio_property projection , "{orthographic}|perpective" radio_property tickdir mu , "{in}|out" radio_property tickdirmode u , "{auto}|manual" - array_property ticklength , default_axes_ticklength () + array_property ticklength u , default_axes_ticklength () array_property tightinset r , Matrix (1, 4, 0.0) // FIXME -- uicontextmenu should be moved here. radio_property units SU , "{normalized}|inches|centimeters|points|pixels|characters" @@ -3897,9 +3897,9 @@ void update_ydir (void) { update_camera (); update_axes_layout (); } void update_zdir (void) { update_camera (); update_axes_layout (); } - void update_ticklengths (void); - void update_tickdir (void) { update_ticklengths (); } - void update_tickdirmode (void) { update_ticklengths (); } + void update_ticklength (void); + void update_tickdir (void) { update_ticklength (); } + void update_tickdirmode (void) { update_ticklength (); } void update_xtick (void) { @@ -4235,13 +4235,38 @@ public: double get_fontsize_points (double box_pix_height = 0) const; + void set_position (const octave_value& val) + { + if (! error_state) + { + octave_value new_val (val); + + if (new_val.numel () == 2) + { + dim_vector dv (1, 3); + + new_val = new_val.resize (dv, true); + } + + if (position.set (new_val, false)) + { + set_positionmode ("manual"); + update_position (); + position.run_listeners (POSTSET); + mark_modified (); + } + else + set_positionmode ("manual"); + } + } + // See the genprops.awk script for an explanation of the // properties declarations. BEGIN_PROPERTIES (text) text_label_property string u , "" radio_property units u , "{data}|pixels|normalized|inches|centimeters|points" - array_property position mu , Matrix (1, 3, 0.0) + array_property position smu , Matrix (1, 3, 0.0) double_property rotation mu , 0 radio_property horizontalalignment mu , "{left}|center|right" color_property color u , color_values (0, 0, 0) @@ -4287,7 +4312,6 @@ protected: void init (void) { - position.add_constraint (dim_vector (1, 2)); position.add_constraint (dim_vector (1, 3)); cached_units = get_units (); update_font ();
--- a/src/mappers.cc +++ b/src/mappers.cc @@ -112,7 +112,7 @@ %!test %! x = single ([1, rt3/2, rt2/2, 1/2, 0, -1/2, -rt2/2, -rt3/2, -1]); %! v = single ([0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]); -%! assert (acos (x), v, sqrt (eps ('single'))); +%! assert (acos (x), v, sqrt (eps ("single"))); %!error acos () %!error acos (1, 2) @@ -143,7 +143,7 @@ %!test %! x = single ([1, 0, -1, 0]); %! v = single ([0, pi/2*i, pi*i, pi/2*i]); -%! assert (acosh (x), v, sqrt (eps ('single'))); +%! assert (acosh (x), v, sqrt (eps ("single"))); %!error acosh () %!error acosh (1, 2) @@ -213,7 +213,7 @@ %! assert (arg (single (-1)), single (pi)); %! endif %!assert (arg (single (-i)), single (-pi/2)) -%!assert (arg (single ([1, i; -1, -i])), single ([0, pi/2; pi, -pi/2]), 2e1*eps ('single')) +%!assert (arg (single ([1, i; -1, -i])), single ([0, pi/2; pi, -pi/2]), 2e1*eps ("single")) %!error arg () %!error arg (1, 2) @@ -272,7 +272,7 @@ %!test %! v = single ([0, pi/2*i, 0, -pi/2*i]); %! x = single ([0, i, 0, -i]); -%! assert (asinh (x), v, sqrt (eps ('single'))); +%! assert (asinh (x), v, sqrt (eps ("single"))); %!error asinh () %!error asinh (1, 2) @@ -307,7 +307,7 @@ %!test %! v = single ([0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]); %! x = single ([0, rt3/3, 1, rt3, -rt3, -1, -rt3/3, 0]); -%! assert (atan (x), v, sqrt (eps ('single'))); +%! assert (atan (x), v, sqrt (eps ("single"))); %!error atan () %!error atan (1, 2) @@ -338,7 +338,7 @@ %!test %! v = single ([0, 0]); %! x = single ([0, 0]); -%! assert (atanh (x), v, sqrt (eps ('single'))); +%! assert (atanh (x), v, sqrt (eps ("single"))); %!error atanh () %!error atanh (1, 2) @@ -402,16 +402,16 @@ } /* -%% double precision +## double precision %!assert (ceil ([2, 1.1, -1.1, -1]), [2, 2, -1, -1]) -%% complex double precison +## complex double precison %!assert (ceil ([2+2i, 1.1+1.1i, -1.1-1.1i, -1-i]), [2+2i, 2+2i, -1-i, -1-i]) -%% single precision +## single precision %!assert (ceil (single ([2, 1.1, -1.1, -1])), single ([2, 2, -1, -1])) -%% complex single precision +## complex single precision %!assert (ceil (single ([2+2i, 1.1+1.1i, -1.1-1.1i, -1-i])), single ([2+2i, 2+2i, -1-i, -1-i])) %!error ceil () @@ -488,7 +488,7 @@ %! rt3 = sqrt (3); %! x = single ([0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]); %! v = single ([1, rt3/2, rt2/2, 1/2, 0, -1/2, -rt2/2, -rt3/2, -1]); -%! assert (cos (x), v, sqrt (eps ('single'))); +%! assert (cos (x), v, sqrt (eps ("single"))); %!error cos () %!error cos (1, 2) @@ -519,7 +519,7 @@ %!test %! x = single ([0, pi/2*i, pi*i, 3*pi/2*i]); %! v = single ([1, 0, -1, 0]); -%! assert (cosh (x), v, sqrt (eps ('single'))); +%! assert (cosh (x), v, sqrt (eps ("single"))); %!error cosh () %!error cosh (1, 2) @@ -538,12 +538,11 @@ \n\ @example\n\ @group\n\ -@c spacing appears odd here, but is correct after Makeinfo\n\ - z\n\ - /\n\ -erf (z) = (2/sqrt (pi)) | e^(-t^2) dt\n\ - /\n\ - t=0\n\ + z\n\ + 2 /\n\ +erf (z) = --------- * | e^(-t^2) dt\n\ + sqrt (pi) /\n\ + t=0\n\ @end group\n\ @end example\n\ \n\ @@ -568,10 +567,10 @@ %!test %! x = [0,.5,1]; %! v = [0, .520499877813047, .842700792949715]; -%! assert (all (abs (erf (x)-v) < 1.e-10)); -%! assert (all (abs (erf (-x)+v) < 1.e-10)); -%! assert (all (abs (erfc (x)+v-1) < 1.e-10)); -%! assert (all (abs (erfinv (v)-x) < 1.e-10)); +%! assert (erf (x), v, 1.e-10); +%! assert (erf (-x), -v, 1.e-10); +%! assert (erfc (x), 1-v, 1.e-10); +%! assert (erfinv (v), x, 1.e-10); %!test %! a = -1i*sqrt (single (-1/(6.4187*6.4187))); @@ -580,10 +579,10 @@ %!test %! x = single ([0,.5,1]); %! v = single ([0, .520499877813047, .842700792949715]); -%! assert (all (abs (erf (x)-v) < 1.e-6)); -%! assert (all (abs (erf (-x)+v) < 1.e-6)); -%! assert (all (abs (erfc (x)+v-1) < 1.e-6)); -%! assert (all (abs (erfinv (v)-x) < 1.e-6)); +%! assert (erf (x), v, 1.e-6); +%! assert (erf (-x), -v, 1.e-6); +%! assert (erfc (x), 1-v, 1.e-6); +%! assert (erfinv (v), x, 1.e-6); %!error erf () %!error erf (1, 2) @@ -610,16 +609,16 @@ } /* -%% middle region +## middle region %!assert (erf (erfinv ([-0.9 -0.3 0 0.4 0.8])), [-0.9 -0.3 0 0.4 0.8], eps) %!assert (erf (erfinv (single ([-0.9 -0.3 0 0.4 0.8]))), single ([-0.9 -0.3 0 0.4 0.8]), 1e-8) -%% tail region +## tail region %!assert (erf (erfinv ([-0.999 -0.99 0.9999 0.99999])), [-0.999 -0.99 0.9999 0.99999], eps) %!assert (erf (erfinv (single ([-0.999 -0.99 0.9999 0.99999]))), single ([-0.999 -0.99 0.9999 0.99999]), 1e-8) -%% backward - loss of accuracy +## backward - loss of accuracy %!assert (erfinv (erf ([-3 -1 -0.4 0.7 1.3 2.8])), [-3 -1 -0.4 0.7 1.3 2.8], -1e-12) %!assert (erfinv (erf (single ([-3 -1 -0.4 0.7 1.3 2.8]))), single ([-3 -1 -0.4 0.7 1.3 2.8]), -1e-4) -%% exceptional +## exceptional %!assert (erfinv ([-1, 1, 1.1, -2.1]), [-Inf, Inf, NaN, NaN]) %!error erfinv (1+2i) @@ -687,7 +686,7 @@ } /* -%% FIXME: Need a test for erfcx +## FIXME: Need a test for erfcx %!error erfcx () %!error erfcx (1, 2) @@ -720,8 +719,8 @@ /* %!assert (exp ([0, 1, -1, -1000]), [1, e, 1/e, 0], sqrt (eps)) %!assert (exp (1+i), e * (cos (1) + sin (1) * i), sqrt (eps)) -%!assert (exp (single ([0, 1, -1, -1000])), single ([1, e, 1/e, 0]), sqrt (eps ('single'))) -%!assert (exp (single (1+i)), single (e * (cos (1) + sin (1) * i)), sqrt (eps ('single'))) +%!assert (exp (single ([0, 1, -1, -1000])), single ([1, e, 1/e, 0]), sqrt (eps ("single"))) +%!assert (exp (single (1+i)), single (e * (cos (1) + sin (1) * i)), sqrt (eps ("single"))) %!assert (exp ([Inf, -Inf, NaN]), [Inf 0 NaN]) %!assert (exp (single ([Inf, -Inf, NaN])), single ([Inf 0 NaN])) @@ -885,9 +884,8 @@ \n\ @example\n\ @group\n\ -@c spacing appears odd here, but is correct after Makeinfo\n\ - infinity\n\ - /\n\ + infinity\n\ + /\n\ gamma (z) = | t^(z-1) exp (-t) dt.\n\ /\n\ t=0\n\ @@ -924,7 +922,7 @@ %!test %! x = single ([.5, 1, 1.5, 2, 3, 4, 5]); %! v = single ([sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24]); -%! assert (gamma (x), v, sqrt (eps ('single'))); +%! assert (gamma (x), v, sqrt (eps ("single"))); %!test %! x = [-1, 0, 1, Inf]; @@ -961,7 +959,7 @@ %!assert (imag (single (1)), single (0)) %!assert (imag (single (i)), single (1)) %!assert (imag (single (1+i)), single (1)) -%!assert (imag (single ([i, 1; 1, i])), full (eye (2,'single'))) +%!assert (imag (single ([i, 1; 1, i])), full (eye (2,"single"))) %!error imag () %!error imag (1, 2) @@ -992,7 +990,7 @@ %! result(toascii ("A":"Z") + 1) = true; %! result(toascii ("0":"9") + 1) = true; %! result(toascii ("a":"z") + 1) = true; -%! assert (all (isalnum (charset) == result)); +%! assert (isalnum (charset), result); %!error isalnum () %!error isalnum (1, 2) @@ -1022,7 +1020,7 @@ %! result = false (1, 128); %! result(toascii ("A":"Z") + 1) = true; %! result(toascii ("a":"z") + 1) = true; -%! assert (all (isalpha (charset) == result)); +%! assert (isalpha (charset), result); %!error isalpha () %!error isalpha (1, 2) @@ -1049,7 +1047,7 @@ %!test %! charset = char (0:127); %! result = true (1, 128); -%! assert (all (isascii (charset) == result)); +%! assert (isascii (charset), result); %!error isascii () %!error isascii (1, 2) @@ -1078,7 +1076,7 @@ %! result = false (1, 128); %! result(1:32) = true; %! result(128) = true; -%! assert (all (iscntrl (charset) == result)); +%! assert (iscntrl (charset), result); %!error iscntrl () %!error iscntrl (1, 2) @@ -1106,7 +1104,7 @@ %! charset = char (0:127); %! result = false (1, 128); %! result(toascii ("0":"9") + 1) = true; -%! assert (all (isdigit (charset) == result)); +%! assert (isdigit (charset), result); %!error isdigit () %!error isdigit (1, 2) @@ -1177,7 +1175,7 @@ %! charset = char (0:127); %! result = false (1, 128); %! result(34:127) = true; -%! assert (all (isgraph (charset) == result)); +%! assert (isgraph (charset), result); %!error isgraph () %!error isgraph (1, 2) @@ -1205,7 +1203,7 @@ %! charset = char (0:127); %! result = false (1, 128); %! result(toascii ("a":"z") + 1) = true; -%! assert (all (islower (charset) == result)); +%! assert (islower (charset), result); %!error islower () %!error islower (1, 2) @@ -1318,7 +1316,7 @@ %! charset = char (0:127); %! result = false (1, 128); %! result(33:127) = true; -%! assert (all (isprint (charset) == result)); +%! assert (isprint (charset), result); %!error isprint () %!error isprint (1, 2) @@ -1349,7 +1347,7 @@ %! result(59:65) = true; %! result(92:97) = true; %! result(124:127) = true; -%! assert (all (ispunct (charset) == result)); +%! assert (ispunct (charset), result); %!error ispunct () %!error ispunct (1, 2) @@ -1378,7 +1376,7 @@ %! charset = char (0:127); %! result = false (1, 128); %! result(toascii (" \f\n\r\t\v") + 1) = true; -%! assert (all (isspace (charset) == result)); +%! assert (isspace (charset), result); %!error isspace () %!error isspace (1, 2) @@ -1406,7 +1404,7 @@ %! charset = char (0:127); %! result = false (1, 128); %! result(toascii ("A":"Z") + 1) = true; -%! assert (all (isupper (charset) == result)); +%! assert (isupper (charset), result); %!error isupper () %!error isupper (1, 2) @@ -1436,7 +1434,7 @@ %! result(toascii ("A":"F") + 1) = true; %! result(toascii ("0":"9") + 1) = true; %! result(toascii ("a":"f") + 1) = true; -%! assert (all (isxdigit (charset) == result)); +%! assert (isxdigit (charset), result); %!error isxdigit () %!error isxdigit (1, 2) @@ -1462,30 +1460,30 @@ /* %!test %! a = -1i*sqrt (-1/(6.4187*6.4187)); -%! assert (lgamma(a), lgamma(real(a))); +%! assert (lgamma (a), lgamma (real (a))); %!test %! x = [.5, 1, 1.5, 2, 3, 4, 5]; %! v = [sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24]; -%! assert (lgamma(x), log(v), sqrt (eps)) +%! assert (lgamma (x), log (v), sqrt (eps)) %!test %! a = single (-1i*sqrt (-1/(6.4187*6.4187))); -%! assert (lgamma(a), lgamma(real(a))); +%! assert (lgamma (a), lgamma (real (a))); %!test %! x = single ([.5, 1, 1.5, 2, 3, 4, 5]); %! v = single ([sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24]); -%! assert (lgamma(x), log(v), sqrt (eps ('single'))) +%! assert (lgamma (x), log (v), sqrt (eps ("single"))) %!test %! x = [-1, 0, 1, Inf]; %! v = [Inf, Inf, 0, Inf]; -%! assert (lgamma(x), v); -%! assert (lgamma(single (x)), single (v)); +%! assert (lgamma (x), v); +%! assert (lgamma (single (x)), single (v)); -%!error lgamma() -%!error lgamma(1,2) +%!error lgamma () +%!error lgamma (1,2) */ DEFUN (log, args, , @@ -1514,10 +1512,10 @@ /* %!assert (log ([1, e, e^2]), [0, 1, 2], sqrt (eps)) -%!assert (log ([-0.5, -1.5, -2.5]), log([0.5, 1.5, 2.5]) + pi*1i, sqrt (eps)) +%!assert (log ([-0.5, -1.5, -2.5]), log ([0.5, 1.5, 2.5]) + pi*1i, sqrt (eps)) -%!assert (log (single ([1, e, e^2])), single ([0, 1, 2]), sqrt (eps ('single'))) -%!assert (log (single ([-0.5, -1.5, -2.5])), single (log([0.5, 1.5, 2.5]) + pi*1i), 4*eps ('single')) +%!assert (log (single ([1, e, e^2])), single ([0, 1, 2]), sqrt (eps ("single"))) +%!assert (log (single ([-0.5, -1.5, -2.5])), single (log ([0.5, 1.5, 2.5]) + pi*1i), 4*eps ("single")) %!error log () %!error log (1, 2) @@ -1541,7 +1539,7 @@ /* %!assert (log10 ([0.01, 0.1, 1, 10, 100]), [-2, -1, 0, 1, 2], sqrt (eps)) -%!assert (log10 (single ([0.01, 0.1, 1, 10, 100])), single ([-2, -1, 0, 1, 2]), sqrt (eps ('single'))) +%!assert (log10 (single ([0.01, 0.1, 1, 10, 100])), single ([-2, -1, 0, 1, 2]), sqrt (eps ("single"))) %!error log10 () %!error log10 (1, 2) @@ -1572,7 +1570,7 @@ /* %!assert (log1p ([0, 2*eps, -2*eps]), [0, 2*eps, -2*eps], 1e-29) -%!assert (log1p (single ([0, 2*eps, -2*eps])), single([0, 2*eps, -2*eps]), 1e-29) +%!assert (log1p (single ([0, 2*eps, -2*eps])), single ([0, 2*eps, -2*eps]), 1e-29) %!error log1p () %!error log1p (1, 2) @@ -1603,7 +1601,7 @@ %!assert (real (single (1)), single (1)) %!assert (real (single (i)), single (0)) %!assert (real (single (1+i)), single (1)) -%!assert (real (single ([1, i; i, 1])), full (eye (2,'single'))) +%!assert (real (single ([1, i; i, 1])), full (eye (2,"single"))) %!error real () %!error real (1, 2) @@ -1773,7 +1771,7 @@ %!test %! x = single ([0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]); %! v = single ([0, 1/2, rt2/2, rt3/2, 1, rt3/2, rt2/2, 1/2, 0]); -%! assert (sin (x), v, sqrt (eps ('single'))); +%! assert (sin (x), v, sqrt (eps ("single"))); %!error sin () %!error sin (1, 2) @@ -1804,7 +1802,7 @@ %!test %! x = single ([0, pi/2*i, pi*i, 3*pi/2*i]); %! v = single ([0, i, 0, -i]); -%! assert (sinh (x), v, sqrt (eps ('single'))); +%! assert (sinh (x), v, sqrt (eps ("single"))); %!error sinh () %!error sinh (1, 2) @@ -1836,8 +1834,8 @@ %!assert (sqrt (single (4)), single (2)) %!assert (sqrt (single (-1)), single (i)) -%!assert (sqrt (single (1+i)), single (exp (0.5 * log (1+i))), sqrt (eps ('single'))) -%!assert (sqrt (single ([4, -4; i, 1-i])), single ([2, 2i; exp(0.5 * log (i)), exp(0.5 * log (1-i))]), sqrt (eps ('single'))) +%!assert (sqrt (single (1+i)), single (exp (0.5 * log (1+i))), sqrt (eps ("single"))) +%!assert (sqrt (single ([4, -4; i, 1-i])), single ([2, 2i; exp(0.5 * log (i)), exp(0.5 * log (1-i))]), sqrt (eps ("single"))) %!error sqrt () %!error sqrt (1, 2) @@ -1872,7 +1870,7 @@ %!test %! x = single ([0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]); %! v = single ([0, rt3/3, 1, rt3, -rt3, -1, -rt3/3, 0]); -%! assert (tan (x), v, sqrt (eps ('single'))); +%! assert (tan (x), v, sqrt (eps ("single"))); %!error tan () %!error tan (1, 2) @@ -1903,7 +1901,7 @@ %!test %! x = single ([0, pi*i]); %! v = single ([0, 0]); -%! assert (tanh (x), v, sqrt (eps ('single'))); +%! assert (tanh (x), v, sqrt (eps ("single"))); %!error tanh () %!error tanh (1, 2) @@ -1974,25 +1972,25 @@ DEFALIAS (lower, tolower); /* -%!assert (tolower("OCTAVE"), "octave") -%!assert (tolower("123OCTave!_&"), "123octave!_&") -%!assert (tolower({"ABC", "DEF", {"GHI", {"JKL"}}}), {"abc", "def", {"ghi", {"jkl"}}}) -%!assert (tolower(["ABC"; "DEF"]), ["abc"; "def"]) -%!assert (tolower({["ABC"; "DEF"]}), {["abc";"def"]}) -%!assert (tolower(68), "d") -%!assert (tolower({[68, 68; 68, 68]}), {["dd";"dd"]}) +%!assert (tolower ("OCTAVE"), "octave") +%!assert (tolower ("123OCTave!_&"), "123octave!_&") +%!assert (tolower ({"ABC", "DEF", {"GHI", {"JKL"}}}), {"abc", "def", {"ghi", {"jkl"}}}) +%!assert (tolower (["ABC"; "DEF"]), ["abc"; "def"]) +%!assert (tolower ({["ABC"; "DEF"]}), {["abc";"def"]}) +%!assert (tolower (68), "d") +%!assert (tolower ({[68, 68; 68, 68]}), {["dd";"dd"]}) %!test -%! a(3,3,3,3) = "D"; -%! assert(tolower(a)(3,3,3,3), "d"); +%! a(3,3,3,3) = "D"; +%! assert (tolower (a)(3,3,3,3), "d"); %!test %! charset = char (0:127); %! result = charset; -%! result(toascii ("A":"Z") + 1) = result(toascii ("a":"z") + 1); -%! assert (all (tolower (charset) == result)); +%! result (toascii ("A":"Z") + 1) = result (toascii ("a":"z") + 1); +%! assert (tolower (charset), result); -%!error <Invalid call to tolower> tolower() -%!error <Invalid call to tolower> lower() +%!error <Invalid call to tolower> lower () +%!error <Invalid call to tolower> tolower () %!error tolower (1, 2) */ @@ -2033,16 +2031,16 @@ %!assert (toupper (100), "D") %!assert (toupper ({[100, 100; 100, 100]}), {["DD";"DD"]}) %!test -%! a(3,3,3,3) = "d"; -%! assert(toupper (a)(3,3,3,3), "D"); +%! a(3,3,3,3) = "d"; +%! assert (toupper (a)(3,3,3,3), "D"); %!test %! charset = char (0:127); %! result = charset; -%! result(toascii ("a":"z") + 1) = result(toascii ("A":"Z") + 1); -%! assert (all (toupper (charset) == result)); +%! result (toascii ("a":"z") + 1) = result (toascii ("A":"Z") + 1); +%! assert (toupper (charset), result); -%!error <Invalid call to toupper> toupper() -%!error <Invalid call to toupper> upper() +%!error <Invalid call to toupper> toupper () +%!error <Invalid call to toupper> upper () %!error toupper (1, 2) */
--- a/src/oct-map.cc +++ b/src/oct-map.cc @@ -448,10 +448,10 @@ } /* -%!# test preservation of xkeys by squeeze +## test preservation of xkeys by squeeze %!test -%! x(1,1,1,1).d = 10; x(3,5,1,7).a = "b"; x(2,4,1,7).f = 27; -%! assert (fieldnames (squeeze (x)), {"d"; "a"; "f"}); +%! x(1,1,1,1).d = 10; x(3,5,1,7).a = "b"; x(2,4,1,7).f = 27; +%! assert (fieldnames (squeeze (x)), {"d"; "a"; "f"}); */ octave_map @@ -482,10 +482,10 @@ } /* -%!# test preservation of key order by permute +## test preservation of key order by permute %!test -%! x(1,1,1,1).d = 10; x(3,5,1,7).a = "b"; x(2,4,1,7).f = 27; -%! assert (fieldnames (permute (x, [3, 4, 1, 2])), {"d"; "a"; "f"}); +%! x(1,1,1,1).d = 10; x(3,5,1,7).a = "b"; x(2,4,1,7).f = 27; +%! assert (fieldnames (permute (x, [3, 4, 1, 2])), {"d"; "a"; "f"}); */ octave_map @@ -507,12 +507,12 @@ } /* -%!# test preservation of key order by transpose +## test preservation of key order by transpose %!test -%! x(1,1).d = 10; x(3,5).a = "b"; x(2,4).f = 27; -%! assert (fieldnames (transpose (x)), {"d"; "a"; "f"}); -%! assert (fieldnames (x'), {"d"; "a"; "f"}); -%! assert (fieldnames (x.'), {"d"; "a"; "f"}); +%! x(1,1).d = 10; x(3,5).a = "b"; x(2,4).f = 27; +%! assert (fieldnames (transpose (x)), {"d"; "a"; "f"}); +%! assert (fieldnames (x'), {"d"; "a"; "f"}); +%! assert (fieldnames (x.'), {"d"; "a"; "f"}); */ octave_map @@ -542,10 +542,10 @@ } /* -%!# test preservation of key order by reshape +## test preservation of key order by reshape %!test -%! x(1,1).d = 10; x(4,6).a = "b"; x(2,4).f = 27; -%! assert (fieldnames (reshape (x, 3, 8)), {"d"; "a"; "f"}); +%! x(1,1).d = 10; x(4,6).a = "b"; x(2,4).f = 27; +%! assert (fieldnames (reshape (x, 3, 8)), {"d"; "a"; "f"}); */ void @@ -804,23 +804,23 @@ } /* -%!# test preservation of key order by concatenation +## test preservation of key order by concatenation %!test -%! x(1, 1).d = 10; x(4, 6).a = "b"; x(2, 4).f = 27; -%! y(1, 6).f = 11; y(1, 6).a = "c"; y(1, 6).d = 33; -%! assert (fieldnames ([x; y]), {"d"; "a"; "f"}); +%! x(1, 1).d = 10; x(4, 6).a = "b"; x(2, 4).f = 27; +%! y(1, 6).f = 11; y(1, 6).a = "c"; y(1, 6).d = 33; +%! assert (fieldnames ([x; y]), {"d"; "a"; "f"}); %!test -%! s = struct (); -%! sr = [s,s]; -%! sc = [s;s]; -%! sm = [s,s;s,s]; -%! assert (nfields (sr), 0); -%! assert (nfields (sc), 0); -%! assert (nfields (sm), 0); -%! assert (size (sr), [1, 2]); -%! assert (size (sc), [2, 1]); -%! assert (size (sm), [2, 2]); +%! s = struct (); +%! sr = [s,s]; +%! sc = [s;s]; +%! sm = [s,s;s,s]; +%! assert (nfields (sr), 0); +%! assert (nfields (sc), 0); +%! assert (nfields (sm), 0); +%! assert (size (sr), [1, 2]); +%! assert (size (sc), [2, 1]); +%! assert (size (sm), [2, 2]); */ octave_map @@ -1250,10 +1250,10 @@ } /* -%!# test preservation of key order by indexing +## test preservation of key order by indexing %!test -%! x(1, 1).d = 10; x(4, 6).a = "b"; x(2, 4).f = 27; -%! assert (fieldnames (x([1, 2], [2:5])), {"d"; "a"; "f"}); +%! x(1, 1).d = 10; x(4, 6).a = "b"; x(2, 4).f = 27; +%! assert (fieldnames (x([1, 2], [2:5])), {"d"; "a"; "f"}); */ octave_map
--- a/src/oct-stream.h +++ b/src/oct-stream.h @@ -374,9 +374,9 @@ // If the derived class is locale-aware, it must implement this function // in order to set a new locale. By default, this function avoids messing // with locales and ignores its input argument. - virtual std::locale imbue ( const std::locale & loc ) + virtual std::locale imbue ( const std::locale &) { return std::locale::classic (); } - + // Return TRUE if this stream is open. bool is_open (void) const { return open_state; }
--- a/src/octave.cc +++ b/src/octave.cc @@ -982,8 +982,8 @@ } /* -%!error argv (1); -%!assert (iscellstr (argv ())); +%!assert (iscellstr (argv ())) +%!error argv (1) */ DEFUN (program_invocation_name, args, , @@ -1009,8 +1009,8 @@ } /* -%!error program_invocation_name (1); -%!assert (ischar (program_invocation_name ())); +%!assert (ischar (program_invocation_name ())) +%!error program_invocation_name (1) */ DEFUN (program_name, args, , @@ -1032,6 +1032,6 @@ } /* -%!error program_name (1); -%!assert (ischar (program_name ())); +%!assert (ischar (program_name ())) +%!error program_name (1) */
--- a/src/ov-base.cc +++ b/src/ov-base.cc @@ -1558,14 +1558,13 @@ } /* - %!test - s = speye(3); - sparse_auto_mutate (false); - s(:, 1) = 1; - assert (typeinfo (s), "sparse matrix"); - sparse_auto_mutate (true); - s(1, :) = 1; - assert (typeinfo (s), "matrix"); - +%! s = speye (3); +%! sparse_auto_mutate (false); +%! s(:, 1) = 1; +%! assert (typeinfo (s), "sparse matrix"); +%! sparse_auto_mutate (true); +%! s(1, :) = 1; +%! assert (typeinfo (s), "matrix"); +%! sparse_auto_mutate (false); */
--- a/src/ov-bool-mat.cc +++ b/src/ov-bool-mat.cc @@ -577,11 +577,10 @@ } /* -%!shared m, s, c +%!test %! m = eye (2) != 0; %! s = !0; %! c = {"double", "single", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "logical"}; -%!test %! for i = 1:numel (c) %! assert (logical (eye (2, c{i})), m) %! assert (logical (eye (1, c{i})), s)
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -1471,14 +1471,14 @@ /* %!test -%! keys = cellstr (char (floor (rand (11,10)*24+65)))'; -%! vals = cellfun(@(x) mat2cell(rand (19,1), ones (19,1), 1), ... -%! mat2cell([1:11]', ones(11,1), 1), "uniformoutput", false)'; -%! s = struct ([keys; vals]{:}); -%! t = cell2struct ([vals{:}], keys, 2); -%! assert (s, t); -%! assert (struct2cell (s), [vals{:}]'); -%! assert (fieldnames (s), keys'); +%! keys = cellstr (char (floor (rand (11,10)*24+65)))'; +%! vals = cellfun (@(x) mat2cell (rand (19,1), ones (19,1), 1), ... +%! mat2cell ([1:11]', ones (11,1), 1), "uniformoutput", false)'; +%! s = struct ([keys; vals]{:}); +%! t = cell2struct ([vals{:}], keys, 2); +%! assert (s, t); +%! assert (struct2cell (s), [vals{:}]'); +%! assert (fieldnames (s), keys'); */ mxArray *
--- a/src/ov-fcn-handle.cc +++ b/src/ov-fcn-handle.cc @@ -1288,7 +1288,6 @@ #endif /* - %!test %! a = 2; %! f = @(x) a + x; @@ -1302,26 +1301,25 @@ %! hdld2 = hdld; %! hbi2 = hbi; %! modes = {"-text", "-binary"}; -%! if (!isempty(findstr(octave_config_info ("DEFS"),"HAVE_HDF5"))) +%! if (!isempty (findstr (octave_config_info ("DEFS"), "HAVE_HDF5"))) %! modes(end+1) = "-hdf5"; %! endif %! for i = 1:numel (modes) %! mode = modes{i}; -%! nm = tmpnam(); +%! nm = tmpnam (); %! unwind_protect %! save (mode, nm, "f2", "g2", "hm2", "hdld2", "hbi2"); %! clear f2 g2 hm2 hdld2 hbi2 %! load (nm); -%! assert (f(2),f2(2)); -%! assert (g(2),g2(2)); -%! assert (g(3),g2(3)); +%! assert (f (2), f2 (2)); +%! assert (g (2), g2 (2)); +%! assert (g (3), g2 (3)); %! unlink (nm); %! save (mode, nm, "f2", "g2", "hm2", "hdld2", "hbi2"); %! unwind_protect_cleanup %! unlink (nm); %! end_unwind_protect %! endfor - */ void @@ -1592,7 +1590,7 @@ %! "&", "and"; %! "|", "or"}; %! for i = 1:rows (x) -%! assert (functions (str2func (x{i,1})).function, x{i,2}) +%! assert (functions (str2func (x{i,1})).function, x{i,2}); %! endfor */ @@ -1759,7 +1757,6 @@ } /* - %!function y = __testrecursionfunc (f, x, n) %! if (nargin < 3) %! n = 0; @@ -1768,12 +1765,11 @@ %! y = f (x); %! else %! n++; -%! y = __testrecursionfunc (@(x) f(2*x), x, n); +%! y = __testrecursionfunc (@(x) f (2*x), x, n); %! endif %!endfunction %! %!assert (__testrecursionfunc (@(x) x, 1), 8) - */ DEFUN (is_function_handle, args, , @@ -1802,12 +1798,11 @@ %!assert (is_function_handle (fh)) %!assert (! is_function_handle ({fh})) %!assert (! is_function_handle (1)) -%!error is_function_handle (); -%!error is_function_handle (1, 2); +%!error is_function_handle () +%!error is_function_handle (1, 2) */ - octave_fcn_binder::octave_fcn_binder (const octave_value& f, const octave_value& root, const octave_value_list& templ,
--- a/src/ov-fcn-inline.cc +++ b/src/ov-fcn-inline.cc @@ -825,9 +825,9 @@ %! fn = inline ("x.^2 + 1"); %!assert (feval (fn, 6), 37) %!assert (fn (6), 37) -%% FIXME: Need tests for other 2 calling forms of inline() +## FIXME: Need tests for other 2 calling forms of inline() -%% Test input validation +## Test input validation %!error inline () %!error <STR argument must be a string> inline (1) %!error <N must be an integer> inline ("2", ones (2,2)) @@ -867,7 +867,7 @@ %!assert (formula (fn), "x.^2 + 1") %!assert (formula (fn), char (fn)) -%% Test input validation +## Test input validation %!error formula () %!error formula (1, 2) %!error <FUN must be an inline function> formula (1) @@ -914,7 +914,7 @@ %!assert (argnames (inline ("1e-3*y + 2e4*z")), {"y"; "z"}) %!assert (argnames (inline ("2", 2)), {"x"; "P1"; "P2"}) -%% Test input validation +## Test input validation %!error argnames () %!error argnames (1, 2) %!error <FUN must be an inline function> argnames (1) @@ -1012,9 +1012,8 @@ %!assert (vectorize ("1e-3*y + 2e4*z"), "1e-3.*y + 2e4.*z") %!assert (vectorize ("2**x^5"), "2.**x.^5") -%% Test input validation +## Test input validation %!error vectorize () %!error vectorize (1, 2) %!error <FUN must be a string or inline function> vectorize (1) */ -
--- a/src/ov-flt-re-mat.cc +++ b/src/ov-flt-re-mat.cc @@ -841,7 +841,6 @@ } /* - %!assert (class (single(1)), "single") %!assert (class (single(1 + i)), "single") %!assert (class (single (int8 (1))), "single") @@ -865,6 +864,4 @@ %! y = single (x); %! assert (class (x), "double"); %! assert (class (y), "single"); - */ -
--- a/src/ov-int16.cc +++ b/src/ov-int16.cc @@ -84,13 +84,10 @@ } /* - %!assert (class (int16 (1)), "int16") %!assert (int16 (1.25), int16 (1)) %!assert (int16 (1.5), int16 (2)) %!assert (int16 (-1.5), int16 (-2)) %!assert (int16 (2^17), int16 (2^16-1)) %!assert (int16 (-2^17), int16 (-2^16)) - */ -
--- a/src/ov-int32.cc +++ b/src/ov-int32.cc @@ -84,13 +84,10 @@ } /* - %!assert (class (int32 (1)), "int32") %!assert (int32 (1.25), int32 (1)) %!assert (int32 (1.5), int32 (2)) %!assert (int32 (-1.5), int32 (-2)) %!assert (int32 (2^33), int32 (2^32-1)) %!assert (int32 (-2^33), int32 (-2^32)) - */ -
--- a/src/ov-int64.cc +++ b/src/ov-int64.cc @@ -84,13 +84,10 @@ } /* - %!assert (class (int64 (1)), "int64") %!assert (int64 (1.25), int64 (1)) %!assert (int64 (1.5), int64 (2)) %!assert (int64 (-1.5), int64 (-2)) %!assert (int64 (2^65), int64 (2^64-1)) %!assert (int64 (-2^65), int64 (-2^64)) - */ -
--- a/src/ov-int8.cc +++ b/src/ov-int8.cc @@ -84,12 +84,10 @@ } /* - %!assert (class (int8 (1)), "int8") %!assert (int8 (1.25), int8 (1)) %!assert (int8 (1.5), int8 (2)) %!assert (int8 (-1.5), int8 (-2)) %!assert (int8 (2^9), int8 (2^8-1)) %!assert (int8 (-2^9), int8 (-2^8)) - */
--- a/src/ov-null-mat.cc +++ b/src/ov-null-mat.cc @@ -120,7 +120,6 @@ } /* - %!assert (isnull ([]), true) %!assert (isnull ([1]), false) %!assert (isnull (zeros (0,3)), false) @@ -131,5 +130,4 @@ %!test %! x = []; %! assert (isnull (x), false); - */
--- a/src/ov-oncleanup.cc +++ b/src/ov-oncleanup.cc @@ -211,17 +211,15 @@ } /* - %!test %! old_wstate = warning ("query"); %! unwind_protect %! trigger = onCleanup (@() warning ("on", "__MY_WARNING__")); %! warning ("off", "__MY_WARNING__"); %! assert ((warning ("query", "__MY_WARNING__")).state, "off"); -%! clear trigger +%! clear trigger; %! assert ((warning ("query", "__MY_WARNING__")).state, "on"); %! unwind_protect_cleanup %! warning (old_wstate); %! end_unwind_protect - */
--- a/src/ov-range.cc +++ b/src/ov-range.cc @@ -670,7 +670,7 @@ %! warn_state = warning ("query", "Octave:noninteger-range-as-index"); %! unwind_protect %! allow_noninteger_range_as_index (false); -%! fail ('x(2.1:5)'); +%! fail ("x(2.1:5)"); %! assert (x(2:5), 1:4); %! allow_noninteger_range_as_index (true); %! warning ("off", "Octave:noninteger-range-as-index");
--- a/src/ov-re-mat.cc +++ b/src/ov-re-mat.cc @@ -981,7 +981,6 @@ } /* - %!assert (class (double (single (1))), "double") %!assert (class (double (single (1 + i))), "double") %!assert (class (double (int8 (1))), "double") @@ -1010,5 +1009,4 @@ %! y = double (x); %! assert (class (x), "single"); %! assert (class (y), "double"); - */
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -249,7 +249,8 @@ /* %!test -%! x(1).a.a = 1; x(2).a.a = 2; +%! x(1).a.a = 1; +%! x(2).a.a = 2; %! assert (size (x), [1, 2]); %! assert (x(1).a.a, 1); %! assert (x(2).a.a, 2); @@ -691,25 +692,6 @@ return dims.length () == 2 && dims (0) == 1 && dims (1) == 1; } -/* -%!shared x -%! x(1).a=1; x(2).a=2; x(1).b=3; x(2).b=3; -%!assert(struct('a',1,'b',3),x(1)) -%!assert(isempty(x([]))) -%!assert(isempty(struct('a',{},'b',{}))) -%!assert(struct('a',{1,2},'b',{3,3}),x) -%!assert(struct('a',{1,2},'b',3),x) -%!assert(struct('a',{1,2},'b',{3}),x) -%!assert(struct('b',3,'a',{1,2}),x) -%!assert(struct('b',{3},'a',{1,2}),x) -%!test x=struct([]); -%!assert(size(x),[0,0]); -%!assert(isstruct(x)); -%!assert(isempty(fieldnames(x))); -%!fail("struct('a',{1,2},'b',{1,2,3})","dimensions of parameter 2 do not match those of parameter 4") -%!fail("struct(1,2,3,4)","struct: expecting alternating \"field\", VALUE pairs"); -%!fail("struct('1',2,'3')","struct: expecting alternating \"field\", VALUE pairs"); -*/ bool octave_struct::save_ascii (std::ostream& os) @@ -1189,7 +1171,8 @@ /* %!test -%! x(1).a.a = 1; x(2).a.a = 2; +%! x(1).a.a = 1; +%! x(2).a.a = 2; %! assert (size (x), [1, 2]); %! assert (x(1).a.a, 1); %! assert (x(2).a.a, 2); @@ -1712,25 +1695,6 @@ else return false; } -/* -%!shared x -%! x(1).a=1; x(2).a=2; x(1).b=3; x(2).b=3; -%!assert(struct('a',1,'b',3),x(1)) -%!assert(isempty(x([]))) -%!assert(isempty(struct('a',{},'b',{}))) -%!assert(struct('a',{1,2},'b',{3,3}),x) -%!assert(struct('a',{1,2},'b',3),x) -%!assert(struct('a',{1,2},'b',{3}),x) -%!assert(struct('b',3,'a',{1,2}),x) -%!assert(struct('b',{3},'a',{1,2}),x) -%!test x=struct([]); -%!assert(size(x),[0,0]); -%!assert(isstruct(x)); -%!assert(isempty(fieldnames(x))); -%!fail("struct('a',{1,2},'b',{1,2,3})","dimensions of parameter 2 do not match those of parameter 4") -%!fail("struct(1,2,3,4)","struct: expecting alternating \"field\", VALUE pairs"); -%!fail("struct('1',2,'3')","struct: expecting alternating \"field\", VALUE pairs"); -*/ DEFUN (struct, args, , "-*- texinfo -*-\n\ @@ -1874,6 +1838,26 @@ return octave_value (map); } +/* +%!shared x +%! x(1).a=1; x(2).a=2; x(1).b=3; x(2).b=3; +%!assert (struct ("a",1, "b",3), x(1)) +%!assert (isempty (x([]))) +%!assert (isempty (struct ("a",{}, "b",{}))) +%!assert (struct ("a",{1,2}, "b",{3,3}), x) +%!assert (struct ("a",{1,2}, "b",3), x) +%!assert (struct ("a",{1,2}, "b",{3}), x) +%!assert (struct ("b",3, "a",{1,2}), x) +%!assert (struct ("b",{3}, "a",{1,2}), x) +%!test x = struct ([]); +%!assert (size (x), [0,0]) +%!assert (isstruct (x)) +%!assert (isempty (fieldnames (x))) +%!fail ('struct ("a",{1,2},"b",{1,2,3})', 'dimensions of parameter 2 do not match those of parameter 4') +%!fail ('struct (1,2,3,4)', 'struct: expecting alternating "field", VALUE pairs') +%!fail ('struct ("1",2,"3")', 'struct: expecting alternating "field", VALUE pairs') +*/ + DEFUN (isstruct, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} isstruct (@var{x})\n\ @@ -1928,10 +1912,10 @@ } /* -%!# test preservation of fieldname order +## test preservation of fieldname order %!test -%! x(3).d=1; x(2).a=2; x(1).b=3; x(2).c=3; -%! assert(fieldnames(x), {"d"; "a"; "b"; "c"}); +%! x(3).d=1; x(2).a=2; x(1).b=3; x(2).c=3; +%! assert (fieldnames (x), {"d"; "a"; "b"; "c"}); */ DEFUN (isfield, args, , @@ -2012,15 +1996,15 @@ } /* -%!# test isfield +## test isfield %!test -%! x(3).d=1; x(2).a=2; x(1).b=3; x(2).c=3; -%! assert (isfield (x, 'b')); -%!assert (isfield (struct('a', '1'), 'a')); -%!assert (isfield ({1}, 'c'), false); -%!assert (isfield (struct('a', '1'), 10), false); -%!assert (isfield (struct('a', 'b'), "a "), false); -%!assert (isfield (struct('a', 1, 'b', 2), {'a', 'c'}), [true, false]); +%! x(3).d=1; x(2).a=2; x(1).b=3; x(2).c=3; +%! assert (isfield (x, "b")); +%!assert (isfield (struct("a", "1"), "a")) +%!assert (isfield ({1}, "c"), false) +%!assert (isfield (struct("a", "1"), 10), false) +%!assert (isfield (struct("a", "b"), "a "), false) +%!assert (isfield (struct("a", 1, "b", 2), {"a", "c"}), [true, false]) */ DEFUN (cell2struct, args, , @@ -2138,15 +2122,15 @@ } /* -%!# test cell2struct versus struct2cell +## test cell2struct versus struct2cell %!test -%! keys = cellstr (char (floor (rand (100,10)*24+65)))'; -%! vals = mat2cell(rand (100,1), ones (100,1), 1)'; -%! s = struct ([keys; vals]{:}); -%! t = cell2struct (vals, keys, 2); -%! assert (s, t); -%! assert (struct2cell (s), vals'); -%! assert (fieldnames (s), keys'); +%! keys = cellstr (char (floor (rand (100,10)*24+65)))'; +%! vals = mat2cell (rand (100,1), ones (100,1), 1)'; +%! s = struct ([keys; vals]{:}); +%! t = cell2struct (vals, keys, 2); +%! assert (s, t); +%! assert (struct2cell (s), vals'); +%! assert (fieldnames (s), keys'); %!assert (cell2struct ({1; 2}, {"a"; "b"}), struct ("a", 1, "b", 2)); */ @@ -2204,12 +2188,12 @@ } /* -%!# test rmfield +## test rmfield %!test -%! x(3).d=1; x(2).a=2; x(1).b=3; x(2).c=3; x(6).f="abc123"; -%! y = rmfield (x, {"a", "f"}); -%! assert (fieldnames (y), {"d"; "b"; "c"}); -%! assert (size (y), [1, 6]); +%! x(3).d=1; x(2).a=2; x(1).b=3; x(2).c=3; x(6).f="abc123"; +%! y = rmfield (x, {"a", "f"}); +%! assert (fieldnames (y), {"d"; "b"; "c"}); +%! assert (size (y), [1, 6]); */ DEFUN (struct_levels_to_print, args, nargout,
--- a/src/ov-typeinfo.cc +++ b/src/ov-typeinfo.cc @@ -620,72 +620,88 @@ } /* -%!error typeinfo ("foo", 1); +%!assert (iscellstr (typeinfo ())) -%!assert (iscellstr (typeinfo ())); +%!assert (typeinfo ({"cell"}), "cell") -%!assert (typeinfo (false), "bool"); -%!assert (typeinfo ([true, false]), "bool matrix"); - -%!assert (typeinfo (1:2), "range"); +%!assert (typeinfo (1), "scalar") +%!assert (typeinfo (double (1)), "scalar") +%!assert (typeinfo (i), "complex scalar") -%!assert (typeinfo ("string"), "string"); -%!assert (typeinfo ('string'), "sq_string"); - +%!assert (typeinfo ([1, 2]), "matrix") +%!assert (typeinfo (double ([1, 2])), "matrix") %!assert (typeinfo (diag ([1, 2])), "diagonal matrix") +%!assert (typeinfo ([i, 2]), "complex matrix") %!assert (typeinfo (diag ([i, 2])), "complex diagonal matrix") -%!assert (typeinfo (single (diag ([1, 2]))), "float diagonal matrix") -%!assert (typeinfo (single (diag ([i, 2]))), "float complex diagonal matrix") -%!assert (typeinfo (diag (single ([1, 2]))), "float diagonal matrix") -%!assert (typeinfo (diag (single ([i, 2]))), "float complex diagonal matrix") + +%!assert (typeinfo (1:2), "range") -%!assert (typeinfo ([]), "null_matrix"); -%!assert (typeinfo (""), "null_string"); -%!assert (typeinfo (''), "null_sq_string"); +%!assert (typeinfo (false), "bool") +%!assert (typeinfo ([true, false]), "bool matrix") + +%!assert (typeinfo ("string"), "string") +%!assert (typeinfo ('string'), "sq_string") -%!assert (typeinfo (1), "scalar"); -%!assert (typeinfo (double (1)), "scalar"); -%!assert (typeinfo ([1, 2]), "matrix"); -%!assert (typeinfo (double ([1, 2])), "matrix"); - -%!assert (typeinfo (i), "complex scalar"); -%!assert (typeinfo ([i, 2]), "complex matrix"); - -%!assert (typeinfo (single (1)), "float scalar"); -%!assert (typeinfo (single ([1, 2])), "float matrix"); +%!assert (typeinfo (int8 (1)), "int8 scalar") +%!assert (typeinfo (int16 (1)), "int16 scalar") +%!assert (typeinfo (int32 (1)), "int32 scalar") +%!assert (typeinfo (int64 (1)), "int64 scalar") +%!assert (typeinfo (uint8 (1)), "uint8 scalar") +%!assert (typeinfo (uint16 (1)), "uint16 scalar") +%!assert (typeinfo (uint32 (1)), "uint32 scalar") +%!assert (typeinfo (uint64 (1)), "uint64 scalar") -%!assert (typeinfo (single (i)), "float complex scalar"); -%!assert (typeinfo (single ([i, 2])), "float complex matrix"); - -%!assert (typeinfo (sparse (eye (10))), "sparse matrix"); -%!assert (typeinfo (sparse (i * eye (10))), "sparse complex matrix"); -%!assert (typeinfo (logical (sparse (i * eye (10)))), "sparse bool matrix"); +%!assert (typeinfo (int8 ([1,2])), "int8 matrix") +%!assert (typeinfo (int16 ([1,2])), "int16 matrix") +%!assert (typeinfo (int32 ([1,2])), "int32 matrix") +%!assert (typeinfo (int64 ([1,2])), "int64 matrix") +%!assert (typeinfo (uint8 ([1,2])), "uint8 matrix") +%!assert (typeinfo (uint16 ([1,2])), "uint16 matrix") +%!assert (typeinfo (uint32 ([1,2])), "uint32 matrix") +%!assert (typeinfo (uint64 ([1,2])), "uint64 matrix") -%!assert (typeinfo (int8 (1)), "int8 scalar"); -%!assert (typeinfo (int16 (1)), "int16 scalar"); -%!assert (typeinfo (int32 (1)), "int32 scalar"); -%!assert (typeinfo (int64 (1)), "int64 scalar"); -%!assert (typeinfo (uint8 (1)), "uint8 scalar"); -%!assert (typeinfo (uint16 (1)), "uint16 scalar"); -%!assert (typeinfo (uint32 (1)), "uint32 scalar"); -%!assert (typeinfo (uint64 (1)), "uint64 scalar"); +%!assert (typeinfo (sparse ([true, false])), "sparse bool matrix") +%!assert (typeinfo (logical (sparse (i * eye (10)))), "sparse bool matrix") +%!assert (typeinfo (sparse ([1,2])), "sparse matrix") +%!assert (typeinfo (sparse (eye (10))), "sparse matrix") +%!assert (typeinfo (sparse ([i,2])), "sparse complex matrix") +%!assert (typeinfo (sparse (i * eye (10))), "sparse complex matrix") + +%!test +%! s(2).a = 1; +%! assert (typeinfo (s), "struct"); %!test %! s.a = 1; %! assert (typeinfo (s), "scalar struct"); -%!test -%! s(2).a = 1; -%! assert (typeinfo (s), "struct"); +## FIXME: This doesn't work as a test for comma-separated list +%!#test +%! clist = {1, 2, 3}; +%! assert (typeinfo (clist{:}), "cs-list"); -%!assert (typeinfo ({"cell"}), "cell"); +%!assert (typeinfo (@sin), "function handle") +%!assert (typeinfo (@(x) x), "function handle") + +%!assert (typeinfo (inline ("x^2")), "inline function") -%!assert (typeinfo (@sin), "function handle"); -%!assert (typeinfo (@(x) x), "function handle"); +%!assert (typeinfo (single (1)), "float scalar") +%!assert (typeinfo (single (i)), "float complex scalar") +%!assert (typeinfo (single ([1, 2])), "float matrix") -%!assert (typeinfo (inline ('x^2')), "inline function"); +%!assert (typeinfo (single (diag ([1, 2]))), "float diagonal matrix") +%!assert (typeinfo (diag (single ([1, 2]))), "float diagonal matrix") +%!assert (typeinfo (single (diag ([i, 2]))), "float complex diagonal matrix") +%!assert (typeinfo (diag (single ([i, 2]))), "float complex diagonal matrix") +%!assert (typeinfo (eye(3)(:,[1 3 2])), "permutation matrix") %!test %! [l, u, p] = lu (rand (3)); %! assert (typeinfo (p), "permutation matrix"); + +%!assert (typeinfo ([]), "null_matrix") +%!assert (typeinfo (""), "null_string") +%!assert (typeinfo (''), "null_sq_string") + +%!error typeinfo ("foo", 1) */
--- a/src/ov-uint16.cc +++ b/src/ov-uint16.cc @@ -84,13 +84,10 @@ } /* - %!assert (class (uint16 (1)), "uint16") %!assert (uint16 (1.25), uint16 (1)) %!assert (uint16 (1.5), uint16 (2)) %!assert (uint16 (-1.5), uint16 (0)) %!assert (uint16 (2^17), uint16 (2^16-1)) %!assert (uint16 (-2^17), uint16 (0)) - */ -
--- a/src/ov-uint32.cc +++ b/src/ov-uint32.cc @@ -84,12 +84,10 @@ } /* - %!assert (class (uint32 (1)), "uint32") %!assert (uint32 (1.25), uint32 (1)) %!assert (uint32 (1.5), uint32 (2)) %!assert (uint32 (-1.5), uint32 (0)) %!assert (uint32 (2^33), uint32 (2^32-1)) %!assert (uint32 (-2^33), uint32 (0)) - */
--- a/src/ov-uint64.cc +++ b/src/ov-uint64.cc @@ -84,12 +84,10 @@ } /* - %!assert (class (uint64 (1)), "uint64") %!assert (uint64 (1.25), uint64 (1)) %!assert (uint64 (1.5), uint64 (2)) %!assert (uint64 (-1.5), uint64 (0)) %!assert (uint64 (2^65), uint64 (2^64-1)) %!assert (uint64 (-2^65), uint64 (0)) - */
--- a/src/ov-uint8.cc +++ b/src/ov-uint8.cc @@ -84,12 +84,10 @@ } /* - %!assert (class (uint8 (1)), "uint8") %!assert (uint8 (1.25), uint8 (1)) %!assert (uint8 (1.5), uint8 (2)) %!assert (uint8 (-1.5), uint8 (0)) %!assert (uint8 (2^9), uint8 (2^8-1)) %!assert (uint8 (-2^9), uint8 (0)) - */
--- a/src/ov.cc +++ b/src/ov.cc @@ -2944,7 +2944,7 @@ %! 0 8 0 18 0 %! 0 0 14 0 0 %! 0 10 15 20 0]; -%! assert (a,b); +%! assert (a, b); %!test %! c = num2cell (reshape ([1:25],5,5)); @@ -2989,7 +2989,6 @@ %! t.b = "There"; %! t.c = 163; %! assert (s, t); - */ DEFUN (is_sq_string, args, , @@ -3010,10 +3009,11 @@ } /* -%!assert (is_sq_string ('foo'), true); -%!assert (is_sq_string ("foo"), false); -%!assert (is_sq_string (1.0), false); -%!assert (is_sq_string ({2.0}), false); +%!assert (is_sq_string ('foo'), true) +%!assert (is_sq_string ("foo"), false) +%!assert (is_sq_string (1.0), false) +%!assert (is_sq_string ({2.0}), false) + %!error is_sq_string () %!error is_sq_string ('foo', 2) */ @@ -3036,10 +3036,11 @@ } /* -%!assert (is_dq_string ("foo"), true); -%!assert (is_dq_string ('foo'), false); -%!assert (is_dq_string (1.0), false); -%!assert (is_dq_string ({2.0}), false); +%!assert (is_dq_string ("foo"), true) +%!assert (is_dq_string ('foo'), false) +%!assert (is_dq_string (1.0), false) +%!assert (is_dq_string ({2.0}), false) + %!error is_dq_string () %!error is_dq_string ("foo", 2) */
--- a/src/ov.h +++ b/src/ov.h @@ -315,7 +315,7 @@ { if (rep->count > 1) { - octave_base_value *r = rep->unique_clone (); + octave_base_value *r = rep->unique_clone (); if (--rep->count == 0) delete rep;
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -3555,12 +3555,12 @@ %! foo.cell = {foo.real, foo.complex, foo.char}; %! fields = fieldnames (foo); %! for f = 1:numel(fields) -%! format loose +%! format loose; %! loose = disp (foo.(fields{f})); -%! format compact +%! format compact; %! compact = disp (foo.(fields{f})); %! expected = strrep (loose, "\n\n", "\n"); -%! assert (expected, compact) +%! assert (expected, compact); %! endfor */
--- a/src/pt-binop.cc +++ b/src/pt-binop.cc @@ -302,7 +302,6 @@ } /* - %!test %! x = 0; %! do_braindead_shortcircuit_evaluation (0); @@ -313,6 +312,4 @@ %! if (1 | (x = 0)) %! endif %! assert (x, 1); - */ -
--- a/src/pt-eval.cc +++ b/src/pt-eval.cc @@ -1207,7 +1207,6 @@ } /* -%!error (max_recursion_depth (1, 2)); %!test %! orig_val = max_recursion_depth (); %! old_val = max_recursion_depth (2*orig_val); @@ -1215,6 +1214,8 @@ %! assert (max_recursion_depth (), 2*orig_val); %! max_recursion_depth (orig_val); %! assert (max_recursion_depth (), orig_val); + +%!error (max_recursion_depth (1, 2)) */ DEFUN (silent_functions, args, nargout, @@ -1236,7 +1237,6 @@ } /* -%!error (silent_functions (1, 2)); %!test %! orig_val = silent_functions (); %! old_val = silent_functions (! orig_val); @@ -1244,4 +1244,6 @@ %! assert (silent_functions (), ! orig_val); %! silent_functions (orig_val); %! assert (silent_functions (), orig_val); + +%!error (silent_functions (1, 2)) */
--- a/src/pt-idx.cc +++ b/src/pt-idx.cc @@ -601,13 +601,13 @@ /* %!test -%! clear x -%! clear y +%! clear x; +%! clear y; %! y = 3; %! x(y(end)) = 1; %! assert (x, [0, 0, 1]); -%! clear x -%! clear y +%! clear x; +%! clear y; %! y = {3}; %! x(y{end}) = 1; %! assert (x, [0, 0, 1]);
--- a/src/pt-mat.cc +++ b/src/pt-mat.cc @@ -1193,198 +1193,198 @@ } /* -%% test concatenation with all zero matrices -%!assert([ '' 65*ones(1,10) ], 'AAAAAAAAAA'); -%!assert([ 65*ones(1,10) '' ], 'AAAAAAAAAA'); +## test concatenation with all zero matrices +%!assert ([ "" 65*ones(1,10) ], "AAAAAAAAAA"); +%!assert ([ 65*ones(1,10) "" ], "AAAAAAAAAA"); %!test -%! c = {'foo'; 'bar'; 'bazoloa'}; -%! assert ([c; 'a'; 'bc'; 'def'], {'foo'; 'bar'; 'bazoloa'; 'a'; 'bc'; 'def'}); +%! c = {"foo"; "bar"; "bazoloa"}; +%! assert ([c; "a"; "bc"; "def"], {"foo"; "bar"; "bazoloa"; "a"; "bc"; "def"}); -%!assert (class ([int64(1), int64(1)]), 'int64') -%!assert (class ([int64(1), int32(1)]), 'int64') -%!assert (class ([int64(1), int16(1)]), 'int64') -%!assert (class ([int64(1), int8(1)]), 'int64') -%!assert (class ([int64(1), uint64(1)]), 'int64') -%!assert (class ([int64(1), uint32(1)]), 'int64') -%!assert (class ([int64(1), uint16(1)]), 'int64') -%!assert (class ([int64(1), uint8(1)]), 'int64') -%!assert (class ([int64(1), single(1)]), 'int64') -%!assert (class ([int64(1), double(1)]), 'int64') -%!assert (class ([int64(1), cell(1)]), 'cell') -%!assert (class ([int64(1), true]), 'int64') -%!assert (class ([int64(1), 'a']), 'char') +%!assert (class ([int64(1), int64(1)]), "int64") +%!assert (class ([int64(1), int32(1)]), "int64") +%!assert (class ([int64(1), int16(1)]), "int64") +%!assert (class ([int64(1), int8(1)]), "int64") +%!assert (class ([int64(1), uint64(1)]), "int64") +%!assert (class ([int64(1), uint32(1)]), "int64") +%!assert (class ([int64(1), uint16(1)]), "int64") +%!assert (class ([int64(1), uint8(1)]), "int64") +%!assert (class ([int64(1), single(1)]), "int64") +%!assert (class ([int64(1), double(1)]), "int64") +%!assert (class ([int64(1), cell(1)]), "cell") +%!assert (class ([int64(1), true]), "int64") +%!assert (class ([int64(1), "a"]), "char") -%!assert (class ([int32(1), int64(1)]), 'int32') -%!assert (class ([int32(1), int32(1)]), 'int32') -%!assert (class ([int32(1), int16(1)]), 'int32') -%!assert (class ([int32(1), int8(1)]), 'int32') -%!assert (class ([int32(1), uint64(1)]), 'int32') -%!assert (class ([int32(1), uint32(1)]), 'int32') -%!assert (class ([int32(1), uint16(1)]), 'int32') -%!assert (class ([int32(1), uint8(1)]), 'int32') -%!assert (class ([int32(1), single(1)]), 'int32') -%!assert (class ([int32(1), double(1)]), 'int32') -%!assert (class ([int32(1), cell(1)]), 'cell') -%!assert (class ([int32(1), true]), 'int32') -%!assert (class ([int32(1), 'a']), 'char') +%!assert (class ([int32(1), int64(1)]), "int32") +%!assert (class ([int32(1), int32(1)]), "int32") +%!assert (class ([int32(1), int16(1)]), "int32") +%!assert (class ([int32(1), int8(1)]), "int32") +%!assert (class ([int32(1), uint64(1)]), "int32") +%!assert (class ([int32(1), uint32(1)]), "int32") +%!assert (class ([int32(1), uint16(1)]), "int32") +%!assert (class ([int32(1), uint8(1)]), "int32") +%!assert (class ([int32(1), single(1)]), "int32") +%!assert (class ([int32(1), double(1)]), "int32") +%!assert (class ([int32(1), cell(1)]), "cell") +%!assert (class ([int32(1), true]), "int32") +%!assert (class ([int32(1), "a"]), "char") -%!assert (class ([int16(1), int64(1)]), 'int16') -%!assert (class ([int16(1), int32(1)]), 'int16') -%!assert (class ([int16(1), int16(1)]), 'int16') -%!assert (class ([int16(1), int8(1)]), 'int16') -%!assert (class ([int16(1), uint64(1)]), 'int16') -%!assert (class ([int16(1), uint32(1)]), 'int16') -%!assert (class ([int16(1), uint16(1)]), 'int16') -%!assert (class ([int16(1), uint8(1)]), 'int16') -%!assert (class ([int16(1), single(1)]), 'int16') -%!assert (class ([int16(1), double(1)]), 'int16') -%!assert (class ([int16(1), cell(1)]), 'cell') -%!assert (class ([int16(1), true]), 'int16') -%!assert (class ([int16(1), 'a']), 'char') +%!assert (class ([int16(1), int64(1)]), "int16") +%!assert (class ([int16(1), int32(1)]), "int16") +%!assert (class ([int16(1), int16(1)]), "int16") +%!assert (class ([int16(1), int8(1)]), "int16") +%!assert (class ([int16(1), uint64(1)]), "int16") +%!assert (class ([int16(1), uint32(1)]), "int16") +%!assert (class ([int16(1), uint16(1)]), "int16") +%!assert (class ([int16(1), uint8(1)]), "int16") +%!assert (class ([int16(1), single(1)]), "int16") +%!assert (class ([int16(1), double(1)]), "int16") +%!assert (class ([int16(1), cell(1)]), "cell") +%!assert (class ([int16(1), true]), "int16") +%!assert (class ([int16(1), "a"]), "char") -%!assert (class ([int8(1), int64(1)]), 'int8') -%!assert (class ([int8(1), int32(1)]), 'int8') -%!assert (class ([int8(1), int16(1)]), 'int8') -%!assert (class ([int8(1), int8(1)]), 'int8') -%!assert (class ([int8(1), uint64(1)]), 'int8') -%!assert (class ([int8(1), uint32(1)]), 'int8') -%!assert (class ([int8(1), uint16(1)]), 'int8') -%!assert (class ([int8(1), uint8(1)]), 'int8') -%!assert (class ([int8(1), single(1)]), 'int8') -%!assert (class ([int8(1), double(1)]), 'int8') -%!assert (class ([int8(1), cell(1)]), 'cell') -%!assert (class ([int8(1), true]), 'int8') -%!assert (class ([int8(1), 'a']), 'char') +%!assert (class ([int8(1), int64(1)]), "int8") +%!assert (class ([int8(1), int32(1)]), "int8") +%!assert (class ([int8(1), int16(1)]), "int8") +%!assert (class ([int8(1), int8(1)]), "int8") +%!assert (class ([int8(1), uint64(1)]), "int8") +%!assert (class ([int8(1), uint32(1)]), "int8") +%!assert (class ([int8(1), uint16(1)]), "int8") +%!assert (class ([int8(1), uint8(1)]), "int8") +%!assert (class ([int8(1), single(1)]), "int8") +%!assert (class ([int8(1), double(1)]), "int8") +%!assert (class ([int8(1), cell(1)]), "cell") +%!assert (class ([int8(1), true]), "int8") +%!assert (class ([int8(1), "a"]), "char") -%!assert (class ([uint64(1), int64(1)]), 'uint64') -%!assert (class ([uint64(1), int32(1)]), 'uint64') -%!assert (class ([uint64(1), int16(1)]), 'uint64') -%!assert (class ([uint64(1), int8(1)]), 'uint64') -%!assert (class ([uint64(1), uint64(1)]), 'uint64') -%!assert (class ([uint64(1), uint32(1)]), 'uint64') -%!assert (class ([uint64(1), uint16(1)]), 'uint64') -%!assert (class ([uint64(1), uint8(1)]), 'uint64') -%!assert (class ([uint64(1), single(1)]), 'uint64') -%!assert (class ([uint64(1), double(1)]), 'uint64') -%!assert (class ([uint64(1), cell(1)]), 'cell') -%!assert (class ([uint64(1), true]), 'uint64') -%!assert (class ([uint64(1), 'a']), 'char') +%!assert (class ([uint64(1), int64(1)]), "uint64") +%!assert (class ([uint64(1), int32(1)]), "uint64") +%!assert (class ([uint64(1), int16(1)]), "uint64") +%!assert (class ([uint64(1), int8(1)]), "uint64") +%!assert (class ([uint64(1), uint64(1)]), "uint64") +%!assert (class ([uint64(1), uint32(1)]), "uint64") +%!assert (class ([uint64(1), uint16(1)]), "uint64") +%!assert (class ([uint64(1), uint8(1)]), "uint64") +%!assert (class ([uint64(1), single(1)]), "uint64") +%!assert (class ([uint64(1), double(1)]), "uint64") +%!assert (class ([uint64(1), cell(1)]), "cell") +%!assert (class ([uint64(1), true]), "uint64") +%!assert (class ([uint64(1), "a"]), "char") -%!assert (class ([uint32(1), int64(1)]), 'uint32') -%!assert (class ([uint32(1), int32(1)]), 'uint32') -%!assert (class ([uint32(1), int16(1)]), 'uint32') -%!assert (class ([uint32(1), int8(1)]), 'uint32') -%!assert (class ([uint32(1), uint64(1)]), 'uint32') -%!assert (class ([uint32(1), uint32(1)]), 'uint32') -%!assert (class ([uint32(1), uint16(1)]), 'uint32') -%!assert (class ([uint32(1), uint8(1)]), 'uint32') -%!assert (class ([uint32(1), single(1)]), 'uint32') -%!assert (class ([uint32(1), double(1)]), 'uint32') -%!assert (class ([uint32(1), cell(1)]), 'cell') -%!assert (class ([uint32(1), true]), 'uint32') -%!assert (class ([uint32(1), 'a']), 'char') +%!assert (class ([uint32(1), int64(1)]), "uint32") +%!assert (class ([uint32(1), int32(1)]), "uint32") +%!assert (class ([uint32(1), int16(1)]), "uint32") +%!assert (class ([uint32(1), int8(1)]), "uint32") +%!assert (class ([uint32(1), uint64(1)]), "uint32") +%!assert (class ([uint32(1), uint32(1)]), "uint32") +%!assert (class ([uint32(1), uint16(1)]), "uint32") +%!assert (class ([uint32(1), uint8(1)]), "uint32") +%!assert (class ([uint32(1), single(1)]), "uint32") +%!assert (class ([uint32(1), double(1)]), "uint32") +%!assert (class ([uint32(1), cell(1)]), "cell") +%!assert (class ([uint32(1), true]), "uint32") +%!assert (class ([uint32(1), "a"]), "char") -%!assert (class ([uint16(1), int64(1)]), 'uint16') -%!assert (class ([uint16(1), int32(1)]), 'uint16') -%!assert (class ([uint16(1), int16(1)]), 'uint16') -%!assert (class ([uint16(1), int8(1)]), 'uint16') -%!assert (class ([uint16(1), uint64(1)]), 'uint16') -%!assert (class ([uint16(1), uint32(1)]), 'uint16') -%!assert (class ([uint16(1), uint16(1)]), 'uint16') -%!assert (class ([uint16(1), uint8(1)]), 'uint16') -%!assert (class ([uint16(1), single(1)]), 'uint16') -%!assert (class ([uint16(1), double(1)]), 'uint16') -%!assert (class ([uint16(1), cell(1)]), 'cell') -%!assert (class ([uint16(1), true]), 'uint16') -%!assert (class ([uint16(1), 'a']), 'char') +%!assert (class ([uint16(1), int64(1)]), "uint16") +%!assert (class ([uint16(1), int32(1)]), "uint16") +%!assert (class ([uint16(1), int16(1)]), "uint16") +%!assert (class ([uint16(1), int8(1)]), "uint16") +%!assert (class ([uint16(1), uint64(1)]), "uint16") +%!assert (class ([uint16(1), uint32(1)]), "uint16") +%!assert (class ([uint16(1), uint16(1)]), "uint16") +%!assert (class ([uint16(1), uint8(1)]), "uint16") +%!assert (class ([uint16(1), single(1)]), "uint16") +%!assert (class ([uint16(1), double(1)]), "uint16") +%!assert (class ([uint16(1), cell(1)]), "cell") +%!assert (class ([uint16(1), true]), "uint16") +%!assert (class ([uint16(1), "a"]), "char") -%!assert (class ([uint8(1), int64(1)]), 'uint8') -%!assert (class ([uint8(1), int32(1)]), 'uint8') -%!assert (class ([uint8(1), int16(1)]), 'uint8') -%!assert (class ([uint8(1), int8(1)]), 'uint8') -%!assert (class ([uint8(1), uint64(1)]), 'uint8') -%!assert (class ([uint8(1), uint32(1)]), 'uint8') -%!assert (class ([uint8(1), uint16(1)]), 'uint8') -%!assert (class ([uint8(1), uint8(1)]), 'uint8') -%!assert (class ([uint8(1), single(1)]), 'uint8') -%!assert (class ([uint8(1), double(1)]), 'uint8') -%!assert (class ([uint8(1), cell(1)]), 'cell') -%!assert (class ([uint8(1), true]), 'uint8') -%!assert (class ([uint8(1), 'a']), 'char') +%!assert (class ([uint8(1), int64(1)]), "uint8") +%!assert (class ([uint8(1), int32(1)]), "uint8") +%!assert (class ([uint8(1), int16(1)]), "uint8") +%!assert (class ([uint8(1), int8(1)]), "uint8") +%!assert (class ([uint8(1), uint64(1)]), "uint8") +%!assert (class ([uint8(1), uint32(1)]), "uint8") +%!assert (class ([uint8(1), uint16(1)]), "uint8") +%!assert (class ([uint8(1), uint8(1)]), "uint8") +%!assert (class ([uint8(1), single(1)]), "uint8") +%!assert (class ([uint8(1), double(1)]), "uint8") +%!assert (class ([uint8(1), cell(1)]), "cell") +%!assert (class ([uint8(1), true]), "uint8") +%!assert (class ([uint8(1), "a"]), "char") -%!assert (class ([single(1), int64(1)]), 'int64') -%!assert (class ([single(1), int32(1)]), 'int32') -%!assert (class ([single(1), int16(1)]), 'int16') -%!assert (class ([single(1), int8(1)]), 'int8') -%!assert (class ([single(1), uint64(1)]), 'uint64') -%!assert (class ([single(1), uint32(1)]), 'uint32') -%!assert (class ([single(1), uint16(1)]), 'uint16') -%!assert (class ([single(1), uint8(1)]), 'uint8') -%!assert (class ([single(1), single(1)]), 'single') -%!assert (class ([single(1), double(1)]), 'single') -%!assert (class ([single(1), cell(1)]), 'cell') -%!assert (class ([single(1), true]), 'single') -%!assert (class ([single(1), 'a']), 'char') +%!assert (class ([single(1), int64(1)]), "int64") +%!assert (class ([single(1), int32(1)]), "int32") +%!assert (class ([single(1), int16(1)]), "int16") +%!assert (class ([single(1), int8(1)]), "int8") +%!assert (class ([single(1), uint64(1)]), "uint64") +%!assert (class ([single(1), uint32(1)]), "uint32") +%!assert (class ([single(1), uint16(1)]), "uint16") +%!assert (class ([single(1), uint8(1)]), "uint8") +%!assert (class ([single(1), single(1)]), "single") +%!assert (class ([single(1), double(1)]), "single") +%!assert (class ([single(1), cell(1)]), "cell") +%!assert (class ([single(1), true]), "single") +%!assert (class ([single(1), "a"]), "char") -%!assert (class ([double(1), int64(1)]), 'int64') -%!assert (class ([double(1), int32(1)]), 'int32') -%!assert (class ([double(1), int16(1)]), 'int16') -%!assert (class ([double(1), int8(1)]), 'int8') -%!assert (class ([double(1), uint64(1)]), 'uint64') -%!assert (class ([double(1), uint32(1)]), 'uint32') -%!assert (class ([double(1), uint16(1)]), 'uint16') -%!assert (class ([double(1), uint8(1)]), 'uint8') -%!assert (class ([double(1), single(1)]), 'single') -%!assert (class ([double(1), double(1)]), 'double') -%!assert (class ([double(1), cell(1)]), 'cell') -%!assert (class ([double(1), true]), 'double') -%!assert (class ([double(1), 'a']), 'char') +%!assert (class ([double(1), int64(1)]), "int64") +%!assert (class ([double(1), int32(1)]), "int32") +%!assert (class ([double(1), int16(1)]), "int16") +%!assert (class ([double(1), int8(1)]), "int8") +%!assert (class ([double(1), uint64(1)]), "uint64") +%!assert (class ([double(1), uint32(1)]), "uint32") +%!assert (class ([double(1), uint16(1)]), "uint16") +%!assert (class ([double(1), uint8(1)]), "uint8") +%!assert (class ([double(1), single(1)]), "single") +%!assert (class ([double(1), double(1)]), "double") +%!assert (class ([double(1), cell(1)]), "cell") +%!assert (class ([double(1), true]), "double") +%!assert (class ([double(1), "a"]), "char") -%!assert (class ([cell(1), int64(1)]), 'cell') -%!assert (class ([cell(1), int32(1)]), 'cell') -%!assert (class ([cell(1), int16(1)]), 'cell') -%!assert (class ([cell(1), int8(1)]), 'cell') -%!assert (class ([cell(1), uint64(1)]), 'cell') -%!assert (class ([cell(1), uint32(1)]), 'cell') -%!assert (class ([cell(1), uint16(1)]), 'cell') -%!assert (class ([cell(1), uint8(1)]), 'cell') -%!assert (class ([cell(1), single(1)]), 'cell') -%!assert (class ([cell(1), double(1)]), 'cell') -%!assert (class ([cell(1), cell(1)]), 'cell') -%!assert (class ([cell(1), true]), 'cell') -%!assert (class ([cell(1), 'a']), 'cell') +%!assert (class ([cell(1), int64(1)]), "cell") +%!assert (class ([cell(1), int32(1)]), "cell") +%!assert (class ([cell(1), int16(1)]), "cell") +%!assert (class ([cell(1), int8(1)]), "cell") +%!assert (class ([cell(1), uint64(1)]), "cell") +%!assert (class ([cell(1), uint32(1)]), "cell") +%!assert (class ([cell(1), uint16(1)]), "cell") +%!assert (class ([cell(1), uint8(1)]), "cell") +%!assert (class ([cell(1), single(1)]), "cell") +%!assert (class ([cell(1), double(1)]), "cell") +%!assert (class ([cell(1), cell(1)]), "cell") +%!assert (class ([cell(1), true]), "cell") +%!assert (class ([cell(1), "a"]), "cell") -%!assert (class ([true, int64(1)]), 'int64') -%!assert (class ([true, int32(1)]), 'int32') -%!assert (class ([true, int16(1)]), 'int16') -%!assert (class ([true, int8(1)]), 'int8') -%!assert (class ([true, uint64(1)]), 'uint64') -%!assert (class ([true, uint32(1)]), 'uint32') -%!assert (class ([true, uint16(1)]), 'uint16') -%!assert (class ([true, uint8(1)]), 'uint8') -%!assert (class ([true, single(1)]), 'single') -%!assert (class ([true, double(1)]), 'double') -%!assert (class ([true, cell(1)]), 'cell') -%!assert (class ([true, true]), 'logical') -%!assert (class ([true, 'a']), 'char') +%!assert (class ([true, int64(1)]), "int64") +%!assert (class ([true, int32(1)]), "int32") +%!assert (class ([true, int16(1)]), "int16") +%!assert (class ([true, int8(1)]), "int8") +%!assert (class ([true, uint64(1)]), "uint64") +%!assert (class ([true, uint32(1)]), "uint32") +%!assert (class ([true, uint16(1)]), "uint16") +%!assert (class ([true, uint8(1)]), "uint8") +%!assert (class ([true, single(1)]), "single") +%!assert (class ([true, double(1)]), "double") +%!assert (class ([true, cell(1)]), "cell") +%!assert (class ([true, true]), "logical") +%!assert (class ([true, "a"]), "char") -%!assert (class (['a', int64(1)]), 'char') -%!assert (class (['a', int32(1)]), 'char') -%!assert (class (['a', int16(1)]), 'char') -%!assert (class (['a', int8(1)]), 'char') -%!assert (class (['a', int64(1)]), 'char') -%!assert (class (['a', int32(1)]), 'char') -%!assert (class (['a', int16(1)]), 'char') -%!assert (class (['a', int8(1)]), 'char') -%!assert (class (['a', single(1)]), 'char') -%!assert (class (['a', double(1)]), 'char') -%!assert (class (['a', cell(1)]), 'cell') -%!assert (class (['a', true]), 'char') -%!assert (class (['a', 'a']), 'char') +%!assert (class (["a", int64(1)]), "char") +%!assert (class (["a", int32(1)]), "char") +%!assert (class (["a", int16(1)]), "char") +%!assert (class (["a", int8(1)]), "char") +%!assert (class (["a", int64(1)]), "char") +%!assert (class (["a", int32(1)]), "char") +%!assert (class (["a", int16(1)]), "char") +%!assert (class (["a", int8(1)]), "char") +%!assert (class (["a", single(1)]), "char") +%!assert (class (["a", double(1)]), "char") +%!assert (class (["a", cell(1)]), "cell") +%!assert (class (["a", true]), "char") +%!assert (class (["a", "a"]), "char") -%!assert (class ([cell(1), struct('foo', 'bar')]), 'cell') -%!error [struct('foo', 'bar'), cell(1)]; +%!assert (class ([cell(1), struct("foo", "bar")]), "cell") +%!error [struct("foo", "bar"), cell(1)] */ DEFUN (string_fill_char, args, nargout, @@ -1400,9 +1400,9 @@ @group\n\ string_fill_char (\"X\");\n\ [ \"these\"; \"are\"; \"strings\" ]\n\ - @result{} \"theseXX\"\n\ - \"areXXXX\"\n\ - \"strings\"\n\ + @result{} \"theseXX\"\n\ + \"areXXXX\"\n\ + \"strings\"\n\ @end group\n\ @end example\n\ \n\ @@ -1415,9 +1415,8 @@ } /* -%!error (string_fill_char (1, 2)); -%% string_fill_char() function call must be outside of %!test block -%% due to the way a %!test block is wrapped inside a function +## string_fill_char() function call must be outside of %!test block +## due to the way a %!test block is wrapped inside a function %!shared orig_val, old_val %! orig_val = string_fill_char (); %! old_val = string_fill_char ("X"); @@ -1427,4 +1426,6 @@ %! assert (["these"; "are"; "strings"], ["theseXX"; "areXXXX"; "strings"]); %! string_fill_char (orig_val); %! assert (string_fill_char (), orig_val); + +%!error (string_fill_char (1, 2)) */
--- a/src/sighandlers.cc +++ b/src/sighandlers.cc @@ -439,6 +439,8 @@ break; case CTRL_CLOSE_EVENT: + clean_up_and_exit (0); + break; case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: default: @@ -957,9 +959,10 @@ } /* -%!error SIG (1); -%!assert (isstruct (SIG ())); -%!assert (! isempty (SIG ())); +%!assert (isstruct (SIG ())) +%!assert (! isempty (SIG ())) + +%!error SIG (1) */ DEFUN (debug_on_interrupt, args, nargout, @@ -981,7 +984,6 @@ } /* -%!error (debug_on_interrupt (1, 2)); %!test %! orig_val = debug_on_interrupt (); %! old_val = debug_on_interrupt (! orig_val); @@ -989,6 +991,8 @@ %! assert (debug_on_interrupt (), ! orig_val); %! debug_on_interrupt (orig_val); %! assert (debug_on_interrupt (), orig_val); + +%!error (debug_on_interrupt (1, 2)) */ DEFUN (sighup_dumps_octave_core, args, nargout, @@ -1009,7 +1013,6 @@ } /* -%!error (sighup_dumps_octave_core (1, 2)); %!test %! orig_val = sighup_dumps_octave_core (); %! old_val = sighup_dumps_octave_core (! orig_val); @@ -1017,6 +1020,8 @@ %! assert (sighup_dumps_octave_core (), ! orig_val); %! sighup_dumps_octave_core (orig_val); %! assert (sighup_dumps_octave_core (), orig_val); + +%!error (sighup_dumps_octave_core (1, 2)) */ DEFUN (sigterm_dumps_octave_core, args, nargout, @@ -1037,7 +1042,6 @@ } /* -%!error (sigterm_dumps_octave_core (1, 2)); %!test %! orig_val = sigterm_dumps_octave_core (); %! old_val = sigterm_dumps_octave_core (! orig_val); @@ -1045,4 +1049,6 @@ %! assert (sigterm_dumps_octave_core (), ! orig_val); %! sigterm_dumps_octave_core (orig_val); %! assert (sigterm_dumps_octave_core (), orig_val); + +%!error (sigterm_dumps_octave_core (1, 2)) */
--- a/src/sparse.cc +++ b/src/sparse.cc @@ -78,7 +78,8 @@ \n\ @strong{Note}: if multiple values are specified with the same\n\ @var{i}, @var{j} indices, the corresponding values in @var{s} will\n\ -be added.\n\ +be added. See @code{accumarray} for an example of how to produce different\n\ +behavior, such as taking the minimum instead.\n\ \n\ The following are all equivalent:\n\ \n\ @@ -98,7 +99,7 @@ \n\ If any of @var{sv}, @var{i} or @var{j} are scalars, they are expanded\n\ to have a common size.\n\ -@seealso{full}\n\ +@seealso{full, accumarray}\n\ @end deftypefn") { octave_value retval;
--- a/src/strfns.cc +++ b/src/strfns.cc @@ -152,23 +152,23 @@ /* %!assert (char (), ''); -%!assert (char (100) == "d"); -%!assert (all(char (100,100) == ["d";"d"])); -%!assert (all(char ({100,100}) == ["d";"d"])); -%!assert (all(char ([100,100]) == ["dd"])); -%!assert (all(char ({100,{100}}) == ["d";"d"])); -%!assert (all(char (100, [], 100) == ["d";" ";"d"])) -%!assert (all(char ({100, [], 100}) == ["d";" ";"d"])) -%!assert (all(char ({100,{100, {""}}}) == ["d";"d";" "])) -%!assert (all(char (["a";"be"], {"c", 100}) == ["a";"be";"c";"d"])) -%!assert(strcmp (char ("a", "bb", "ccc"), ["a "; "bb "; "ccc"])); -%!assert(strcmp (char ([65, 83, 67, 73, 73]), "ASCII")); +%!assert (char (100), "d"); +%!assert (char (100,100), ["d";"d"]) +%!assert (char ({100,100}), ["d";"d"]) +%!assert (char ([100,100]), ["dd"]) +%!assert (char ({100,{100}}), ["d";"d"]) +%!assert (char (100, [], 100), ["d";" ";"d"]) +%!assert (char ({100, [], 100}), ["d";" ";"d"]) +%!assert (char ({100,{100, {""}}}), ["d";"d";" "]) +%!assert (char (["a";"be"], {"c", 100}), ["a";"be";"c";"d"]) +%!assert (char ("a", "bb", "ccc"), ["a "; "bb "; "ccc"]) +%!assert (char ([65, 83, 67, 73, 73]), "ASCII") %!test %! x = char ("foo", "bar", "foobar"); -%! assert((strcmp (x(1,:), "foo ") -%! && strcmp (x(2,:), "bar ") -%! && strcmp (x(3,:), "foobar"))); +%! assert (x(1,:), "foo "); +%! assert (x(2,:), "bar "); +%! assert (x(3,:), "foobar"); */ DEFUN (strvcat, args, , @@ -286,18 +286,19 @@ } /* -%!error <Invalid call to strvcat> strvcat() %!assert (strvcat (""), ""); %!assert (strvcat (100) == "d"); -%!assert (all(strvcat (100,100) == ["d";"d"])); -%!assert (all(strvcat ({100,100}) == ["d";"d"])); -%!assert (all(strvcat ([100,100]) == ["dd"])); -%!assert (all(strvcat ({100,{100}}) == ["d";"d"])); -%!assert (all(strvcat (100, [], 100) == ["d";"d"])) -%!assert (all(strvcat ({100, [], 100}) == ["d";"d"])) -%!assert (all(strvcat ({100,{100, {""}}}) == ["d";"d"])) -%!assert (all(strvcat (["a";"be"], {"c", 100}) == ["a";"be";"c";"d"])) -%!assert(strcmp (strvcat ("a", "bb", "ccc"), ["a "; "bb "; "ccc"])); +%!assert (strvcat (100,100), ["d";"d"]) +%!assert (strvcat ({100,100}), ["d";"d"]) +%!assert (strvcat ([100,100]), ["dd"]) +%!assert (strvcat ({100,{100}}), ["d";"d"]) +%!assert (strvcat (100, [], 100), ["d";"d"]) +%!assert (strvcat ({100, [], 100}), ["d";"d"]) +%!assert (strvcat ({100,{100, {""}}}), ["d";"d"]) +%!assert (strvcat (["a";"be"], {"c", 100}), ["a";"be";"c";"d"]) +%!assert (strvcat ("a", "bb", "ccc"), ["a "; "bb "; "ccc"]) + +%!error strvcat () */ @@ -321,19 +322,20 @@ } /* -%!assert (ischar ("a"), logical (1)); -%!assert (ischar (["ab";"cd"]), logical (1)); -%!assert (ischar ({"ab"}), logical (0)); -%!assert (ischar (1), logical (0)); -%!assert(ischar ([1, 2]), logical (0)); -%!assert(ischar ([]), logical (0)); -%!assert(ischar ([1, 2; 3, 4]), logical (0)); -%!assert(ischar (""), logical (1)); -%!assert(ischar ("test"), logical (1)); -%!assert(ischar (["test"; "ing"]), logical (1)); -%!assert(ischar (struct ("foo", "bar")), logical (0)); -%!error <Invalid call to ischar> ischar (); -%!error <Invalid call to ischar> ischar ("test", 1); +%!assert (ischar ("a"), true) +%!assert (ischar (["ab";"cd"]), true) +%!assert (ischar ({"ab"}), false) +%!assert (ischar (1), false) +%!assert (ischar ([1, 2]), false) +%!assert (ischar ([]), false) +%!assert (ischar ([1, 2; 3, 4]), false) +%!assert (ischar (""), true) +%!assert (ischar ("test"), true) +%!assert (ischar (["test"; "ing"]), true) +%!assert (ischar (struct ("foo", "bar")), false) + +%!error ischar () +%!error ischar ("test", 1) */ static octave_value @@ -589,51 +591,51 @@ } /* -%!error <Invalid call to strcmp> strcmp (); -%!error <Invalid call to strcmp> strcmp ("foo", "bar", 3); -%! %!shared x -%! x = char (zeros (0, 2)); -%!assert (strcmp ('', x) == false); -%!assert (strcmp (x, '') == false); -%!assert (strcmp (x, x) == true); -## %!assert (strcmp ({''}, x) == true); -## %!assert (strcmp ({x}, '') == false); -## %!assert (strcmp ({x}, x) == true); -## %!assert (strcmp ('', {x}) == false); -## %!assert (strcmp (x, {''}) == false); -## %!assert (strcmp (x, {x}) == true); -## %!assert (all (strcmp ({x; x}, '') == [false; false])); -## %!assert (all (strcmp ({x; x}, {''}) == [false; false])); -## %!assert (all (strcmp ('', {x; x}) == [false; false])); -## %!assert (all (strcmp ({''}, {x; x}) == [false; false])); -%!assert (strcmp ({'foo'}, x) == false); -%!assert (strcmp ({'foo'}, 'foo') == true); -%!assert (strcmp ({'foo'}, x) == false); -%!assert (strcmp (x, {'foo'}) == false); -%!assert (strcmp ('foo', {'foo'}) == true); -%!assert (strcmp (x, {'foo'}) == false); +%! x = char (zeros (0, 2)); +%!assert (strcmp ("", x), false) +%!assert (strcmp (x, ""), false) +%!assert (strcmp (x, x), true) +## %!assert (strcmp ({""}, x), true) +## %!assert (strcmp ({x}, ""), false) +## %!assert (strcmp ({x}, x), true) +## %!assert (strcmp ("", {x}), false) +## %!assert (strcmp (x, {""}), false) +## %!assert (strcmp (x, {x}), true) +## %!assert (strcmp ({x; x}, ""), [false; false]) +## %!assert (strcmp ({x; x}, {""}), [false; false]) +## %!assert (strcmp ("", {x; x}), [false; false]) +## %!assert (strcmp ({""}, {x; x}), [false; false]) +%!assert (strcmp ({"foo"}, x), false) +%!assert (strcmp ({"foo"}, "foo"), true) +%!assert (strcmp ({"foo"}, x), false) +%!assert (strcmp (x, {"foo"}), false) +%!assert (strcmp ("foo", {"foo"}), true) +%!assert (strcmp (x, {"foo"}), false) %!shared y -%! y = char (zeros (2, 0)); -%!assert (strcmp ('', y) == false); -%!assert (strcmp (y, '') == false); -%!assert (strcmp (y, y) == true); -%!assert (all (strcmp ({''}, y) == [true; true])); -%!assert (strcmp ({y}, '') == true); -%!assert (all (strcmp ({y}, y) == [true; true])); -%!assert (all (strcmp ('', {y}) == [true; true])); -%!assert (all (strcmp (y, {''}) == [true; true])); -%!assert (all (strcmp (y, {y}) == [true; true])); -%!assert (all (strcmp ({y; y}, '') == [true; true])); -%!assert (all (strcmp ({y; y}, {''}) == [true; true])); -%!assert (all (strcmp ('', {y; y}) == [true; true])); -%!assert (all (strcmp ({''}, {y; y}) == [true; true])); -%!assert (all (strcmp ({'foo'}, y) == [false; false])); -%!assert (all (strcmp ({'foo'}, y) == [false; false])); -%!assert (all (strcmp (y, {'foo'}) == [false; false])); -%!assert (all (strcmp (y, {'foo'}) == [false; false])); -%!assert (strcmp ("foobar", "foobar"), true); -%!assert (strcmp ("fooba", "foobar"), false); +%! y = char (zeros (2, 0)); +%!assert (strcmp ("", y), false) +%!assert (strcmp (y, ""), false) +%!assert (strcmp (y, y), true) +%!assert (strcmp ({""}, y), [true; true]) +%!assert (strcmp ({y}, ""), true) +%!assert (strcmp ({y}, y), [true; true]) +%!assert (strcmp ("", {y}), true) +%!assert (strcmp (y, {""}), [true; true]) +%!assert (strcmp (y, {y}), [true; true]) +%!assert (strcmp ({y; y}, ""), [true; true]) +%!assert (strcmp ({y; y}, {""}), [true; true]) +%!assert (strcmp ("", {y; y}), [true; true]) +%!assert (strcmp ({""}, {y; y}), [true; true]) +%!assert (strcmp ({"foo"}, y), [false; false]) +%!assert (strcmp ({"foo"}, y), [false; false]) +%!assert (strcmp (y, {"foo"}), [false; false]) +%!assert (strcmp (y, {"foo"}), [false; false]) +%!assert (strcmp ("foobar", "foobar"), true) +%!assert (strcmp ("fooba", "foobar"), false) + +%!error strcmp () +%!error strcmp ("foo", "bar", 3) */ // Apparently, Matlab ignores the dims with strncmp. It also @@ -712,15 +714,16 @@ } /* -%!error <Invalid call to strncmp> strncmp (); -%!error <Invalid call to strncmp> strncmp ("abc", "def"); -%!assert (strncmp ("abce", "abc", 3) == 1) -%!assert (strncmp (100, 100, 1) == 0) -%!assert (all (strncmp ("abce", {"abcd", "bca", "abc"}, 3) == [1, 0, 1])) -%!assert (all (strncmp ("abc", {"abcd", "bca", "abc"}, 4) == [0, 0, 0])) -%!assert (all (strncmp ({"abcd", "bca", "abc"},"abce", 3) == [1, 0, 1])) -%!assert (all (strncmp ({"abcd", "bca", "abc"},{"abcd", "bca", "abe"}, 3) == [1, 1, 0])) -%!assert (all (strncmp("abc", {"abcd", 10}, 2) == [1, 0])) +%!assert (strncmp ("abce", "abc", 3), true) +%!assert (strncmp (100, 100, 1), false) +%!assert (strncmp ("abce", {"abcd", "bca", "abc"}, 3), logical ([1, 0, 1])) +%!assert (strncmp ("abc", {"abcd", "bca", "abc"}, 4), logical ([0, 0, 0])) +%!assert (strncmp ({"abcd", "bca", "abc"},"abce", 3), logical ([1, 0, 1])) +%!assert (strncmp ({"abcd", "bca", "abc"},{"abcd", "bca", "abe"}, 3), logical ([1, 1, 0])) +%!assert (strncmp ("abc", {"abcd", 10}, 2), logical ([1, 0])) + +%!error strncmp () +%!error strncmp ("abc", "def") */ // case-insensitive character equality functor @@ -783,7 +786,7 @@ } /* -%!assert (strcmpi("abc123", "ABC123"), logical(1)); +%!assert (strcmpi ("abc123", "ABC123"), true) */ // Like strncmp. @@ -850,7 +853,7 @@ } /* -%!assert (strncmpi("abc123", "ABC456", 3), logical(1)); +%!assert (strncmpi ("abc123", "ABC456", 3), true) */ DEFUN (list_in_columns, args, , @@ -923,15 +926,16 @@ } /* -%!error <Invalid call to list_in_columns> list_in_columns (); -%!error <Invalid call to list_in_columns> list_in_columns (["abc", "def"], 20, 2); -%!error <invalid conversion from string to real scalar> list_in_columns (["abc", "def"], "a"); +%!test +%! input = {"abc", "def", "ghijkl", "mnop", "qrs", "tuv"}; +%! result = "abc mnop\ndef qrs\nghijkl tuv\n"; +%! assert (list_in_columns (input, 20), result); %!test -%! input = {"abc", "def", "ghijkl", "mnop", "qrs", "tuv"}; -%! result = "abc mnop\ndef qrs\nghijkl tuv\n"; -%! assert (list_in_columns (input, 20) == result); -%!test -%! input = ["abc"; "def"; "ghijkl"; "mnop"; "qrs"; "tuv"]; -%! result = "abc mnop \ndef qrs \nghijkl tuv \n"; -%! assert (list_in_columns (input, 20) == result); +%! input = ["abc"; "def"; "ghijkl"; "mnop"; "qrs"; "tuv"]; +%! result = "abc mnop \ndef qrs \nghijkl tuv \n"; +%! assert (list_in_columns (input, 20), result); + +%!error list_in_columns () +%!error list_in_columns (["abc", "def"], 20, 2) +%!error <invalid conversion from string to real scalar> list_in_columns (["abc", "def"], "a") */
--- a/src/symtab.cc +++ b/src/symtab.cc @@ -1531,11 +1531,10 @@ %! assert (ignore_function_time_stamp (), "system"); %! ignore_function_time_stamp (old_state); -%% Test input validation +## Test input validation %!error (ignore_function_time_stamp ("all", "all")) %!error (ignore_function_time_stamp ("UNKNOWN_VALUE")) %!error (ignore_function_time_stamp (42)) - */ DEFUN (__current_scope__, , ,
--- a/src/syscalls.cc +++ b/src/syscalls.cc @@ -369,46 +369,44 @@ } /* - %!test -%! if (isunix()) -%! [in, out, pid] = popen2 ("sort", "-r"); -%! EAGAIN = errno ("EAGAIN"); -%! else -%! [in, out, pid] = popen2 ("sort", "/R"); -%! EAGAIN = errno ("EINVAL"); -%! endif -%! fputs (in, "these\nare\nsome\nstrings\n"); -%! fclose (in); -%! done = false; -%! str = {}; -%! idx = 0; -%! errs = 0; -%! do -%! if (!isunix()) -%! errno (0); -%! endif -%! s = fgets (out); -%! if (ischar (s)) -%! idx++; -%! str{idx} = s; -%! elseif (errno () == EAGAIN) -%! fclear (out); -%! sleep (0.1); -%! if (++errs == 100) -%! done = true; -%! endif -%! else +%! if (isunix ()) +%! [in, out, pid] = popen2 ("sort", "-r"); +%! EAGAIN = errno ("EAGAIN"); +%! else +%! [in, out, pid] = popen2 ("sort", "/R"); +%! EAGAIN = errno ("EINVAL"); +%! endif +%! fputs (in, "these\nare\nsome\nstrings\n"); +%! fclose (in); +%! done = false; +%! str = {}; +%! idx = 0; +%! errs = 0; +%! do +%! if (!isunix ()) +%! errno (0); +%! endif +%! s = fgets (out); +%! if (ischar (s)) +%! idx++; +%! str{idx} = s; +%! elseif (errno () == EAGAIN) +%! fclear (out); +%! sleep (0.1); +%! if (++errs == 100) %! done = true; %! endif -%! until (done) -%! fclose (out); -%! if (isunix()) -%! assert(str,{"these\n","strings\n","some\n","are\n"}) -%! else -%! assert(str,{"these\r\n","strings\r\n","some\r\n","are\r\n"}) -%! end - +%! else +%! done = true; +%! endif +%! until (done) +%! fclose (out); +%! if (isunix ()) +%! assert(str, {"these\n","strings\n","some\n","are\n"}); +%! else +%! assert(str, {"these\r\n","strings\r\n","some\r\n","are\r\n"}); +%! endif */ DEFUNX ("fcntl", Ffcntl, args, ,
--- a/src/sysdep.cc +++ b/src/sysdep.cc @@ -124,21 +124,21 @@ mod_info.dwSize = sizeof (mod_info); if (Module32First (h, &mod_info)) - { - do - { - std::string mod_name (mod_info.szModule); + { + do + { + std::string mod_name (mod_info.szModule); - if (mod_name.find ("octinterp") != std::string::npos) - { - bin_dir = mod_info.szExePath; - if (bin_dir[bin_dir.length () - 1] != '\\') - bin_dir.append (1, '\\'); - break; - } - } - while (Module32Next (h, &mod_info)); - } + if (mod_name.find ("octinterp") != std::string::npos) + { + bin_dir = mod_info.szExePath; + if (bin_dir[bin_dir.length () - 1] != '\\') + bin_dir.append (1, '\\'); + break; + } + } + while (Module32Next (h, &mod_info)); + } CloseHandle (h); } @@ -608,7 +608,7 @@ DEFALIAS (setenv, putenv); /* -%!assert (ischar (getenv ("OCTAVE_HOME"))); +%!assert (ischar (getenv ("OCTAVE_HOME"))) %!test %! setenv ("dummy_variable_that_cannot_matter", "foobar"); %! assert (getenv ("dummy_variable_that_cannot_matter"), "foobar"); @@ -722,9 +722,10 @@ } /* -%!error (pause (1, 2)); %!test %! pause (1); + +%!error (pause (1, 2)) */ DEFUN (sleep, args, , @@ -757,10 +758,11 @@ } /* -%!error (sleep ()); -%!error (sleep (1, 2)); %!test %! sleep (1); + +%!error (sleep ()) +%!error (sleep (1, 2)) */ DEFUN (usleep, args, , @@ -800,10 +802,11 @@ } /* -%!error (usleep ()); -%!error (usleep (1, 2)); %!test %! usleep (1000); + +%!error (usleep ()) +%!error (usleep (1, 2)) */ // FIXME -- maybe this should only return 1 if IEEE floating @@ -823,7 +826,7 @@ } /* -%!assert (islogical (isieee ())); +%!assert (islogical (isieee ())) */ DEFUN (native_float_format, , , @@ -838,7 +841,7 @@ } /* -%!assert (ischar (native_float_format ())); +%!assert (ischar (native_float_format ())) */ DEFUN (tilde_expand, args, ,
--- a/src/toplev.cc +++ b/src/toplev.cc @@ -1484,12 +1484,13 @@ } /* -%!error octave_config_info (1, 2); -%!assert (ischar (octave_config_info ("version"))); +%!assert (ischar (octave_config_info ("version"))) %!test %! x = octave_config_info (); %! assert (isstruct (x)); %! assert (! isempty (x)); + +%!error octave_config_info (1, 2) */ #if defined (__GNUG__) && defined (DEBUG_NEW_DELETE)
--- a/src/utils.cc +++ b/src/utils.cc @@ -117,14 +117,14 @@ } /* -%!error isvarname (); -%!error isvarname ("foo", "bar"); +%!assert (isvarname ("foo"), true) +%!assert (isvarname ("_foo"), true) +%!assert (isvarname ("_1"), true) +%!assert (isvarname ("1foo"), false) +%!assert (isvarname (""), false) -%!assert (isvarname ("foo"), true); -%!assert (isvarname ("_foo"), true); -%!assert (isvarname ("_1"), true); -%!assert (isvarname ("1foo"), false); -%!assert (isvarname (""), false); +%!error isvarname () +%!error isvarname ("foo", "bar"); */ // Return TRUE if F and G are both names for the same file. @@ -339,9 +339,6 @@ } /* -%!error file_in_loadpath (); -%!error file_in_loadpath ("foo", "bar", 1); - %!test %! f = file_in_loadpath ("plot.m"); %! assert (ischar (f)); @@ -354,6 +351,9 @@ %!test %! lst = file_in_loadpath ("$$probably_!!_not_&&_a_!!_file$$", "all"); %! assert (lst, {}); + +%!error file_in_loadpath () +%!error file_in_loadpath ("foo", "bar", 1) */ DEFUN (file_in_path, args, , @@ -422,10 +422,6 @@ } /* -%!error file_in_path (); -%!error file_in_path ("foo"); -%!error file_in_path ("foo", "bar", "baz", 1); - %!test %! f = file_in_path (path (), "plot.m"); %! assert (ischar (f)); @@ -438,6 +434,10 @@ %!test %! lst = file_in_path (path (), "$$probably_!!_not_&&_a_!!_file$$", "all"); %! assert (lst, {}); + +%!error file_in_path () +%!error file_in_path ("foo") +%!error file_in_path ("foo", "bar", "baz", 1) */ std::string @@ -674,19 +674,19 @@ } /* -%!error do_string_escapes (); -%!error do_string_escapes ("foo", "bar"); +%!assert (do_string_escapes ('foo\nbar'), "foo\nbar") +%!assert (do_string_escapes ("foo\\nbar"), "foo\nbar") +%!assert (do_string_escapes ("foo\\nbar"), ["foo", char(10), "bar"]) +%!assert ("foo\nbar", ["foo", char(10), "bar"]) -%!assert (do_string_escapes ('foo\nbar'), "foo\nbar"); -%!assert (do_string_escapes ("foo\\nbar"), "foo\nbar"); -%!assert (do_string_escapes ("foo\\nbar"), ["foo", char(10), "bar"]); -%!assert ("foo\nbar", ["foo", char(10), "bar"]); +%!assert (do_string_escapes ('\a\b\f\n\r\t\v'), "\a\b\f\n\r\t\v") +%!assert (do_string_escapes ("\\a\\b\\f\\n\\r\\t\\v"), "\a\b\f\n\r\t\v") +%!assert (do_string_escapes ("\\a\\b\\f\\n\\r\\t\\v"), +%! char ([7, 8, 12, 10, 13, 9, 11])) +%!assert ("\a\b\f\n\r\t\v", char ([7, 8, 12, 10, 13, 9, 11])) -%!assert (do_string_escapes ('\a\b\f\n\r\t\v'), "\a\b\f\n\r\t\v"); -%!assert (do_string_escapes ("\\a\\b\\f\\n\\r\\t\\v"), "\a\b\f\n\r\t\v"); -%!assert (do_string_escapes ("\\a\\b\\f\\n\\r\\t\\v"), -%! char ([7, 8, 12, 10, 13, 9, 11])); -%!assert ("\a\b\f\n\r\t\v", char ([7, 8, 12, 10, 13, 9, 11])); +%!error do_string_escapes () +%!error do_string_escapes ("foo", "bar") */ const char * @@ -796,17 +796,17 @@ } /* -%!error undo_string_escapes (); -%!error undo_string_escapes ("foo", "bar"); +%!assert (undo_string_escapes ("foo\nbar"), 'foo\nbar') +%!assert (undo_string_escapes ("foo\nbar"), "foo\\nbar") +%!assert (undo_string_escapes (["foo", char(10), "bar"]), "foo\\nbar") -%!assert (undo_string_escapes ("foo\nbar"), 'foo\nbar'); -%!assert (undo_string_escapes ("foo\nbar"), "foo\\nbar"); -%!assert (undo_string_escapes (["foo", char(10), "bar"]), "foo\\nbar"); +%!assert (undo_string_escapes ("\a\b\f\n\r\t\v"), '\a\b\f\n\r\t\v') +%!assert (undo_string_escapes ("\a\b\f\n\r\t\v"), "\\a\\b\\f\\n\\r\\t\\v") +%!assert (undo_string_escapes (char ([7, 8, 12, 10, 13, 9, 11])), +%! "\\a\\b\\f\\n\\r\\t\\v") -%!assert (undo_string_escapes ("\a\b\f\n\r\t\v"), '\a\b\f\n\r\t\v'); -%!assert (undo_string_escapes ("\a\b\f\n\r\t\v"), "\\a\\b\\f\\n\\r\\t\\v"); -%!assert (undo_string_escapes (char ([7, 8, 12, 10, 13, 9, 11])), -%! "\\a\\b\\f\\n\\r\\t\\v"); +%!error undo_string_escapes () +%!error undo_string_escapes ("foo", "bar") */ DEFUN (is_absolute_filename, args, , @@ -828,10 +828,10 @@ } /* -%!error is_absolute_filename (); -%!error is_absolute_filename ("foo", "bar"); +## FIXME: We need system-dependent tests here. -FIXME -- we need system-dependent tests here. +%!error is_absolute_filename () +%!error is_absolute_filename ("foo", "bar") */ DEFUN (is_rooted_relative_filename, args, , @@ -853,10 +853,10 @@ } /* -%!error is_rooted_relative_filename (); -%!error is_rooted_relative_filename ("foo", "bar"); +## FIXME: We need system-dependent tests here. -FIXME -- we need system-dependent tests here. +%!error is_rooted_relative_filename () +%!error is_rooted_relative_filename ("foo", "bar") */ DEFUN (make_absolute_filename, args, , @@ -884,10 +884,10 @@ } /* -%!error make_absolute_filename (); -%!error make_absolute_filename ("foo", "bar"); +## FIXME: We need system-dependent tests here. -FIXME -- we need system-dependent tests here. +%!error make_absolute_filename () +%!error make_absolute_filename ("foo", "bar") */ DEFUN (find_dir_in_path, args, , @@ -931,10 +931,10 @@ } /* -%!error find_dir_in_path (); -%!error find_dir_in_path ("foo", "bar", 1); +## FIXME: We need system-dependent tests here. -FIXME -- need to create tests using current path, pathsep, and dirsep. +%!error find_dir_in_path () +%!error find_dir_in_path ("foo", "bar", 1) */ DEFUNX ("errno", Ferrno, args, , @@ -982,9 +982,7 @@ } /* -%!error errno ("foo", 1); - -%!assert (isnumeric (errno ())); +%!assert (isnumeric (errno ())) %!test %! lst = errno_list (); @@ -994,6 +992,8 @@ %! errno (oldval); %! newval = errno (); %! assert (oldval, newval); + +%!error errno ("foo", 1) */ DEFUN (errno_list, args, , @@ -1013,9 +1013,9 @@ } /* -%!error errno_list ("foo"); +%!assert (isstruct (errno_list ())) -%!assert (isstruct (errno_list ())); +%!error errno_list ("foo") */ static void @@ -1331,11 +1331,11 @@ } /* -%!error isindex (); +%!assert (isindex ([1, 2, 3])) +%!assert (isindex (1:3)) +%!assert (isindex ([1, 2, -3]), false) -%!assert (isindex ([1, 2, 3])); -%!assert (isindex (1:3)); -%!assert (isindex ([1, 2, -3]), false); +%!error isindex () */ octave_value_list
--- a/src/variables.cc +++ b/src/variables.cc @@ -580,17 +580,17 @@ /* %!test -%! if (isunix ()) -%! assert (exist ("/tmp") == 7); -%! assert (exist ("/tmp", "file") == 7); -%! assert (exist ("/tmp", "dir") == 7); -%! assert (exist ("/bin/sh") == 2); -%! assert (exist ("/bin/sh", "file") == 2); -%! assert (exist ("/bin/sh", "dir") == 0); -%! assert (exist ("/dev/null") == 2); -%! assert (exist ("/dev/null", "file") == 2); -%! assert (exist ("/dev/null", "dir") == 0); -%! endif +%! if (isunix ()) +%! assert (exist ("/tmp") == 7); +%! assert (exist ("/tmp", "file") == 7); +%! assert (exist ("/tmp", "dir") == 7); +%! assert (exist ("/bin/sh") == 2); +%! assert (exist ("/bin/sh", "file") == 2); +%! assert (exist ("/bin/sh", "dir") == 0); +%! assert (exist ("/dev/null") == 2); +%! assert (exist ("/dev/null", "file") == 2); +%! assert (exist ("/dev/null", "dir") == 0); +%! endif */ octave_value