abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cuddAddNeg.c File Reference
#include "misc/util/util_hack.h"
#include "cuddInt.h"

Go to the source code of this file.

Functions

DdNodeCudd_addNegate (DdManager *dd, DdNode *f)
 
DdNodeCudd_addRoundOff (DdManager *dd, DdNode *f, int N)
 
DdNodecuddAddNegateRecur (DdManager *dd, DdNode *f)
 
DdNodecuddAddRoundOffRecur (DdManager *dd, DdNode *f, double trunc)
 

Variables

static
ABC_NAMESPACE_IMPL_START char
rcsid[] 
DD_UNUSED = "$Id: cuddAddNeg.c,v 1.12 2009/02/20 02:14:58 fabio Exp $"
 

Function Documentation

DdNode* Cudd_addNegate ( DdManager dd,
DdNode f 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Computes the additive inverse of an ADD.]

Description [Computes the additive inverse of an ADD. Returns a pointer to the result if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addCmpl]

Definition at line 120 of file cuddAddNeg.c.

123 {
124  DdNode *res;
125 
126  do {
127  res = cuddAddNegateRecur(dd,f);
128  } while (dd->reordered == 1);
129  return(res);
130 
131 } /* end of Cudd_addNegate */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddNegateRecur(DdManager *dd, DdNode *f)
Definition: cuddAddNeg.c:180
DdNode* Cudd_addRoundOff ( DdManager dd,
DdNode f,
int  N 
)

Function********************************************************************

Synopsis [Rounds off the discriminants of an ADD.]

Description [Rounds off the discriminants of an ADD. The discriminants are rounded off to N digits after the decimal. Returns a pointer to the result ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 148 of file cuddAddNeg.c.

152 {
153  DdNode *res;
154  double trunc = pow(10.0,(double)N);
155 
156  do {
157  res = cuddAddRoundOffRecur(dd,f,trunc);
158  } while (dd->reordered == 1);
159  return(res);
160 
161 } /* end of Cudd_addRoundOff */
Definition: cudd.h:278
int reordered
Definition: cuddInt.h:409
DdNode * cuddAddRoundOffRecur(DdManager *dd, DdNode *f, double trunc)
Definition: cuddAddNeg.c:240
DdNode* cuddAddNegateRecur ( DdManager dd,
DdNode f 
)

Function********************************************************************

Synopsis [Implements the recursive step of Cudd_addNegate.]

Description [Implements the recursive step of Cudd_addNegate. Returns a pointer to the result.]

SideEffects [None]

Definition at line 180 of file cuddAddNeg.c.

183 {
184  DdNode *res,
185  *fv, *fvn,
186  *T, *E;
187 
188  statLine(dd);
189  /* Check terminal cases. */
190  if (cuddIsConstant(f)) {
191  res = cuddUniqueConst(dd,-cuddV(f));
192  return(res);
193  }
194 
195  /* Check cache */
196  res = cuddCacheLookup1(dd,Cudd_addNegate,f);
197  if (res != NULL) return(res);
198 
199  /* Recursive Step */
200  fv = cuddT(f);
201  fvn = cuddE(f);
202  T = cuddAddNegateRecur(dd,fv);
203  if (T == NULL) return(NULL);
204  cuddRef(T);
205 
206  E = cuddAddNegateRecur(dd,fvn);
207  if (E == NULL) {
208  Cudd_RecursiveDeref(dd,T);
209  return(NULL);
210  }
211  cuddRef(E);
212  res = (T == E) ? T : cuddUniqueInter(dd,(int)f->index,T,E);
213  if (res == NULL) {
214  Cudd_RecursiveDeref(dd, T);
215  Cudd_RecursiveDeref(dd, E);
216  return(NULL);
217  }
218  cuddDeref(T);
219  cuddDeref(E);
220 
221  /* Store result. */
223 
224  return(res);
225 
226 } /* end of cuddAddNegateRecur */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
#define statLine(dd)
Definition: cuddInt.h:1037
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup1(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:556
DdNode * cuddAddNegateRecur(DdManager *dd, DdNode *f)
Definition: cuddAddNeg.c:180
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdNode * Cudd_addNegate(DdManager *dd, DdNode *f)
Definition: cuddAddNeg.c:120
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323
DdNode* cuddAddRoundOffRecur ( DdManager dd,
DdNode f,
double  trunc 
)

Function********************************************************************

Synopsis [Implements the recursive step of Cudd_addRoundOff.]

Description [Implements the recursive step of Cudd_addRoundOff. Returns a pointer to the result.]

SideEffects [None]

Definition at line 240 of file cuddAddNeg.c.

244 {
245 
246  DdNode *res, *fv, *fvn, *T, *E;
247  double n;
248  DD_CTFP1 cacheOp;
249 
250  statLine(dd);
251  if (cuddIsConstant(f)) {
252  n = ceil(cuddV(f)*trunc)/trunc;
253  res = cuddUniqueConst(dd,n);
254  return(res);
255  }
256  cacheOp = (DD_CTFP1) Cudd_addRoundOff;
257  res = cuddCacheLookup1(dd,cacheOp,f);
258  if (res != NULL) {
259  return(res);
260  }
261  /* Recursive Step */
262  fv = cuddT(f);
263  fvn = cuddE(f);
264  T = cuddAddRoundOffRecur(dd,fv,trunc);
265  if (T == NULL) {
266  return(NULL);
267  }
268  cuddRef(T);
269  E = cuddAddRoundOffRecur(dd,fvn,trunc);
270  if (E == NULL) {
271  Cudd_RecursiveDeref(dd,T);
272  return(NULL);
273  }
274  cuddRef(E);
275  res = (T == E) ? T : cuddUniqueInter(dd,(int)f->index,T,E);
276  if (res == NULL) {
277  Cudd_RecursiveDeref(dd,T);
278  Cudd_RecursiveDeref(dd,E);
279  return(NULL);
280  }
281  cuddDeref(T);
282  cuddDeref(E);
283 
284  /* Store result. */
285  cuddCacheInsert1(dd,cacheOp,f,res);
286  return(res);
287 
288 } /* end of cuddAddRoundOffRecur */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
DdNode *(* DD_CTFP1)(DdManager *, DdNode *)
Definition: cudd.h:322
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * Cudd_addRoundOff(DdManager *dd, DdNode *f, int N)
Definition: cuddAddNeg.c:148
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup1(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:556
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
DdHalfWord index
Definition: cudd.h:279
DdNode * cuddAddRoundOffRecur(DdManager *dd, DdNode *f, double trunc)
Definition: cuddAddNeg.c:240
#define cuddE(node)
Definition: cuddInt.h:652
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323

Variable Documentation

ABC_NAMESPACE_IMPL_START char rcsid [] DD_UNUSED = "$Id: cuddAddNeg.c,v 1.12 2009/02/20 02:14:58 fabio Exp $"
static

CFile***********************************************************************

FileName [cuddAddNeg.c]

PackageName [cudd]

Synopsis [Function to compute the negation of an ADD.]

Description [External procedures included in this module:

Internal procedures included in this module:

]

Author [Fabio Somenzi, Balakrishna Kumthekar]

Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the University of Colorado nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.]

Definition at line 84 of file cuddAddNeg.c.