Accessing the stack

ycollet at freesurf.fr ycollet at freesurf.fr
Fri Jan 9 09:57:05 CET 2009


Hello,

I have some questions related to how to access the stack.
I would like to create a function which takes a mlist as parameters and
returns a pointers to one element of the list. Something like:

GetRhsVar(1, "m", &m_list, &n_list, &l_list);
GetListVar(1, &m_list, &n_list, &l_list, 2, "d", &m_param_2, &n_param_2,
&l_param_2);

And now, I am able to access to the element 2 of the mlist like a normal
scilab variable.
I needed such a function to be able to access / create mlist in mlist.

So my questions are related to the functions used to access the stack.

iadr(pos): returns a "scilab pointer" to an int variable stored at position
pos on the stack ?
sard(pos): returns a "scilab pointer" to a double variable stored at
position pos on the stack ?
card(pos): returns a "scilab pointer" to a char variable stored at position
pos on the stack ?

Lstk(pos): returns a generic "scilab pointer" to a variable stored at
position pos on the stack ?

What are the use of the vstk, com and iop stack structure ?

The document "scilab internal" is a little bit hard to understand / read
for such questions.

Now, let's try to create manually a vector of doubles:

>From the wiki:

Type           32 bits     1 integer from Scilab Internal Datatypes
Lines          32 bits     1 integer, number of lines in the matrix, for a
single number, Scilab store it like a matrix [1,1]
Columns        32 bits     1 integer, number of columns in the matrix, for
a single number, Scilab store it like a matrix [1,1]
Complex        32 bits     1 integer, 0 for real number, 1 for complex
number
Real part      n * 64 bits Each real part is store in a double
Imaginary part n * 64 bits Each imaginary part is store in a double 

// My var is at position 1

*istk(iadr(1)) = 1; // For a vector of double
*istk(iadr(1)+1) = 2;
*istk(iadr(1)+2) = 3; // So we have a 2x3 matrix
*istk(iadr(1)+3) = 0: // and it's a real matrix
for(i=0;i<6;i++) *istk(iadr(1)+4+2*i+0) = 1.0;

Am I accessing the double vector structure correctly ?

YC




More information about the dev mailing list