Annotation of researchv10no/cmd/ideal/simul.c, revision 1.1

1.1     ! root        1: #include "ideal.h"
        !             2: 
        !             3: 
        !             4: DEPPTR depadd(dlistone, coeffone, dlisttwo, coefftwo)
        !             5: DEPPTR dlistone;
        !             6: float coeffone;
        !             7: DEPPTR dlisttwo;
        !             8: float coefftwo;
        !             9: {
        !            10:        /* produce a dependency list = coeffone*dlistone + coefftwo*dlisttwo */
        !            11:        register DEPPTR onewalk, twowalk, newhead, newwalk, prevnew;
        !            12:        DEPNODE nuhead;
        !            13:        prevnew = &nuhead;
        !            14:        prevnew->next = NULL;
        !            15:        onewalk = dlistone;
        !            16:        twowalk = dlisttwo;
        !            17:        while ((onewalk != NULL) || (twowalk != NULL)) {
        !            18:                if (onewalk != NULL)
        !            19:                        if (twowalk != NULL)
        !            20:                                if (onewalk->var > twowalk ->var) {
        !            21:                                        newwalk = depgen (
        !            22:                                                onewalk->var,
        !            23:                                                coeffone*onewalk->coeff
        !            24:                                        );
        !            25:                                        onewalk = onewalk->next;
        !            26:                                }
        !            27:                                else
        !            28:                                        if (onewalk->var == twowalk->var) {
        !            29:                                                newwalk = depgen (
        !            30:                                                        onewalk->var,
        !            31:                                                        coeffone*onewalk->coeff
        !            32:                                                        + coefftwo*twowalk->coeff
        !            33:                                                );
        !            34:                                                onewalk = onewalk->next;
        !            35:                                                twowalk = twowalk->next;
        !            36:                                        }
        !            37:                                        else {
        !            38:                                                newwalk = depgen (
        !            39:                                                        twowalk->var,
        !            40:                                                        coefftwo*twowalk->coeff
        !            41:                                                );
        !            42:                                                twowalk = twowalk->next;
        !            43:                                        }
        !            44:                        else {
        !            45:                                newwalk = depgen (
        !            46:                                        onewalk->var,
        !            47:                                        coeffone*onewalk->coeff
        !            48:                                );
        !            49:                                onewalk = onewalk->next;
        !            50:                        }
        !            51:                else {
        !            52:                        newwalk = depgen (
        !            53:                                twowalk->var,
        !            54:                                coefftwo*twowalk->coeff
        !            55:                        );
        !            56:                        twowalk = twowalk->next;
        !            57:                }
        !            58:                if (fabs(newwalk->coeff) > EPSILON) {
        !            59:                        prevnew->next = newwalk;
        !            60:                        prevnew = newwalk;
        !            61:                } else
        !            62:                        depfree (newwalk);
        !            63:        }
        !            64:        newhead = nuhead.next;
        !            65:        if (newhead != NULL) {
        !            66:                if (dbg) {
        !            67:                        depprint (newhead);
        !            68:                        fprintf (stderr, "\n");
        !            69:                }
        !            70:                return(newhead);
        !            71:        }
        !            72:        else {
        !            73:                dprintf "empty dep rep\n");
        !            74:                return (depgen ((VARPTR) NULL, 0.0));
        !            75:        }
        !            76: }
        !            77: 
        !            78: DEPPTR depsubst(depinto, depfrom, depwho)
        !            79:        /* substitutes depfrom for depwho in depinto
        !            80:        /* WARNING:  if depinto actually contains depfrom,
        !            81:        /* depinto is replaced */
        !            82: DEPPTR depinto,
        !            83:        depfrom;
        !            84: VARPTR depwho;
        !            85: {
        !            86:        DEPPTR intowalker, intoparent, temp;
        !            87:        for (intowalker = depinto;
        !            88:            intowalker != NULL;
        !            89:            intowalker = intowalker->next)
        !            90:                if (intowalker->var == depwho)
        !            91:                        break;
        !            92:                else
        !            93:                        intoparent = intowalker;
        !            94:        if (intowalker == NULL)
        !            95:                return(depinto);
        !            96:        if (intowalker == depinto)
        !            97:                depinto = depinto->next;
        !            98:        else
        !            99:                intoparent->next = intowalker->next;
        !           100:        dprintf "Variable substitution proceeding\n");
        !           101:        temp = depadd(depinto, 1.0, depfrom, intowalker->coeff);
        !           102:        depfree (depinto);
        !           103:        tryfree(intowalker);
        !           104:        depinto = temp;
        !           105:        return (temp);
        !           106: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.