[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Function pointers in subfunctions
From: |
Andy Adler |
Subject: |
Function pointers in subfunctions |
Date: |
Sun, 30 Oct 2005 07:39:42 -0500 (EST) |
There appears to be a limitation for octave's function pointers,
when used with the octave-forge optimization functions.
For example, this works:
function testfcn()
disp( fmins(@fcn, 0, [], [], 2, 1) )
function y= fcn( x, p1, p2)
y= abs( p1*x + p2 );
octave:28> testfcn
-0.50000
but this doesn't
function testfcn()
disp( fmins(@fcn, 0, [], [], 2, 1) )
function y= fcn( x, p1, p2)
y= ptr_fcn(x,p1,p2);
function y= ptr_fcn( x, p1, p2)
y= abs( p1*x + p2 );
octave:27> testfcn
error: `ptr_fcn' undefined near line 6 column 7
error: evaluating assignment expression near line 6, column 5
error: called from `testfcn:fcn' in file `.... /testfcn.m'
Both work in Matlab.
As an aside, I would really like to be able to use
'fsolve' with parameters provided. I tried to look at
fsolve.cc but it seemed to be based on a really old
method of creating tmp functions, so I wanted to check
whether it was worth trying to submit a patch to fsolve.cc
or not.
--
Andy Adler <address@hidden> 1(613)562-5800x6218