[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.21

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

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