source: vis_dev/glu-2.3/src/mdd/mdd_func2cmod.c @ 13

Last change on this file since 13 was 13, checked in by cecile, 13 years ago

library glu 2.3

File size: 3.3 KB
Line 
1#include "mdd.h"
2
3/*
4 * MDD Package
5 *
6 * $Id: mdd_func2cmod.c,v 1.4 2002/08/25 05:30:12 fabio Exp $
7 *
8 * Author: Timothy Kam
9 *
10 * Copyright 1992 by the Regents of the University of California.
11 *
12 * All rights reserved.  Permission to use, copy, modify and distribute
13 * this software is hereby granted, provided that the above copyright
14 * notice and this permission notice appear in all copies.  This software
15 * is made available as is, with no warranties.
16 */
17
18mdd_t *
19mdd_func2c_mod(
20  mdd_manager *mgr, 
21  int mvar1,
22  int mvar2,
23  int constant,
24  boolean (*func4)(int, int, int, int))
25{
26    mvar_type x, y;
27    array_t *child_list_x, *child_list_y;
28    int i, j;
29    mdd_t *tx, *ty;
30    array_t *mvar_list = mdd_ret_mvar_list(mgr);
31    mdd_t *one, *zero;
32
33    x = array_fetch(mvar_type, mvar_list, mvar1);
34    y = array_fetch(mvar_type, mvar_list, mvar2);
35
36    if (x.status == MDD_BUNDLED) {
37        (void) fprintf(stderr, 
38                "\nWarning: mdd_func2c, bundled variable %s is used\n", x.name);
39        fail("");
40    }
41
42    if (y.status == MDD_BUNDLED) {
43        (void) fprintf(stderr,
44                "\nWarning: mdd_func2c, bundled variable %s is used\n", y.name);
45        fail("");
46    }
47
48    if((x.values   != y.values)  || ( constant < 0) || ( constant >= x.values) ) {
49      (void) fprintf(stderr, "\n mdd_func2c_mod: Cannot operate with two different ranges\n");
50      exit(1);
51    }
52   
53
54    one = mdd_one(mgr);
55    zero = mdd_zero(mgr);
56
57    child_list_x = array_alloc(mdd_t *, 0);
58    for (i=0; i<x.values; i++) {
59        child_list_y = array_alloc(mdd_t *, 0);
60        for (j=0; j<y.values; j++) {
61            if (func4(i,j,constant,x.values))
62                array_insert_last(mdd_t *, child_list_y, one);
63            else
64                array_insert_last(mdd_t *, child_list_y, zero);
65        }
66        ty = mdd_case(mgr, mvar2, child_list_y);
67        array_insert_last(mdd_t *, child_list_x, ty);
68        array_free(child_list_y);
69    }
70    tx = mdd_case(mgr, mvar1, child_list_x);
71    array_free(child_list_x);
72
73    mdd_free(zero);
74    mdd_free(one);
75
76    return tx;
77}
78
79
80
81/***** internal functions *****/       
82
83boolean
84eq_plus3mod(int x, int y, int z, int range)
85{
86    return (x == (y + z) % range);
87}
88
89boolean
90geq_plus3mod(int x, int y, int z, int range)
91{
92    return (x >= (y + z) % range);
93}
94
95boolean
96gt_plus3mod(int x, int y, int z, int range)
97{
98    return (x > (y + z) % range);
99}
100
101boolean
102leq_plus3mod(int x, int y, int z, int range)
103{
104    return (x <= (y + z) % range);
105}
106
107boolean
108lt_plus3mod(int x, int y, int z, int range)
109{
110    return (x < (y + z) % range);
111}
112
113boolean
114neq_plus3mod(int x, int y, int z, int range)
115{
116    return (x != (y + z) % range);
117}
118
119boolean
120eq_minus3mod(int x, int y, int z, int range)
121{
122    return (x == (y - z) % range);
123}
124
125boolean
126geq_minus3mod(int x, int y, int z, int range)
127{
128    return (x >= (y - z) % range);
129}
130
131boolean
132gt_minus3mod(int x, int y, int z, int range)
133{
134    return (x > (y - z) % range);
135}
136
137boolean
138leq_minus3mod(int x, int y, int z, int range)
139{
140    return (x <= (y - z) % range);
141}
142
143boolean
144lt_minus3mod(int x, int y, int z, int range)
145{
146    return (x < (y - z) % range);
147}
148
149boolean
150neq_minus3mod(int x, int y, int z, int range)
151{
152    return (x != (y - z) % range);
153}
154
155
156/*---------------------------------------------------------------------------*/
157/* Static function prototypes                                                */
158/*---------------------------------------------------------------------------*/
159
Note: See TracBrowser for help on using the repository browser.