[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Error defining anonymous function handle, inline function or embedded fu
From: |
David Bateman |
Subject: |
Error defining anonymous function handle, inline function or embedded function |
Date: |
Wed, 18 May 2005 18:58:26 +0200 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040923) |
I'm trying to write some test code using the octave-forge test/assert
functions and I have a block like
%!test
%! function y = fn (x), n = 10; y =
spdiags([ones(n,1),4*ones(n,1),ones(n,1)],[-2,0,2],n,n) * x; endfunction;
%! opts.issym = 1; opts.isreal = 1;
%! d1 = eigs (@fn, n, k, 'lm', opts);
%! assert (d1, d0((end-k+1):end), 1e-12);
Running this test results in the error
!!!!! test failed
error: nested functions not implemented in this context
which seems to be coming from the parser. Changing this to read
%! fn = inline
('spdiags([ones(10,1),4*ones(10,1),ones(10,1)],[-2,0,2],10,10) * x', 'x');
results in the equally confusing error
error: error creating function handle "@fn", though
%! fn = @(x)
spdiags([ones(10,1),4*ones(10,1),ones(10,1)],[-2,0,2],10,10) * x;
seems to work. Before filing a bug report, is this the expected
behaviour? I believe that the test.m function in octave-forge reads
these comments then calls eval on them embedded in another function. So
in this case the first error is understandable as we can't do
function y = f1 (x)
function p = f2 (q)
p = q+1;
endfunction
y = f2(x) + 1;
endfunction
but the second error I don't understand at all, or why it works for a
function handle.. All of these work is they aren't used in a test block...
Regards
David
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax)
91193 Gif-Sur-Yvette FRANCE
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Error defining anonymous function handle, inline function or embedded function,
David Bateman <=