octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bi variate to mono variate functions


From: David Bateman
Subject: Re: Bi variate to mono variate functions
Date: Fri, 31 Mar 2006 10:59:08 +0200
User-agent: Mozilla Thunderbird 1.0.6-7.5.20060mdk (X11/20050322)

John W. Eaton wrote:

>On 31-Mar-2006, David Bateman wrote:
>
>| John W. Eaton wrote:
>| 
>| >On 30-Mar-2006, I wrote:
>| >
>| >| Inline functions are created using eval_string, which is given
>| >| something like
>| >| 
>| >|   "@(ARGS) EXPRESSION"
>| >| 
>| >| where EXPRESSION is the argument passed to inline, and ARGS are the
>| >| variable names extracted from EXPRESSION.
>| >
>| >The answer appears to be yes, it would cause an incompatibility,
>| >because functions constructed with inline don't seem to pick up
>| >unbound variables from the parent context when they are constructed.
>| >So we would need a way to limit this feature to actual anonymous
>| >functions.
>| >
>| >jwe
>| >
>| >
>| >  
>| >
>| John,
>| 
>| However, the Finline function indentifies all of the args and makes them
>| part of the anonymous function handle. That is "inline('x+y+z')" is
>| constructed using an anonymous function handle like "@(x,y,z) x +y + z".
>| Whereas the case of a fixed value in a user function is more like
>| "@(x,y) x + y + z", where in this case "z" is fixed. So in that can we
>| can change make_anon_fcn_handle to resolve any arguments that are not in
>| the leading parathesis at the time the function handle is defined.
>
>What about the case of
>
>  b = 1;
>  f = inline ('a+b', 'a')
>  f(1)
>
>which I think produces an error in Matlab.  So I think we still need a
>way to skip the new step of providing initial values for symbols when
>defining inline functions.  OTOH, this seems to me to be a strange
>inconsistency, so maybe it is a bug in Matlab that anonymous and
>inline functions behave in fundamentally different ways.  So are there
>any bad consequences if Octave returns 2 for the f(1) expression in my
>example above?  If there aren't any, then I think it would be simpler
>to implement as we wouldn't need the special case for inline functions.
>  
>
Matlab R14sp3

>> b = 1;
>> f = inline ('a+b', 'a')

f =

Inline function:
f(a) = a+b

>> f(1)
??? Error using ==> inlineeval
Error in inline expression ==> a+b
??? Error using ==> eval
Undefined function or variable 'b'.

Error in ==> inline.subsref at 25
INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr,
INLINE_OBJ_.expr);

Octave 2.9.5+

octave:4> b = 1;
octave:5> f = inline ('a+b', 'a')
f =

f(a) = a+b

octave:6> f(1)
error: `b' undefined near line 4 column 8
error: evaluating binary operator `+' near line 4, column 7
error: called from `?unknown?'

I get the same behaviour for both octave and matlab, so I don't think
this is an issue, as we can't define initial values for symbols in
inline functions. I tried hard to get the parser of the octave inline
function to do the same as the matlab version, and so this is probably
related to that. As inline functions are depreciated relative to
anonymous function handles I don't thnink its worth allowing undefined
parameters of inline functions to be defined at the time of their
definition, which matlab doesn't do in any case.

D.

-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

[Prev in Thread] Current Thread [Next in Thread]