Mercurial > octave
comparison scripts/legacy/@inline/vectorize.m @ 30911:b7edac56a810
Add functions to @inline class for Matlab compatibility (Bug #62260).
* scripts/legacy/@inline/cat.m, scripts/legacy/@inline/cat.m,
scripts/legacy/@inline/disp.m, scripts/legacy/@inline/exist.m,
scripts/legacy/@inline/horzcat.m, scripts/legacy/@inline/nargin.m,
scripts/legacy/@inline/nargout.m, scripts/legacy/@inline/symvar.m,
scripts/legacy/@inline/vertcat.m: New functions
* scripts/legacy/module.mk: Add new functions to build system.
* scripts/legacy/@inline/argnames.m: scripts/legacy/@inline/char.m,
scripts/legacy/@inline/feval.m, scripts/legacy/@inline/formula.m,
scripts/legacy/@inline/subsref.m, scripts/legacy/@inline/vectorize.m:
Redo documentation. Change FCN input name to FOBJ.
* scripts/legacy/@inline/inline.m: Single tweak to documentation.
* scripts/legacy/__vectorize__.m: Add note that this function was translated
from C++.
* scripts/legacy/vectorize.m: Remove incorrect note about function being
translated from C++.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 06 Apr 2022 21:25:58 -0700 |
parents | 78c3dcadf130 |
children | 597f3ee61a48 |
comparison
equal
deleted
inserted
replaced
30910:78c3dcadf130 | 30911:b7edac56a810 |
---|---|
22 ## <https://www.gnu.org/licenses/>. | 22 ## <https://www.gnu.org/licenses/>. |
23 ## | 23 ## |
24 ######################################################################## | 24 ######################################################################## |
25 | 25 |
26 ## -*- texinfo -*- | 26 ## -*- texinfo -*- |
27 ## @deftypefn {} {@var{vfcn} =} vectorize (@var{fcn}) | 27 ## @deftypefn {} {@var{vfcn} =} vectorize (@var{fobj}) |
28 ## Create a vectorized version of the inline function @var{fcn} by | 28 ## Create a vectorized version of the inline function @var{fobj} by |
29 ## replacing all occurrences of @code{*}, @code{/}, etc., with | 29 ## replacing all occurrences of @code{*}, @code{/}, etc., with |
30 ## @code{.*}, @code{./}, etc. | 30 ## @code{.*}, @code{./}, etc. |
31 ## | 31 ## |
32 ## This may be useful, for example, when using inline functions with | 32 ## This may be useful, for example, when using inline functions with |
33 ## numerical integration or optimization where a vector-valued function | 33 ## numerical integration or optimization where a vector-valued function |
34 ## is expected. | 34 ## is expected. |
35 ## | 35 ## |
36 ## @example | 36 ## @example |
37 ## @group | 37 ## @group |
38 ## fcn = vectorize (inline ("x^2 - 1")) | 38 ## fobj = vectorize (inline ("x^2 - 1")) |
39 ## @result{} fcn = f(x) = x.^2 - 1 | 39 ## @result{} fobj = f(x) = x.^2 - 1 |
40 ## quadv (fcn, 0, 3) | 40 ## quadv (fobj, 0, 3) |
41 ## @result{} 6 | 41 ## @result{} 6 |
42 ## @end group | 42 ## @end group |
43 ## @end example | 43 ## @end example |
44 ## @seealso{inline, formula, argnames} | 44 ## @seealso{inline, formula, argnames} |
45 ## @end deftypefn | 45 ## @end deftypefn |
46 | 46 |
47 ## The following function was translated directly from the original C++ | 47 function vfcn = vectorize (fobj) |
48 ## version. Yes, it will be slow, but the use of inline functions is | |
49 ## strongly discouraged anyway, and most expressions will probably be | |
50 ## short. It may also be buggy. Well, don't use this function! Use | |
51 ## function handles instead! | |
52 | 48 |
53 function vfcn = vectorize (fcn) | 49 vfcn = inline (__vectorize__ (fobj.expr)); |
54 | |
55 vfcn = inline (__vectorize__ (fcn.expr)); | |
56 | 50 |
57 endfunction | 51 endfunction |