Mercurial > hg > octave-terminal
changeset 7040:1f16da18d85d
[project @ 2007-10-19 18:24:19 by jwe]
author | jwe |
---|---|
date | Fri, 19 Oct 2007 18:24:19 +0000 |
parents | 258dd5c9bfe0 |
children | 32da63705bf9 |
files | doc/ChangeLog doc/refcard/refcard.tex scripts/ChangeLog scripts/plot/print.m scripts/plot/subplot.m scripts/time/datevec.m src/ChangeLog src/ov-cell.cc src/ov-struct.cc src/pt-idx.cc |
diffstat | 10 files changed, 198 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2007-10-19 David Bateman <dbateman@free.fr> + + * refcard/refcard.tex: Update for 3.0. + 2007-10-15 Søren Hauberg <hauberg@gmail.com> * interpreter/preface.txi, interpreter/basics.txi,
--- a/doc/refcard/refcard.tex +++ b/doc/refcard/refcard.tex @@ -50,8 +50,8 @@ % I chose to omit. In general, not all synonyms for commands are % covered, nor all variations of a command. -\def\octaveversion{1.1.1} -\def\refcardedition{1.1} +\def\octaveversion{3.0.0} +\def\refcardedition{2.0} % ------------------ % multicolumn format @@ -378,6 +378,7 @@ \sec Starting Octave; octave&start interactive Octave session\cr octave {\it file}&run Octave on commands in {\it file}\cr +octave --eval {\it code}&Evaluate {\it code} using Octave\cr octave --help&describe command line options\cr \endsec @@ -390,8 +391,9 @@ \sec Getting Help; help&list all commands and built-in variables\cr help {\it command}&briefly describe {\it command}\cr -help -i&use Info to browse Octave manual\cr -help -i {\it command}&search for {\it command\/} in Octave manual\cr +doc&use Info to browse Octave manual\cr +doc {\it command}&search for {\it command} in Octave manual\cr +lookfor {\it str}&search for {\it command} based on {\it str}\cr \endsec \sec Motion in Info; @@ -448,7 +450,6 @@ \line{\smrm \opt{ } surround optional arguments \hfill ... show one or more arguments} \vskip0.25\baselineskip -\centerline{\smrm Copyright 1996, 1997 John W. Eaton\qquad Permissions on back} \eject \sec Killing and Yanking; @@ -505,13 +506,39 @@ Square brackets delimit literal matrices. Commas separate elements on the same row. Semicolons separate rows. Commas may be replaced by spaces, and semicolons may be replaced by one or more newlines. - Elements of a matrix may be arbitrary expressions, provided that + Elements of a matrix may be arbitrary expressions, assuming all the dimensions agree.\vskip0.75ex}\span\cr [ {\it x}, {\it y}, ... ]&enter a row vector\cr [ {\it x}; {\it y}; ... ]&enter a column vector\cr [ {\it w}, {\it x}; {\it y}, {\it z} ]&enter a 2$\times$2 matrix\cr \endsec +\sec Multi-dimensional Arrays; +\omit\vbox{\rm\vskip0.25ex + Multi-dimensional arrays may be created with the {\it cat} or + {\it reshape} commands from two-dimensional sub-matrices. + \vskip0.75ex}\span\cr +squeeze ({\it arr})&remove singleton dimensions of the array.\cr +ndims ({\it arr})&number of dimensions in the array.\cr +permute ({\it arr}, {\it p})&permute the dimensions of an array.\cr +ipermute ({\it arr}, {\it p})&array inverse permutation.\cr +\endsec + +\vfill\eject + +\sec ; +shiftdim ({\it arr}, {\it s})&rotate the array dimensions.\cr +circshift ({\it arr}, {\it s})&rotate the array elements.\cr +\endsec + +\sec Sparse Matrices; +sparse (...)&create a sparse matrix.\cr +speye ({\it n)}&create sparse identify matrix.\cr +sprand ({\it n}, {\it m}, {\it d})&sparse rand matrix of density {\it d}.\cr +spdiags (...)&sparse generalization of {\it diag}.\cr +nnz ({\it s})&No. non-zero elements in sparse matrix.\cr +\endsec + \sec Ranges; {\it base} : {\it limit}\cr {\it base} : {\it incr} : {\it limit}\cr @@ -521,12 +548,12 @@ {\it incr\/} is 1. Negative increments are permitted.}\span\cr \endsec -\vfill\eject - \sec Strings and Common Escape Sequences; \omit\vbox{\rm\vskip0.5ex A {\it string constant\/} consists of a sequence of characters - enclosed in either double-quote or single-quote marks.\vskip0.75ex}\span\cr + enclosed in either double-quote or single-quote marks. Strings + in double-quotes allow the use of the escape sequences below. + \vskip0.75ex}\span\cr \char'134\char'134&a literal backslash\cr \char'134 "&a literal double-quote character\cr \char'134 '&a literal single-quote character\cr @@ -546,26 +573,41 @@ \quad :&select all rows (columns)\cr \endsec -\sec Global Variables; +\sec Global and Persistent Variables; global {\it var1} ...&Declare variables global.\cr -\omit\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex +global {\it var1} = {\it val}&Declare variable global. Set intial value.\cr +persistent {\it var1}&Declare a variable as static to a function.\cr +persistent {\it var1} = {\it val}&Declare a variable as static to a + function and set its initial value.\cr +\omit\hfill\vbox{\rm\vskip0.25ex Global variables may be accessed inside the body of a function without having to be passed in the function parameter list provided - they are also declared global within the function.}\span\cr + they are declared global when used.}\span\cr \endsec \sec Selected Built-in Functions; EDITOR&editor to use with {\tt edit\_history}\cr Inf, NaN&IEEE infinity, NaN\cr +NA&Missing value\cr PAGER&program to use to paginate output\cr ans&last result not explicitly assigned\cr eps&machine precision\cr pi&$\pi$\cr +1i&$\sqrt{-1}$\cr realmax&maximum representable value\cr realmin&minimum representable value\cr \endsec -\vfill\eject +\vfill +\centerline{\smrm Copyright 1996, 1997, 2007 John W. Eaton\qquad Permissions on back} +\eject + +\sec Assignment Expressions; +{\it var} = {\it expr}&assign expression to variable\cr +{\it var} ({\it idx}) = {\it expr}&assign expression to indexed variable\cr +{\it var} ({\it idx}) = []&delete the indexed elements.\cr +{\it var} $\{${\it idx}$\}$ = {\it expr}&assign elements of a cell array.\cr +\endsec \sec Arithmetic and Increment Operators; {\it x} + {\it y}&addition\cr @@ -584,17 +626,12 @@ + {\it x}&unary plus (a no-op)\cr {\it x} '&complex conjugate transpose\cr {\it x} .'&transpose\cr -++ {\it x}\quad{\rm(}-- {\it x}{\rm)}&increment (decrement) {\it x}, +++ {\it x}\quad{\rm(}-- {\it x}{\rm)}&increment (decrement), return {\it new\/} value\cr -{\it x} ++\quad{\rm(}{\it x} --{\rm)}&increment (decrement) {\it x}, +{\it x} ++\quad{\rm(}{\it x} --{\rm)}&increment (decrement), return {\it old\/} value\cr \endsec -\sec Assignment Expressions; -{\it var} = {\it expr}&assign expression to variable\cr -{\it var} ({\it idx}) = {\it expr}&assign expression to indexed variable\cr -\endsec - \sec Comparison and Boolean Operators; \omit \vbox{\rm\vskip0.75ex These operators work on an element-by-element basis. Both arguments @@ -612,17 +649,17 @@ \sec Short-circuit Boolean Operators; \omit \vbox{\rm\vskip0.75ex - Operators evaluate left-to-right, expecting scalar operands. - Operands are only evaluated if necessary, stopping once overall - truth value can be determined. Operands are converted to scalars by - applying the {\tt all} function.\vskip0.75ex}\span\cr + Operators evaluate left-to-right. Operands are only evaluated if + necessary, stopping once overall truth value can be determined. + Operands are converted to scalars using the {\tt all} + function.\vskip0.75ex}\span\cr {\it x} \&\& {\it y}&true if both {\it x\/} and {\it y\/} are true\cr {\it x} || {\it y}&true if at least one of {\it x\/} or {\it y\/} is true\cr \endsec \sec Operator Precedence; \omit \vbox{\rm\vskip0.5ex - Here is a table of the operators in Octave, in order of increasing + Table of Octave operators, in order of increasing precedence.\vskip0.75ex}\span\cr ;\ \ ,&statement separators\cr =&assignment, groups left to right\cr @@ -639,6 +676,22 @@ \vfill\eject +\sec Paths and Packages; +path&display the current Octave cunction path.\cr +pathdef&display the default path.\cr +addpath({\it dir})&add a directory to the path.\cr +EXEC\_PATH&manipulate the Octave executable path.\cr +pkg list&display installed packages.\cr +pkg load {\it pack}&Load an installed package.\cr +\endsec + +\sec Cells and Structures; +{\it{var}}.{\it{field}} = ...&set a field of a structure.\cr +{\it{var}}$\{${\it{idx}}$\}$ = ...&set an element of a cell array.\cr +cellfun({\it f}, {\it c})&apply a function to elements of cell array.\cr +fieldnames({\it s})&returns the fields of a structure.\cr +\endsec + \widesec Statements; for {\it identifier} = {\it expr} {\it stmt-list} endfor\cr \hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex @@ -671,6 +724,16 @@ \hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex Execute {\it body}. Execute {\it cleanup} no matter how control exits {\it body}.}\cr +try {\it body} catch {\it cleanup} end\cr +\hfill\vbox{\hsize=\idnwid\rm\vskip0.25ex + Execute {\it body}. Execute {\it cleanup} if {\it body} fails.}\cr +\endsec + +\altsec Strings; +strcmp ({\it s}, {\it t})&compare strings\cr +strcat ({\it s}, {\it t}, ...)&concatenate strings\cr +regexp ({\it str}, {\it pat})&strings matching regular expression\cr +regexprep ({\it str}, {\it pat}, {\it rep})&Match and replace sub-strings\cr \endsec \widesec Defining Functions; @@ -684,11 +747,41 @@ be empty.}\cr \endsec +\vfill\eject + +\sec Function Handles; +@{\it{func}}& Define a function handle to {\it func}.\cr +@({\it var1}, ...) {\it expr}&Define an anonymous function handle.\cr +str2func ({\it str})&Create a function handle from a string.\cr +functions ({\it handle})&Return information about a function handle.\cr +func2str ({\it handle})&Return a string representation of a +function handle.\cr +{\it handle} ({\it arg1}, ...)&Evaluate a function handle.\cr +feval ({\it func}, {\it arg1}, ...)&Evaluate a function handle or + string, passing remaining args to {\it func}\cr +\omit\vbox{\rm\vskip0.25ex + Anonymous function handles take a copy of the variables in the + current workspace.\vskip0.75ex}\span\cr +\endsec + +\sec Miscellaneous Functions; +eval ({\it str})&evaluate {\it str} as a command\cr +error ({\it message})&print message and return to top level\cr +warning ({\it message})&print a warning message\cr +clear {\it pattern}&clear variables matching pattern\cr +exist ({\it str})&check existence of variable or function\cr +who, whos&list current variables\cr +whos {\it var}&details of the varibale {\it var}\cr +\endsec + \sec Basic Matrix Manipulations; rows ({\it a})&return number of rows of {\it a}\cr columns ({\it a})&return number of columns of {\it a}\cr all ({\it a})&check if all elements of {\it a\/} nonzero\cr any ({\it a})&check if any elements of {\it a\/} nonzero\cr +\endsec + +\sec ; find ({\it a})&return indices of nonzero elements\cr sort ({\it a})&order elements in each column of {\it a}\cr sum ({\it a})&sum elements in columns of {\it a}\cr @@ -697,7 +790,7 @@ max ({\it args})&find maximum values\cr rem ({\it x}, {\it y})&find remainder of {\it x}/{\it y}\cr reshape ({\it a}, {\it m}, {\it n})&reformat {\it a} to be {\it m} by - {\it n}\cr\cr + {\it n}\cr diag ({\it v}, {\it k})&create diagonal matrices\cr linspace ({\it b}, {\it l}, {\it n})&create vector of linearly-spaced elements\cr @@ -710,8 +803,6 @@ values\cr \endsec -\vfill\eject - % sin({\it a}) cos({\it a}) tan({\it a})&trigonometric functions\cr % asin({\it a}) acos({\it a}) atan({\it a})&inverse trigonometric functions\cr % sinh({\it a}) cosh({\it a}) tanh({\it a})&hyperbolic trig functions\cr @@ -729,16 +820,19 @@ pinv ({\it a})&compute pseudoinverse of {\it a}\cr qr ({\it a})&compute the QR factorization of a matrix\cr rank ({\it a})&matrix rank\cr +sprank ({\it a})&structrual matrix rank\cr schur ({\it a})&Schur decomposition of a matrix\cr svd ({\it a})&singular value decomposition\cr syl ({\it a}, {\it b}, {\it c})&solve the Sylvester equation\cr \endsec +\vfill\eject + \sec Equations, ODEs, DAEs, Quadrature; *fsolve&solve nonlinear algebraic equations\cr *lsode&integrate nonlinear ODEs\cr *dassl&integrate nonlinear DAEs\cr -*quad&integrate nonlinear functions\cr\cr +*quad&integrate nonlinear functions\cr perror ({\it nm}, {\it code})&for functions that return numeric codes, print error message for named function and given error code\cr\cr @@ -747,11 +841,21 @@ arguments for these functions.}\span\cr \endsec +% \altsec Sets; +% create\_set ({\it a}, {\it b})&create row vector of unique values\cr +% complement ({\it a}, {\it b})&elements of {\it b} not in {\it a}\cr +% intersection ({\it a}, {\it b})&intersection of sets {\it a} and {\it b}\cr +% union ({\it a}, {\it b})&union of sets {\it a} and {\it b}\cr +% \endsec + \sec Signal Processing; -fft ({\it a})&Fast Fourier Transform using FFTPACK\cr -ifft ({\it a})&inverse FFT using FFTPACK\cr +fft ({\it a})&Fast Fourier Transform using FFTW\cr +ifft ({\it a})&inverse FFT using FFTW\cr freqz ({\it args})&FIR filter frequency response\cr -sinc ({\it x})&returns {\tt sin ($\pi$ x)/($\pi$ x)}\cr +filter ({\it a}, {\it b}, {\it x})&filter by transfer function\cr +conv ({\it a}, {\it b})&convolve two vectors\cr +hamming ({\it n})&return Hamming window coefficents\cr +hanning ({\it n})&return Hanning window coefficents\cr \endsec \altsec Image Processing; @@ -770,20 +874,6 @@ save a matrix to {\it file}\span\cr \endsec -\altsec Sets; -create\_set ({\it a}, {\it b})&create row vector of unique values\cr -complement ({\it a}, {\it b})&elements of {\it b} not in {\it a}\cr -intersection ({\it a}, {\it b})&intersection of sets {\it a} and {\it b}\cr -union ({\it a}, {\it b})&union of sets {\it a} and {\it b}\cr -\endsec - -\altsec Strings; -strcmp ({\it s}, {\it t})&compare strings\cr -strcat ({\it s}, {\it t}, ...)&concatenate strings\cr -\endsec - -\vfill\eject - \altsec C-style Input and Output; fopen ({\it name}, {\it mode})&open file {\it name}\cr fclose ({\it file})&close {\it file}\cr @@ -813,15 +903,7 @@ disp ({\it var})&display value of {\it var} to screen\cr \endsec -\sec Miscellaneous Functions; -eval ({\it str})&evaluate {\it str} as a command\cr -feval ({\it str}, ...)&evaluate function named by {\it str}, - passing remaining args to called function\cr\cr -error ({\it message})&print message and return to top level\cr\cr -clear {\it pattern}&clear variables matching pattern\cr -exist ({\it str})&check existence of variable or function\cr -who&list current variables\cr -\endsec +\vfill\eject \sec Polynomials; compan ({\it p})&companion matrix\cr @@ -846,36 +928,38 @@ var ({\it a})&variance\cr \endsec -\vfill\eject - \sec Plotting Functions; plot ({\it args})&2D plot with linear axes\cr plot3 ({\it args})&3D plot with linear axes\cr line ({\it args})&2D or 3D line\cr +patch ({\it args})&2D patch\cr semilogx ({\it args})&2D plot with logarithmic x-axis\cr semilogy ({\it args})&2D plot with logarithmic y-axis\cr loglog ({\it args})&2D plot with logarithmic axes\cr bar ({\it args})&plot bar charts\cr stairs ({\it x}, {\it y})&plot stairsteps\cr -hist ({\it y}, {\it x})&plot histograms\cr\cr -title ({\it string})&set plot title\cr\cr +stem ({\it x}, {it y})&plot a stem graph\cr +hist ({\it y}, {\it x})&plot histograms\cr +contour ({\it x}, {\it y}, {\it z})&contour plot\cr +title ({\it string})&set plot title\cr axis ({\it limits})&set axis ranges\cr xlabel ({\it string})&set x-axis label\cr ylabel ({\it string})&set y-axis label\cr zlabel ({\it string})&set z-axis label\cr +text ({\it x}, {\it y}, {\it str})&add text to a plot\cr legend ({\it string})&set label in plot key\cr grid \opt{on$|$off}&set grid state\cr hold \opt{on$|$off}&set hold state\cr -ishold&return 1 if hold is on, 0 otherwise\cr\cr +ishold&return 1 if hold is on, 0 otherwise\cr mesh ({\it x}, {\it y}, {\it z})&plot 3D surface\cr -meshdom ({\it x}, {\it y})&create mesh coordinate matrices\cr +meshgrid ({\it x}, {\it y})&create mesh coordinate matrices\cr \endsec \vskip 0pt plus 2fill \hrule width \hsize \par\vskip10pt {\smrm\parskip=6pt -Edition \refcardedition for Octave Version \octaveversion. Copyright +Edition \refcardedition\ for Octave Version \octaveversion. Copyright 1996, 2007, John W. Eaton (jwe@bevo.che.wisc.edu). The author assumes no responsibility for any errors on this card.
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2007-10-19 John W. Eaton <jwe@octave.org> + + * plot/subplot.m: Doc fix. + 2007-10-19 David Bateman <dbateman@free.fr> * plot/__bar__.m: Call newplot as needed.
--- a/scripts/plot/print.m +++ b/scripts/plot/print.m @@ -73,9 +73,9 @@ ## Microsoft Enhanced Metafile ## @item fig ## XFig. If this format is selected the additional options -## @code{-textspecial} or @{-textnormal} can be used to control +## @code{-textspecial} or @code{-textnormal} can be used to control ## whether the special flag should be set for the text in the figure -## (default is @{-textnormal}). +## (default is @code{-textnormal}). ## @item hpgl ## HP plotter language ## @item mf
--- a/scripts/plot/subplot.m +++ b/scripts/plot/subplot.m @@ -37,8 +37,8 @@ ## \vskip 10pt ## \hfil\vbox{\offinterlineskip\hrule ## \halign{\vrule#&&\qquad\hfil#\hfil\qquad\vrule\cr -## height13pt&1&2&3&4\cr height12pt&&&&\cr\noalign{\hrule} -## height13pt&5&6&7&8\cr height12pt&&&&\cr\noalign{\hrule}}} +## height13pt&1&2&3\cr height12pt&&&&\cr\noalign{\hrule} +## height13pt&4&5&6\cr height12pt&&&&\cr\noalign{\hrule}}} ## \hfil ## \vskip 10pt ## @end tex @@ -48,11 +48,11 @@ ## @group ## @example ## -## +-----+-----+-----+-----+ -## | 1 | 2 | 3 | 4 | -## +-----+-----+-----+-----+ -## | 5 | 6 | 7 | 8 | -## +-----+-----+-----+-----+ +## +-----+-----+-----+ +## | 1 | 2 | 3 | +## +-----+-----+-----+ +## | 4 | 5 | 6 | +## +-----+-----+-----+ ## @end example ## @end group ## @end display
--- a/scripts/time/datevec.m +++ b/scripts/time/datevec.m @@ -245,6 +245,7 @@ f = strrep (f, "MM", "%M"); f = strrep (f, "SS", "%S"); + ds, f [tm, nc] = strptime (ds, f); if (nc == length (ds) + 1)
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2007-10-19 John W. Eaton <jwe@octave.org> + + * pt-idx.cc (tree_index_expression::lvalue): Correctly compute + number of elements in lvalue expression when last indexing + element is ".". + + * ov-cell.cc (octave_cell::subsasgn): If RHS is cs-list, don't + fail if shape of LHS is different. + * ov-struct.cc (octave_struct::subsasgn): Likewise. + 2007-10-19 Olli Saarela <Olli.Saarela@kcl.fi> * help.cc (Flookfor): Call print_usage instead of usage.
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -252,9 +252,12 @@ { Cell tmp_cell = Cell (t_rhs.list_value ()); - // FIXME -- shouldn't care if the dimensions of the - // RHS don't match the dimensions of the subscripted - // LHS. + // The shape of the RHS is irrelevant, we just want + // the number of elements to agree and to preserve the + // shape of the left hand side of the assignment. + + if (numel () == tmp_cell.numel ()) + tmp_cell = tmp_cell.reshape (dims ()); octave_base_matrix<Cell>::assign (i, tmp_cell); }
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -367,9 +367,12 @@ { Cell tmp_cell = Cell (t_rhs.list_value ()); - // FIXME -- shouldn't care if the dimensions of the - // RHS don't match the dimensions of the subscriped - // LHS. + // The shape of the RHS is irrelevant, we just want + // the number of elements to agree and to preserve the + // shape of the left hand side of the assignment. + + if (numel () == tmp_cell.numel ()) + tmp_cell = tmp_cell.reshape (dims ()); map.assign (key, tmp_cell); }
--- a/src/pt-idx.cc +++ b/src/pt-idx.cc @@ -488,7 +488,18 @@ // comma-separated list? if (first_retval_object.is_map ()) - retval.numel (first_retval_object.numel ()); + { + octave_value_list tmp_list + = first_retval_object.subsref (type, idx, 1); + + if (! error_state) + { + octave_value val = tmp_list(0); + + retval.numel (val.is_cs_list () + ? val.numel () : 1); + } + } } } else