[Scilab-Dev] Gmp in scilab revisited.

Yann COLLETTE ycollet at freesurf.fr
Mon Sep 29 22:17:33 CEST 2008


Hello,

I don't know anybody currently working on this topic today.
I have some idea for the interface: use the pointer type "p". With this 
type, you can allocate the  memory required to store the gmp number.
Then, you store the pointer to the memory allocated in a mlist (here, 
the type of the mlist is fannlist and the fann field contains the pointer).
To retrieve the gmp number, use the GetRhsVar with the "p" type.
Here are some examples I use in a FANN (Fast Artificle Neural Network) 
interface.

For the basic operations like +, -, etc ..., maybe you can use overloading:
for the + operator:
function c = gmplist_a_gmplist(a,b) c = gmp_add(a,b); endfunction

int createScilabFannStructFromCFannStruct(struct fann* ann,unsigned int 
StackPos)
{
  int m_list_labels,  n_list_labels;
  int m_fann_pointer, n_fann_pointer;
  int m_extra,        n_extra,   l_extra;

  //The struct field names
  static char *fieldnames[] = {"fannlist","fann"};

  m_fann_pointer = 1; n_fann_pointer = 1;
  m_extra        = 2; n_extra        = 1;

  CreateVar(StackPos, "m", &m_extra,  &n_extra, &l_extra);
 
  m_list_labels = 2; n_list_labels = 1;
  CreateListVarFromPtr(StackPos, POS_LABELS,       "S", &m_list_labels,  
&n_list_labels,  fieldnames);   // Put the type and the labels
  CreateListVarFromPtr(StackPos, POS_FANN_POINTER, "p", &m_fann_pointer, 
&n_fann_pointer, ann);

  return 0;
}

int createScilabFannStructFromCFannStruct(struct fann* ann,unsigned int 
StackPos)
{
  int m_list_labels,  n_list_labels;
  int m_fann_pointer, n_fann_pointer;
  int m_extra,        n_extra,   l_extra;

  //The struct field names
  static char *fieldnames[] = {"fannlist","fann"};

  m_fann_pointer = 1; n_fann_pointer = 1;
  m_extra        = 2; n_extra        = 1;

  CreateVar(StackPos, "m", &m_extra,  &n_extra, &l_extra);
 
  m_list_labels = 2; n_list_labels = 1;
  CreateListVarFromPtr(StackPos, POS_LABELS,       "S", &m_list_labels,  
&n_list_labels,  fieldnames);   // Put the type and the labels
  CreateListVarFromPtr(StackPos, POS_FANN_POINTER, "p", &m_fann_pointer, 
&n_fann_pointer, ann);

  return 0;
}

I hope this will help ...

YC

Some ideas for the
Sylvestre Ledru a écrit :
> Le lundi 29 septembre 2008 à 16:13 -0300, Jonathan Blanchard a écrit :
>   
>> Sorry to bother everyone on the list again about this subject.
>>
>> I have a question to Ledru you said yes to my question earlier but I'm
>> not sure which. Is there any plan for gmp/mpr in scilab in the future
>> and is there a developer currently looking at this?
>>     
> No and no ;)
> At least, as far I know. Yann is the one who added this idea to the
> Wiki. Maybe he knows someone who is working on it.
>
>   
>> I also didn't listen to your warning and hacked myself a way to use
>> gmp in scilab.
>>     
> Seems you did the right choice ;)
>
>   
>> Sadly because of the nature of gmp it is impossible to
>> create a toolbox for Scilab 5 as I would have loved to create one.
>>     
> Why is it impossible ? Too tightly linked with Scilab's internal stuff?
>
> Sylvestre
>
>   




More information about the dev mailing list