help-octave
[Top][All Lists]
Advanced

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

information about standalone programs ?


From: mallet
Subject: information about standalone programs ?
Date: Thu, 01 Apr 2010 15:44:59 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc11 Thunderbird/3.0.3

Dear all,

I tried to get information about making standalone programs but didn’ t find a lot so i try here.

I have to coupling programs, ones in Fortran others in Matlab with data exchange between them. I can use C or C++ but it have to be standalone programs.

So that’ s my purpose: receive a matrix in an array, send it to a function.m which returns another matrix that y send in an array.

I made it and it works well but i want to understand some things.
Below a simplified example with my questions commented (I made it from the example of the documentation):

/*
Which includes are really needed in the example below?
*/
#include <octave/oct.h>
#include <octave/octave.h>
#include <octave/parse.h>
#include <octave/toplev.h> /* do_octave_atexit */

#define IP_DIM_X 2
#define IP_DIM_Y 3

int main (const int argc, char ** argv) {

const char * argvv [] = {"" /* name of program, not relevant */, "--silent"};
/*
Why the line below doesn’ t work?

const char * argvv [] = {"",""};

What would be the name of program if I would one?
*/
int il_size[2];
int t=12;

il_size[0] = IP_DIM_X;
il_size[1] = IP_DIM_Y;

double fla_transport [ il_size[0] * il_size[1] ];
double fla_rent [ il_size[0] * il_size[1] ];

octave_main (2, (char **) argvv, true /* embedded */);
/*
Is that calling octave? I have a new line in my «~/.octave_hist» each time in run the program.
Does that mean if octave is not installed I cannot use this program?
If it does we can’t talk about a standalone program.

What does the «2» and the «true» mean?

*/

Matrix inMatrix (il_size[0], il_size[1]);

octave_value_list functionArguments;
/*
Do I HAVE to use this to call functions?
*/


//Reception of transport

//Copy fla_transport in inMatrix to give it to Octave.
for (int i=0 ; i<il_size[0]; i++){
for (int j=0 ; j<il_size[1]; j++){
int index = i*il_size[1] + j;
inMatrix (i,j) = fla_transport[index];
}
}

functionArguments (0) = inMatrix;
functionArguments (1) = t;

const octave_value_list result = feval ("multiplication", functionArguments,1);
/*
I found somewhere that the «1» was because I expect one argument,
but if I have to use functionArguments it will allways be 1?

Is there another way to use a function than «feval»?
*/
inMatrix = result (0).matrix_value ();
/*
Where can i found the list of the «octave_value_list» methods?
I thought it was in «oct-obj.cc» but i didn’t find it.
*/

//Copy of inMatrix for send
for (int i=0 ; i<il_size[0]; i++){
for (int j=0 ; j<il_size[1]; j++){
int index = i*il_size[1] + j;
fla_rent [index] = inMatrix (i,j);
}
}

//Send of rent

do_octave_atexit ();
/*
What is the difference with:
clean_up_and_exit(0);
?
*/

return 0;

}





reply via email to

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