# HG changeset patch # User Jaroslav Hajek # Date 1279695666 -7200 # Node ID 5b68000faac16c1ab66402dd832de933d77275dd # Parent e38c071bbc417ec29a478416d6aa4ce5df105d1a tips update diff -r e38c071bbc41 -r 5b68000faac1 doc/ChangeLog --- a/doc/ChangeLog Wed Jul 21 08:47:34 2010 +0200 +++ b/doc/ChangeLog Wed Jul 21 09:01:06 2010 +0200 @@ -1,3 +1,7 @@ +2010-07-21 Jaroslav Hajek + + * interpreter/tips.txi: Update some tips. + 2010-07-19 Rik * interpreter/mk_doc_cache.m: Use regexp rather than fussing with diff -r e38c071bbc41 -r 5b68000faac1 doc/interpreter/tips.txi --- a/doc/interpreter/tips.txi Wed Jul 21 08:47:34 2010 +0200 +++ b/doc/interpreter/tips.txi Wed Jul 21 09:01:06 2010 +0200 @@ -109,8 +109,21 @@ Even with a m-file library function, chances are good that it is already optimized, or will be optimized more in a future release. +For instance, even better than + +@example +a = b(2:n) - b(1:n-1); +@end example + +is + +@example +a = diff (b); +@end example + + @item -Avoid computing costly intermediate results multiple times. Octave currently +Avoid computing costly intermediate results multiple times. Octave currently does not eliminate common subexpressions. Also, certain internal computation results are cached for variables. For instance, if a matrix variable is used multiple times as an index, @@ -238,6 +251,7 @@ Octave includes a number of other functions that can replace common types of loops, including @code{bsxfun}, @code{arrayfun}, @code{structfun}, @code{accumarray}. These functions can take an arbitrary function as a handle. +Be sure to get familiar with them if you want to become an Octave expert. @item Avoid calling @code{eval} or @code{feval} excessively, because