source: vis_dev/glu-2.3/src/mdd/mdd_func2c.c@ 68

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

library glu 2.3

File size: 2.0 KB
Line 
1#include "mdd.h"
2
3/*
4 * MDD Package
5 *
6 * $Id: mdd_func2c.c,v 1.10 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(
20 mdd_manager *mgr,
21 int mvar1,
22 int mvar2,
23 int constant,
24 boolean (*func3)(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
49 one = mdd_one(mgr);
50 zero = mdd_zero(mgr);
51
52 child_list_x = array_alloc(mdd_t *, 0);
53 for (i=0; i<x.values; i++) {
54 child_list_y = array_alloc(mdd_t *, 0);
55 for (j=0; j<y.values; j++) {
56 if (func3(i,j,constant))
57 array_insert_last(mdd_t *, child_list_y, one);
58 else
59 array_insert_last(mdd_t *, child_list_y, zero);
60 }
61 ty = mdd_case(mgr, mvar2, child_list_y);
62 array_insert_last(mdd_t *, child_list_x, ty);
63 array_free(child_list_y);
64 }
65 tx = mdd_case(mgr, mvar1, child_list_x);
66 array_free(child_list_x);
67
68 mdd_free(zero);
69 mdd_free(one);
70
71 return tx;
72}
73
74/*---------------------------------------------------------------------------*/
75/* Static function prototypes */
76/*---------------------------------------------------------------------------*/
77
78
Note: See TracBrowser for help on using the repository browser.