97 static char rcsid[]
DD_UNUSED =
"$Id: cuddApa.c,v 1.19 2009/03/08 01:27:50 fabio Exp $";
201 for (i = 0; i < digits; i++) {
230 for (i = digits - 1; i >= 0; i--) {
262 for (i = digits - 1; i >= 0; i--) {
294 for (i = 0; i < digits; i++) {
327 unsigned int divisor,
332 unsigned int remainder = 0;
333 double ddiv = (double) divisor;
335 for (i = 0; i < digits; i++) {
336 partial = (double) remainder *
DD_APA_BASE + dividend[i];
338 remainder = (
unsigned int) (partial - ((
double)quotient[i] * ddiv));
369 for (i = digits - 1; i > 0; i--) {
370 b[i] = (a[i] >> 1) | ((a[i-1] & 1) << (
DD_APA_BITS - 1));
396 for (i = 0; i < digits - 1; i++)
398 number[digits - 1] = literal;
425 for (i = 0; i < digits; i++)
430 number[i] = 1 << index;
456 int firstNZ, secondNZ;
459 for (firstNZ = 0; firstNZ < digitsFirst; firstNZ++)
460 if (first[firstNZ] != 0)
break;
461 for (secondNZ = 0; secondNZ < digitsSecond; secondNZ++)
462 if (second[secondNZ] != 0)
break;
463 if (digitsFirst - firstNZ > digitsSecond - secondNZ)
return(1);
464 else if (digitsFirst - firstNZ < digitsSecond - secondNZ)
return(-1);
465 for (i = 0; i < digitsFirst - firstNZ; i++) {
466 if (first[firstNZ + i] > second[secondNZ + i])
return(1);
467 else if (first[firstNZ + i] < second[secondNZ + i])
return(-1);
492 unsigned int firstDen,
495 unsigned int secondDen)
499 unsigned int firstRem, secondRem;
509 if ((
double)firstRem/firstDen > (
double)secondRem/secondDen)
511 else if ((
double)firstRem/firstDen < (
double)secondRem/secondDen)
539 for (i = 0; i < digits; i++) {
570 unsigned char *decimal;
572 int decimalDigits = (int) (digits * log10((
double)
DD_APA_BASE)) + 1;
577 decimal =
ABC_ALLOC(
unsigned char, decimalDigits);
578 if (decimal == NULL) {
583 for (i = decimalDigits - 1; i >= 0; i--) {
585 decimal[i] = (
unsigned char) remainder;
590 for (i = 0; i < decimalDigits; i++) {
591 leadingzero = leadingzero && (decimal[i] == 0);
592 if ((!leadingzero) || (i == (decimalDigits - 1))) {
593 result = fprintf(fp,
"%1d",decimal[i]);
625 int i, first, last,
result;
628 unsigned char *decimal;
629 int decimalDigits = (int) (digits * log10((
double)
DD_APA_BASE)) + 1;
634 decimal =
ABC_ALLOC(
unsigned char, decimalDigits);
635 if (decimal == NULL) {
640 first = decimalDigits - 1;
641 for (i = decimalDigits - 1; i >= 0; i--) {
643 decimal[i] = (
unsigned char) remainder;
644 if (remainder != 0) first = i;
647 last =
ddMin(first + precision, decimalDigits);
649 for (i = first; i < last; i++) {
650 result = fprintf(fp,
"%s%1d",i == first+1 ?
"." :
"", decimal[i]);
657 result = fprintf(fp,
"e+%d",decimalDigits - first - 1);
776 if (fprintf(fp,
"\n") == EOF) {
816 if (fprintf(fp,
"\n") == EOF) {
847 unsigned int size, remainder, fractional;
858 fractional = (
unsigned int)((
double)remainder / size * 1000000);
859 if (fprintf(fp,
".%u\n", fractional) == EOF) {
911 if (node == background || node == zero) {
917 if (node->
ref > 1 &&
st__lookup(table, (
const char *)node, (
char **)&mint)) {
924 if (mint1 == NULL)
return(NULL);
void st__free_table(st__table *table)
int Cudd_ApaPrintMinterm(FILE *fp, DdManager *dd, DdNode *node, int nvars)
int Cudd_ApaPrintHex(FILE *fp, int digits, DdApaNumber number)
int st__insert(st__table *table, const char *key, char *value)
#define Cudd_Regular(node)
int Cudd_ApaCompare(int digitsFirst, DdApaNumber first, int digitsSecond, DdApaNumber second)
DdApaDigit Cudd_ApaAdd(int digits, DdApaNumber a, DdApaNumber b, DdApaNumber sum)
int st__ptrcmp(const char *, const char *)
static DdNode * background
#define ABC_ALLOC(type, num)
unsigned short int DdApaDigit
int Cudd_ApaNumberOfDigits(int binaryDigits)
DdApaNumber Cudd_ApaCountMinterm(DdManager *manager, DdNode *node, int nvars, int *digits)
void Cudd_ApaSetToLiteral(int digits, DdApaNumber number, DdApaDigit literal)
void Cudd_ApaCopy(int digits, DdApaNumber source, DdApaNumber dest)
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
DdApaDigit Cudd_ApaShortDivision(int digits, DdApaNumber dividend, DdApaDigit divisor, DdApaNumber quotient)
#define Cudd_IsComplement(node)
unsigned int DdApaDoubleDigit
int Cudd_ApaPrintMintermExp(FILE *fp, DdManager *dd, DdNode *node, int nvars, int precision)
#define ABC_NAMESPACE_IMPL_END
#define cuddIsConstant(node)
DdApaDigit Cudd_ApaSubtract(int digits, DdApaNumber a, DdApaNumber b, DdApaNumber diff)
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
#define ABC_NAMESPACE_IMPL_START
int Cudd_ApaPrintDensity(FILE *fp, DdManager *dd, DdNode *node, int nvars)
int st__lookup(st__table *table, const char *key, char **value)
static ABC_NAMESPACE_IMPL_START char rcsid[] DD_UNUSED
void Cudd_ApaShiftRight(int digits, DdApaDigit in, DdApaNumber a, DdApaNumber b)
int Cudd_ApaCompareRatios(int digitsFirst, DdApaNumber firstNum, unsigned int firstDen, int digitsSecond, DdApaNumber secondNum, unsigned int secondDen)
unsigned int Cudd_ApaIntDivision(int digits, DdApaNumber dividend, unsigned int divisor, DdApaNumber quotient)
int Cudd_ApaPrintDecimal(FILE *fp, int digits, DdApaNumber number)
DdApaNumber Cudd_NewApaNumber(int digits)
void Cudd_ApaPowerOfTwo(int digits, DdApaNumber number, int power)
int Cudd_ApaPrintExponential(FILE *fp, int digits, DdApaNumber number, int precision)
static enum st__retval cuddApaStCountfree(char *key, char *value, char *arg)
int st__ptrhash(const char *, int)
static DdApaNumber cuddApaCountMintermAux(DdNode *node, int digits, DdApaNumber max, DdApaNumber min, st__table *table)
int Cudd_DagSize(DdNode *node)