# HG changeset patch # User jwe # Date 1181681283 0 # Node ID 3f4ccca056124f14ab541141cf29eeb2bc6a54ca # Parent 6d366791e1325f0f5c8d405cb08e9eb20799e0ae [project @ 2007-06-12 20:48:02 by jwe] diff --git a/liboctave/CMatrix.cc b/liboctave/CMatrix.cc --- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -2619,6 +2619,9 @@ ComplexMatrix m = *this; + if (numel () == 1) + return ComplexMatrix (1, 1, exp (m(0))); + octave_idx_type nc = columns (); // Preconditioning step 1: trace normalization to reduce dynamic diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,6 +1,7 @@ -2007-06-04 David Bateman - - * file-ops.cc: Typo. +2007-06-12 John W. Eaton + + * dMatrix.cc (Matrix::expm): Special case for scalar arg. + * CMatrix.cc (ComplexMatrix::expm): Likewise. 2007-06-06 Michael Goffioul @@ -18,6 +19,8 @@ 2007-06-04 David Bateman + * file-ops.cc: Typo. + * Sparse.cc (Sparse Sparse::reshape): If length of new dimensions is greater than 2, collapse to 2-D. diff --git a/liboctave/dMatrix.cc b/liboctave/dMatrix.cc --- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -2252,6 +2252,9 @@ Matrix m = *this; + if (numel () == 1) + return Matrix (1, 1, exp (m(0))); + octave_idx_type nc = columns (); // Preconditioning step 1: trace normalization to reduce dynamic diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2007-06-12 Søren Hauberg + + * plot/fplot.m: If function is inline, vectorize it. + 2007-06-10 David Bateman * pkg/pkg.m (pkg:installed_packages): truncate start of package diff --git a/scripts/plot/fplot.m b/scripts/plot/fplot.m --- a/scripts/plot/fplot.m +++ b/scripts/plot/fplot.m @@ -20,7 +20,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} fplot (@var{fn}, @var{limits}) ## @deftypefnx {Function File} {} fplot (@var{fn}, @var{limits}, @var{n}) -## Plots a function @var{fn}, within the defined limits. @var{fn} +## Plot a function @var{fn}, within the defined limits. @var{fn} ## an be either a string, a function handle or an inline function. ## The limits of the plot are given by @var{limits} of the form ## @code{[@var{xlo}, @var{xhi}]} or @code{[@var{xlo}, @var{xhi}, @@ -28,8 +28,8 @@ ## defaults to 100. ## ## @example -## fplot('cos',[0,2*pi]) -## fplot('[cos(x),sin(x)]',[0,2*pi]) +## fplot ("cos", [0, 2*pi]) +## fplot ("[cos(x), sin(x)]", [0, 2*pi]) ## @end example ## @end deftypefn @@ -44,12 +44,18 @@ x = linspace (limits(1), limits(2), n)'; - if (isa (fn, "inline function") || isa (fn, "function_handle")) + nam = fn; + if (strcmp (typeinfo (fn), "inline function")) + fn = vectorize (fn); y = fn (x); + nam = formula (fn); + elseif (isa (fn, "function_handle")) + y = fn (x); + nam = func2str (fn); elseif (all (isalnum (fn))) y = feval (fn, x); else - finl = inline (fn); + finl = vectorize (inline (fn)); y = finl (x); endif @@ -57,6 +63,6 @@ axis (limits); endif - plot (x, y, [";", fn, ";"]); + plot (x, y, [";", nam, ";"]); endfunction diff --git a/test/ChangeLog b/test/ChangeLog --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2007-06-06 John W. Eaton + + * test_signal.m: Rename internal assert function to xassert. + 2007-04-26 David Bateman * test_for.m: Add tests for multi-dimensional matrices and cell diff --git a/test/test_signal.m b/test/test_signal.m --- a/test/test_signal.m +++ b/test/test_signal.m @@ -123,7 +123,7 @@ %! assert(all( all( abs(s-answer) < 30*eps ) )); %% test/octave.test/signal/unwrap-1.m -%!function t = assert(a,b,tol) +%!function t = xassert(a,b,tol) %! if (nargin == 1) %! t = all(a(:)); %! else @@ -148,18 +148,18 @@ %! w = r - 2*pi*floor((r+pi)/(2*pi)); # wrapped into [-pi,pi] %! tol = 1e3*eps; # maximum expected deviation %! -%! t(++i) = assert(r, unwrap(w), tol); #unwrap single row -%! t(++i) = assert(r', unwrap(w'), tol); #unwrap single column -%! t(++i) = assert([r',r'], unwrap([w',w']), tol); #unwrap 2 columns -%! t(++i) = assert([r;r], unwrap([w;w],[],2), tol); #verify that dim works -%! t(++i) = assert(r+10, unwrap(10+w), tol); #verify that r(1)>pi works +%! t(++i) = xassert(r, unwrap(w), tol); #unwrap single row +%! t(++i) = xassert(r', unwrap(w'), tol); #unwrap single column +%! t(++i) = xassert([r',r'], unwrap([w',w']), tol); #unwrap 2 columns +%! t(++i) = xassert([r;r], unwrap([w;w],[],2), tol); #verify that dim works +%! t(++i) = xassert(r+10, unwrap(10+w), tol); #verify that r(1)>pi works %! -%! t(++i) = assert(w', unwrap(w',[],2)); #unwrap col by rows should not change it -%! t(++i) = assert(w, unwrap(w,[],1)); #unwrap row by cols should not change it -%! t(++i) = assert([w;w], unwrap([w;w])); #unwrap 2 rows by cols should not change them +%! t(++i) = xassert(w', unwrap(w',[],2)); #unwrap col by rows should not change it +%! t(++i) = xassert(w, unwrap(w,[],1)); #unwrap row by cols should not change it +%! t(++i) = xassert([w;w], unwrap([w;w])); #unwrap 2 rows by cols should not change them %! %! ## verify that setting tolerance too low will cause bad results. -%! t(++i) = assert(any(abs(r - unwrap(w,0.8)) > 100)); +%! t(++i) = xassert(any(abs(r - unwrap(w,0.8)) > 100)); %! %! assert(all(t));