[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Better quadrature routine in octave
From: |
Pedro Gonnet |
Subject: |
Re: Better quadrature routine in octave |
Date: |
Sun, 25 Apr 2010 19:52:22 +0100 |
On Sun, 2010-04-25 at 20:38 +0200, David Bateman wrote:
> Why not use the make_fcn_handle function from ov-fcn-handle.cc to create
> an anonymous function using the string above with "f" replaced with the
> string given by the fcn_name method of the ov-fcn-handle class or the
> the arg itself if a string is passed to your quadrature function?
>
> D.
Ok, thanks, that seems to work... Except that if I store the integrand
"f" as
octave_function *fcn = arg(0).function_value();
and then try to access its name using
fcn->name()
I get an empty string for anonymous functions... Am I doing something
wrong here? The complete code is
if ( std::isinf(a) || std::isinf(b) ) {
std::string fstr = "(x) ";
fstr.append(fcn->name());
fstr.append("( tan ( pi / 2 * x ) ) .* ( 1 + tan ( pi * x / 2 ).^2
) * pi / 2; endfunction;");
fcn = make_fcn_handle(fstr).function_value();
for ( i = 0 ; i <= nivals ; i++ )
if ( std::isinf(iivals[i]) )
iivals[i] = copysign(1.0,iivals[i]);
else
iivals[i] = 2.0 * atan(iivals[i]) / M_PI;
}
Cheers and thanks again,
Pedro