Re: outer product implementation

Muthiah Annamalai <[email protected]> Mon, 11 Sep 2006 11:15:31 -0500
Newsgroups gmane.comp.gnu.octave.sources
Message-ID <1157991331.5154.11.camel@localhost>
On Sun, 2006-09-10 at 21:24 +0200, David Bateman wrote:
> Muthiah Annamalai wrote:
> > Paul,
> > I have fixed the 2nd version of the outer product code as you had asked
> > me
> > to using C++ style inline functions etc & TexInfo documentation.
> > 
> > The older code can be found at.
> > http://www.cae.wisc.edu/pipermail/octave-sources/2006-April/000000.html
> > 
> > Im attaching the new code & the same test case.
> > Thanks
> > Muthu
> 
> 
> Muthu,
> 
> For the string name functions, you might want to look at the code in
> quad.cc that creates a temporary function based on the string argument
> that is passed. Extract the relevant parts, you'll need code something like
> 
> 
>   std::string fcn_name;
>   octave_function *fcn;
> 
>   if (args(0).is_function_handle () || args(0).is_inline_function ())
>      fcn = args(0).function_value ();
>   else if (args(0).is_string())
>     {
>       fcn_name = unique_symbol_name ("__fcn_");
>       std::string fname = "function z = ";
>       fname.append (fcn_name);
>       fname.append ("(x, y) z = ");
>       fcn = extract_function (args(0), "outer", fcn_name, fname,
>                                       "(x, y); endfunction");
>     }
> 
>    if (error_state || !fcn)
>      {
>         error("sensible error message");
>         return retval;
>      }
> 
>   // Do want ever you want to do with fcn
>   ....
> 
> 
>   if (fcn_name.length())
>     // We have a string function name. Dealloc temp func
>     clear_function (fcn_name);
> 
> 
> added to your code.
> 
> D.

David,
I think I didnt mention the kind of functionality I wanted: 
To evaluate functions when 

1. Passed by @ sign
2. Passed by function name (string)
3. Passed by inline function code


Now the code you point out to me handles the inline function code.

But I was actually mentioning #2 in the list.

I think I will have to use some way to load the function and 
get a octave_function handle to it, as feval() of this might
make the process slower than it need to be.

So Im working on adding the #2 and #3 using your suggested code in
(quad.cc).

Thanks
Muthu