[BACK]Return to parif.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / builtin

Diff for /OpenXM_contrib2/asir2000/builtin/parif.c between version 1.26 and 1.31

version 1.26, 2015/08/18 02:26:05 version 1.31, 2015/08/20 08:42:07
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2000/builtin/parif.c,v 1.25 2015/08/17 05:18:36 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2000/builtin/parif.c,v 1.30 2015/08/19 05:53:13 noro Exp $ */
 #include "ca.h"  #include "ca.h"
 #include "parse.h"  #include "parse.h"
 #include "ox.h"  #include "ox.h"
   
 Q ox_pari_stream;  Q ox_pari_stream;
 int ox_pari_stream_initialized = 0;  int ox_pari_stream_initialized = 0;
   int ox_get_pari_result = 0;
   
 typedef void (*mpfr_func)(NODE,Obj *);  typedef void (*mpfr_func)(NODE,Obj *);
   
Line 48  mpfr_func mpfr_search(char *name)
Line 49  mpfr_func mpfr_search(char *name)
   return 0;    return 0;
 }  }
   
   Obj list_to_vect(Obj a)
   {
     int len,i;
     VECT v;
     NODE nd;
   
     if ( !a || OID(a) != O_LIST ) return a;
     len = length(BDY((LIST)a));
     MKVECT(v,len);
     for ( i = 0, nd = BDY((LIST)a); nd; nd = NEXT(nd), i++ )
        v->body[i] = (pointer)list_to_vect((Obj)BDY(nd));
     return (Obj)v;
   }
   
   Obj vect_to_mat(VECT v)
   {
     MAT m;
     int len,col,i,j;
   
     len = v->len;
     if ( v->body[0] && OID((Obj)v->body[0]) == O_VECT ) {
       col = ((VECT)v->body[0])->len;
           for ( i = 1; i < len; i++ )
             if ( !v->body[i] || OID((Obj)v->body[i]) != O_VECT
              || ((VECT)v->body[i])->len != col )
             break;
       if ( i == len ) {
             /* convert to a matrix */
             MKMAT(m,len,col);
             for ( i = 0; i < len; i++ )
               for ( j = 0; j < col; j++ )
                     m->body[i][j] = ((VECT)v->body[i])->body[j];
             return (Obj)m;
           }
     }
     return (Obj)v;
   }
   
   void reset_ox_pari()
   {
     NODE nd;
     Obj r;
   
     if ( ox_get_pari_result ) {
           nd = mknode(1,ox_pari_stream);
           Pox_shutdown(nd,&r);
       ox_get_pari_result = 0;
           ox_pari_stream_initialized = 0;
     }
   }
   
 pointer evalparif(FUNC f,NODE arg)  pointer evalparif(FUNC f,NODE arg)
 {  {
   int ac,intarg,opt,prec;    int ac,intarg,opt,prec;
Line 64  pointer evalparif(FUNC f,NODE arg)
Line 116  pointer evalparif(FUNC f,NODE arg)
   }    }
   
   if ( !ox_pari_stream_initialized ) {    if ( !ox_pari_stream_initialized ) {
           MKSTR(name,"ox_pari");          MKSTR(name,"ox_pari");
           nd = mknode(2,NULL,name);          nd = mknode(2,NULL,name);
           Pox_launch(nd,&r);          Pox_launch_nox(nd,&r);
           ox_pari_stream = r;          ox_pari_stream = r;
     ox_pari_stream_initialized = 1;      ox_pari_stream_initialized = 1;
   }    }
   
Line 86  pointer evalparif(FUNC f,NODE arg)
Line 138  pointer evalparif(FUNC f,NODE arg)
   oxarg = mknode(3,ox_pari_stream,name,narg);    oxarg = mknode(3,ox_pari_stream,name,narg);
   Pox_execute_function(oxarg,&dmy);    Pox_execute_function(oxarg,&dmy);
   oxarg = mknode(1,ox_pari_stream);    oxarg = mknode(1,ox_pari_stream);
   Pox_pop_cmo(oxarg,&r);    ox_get_pari_result = 1;
   return r;    Pox_pop_cmo(oxarg,&ret);
     ox_get_pari_result = 0;
     if ( ret && OID(ret) == O_ERR ) {
       char buf[BUFSIZ];
       soutput_init(buf);
       sprintexpr(CO,((ERR)ret)->body);
       error(buf);
     }
     if ( ret && OID(ret) == O_LIST ) {
       ret = list_to_vect(ret);
           ret = vect_to_mat((VECT)ret);
     }
     return ret;
 }  }
   
 struct pariftab {  struct pariftab {

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.31

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>