[BACK]Return to integral.rr CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-contrib / testing / noro

Annotation of OpenXM/src/asir-contrib/testing/noro/integral.rr, Revision 1.1

1.1     ! noro        1: def is_number(F)
        !             2: {
        !             3:        return type(eval_quote(F))==1;
        !             4: }
        !             5:
        !             6: def integral(F,V)
        !             7: {
        !             8:        if ( quote_unify(F,`G+H) ) {
        !             9:                G1 = integral(G,V);
        !            10:                G2 = integral(H,V);
        !            11:                return G1+G2;
        !            12:        } else if ( quote_unify(F,`G-H) ) {
        !            13:                G1 = integral(G,V);
        !            14:                G2 = integral(H,V);
        !            15:                return G1-G2;
        !            16:        } else if ( quote_unify(F,`G*H) ) {
        !            17:                if ( is_number(G) ) {
        !            18:                        H1 = integral(H,V);
        !            19:                        return G*H1;
        !            20:                } else if ( is_number(H) ) {
        !            21:                        G1 = integral(G,V);
        !            22:                        return H*G1;
        !            23:                } else
        !            24:                        error("not implemented");
        !            25:        } else if ( quote_unify(F,`G/H) ) {
        !            26:                if ( is_number(H) ) {
        !            27:                        G1 = integral(G,V);
        !            28:                        return G1/H;
        !            29:                } else
        !            30:                        error("not implemented");
        !            31:        } else if ( quote_unify(F,`G^H) ) {
        !            32:                if ( G == V ) {
        !            33:                        H1 = objtoquote(eval_quote(H)+1);
        !            34:                        return G^H1/H1;
        !            35:                }
        !            36:        } else if ( V == F ) {
        !            37:                return F^2/2;
        !            38:        } else if ( is_number(F) ) {
        !            39:                return F*V;
        !            40:        } else
        !            41:                error("not implemented");
        !            42: }
        !            43:
        !            44: def apply_rec(F,E)
        !            45: {
        !            46:        if ( quote_unify(E,`(G)) )
        !            47:                X = apply_rec(F,G);
        !            48:        else if ( quote_unify(E,`-G) )
        !            49:                X = -apply_rec(F,G);
        !            50:        else if ( quote_unify(E,`G+H) )
        !            51:                X = apply_rec(F,G)+apply_rec(F,H);
        !            52:        else if ( quote_unify(E,`G-H) )
        !            53:                X = apply_rec(F,G)-apply_rec(F,H);
        !            54:        else if ( quote_unify(E,`G*H) )
        !            55:                X = apply_rec(F,G)*apply_rec(F,H);
        !            56:        else if ( quote_unify(E,`G/H) )
        !            57:                X = apply_rec(F,G)/apply_rec(F,H);
        !            58:        else if ( quote_unify(E,`G^H) )
        !            59:                X = apply_rec(F,G)^apply_rec(F,H);
        !            60:        else if ( quote_unify(E,`U(V)) ) {
        !            61:                X = apply_one(U,[apply_rec(F,V)]);
        !            62:        } else if ( quote_unify(E,`U(V,W)) )
        !            63:                X = apply_one(U,[apply_rec(F,V),apply_rec(F,W)]);
        !            64:        else
        !            65:                X = E;
        !            66:        return apply_one(F,[X]);
        !            67: }
        !            68:
        !            69: def apply_one(F,E)
        !            70: {
        !            71:        return funargs_to_quote(append([8,F],E));
        !            72: }
        !            73: end$

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