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

Annotation of OpenXM_contrib2/asir2000/builtin/parif.c, Revision 1.20

1.1       noro        1: #include "ca.h"
                      2: #include "parse.h"
1.19      noro        3: #include "ox.h"
1.1       noro        4:
1.19      noro        5: Q ox_pari_stream;
                      6: int ox_pari_stream_initialized = 0;
1.1       noro        7:
1.19      noro        8: pointer evalparif(FUNC f,NODE arg)
1.1       noro        9: {
1.19      noro       10:   int ac,intarg,opt,prec;
                     11:   Q q,r,narg;
                     12:   NODE nd,oxarg;
                     13:   STRING name;
                     14:   USINT ui;
                     15:   Obj ret,dmy;
                     16:
1.20    ! takayama   17:   if (strcmp(f->name,"gamma")==0) {
        !            18:     Pmpfr_gamma(arg,&ret);
        !            19:     return((pointer) ret);
        !            20:   }
1.19      noro       21:   if ( !ox_pari_stream_initialized ) {
                     22:          MKSTR(name,"ox_pari");
                     23:          nd = mknode(2,NULL,name);
                     24:          Pox_launch(nd,&r);
                     25:          ox_pari_stream = r;
                     26:     ox_pari_stream_initialized = 1;
                     27:   }
1.1       noro       28:        switch ( f->type ) {
1.9       noro       29:                case 0: /* in/out : integer */
                     30:                        ac = argc(arg);
1.19      noro       31:                        if ( ac > 1 ) {
1.9       noro       32:                                fprintf(stderr,"argument mismatch in %s()\n",NAME(f));
                     33:                                error("");
1.10      noro       34:                                /* NOTREACHED */
                     35:                                return 0;
1.9       noro       36:                        }
1.19      noro       37:       intarg = ac == 0 ? 0 : QTOS((Q)ARG0(arg));
                     38:       MKUSINT(ui,intarg);
                     39:       oxarg = mknode(2,ox_pari_stream,ui);
                     40:       Pox_push_cmo(oxarg,&dmy);
                     41:       MKSTR(name,f->name);
                     42:       oxarg = mknode(3,ox_pari_stream,name,ONE);
                     43:       Pox_execute_function(oxarg,&dmy);
                     44:       oxarg = mknode(1,ox_pari_stream);
                     45:       Pox_pop_cmo(oxarg,&r);
                     46:       return r;
1.9       noro       47:
1.1       noro       48:                case 1:
                     49:                        ac = argc(arg);
                     50:                        if ( !ac || ( ac > 2 ) ) {
                     51:                                fprintf(stderr,"argument mismatch in %s()\n",NAME(f));
                     52:                                error("");
1.10      noro       53:                                /* NOTREACHED */
                     54:                                return 0;
1.1       noro       55:                        }
1.19      noro       56:       /* arg1 : prec */
                     57:       prec = ac == 1 ? 0 : QTOS((Q)ARG1(arg));
                     58:       MKUSINT(ui,prec);
                     59:       oxarg = mknode(2,ox_pari_stream,ui);
                     60:       Pox_push_cmo(oxarg,&dmy);
                     61:
                     62:       /* arg0 : arg */
                     63:       oxarg = mknode(2,ox_pari_stream,ARG0(arg));
                     64:       Pox_push_cmo(oxarg,&dmy);
                     65:
                     66:       MKSTR(name,f->name);
                     67:       STOQ(2,narg);
                     68:       oxarg = mknode(3,ox_pari_stream,name,narg);
                     69:       Pox_execute_function(oxarg,&dmy);
                     70:       oxarg = mknode(1,ox_pari_stream);
                     71:       Pox_pop_cmo(oxarg,&r);
                     72:       return r;
1.8       noro       73:
                     74:                case 2:
                     75:                        ac = argc(arg);
                     76:                        if ( !ac || ( ac > 2 ) ) {
                     77:                                fprintf(stderr,"argument mismatch in %s()\n",NAME(f));
                     78:                                error("");
1.10      noro       79:                                /* NOTREACHED */
                     80:                                return 0;
1.8       noro       81:                        }
                     82:                        if ( ac == 1 )
                     83:                                opt = 0;
                     84:                        else
                     85:                                opt = QTOS((Q)ARG1(arg));
                     86:                        return r;
                     87:
1.1       noro       88:                default:
                     89:                        error("evalparif : not implemented yet.");
1.10      noro       90:                        /* NOTREACHED */
                     91:                        return 0;
1.1       noro       92:        }
                     93: }
                     94:
                     95: struct pariftab {
                     96:        char *name;
1.19      noro       97:   int dmy;
1.1       noro       98:        int type;
                     99: };
                    100:
1.8       noro      101: /*
                    102:  * type = 1 => argc = 1, second arg = precision
                    103:  * type = 2 => argc = 1, second arg = optional (long int)
                    104:  *
                    105:  */
1.19      noro      106: /*
                    107: {"abs",0,1},
                    108: {"adj",0,1},
                    109: */
