[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Calling octave functions from oct-files
From: |
Evan |
Subject: |
Re: Calling octave functions from oct-files |
Date: |
Sun, 13 Jan 2008 15:00:09 +0800 |
On Jan 13, 2008 2:30 PM, John W. Eaton <address@hidden> wrote:
>
> On 13-Jan-2008, Evan wrote:
>
> | I am converting some part of my program from octave scripts to
> | oct-files in order to improve performance. I find that I have to call
> | octave functions in a for loop. And if I use "feval" to do this, it
> | consumes a lot of time. The result is that the oct-file is even slower
> | than the octave script. So I wonder if there is an another way to call
> | octave functions. For example, can I get the pointer to the function,
> | then just use (*p)(args) to call the function?
>
> No.
>
> Maybe you could give a complete (but short) example that shows what
> you are trying to do? I don't think feval from a .oct file should be
> slower than running an interpreted script.
>
What I am trying to do is something like
for (i = 0; i < n; i++)
{
quad_args(2) = xf(i);
feval ("quad", quad_args, 4);
}
It turns out to be slower than the corresponding script
I also tried the following examples
// fun1.cc
#include <octave/oct.h>
#include <octave/parse.h>
DEFUN_DLD (fun1, args, , "fun1")
{
return feval("sin", octave_value (3), 1);
}
//end of fun1.cc
// fun2.cc
#include <octave/oct.h>
#include <octave/parse.h>
DEFUN_DLD (fun2, args, , "fun2")
{
int state;
return eval_string ("sin(3)", true, state, 1);
}
// end of fun2.cc
I compared the runing time of fun1, fun2 and sin(3) in octave by
tic; fun1; toc
tic; fun2; toc
tic; sin(3); toc
I find that fun1 and fun2 are hundreds of times slower than sin(3).
(I have taken into account the time consumed by "tic;toc")
any ideas?
- Calling octave functions from oct-files, Evan, 2008/01/13
- Calling octave functions from oct-files, John W. Eaton, 2008/01/13
- Re: Calling octave functions from oct-files,
Evan <=
- Message not available
- Re: Calling octave functions from oct-files, Evan, 2008/01/17
- Re: Calling octave functions from oct-files, Carlo de Falco, 2008/01/17
- Re: Calling octave functions from oct-files, Carlo de Falco, 2008/01/17
- Re: Calling octave functions from oct-files, Evan, 2008/01/17
- Re: Calling octave functions from oct-files, Muthiah Annamalai, 2008/01/17
- Re: Calling octave functions from oct-files, Carlo de Falco, 2008/01/18
- Re: Calling octave functions from oct-files, Evan, 2008/01/19
- Re: Calling octave functions from oct-files, kensmith, 2008/01/27