octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running a script file inside c++ code


From: address@hidden
Subject: Re: Running a script file inside c++ code
Date: Sun, 14 Aug 2016 06:59:18 +0900 (JST)

--- sumeet.kumar507 wrote:
> Hello all, 
> 
> I am using octave parser to evaluate expression inside my c++ code. The 
> expressions can be very simple can can also be complicated  depending upon 
> the user. 
> 
> 1)So basically, I have a string which contains all the commands that needs to 
> be executed by octave. But I am unable to execute and get the results of the 
> string containing commands. 
> 
> 2)So, I found another way, in which I write the string in an file and then 
> parse it using octave as
> 
>     char *oct_argv[3] = 
> {(char*)"embeded",(char*)"-q",(char*)"--interactive"}; 
>     octave_main(3,oct_argv,true);
>     ofstream ScriptFile("script", ios::out);
>     ScriptFile << function ;
>     ScriptFile.close();
>     source_file("script");
> 
> where function is the string that needs to be evaluated. 
> 
> The second approach works but the problem is very slow because of generation 
> of file each time I want a computation. I usually end up in 
> thousands/millions of them and it gets extremely slow, like taking days.. to 
> complete.
> 
> 
> In order to be more efficient, i want to do it as 1st way. So anybody has any 
> idea, how to do it more faster/effecient or how to do as in first way.
> 
> Sumeet
> 
> -- 
>          
> Sumeet Kumar SinhaGraduate Student
> Phone: (+1) 5306018271
> Website : http://www.sumeetsinha.in/  

https://www.gnu.org/software/octave/doc/interpreter/Standalone-Programs.html#Standalone-Programs

Is the second example useful for you?

Other method is to commucate with octave via pipe.

HTH

Tatsuro



reply via email to

[Prev in Thread] Current Thread [Next in Thread]