Felip Alàez Nadal | 30 Sep 09:06

C API: accessing to the elements of an array

Hello:

I'm adding a solveLinearEquations method to Math.Matrix, writting new code in matrix_code.h. There's something I don't know how to do.

Well, from inside solveLinearEquations I call the method which does the LU decompositon, by typing

static void solveLinearEquations ( INT32 args )
{
//SOme code to access to the parameters

matrixX(_lu) (0 ); // the lu decomposition doesn't need any parameters

//Here I need something to access to the elements of the array which matrixX(_lu) returns into pike.


//More code which solve the equations system
}

The matrixX(_lu) method pushes an array with for elements into the stack calling something similar to

push_object( L);
 push_object ( U);
 push_object ( Permutations );
 push_int ( Sign );
 f_aggregate (4); /* Make an array of the 4 top elements on the stack. */

Now I want to access those elements from solveLinearEquations in order to use the L and U matrices to solve a linear equations system. How can I "unaggregate" those elements, or pop the complete array and access Its individual elements?

Thanks you.

--
Felip Alàez Nadal

C API: accessing to the elements of an array

Do you need to access the elements, or do you need to just index them
out and leave them on the stack?

The last is easier, you simply make sure you have the array on top of
the stack, push an integer and do f_index(2), which gives the
equivalent of arr[i].

But I'm not sure what kind of problem you are trying to solve. It
looks like you're calling matrixX(_lu) internally, not via the method
calls, and you wouldn't need the args counter then...


Gmane