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

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

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