Mercurial > hg > octave-nkf
diff doc/interpreter/tips.txi @ 10812:5b68000faac1
tips update
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 21 Jul 2010 09:01:06 +0200 |
parents | 3140cb7a05a1 |
children | 322f43e0e170 |
line wrap: on
line diff
--- a/doc/interpreter/tips.txi +++ b/doc/interpreter/tips.txi @@ -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