1.8       noro      110:
1.1       noro      111: struct pariftab pariftab[] = {
1.19      noro      112: {"arg",0,1},
                    113: {"bigomega",0,1},
                    114: {"binary",0,1},
                    115: {"ceil",0,1},
                    116: {"centerlift",0,1},
                    117: {"cf",0,1},
                    118: {"classno",0,1},
                    119: {"classno2",0,1},
                    120: {"conj",0,1},
                    121: {"content",0,1},
                    122: {"denom",0,1},
                    123: {"det",0,1},
                    124: {"det2",0,1},
                    125: {"dilog",0,1},
                    126: {"disc",0,1},
                    127: {"discf",0,1},
                    128: {"divisors",0,1},
                    129: {"eigen",0,1},
                    130: {"eintg1",0,1},
                    131: {"erfc",0,1},
                    132: {"eta",0,1},
                    133: {"floor",0,1},
                    134: {"frac",0,1},
                    135: {"galois",0,1},
                    136: {"galoisconj",0,1},
                    137: {"gamh",0,1},
                    138: {"gamma",0,1},
                    139: {"hclassno",0,1},
                    140: {"hermite",0,1},
                    141: {"hess",0,1},
                    142: {"imag",0,1},
                    143: {"image",0,1},
                    144: {"image2",0,1},
                    145: {"indexrank",0,1},
                    146: {"indsort",0,1},
                    147: {"initalg",0,1},
                    148: {"isfund",0,1},
                    149: {"ispsp",0,1},
                    150: {"isqrt",0,1},
                    151: {"issqfree",0,1},
                    152: {"issquare",0,1},
                    153: {"jacobi",0,1},
                    154: {"jell",0,1},
                    155: {"ker",0,1},
                    156: {"keri",0,1},
                    157: {"kerint",0,1},
                    158: {"kerintg1",0,1},
                    159: {"length",0,1},
                    160: {"lexsort",0,1},
                    161: {"lift",0,1},
                    162: {"lindep",0,1},
                    163: {"lll",0,1},
                    164: {"lllgen",0,1},
                    165: {"lllgram",0,1},
                    166: {"lllgramgen",0,1},
                    167: {"lllgramint",0,1},
                    168: {"lllgramkerim",0,1},
                    169: {"lllgramkerimgen",0,1},
                    170: {"lllint",0,1},
                    171: {"lllkerim",0,1},
                    172: {"lllkerimgen",0,1},
                    173: {"lngamma",0,1},
                    174: {"logagm",0,1},
                    175: {"mat",0,1},
                    176: {"matrixqz2",0,1},
                    177: {"matrixqz3",0,1},
                    178: {"matsize",0,1},
                    179: {"modreverse",0,1},
                    180: {"mu",0,1},
                    181: {"nextprime",0,1},
                    182: {"norm",0,1},
                    183: {"norml2",0,1},
                    184: {"numdiv",0,1},
                    185: {"numer",0,1},
                    186: {"omega",0,1},
                    187: {"order",0,1},
                    188: {"ordred",0,1},
                    189: {"phi",0,1},
                    190: {"pnqn",0,1},
                    191: {"polred",0,1},
                    192: {"polred2",0,1},
                    193: {"primroot",0,1},
                    194: {"psi",0,1},
                    195: {"quadgen",0,1},
                    196: {"quadpoly",0,1},
                    197: {"real",0,1},
                    198: {"recip",0,1},
                    199: {"redreal",0,1},
                    200: {"regula",0,1},
                    201: {"reorder",0,1},
                    202: {"reverse",0,1},
                    203: {"rhoreal",0,1},
                    204: {"roots",0,1},
                    205: {"round",0,1},
                    206: {"sigma",0,1},
                    207: {"signat",0,1},
                    208: {"simplify",0,1},
                    209: {"smalldiscf",0,1},
                    210: {"smallfact",0,1},
                    211: {"smallpolred",0,1},
                    212: {"smallpolred2",0,1},
                    213: {"smith",0,1},
                    214: {"smith2",0,1},
                    215: {"sort",0,1},
                    216: {"sqr",0,1},
                    217: {"sqred",0,1},
                    218: {"sqrt",0,1},
                    219: {"supplement",0,1},
                    220: {"trace",0,1},
                    221: {"trans",0,1},
                    222: {"trunc",0,1},
                    223: {"unit",0,1},
                    224: {"vec",0,1},
                    225: {"wf",0,1},
                    226: {"wf2",0,1},
                    227: {"zeta",0,1},
                    228: {"factor",0,1},
                    229:
                    230: {"allocatemem",0,0},
                    231:
                    232: {"isprime",0,2},
                    233: {"factorint",0,2},
1.1       noro      234: {0,0,0},
                    235: };
                    236:
                    237: void parif_init() {
                    238:        int i;
                    239:
                    240:        for ( i = 0, parif = 0; pariftab[i].name; i++ )
1.19      noro      241:                 appendparif(&parif,pariftab[i].name, 0,pariftab[i].type);
1.1       noro      242: }

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