source: vis_dev/glu-2.3/src/cmuBdd/bddrelprod.c @ 104

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

library glu 2.3

File size: 2.4 KB
Line 
1/* BDD relational product routine */
2
3
4#include "bddint.h"
5
6
7static
8bdd
9cmu_bdd_rel_prod_step(cmu_bdd_manager bddm, bdd f, bdd g, long op, var_assoc vars)
10{
11  bdd_indexindex_type top_indexindex;
12  bdd f1, f2;
13  bdd g1, g2;
14  bdd temp1, temp2;
15  bdd result;
16  int quantifying;
17
18  BDD_SETUP(f);
19  BDD_SETUP(g);
20  if (BDD_IS_CONST(f) || BDD_IS_CONST(g))
21    {
22      if (f == BDD_ZERO(bddm) || g == BDD_ZERO(bddm))
23        return (BDD_ZERO(bddm));
24      if (f == BDD_ONE(bddm))
25        return (cmu_bdd_exists_temp(bddm, g, op-1));
26      return (cmu_bdd_exists_temp(bddm, f, op-1));
27    }
28  if ((long)BDD_INDEX(bddm, f) > vars->last && (long)BDD_INDEX(bddm, g) > vars->last)
29    return (cmu_bdd_ite_step(bddm, f, g, BDD_ZERO(bddm)));
30  /* Put in canonical order. */
31  if (BDD_OUT_OF_ORDER(f, g))
32    BDD_SWAP(f, g);
33  if (bdd_lookup_in_cache2(bddm, op, f, g, &result))
34    return (result);
35  BDD_TOP_VAR2(top_indexindex, bddm, f, g);
36  quantifying=(vars->assoc[top_indexindex] != 0);
37  BDD_COFACTOR(top_indexindex, f, f1, f2);
38  BDD_COFACTOR(top_indexindex, g, g1, g2);
39  temp1=cmu_bdd_rel_prod_step(bddm, f1, g1, op, vars);
40  if (quantifying && temp1 == BDD_ONE(bddm))
41    result=temp1;
42  else
43    {
44      temp2=cmu_bdd_rel_prod_step(bddm, f2, g2, op, vars);
45      if (quantifying)
46        {
47          BDD_SETUP(temp1);
48          BDD_SETUP(temp2);
49          bddm->op_cache.cache_level++;
50          result=cmu_bdd_ite_step(bddm, temp1, BDD_ONE(bddm), temp2);
51          BDD_TEMP_DECREFS(temp1);
52          BDD_TEMP_DECREFS(temp2);
53          bddm->op_cache.cache_level--;
54        }
55      else
56        result=bdd_find(bddm, top_indexindex, temp1, temp2);
57    }
58  bdd_insert_in_cache2(bddm, op, f, g, result);
59  return (result);
60}
61
62
63/* cmu_bdd_rel_prod(bddm, f, g) returns the BDD for "f and g" with those */
64/* variables which are associated with something in the current */
65/* variable association quantified out. */
66
67bdd
68cmu_bdd_rel_prod(cmu_bdd_manager bddm, bdd f, bdd g)
69{
70  long op;
71
72  if (bdd_check_arguments(2, f, g))
73    {
74      FIREWALL(bddm);
75      if (bddm->curr_assoc_id == -1)
76        {
77          op=bddm->temp_op--;
78          /* We decrement the temporary opcode once more because */
79          /* cmu_bdd_rel_prod may call cmu_bdd_exists_temp, and we don't */
80          /* want to generate new temporary opcodes for each such */
81          /* call.  Instead, we pass op-1 to cmu_bdd_exists_temp, and */
82          /* have it use this opcode for caching. */
83          bddm->temp_op--;
84        }
85      else
86        op=OP_RELPROD+bddm->curr_assoc_id;
87      RETURN_BDD(cmu_bdd_rel_prod_step(bddm, f, g, op, bddm->curr_assoc));
88    }
89  return ((bdd)0);
90}
Note: See TracBrowser for help on using the repository browser.