1 | #include "mdd.h" |
---|
2 | |
---|
3 | /* |
---|
4 | * MDD Package |
---|
5 | * |
---|
6 | * $Id: mdd_smooth.c,v 1.10 2002/08/27 03:17:38 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 | |
---|
18 | mdd_t * |
---|
19 | mdd_smooth( |
---|
20 | mdd_manager *mgr, |
---|
21 | mdd_t *fn, |
---|
22 | array_t *mvars) |
---|
23 | { |
---|
24 | array_t *bdd_vars; |
---|
25 | int i, j, mv_no; |
---|
26 | mvar_type mv; |
---|
27 | mdd_t *top; |
---|
28 | bdd_t *temp; |
---|
29 | array_t *mvar_list = mdd_ret_mvar_list(mgr); |
---|
30 | |
---|
31 | |
---|
32 | if ( mvars == NIL(array_t) ) { |
---|
33 | top = bdd_dup(fn); |
---|
34 | printf("\nWARNING: Empty Array of Smoothing Variables\n"); |
---|
35 | return top; |
---|
36 | } |
---|
37 | else if ( array_n(mvars) == 0) { |
---|
38 | top = bdd_dup(fn); |
---|
39 | printf("\nWARNING: Empty Array of Smoothing Variables\n"); |
---|
40 | return top; |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | bdd_vars = array_alloc(bdd_t *, 0); |
---|
45 | for (i=0; i<array_n(mvars); i++) { |
---|
46 | mv_no = array_fetch(int, mvars, i); |
---|
47 | mv = array_fetch(mvar_type, mvar_list, mv_no); |
---|
48 | if (mv.status == MDD_BUNDLED) { |
---|
49 | (void) fprintf(stderr, |
---|
50 | "\nmdd_smooth: bundled variable %s used\n",mv.name); |
---|
51 | fail(""); |
---|
52 | } |
---|
53 | |
---|
54 | for (j=0; j<mv.encode_length; j++) { |
---|
55 | temp = bdd_get_variable(mgr, mdd_ret_bvar_id(&mv,j) ); |
---|
56 | array_insert_last(bdd_t *, bdd_vars, temp); |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | top = bdd_smooth(fn, bdd_vars); |
---|
61 | |
---|
62 | for (i=0; i<array_n(bdd_vars); i++) { |
---|
63 | temp = array_fetch(bdd_t *, bdd_vars, i); |
---|
64 | bdd_free(temp); |
---|
65 | } |
---|
66 | array_free(bdd_vars); |
---|
67 | |
---|
68 | return top; |
---|
69 | } |
---|
70 | |
---|
71 | /*---------------------------------------------------------------------------*/ |
---|
72 | /* Static function prototypes */ |
---|
73 | /*---------------------------------------------------------------------------*/ |
---|
74 | |
---|