Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
f2945e12
Commit
f2945e12
authored
Mar 02, 2011
by
Alan Mishchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrading epd and mtr packages to be compatible with the latest release of CUDD 2.4.2
parent
e3f2dde1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
337 additions
and
337 deletions
+337
-337
src/bdd/epd/epd.c
+75
-75
src/bdd/epd/epd.h
+14
-14
src/bdd/mtr/mtr.h
+8
-8
src/bdd/mtr/mtrBasic.c
+42
-42
src/bdd/mtr/mtrGroup.c
+198
-198
No files found.
src/bdd/epd/epd.c
View file @
f2945e12
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <math.h>
#include <math.h>
#include "util.h"
#include "util
_hack
.h"
#include "epd.h"
#include "epd.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -71,9 +71,9 @@ ABC_NAMESPACE_IMPL_START
...
@@ -71,9 +71,9 @@ ABC_NAMESPACE_IMPL_START
EpDouble
*
EpDouble
*
EpdAlloc
(
void
)
EpdAlloc
(
void
)
{
{
EpDouble
*
epd
;
EpDouble
*
epd
;
epd
=
ALLOC
(
EpDouble
,
1
);
epd
=
A
BC_A
LLOC
(
EpDouble
,
1
);
return
(
epd
);
return
(
epd
);
}
}
...
@@ -116,7 +116,7 @@ EpdCmp(const char *key1, const char *key2)
...
@@ -116,7 +116,7 @@ EpdCmp(const char *key1, const char *key2)
void
void
EpdFree
(
EpDouble
*
epd
)
EpdFree
(
EpDouble
*
epd
)
{
{
FREE
(
epd
);
ABC_
FREE
(
epd
);
}
}
...
@@ -134,9 +134,9 @@ EpdFree(EpDouble *epd)
...
@@ -134,9 +134,9 @@ EpdFree(EpDouble *epd)
void
void
EpdGetString
(
EpDouble
*
epd
,
char
*
str
)
EpdGetString
(
EpDouble
*
epd
,
char
*
str
)
{
{
double
value
;
double
value
;
int
exponent
;
int
exponent
;
char
*
pos
;
char
*
pos
;
if
(
IsNanDouble
(
epd
->
type
.
value
))
{
if
(
IsNanDouble
(
epd
->
type
.
value
))
{
sprintf
(
str
,
"NaN"
);
sprintf
(
str
,
"NaN"
);
...
@@ -150,7 +150,7 @@ EpdGetString(EpDouble *epd, char *str)
...
@@ -150,7 +150,7 @@ EpdGetString(EpDouble *epd, char *str)
}
}
assert
(
epd
->
type
.
bits
.
exponent
==
EPD_MAX_BIN
||
assert
(
epd
->
type
.
bits
.
exponent
==
EPD_MAX_BIN
||
epd
->
type
.
bits
.
exponent
==
0
);
epd
->
type
.
bits
.
exponent
==
0
);
EpdGetValueAndDecimalExponent
(
epd
,
&
value
,
&
exponent
);
EpdGetValueAndDecimalExponent
(
epd
,
&
value
,
&
exponent
);
sprintf
(
str
,
"%e"
,
value
);
sprintf
(
str
,
"%e"
,
value
);
...
@@ -204,15 +204,15 @@ EpdConvert(double value, EpDouble *epd)
...
@@ -204,15 +204,15 @@ EpdConvert(double value, EpDouble *epd)
void
void
EpdMultiply
(
EpDouble
*
epd1
,
double
value
)
EpdMultiply
(
EpDouble
*
epd1
,
double
value
)
{
{
EpDouble
epd2
;
EpDouble
epd2
;
double
tmp
;
double
tmp
;
int
exponent
;
int
exponent
;
if
(
EpdIsNan
(
epd1
)
||
IsNanDouble
(
value
))
{
if
(
EpdIsNan
(
epd1
)
||
IsNanDouble
(
value
))
{
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
IsInfDouble
(
value
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
IsInfDouble
(
value
))
{
int
sign
;
int
sign
;
EpdConvert
(
value
,
&
epd2
);
EpdConvert
(
value
,
&
epd2
);
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
.
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
.
type
.
bits
.
sign
;
...
@@ -245,14 +245,14 @@ EpdMultiply(EpDouble *epd1, double value)
...
@@ -245,14 +245,14 @@ EpdMultiply(EpDouble *epd1, double value)
void
void
EpdMultiply2
(
EpDouble
*
epd1
,
EpDouble
*
epd2
)
EpdMultiply2
(
EpDouble
*
epd1
,
EpDouble
*
epd2
)
{
{
double
value
;
double
value
;
int
exponent
;
int
exponent
;
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
int
sign
;
int
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
EpdMakeInf
(
epd1
,
sign
);
EpdMakeInf
(
epd1
,
sign
);
...
@@ -284,14 +284,14 @@ EpdMultiply2(EpDouble *epd1, EpDouble *epd2)
...
@@ -284,14 +284,14 @@ EpdMultiply2(EpDouble *epd1, EpDouble *epd2)
void
void
EpdMultiply2Decimal
(
EpDouble
*
epd1
,
EpDouble
*
epd2
)
EpdMultiply2Decimal
(
EpDouble
*
epd1
,
EpDouble
*
epd2
)
{
{
double
value
;
double
value
;
int
exponent
;
int
exponent
;
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
int
sign
;
int
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
EpdMakeInf
(
epd1
,
sign
);
EpdMakeInf
(
epd1
,
sign
);
...
@@ -324,7 +324,7 @@ EpdMultiply3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
...
@@ -324,7 +324,7 @@ EpdMultiply3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
int
sign
;
int
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
EpdMakeInf
(
epd3
,
sign
);
EpdMakeInf
(
epd3
,
sign
);
...
@@ -358,7 +358,7 @@ EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
...
@@ -358,7 +358,7 @@ EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
int
sign
;
int
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
EpdMakeInf
(
epd3
,
sign
);
EpdMakeInf
(
epd3
,
sign
);
...
@@ -385,15 +385,15 @@ EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
...
@@ -385,15 +385,15 @@ EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
void
void
EpdDivide
(
EpDouble
*
epd1
,
double
value
)
EpdDivide
(
EpDouble
*
epd1
,
double
value
)
{
{
EpDouble
epd2
;
EpDouble
epd2
;
double
tmp
;
double
tmp
;
int
exponent
;
int
exponent
;
if
(
EpdIsNan
(
epd1
)
||
IsNanDouble
(
value
))
{
if
(
EpdIsNan
(
epd1
)
||
IsNanDouble
(
value
))
{
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
IsInfDouble
(
value
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
IsInfDouble
(
value
))
{
int
sign
;
int
sign
;
EpdConvert
(
value
,
&
epd2
);
EpdConvert
(
value
,
&
epd2
);
if
(
EpdIsInf
(
epd1
)
&&
IsInfDouble
(
value
))
{
if
(
EpdIsInf
(
epd1
)
&&
IsInfDouble
(
value
))
{
...
@@ -438,14 +438,14 @@ EpdDivide(EpDouble *epd1, double value)
...
@@ -438,14 +438,14 @@ EpdDivide(EpDouble *epd1, double value)
void
void
EpdDivide2
(
EpDouble
*
epd1
,
EpDouble
*
epd2
)
EpdDivide2
(
EpDouble
*
epd1
,
EpDouble
*
epd2
)
{
{
double
value
;
double
value
;
int
exponent
;
int
exponent
;
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
int
sign
;
int
sign
;
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
...
@@ -493,7 +493,7 @@ EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
...
@@ -493,7 +493,7 @@ EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
EpdMakeNan
(
epd3
);
EpdMakeNan
(
epd3
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
int
sign
;
int
sign
;
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
EpdMakeNan
(
epd3
);
EpdMakeNan
(
epd3
);
...
@@ -535,21 +535,21 @@ EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
...
@@ -535,21 +535,21 @@ EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
void
void
EpdAdd
(
EpDouble
*
epd1
,
double
value
)
EpdAdd
(
EpDouble
*
epd1
,
double
value
)
{
{
EpDouble
epd2
;
EpDouble
epd2
;
double
tmp
;
double
tmp
;
int
exponent
,
diff
;
int
exponent
,
diff
;
if
(
EpdIsNan
(
epd1
)
||
IsNanDouble
(
value
))
{
if
(
EpdIsNan
(
epd1
)
||
IsNanDouble
(
value
))
{
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
IsInfDouble
(
value
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
IsInfDouble
(
value
))
{
int
sign
;
int
sign
;
EpdConvert
(
value
,
&
epd2
);
EpdConvert
(
value
,
&
epd2
);
if
(
EpdIsInf
(
epd1
)
&&
IsInfDouble
(
value
))
{
if
(
EpdIsInf
(
epd1
)
&&
IsInfDouble
(
value
))
{
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
.
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
.
type
.
bits
.
sign
;
if
(
sign
==
1
)
if
(
sign
==
1
)
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
}
else
if
(
EpdIsInf
(
&
epd2
))
{
}
else
if
(
EpdIsInf
(
&
epd2
))
{
EpdCopy
(
&
epd2
,
epd1
);
EpdCopy
(
&
epd2
,
epd1
);
}
}
...
@@ -597,19 +597,19 @@ EpdAdd(EpDouble *epd1, double value)
...
@@ -597,19 +597,19 @@ EpdAdd(EpDouble *epd1, double value)
void
void
EpdAdd2
(
EpDouble
*
epd1
,
EpDouble
*
epd2
)
EpdAdd2
(
EpDouble
*
epd1
,
EpDouble
*
epd2
)
{
{
double
value
;
double
value
;
int
exponent
,
diff
;
int
exponent
,
diff
;
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
int
sign
;
int
sign
;
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
if
(
sign
==
1
)
if
(
sign
==
1
)
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
}
else
if
(
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd2
))
{
EpdCopy
(
epd2
,
epd1
);
EpdCopy
(
epd2
,
epd1
);
}
}
...
@@ -623,7 +623,7 @@ EpdAdd2(EpDouble *epd1, EpDouble *epd2)
...
@@ -623,7 +623,7 @@ EpdAdd2(EpDouble *epd1, EpDouble *epd2)
diff
=
epd1
->
exponent
-
epd2
->
exponent
;
diff
=
epd1
->
exponent
-
epd2
->
exponent
;
if
(
diff
<=
EPD_MAX_BIN
)
{
if
(
diff
<=
EPD_MAX_BIN
)
{
value
=
epd1
->
type
.
value
+
value
=
epd1
->
type
.
value
+
epd2
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
);
epd2
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
);
}
else
}
else
value
=
epd1
->
type
.
value
;
value
=
epd1
->
type
.
value
;
exponent
=
epd1
->
exponent
;
exponent
=
epd1
->
exponent
;
...
@@ -631,7 +631,7 @@ EpdAdd2(EpDouble *epd1, EpDouble *epd2)
...
@@ -631,7 +631,7 @@ EpdAdd2(EpDouble *epd1, EpDouble *epd2)
diff
=
epd2
->
exponent
-
epd1
->
exponent
;
diff
=
epd2
->
exponent
-
epd1
->
exponent
;
if
(
diff
<=
EPD_MAX_BIN
)
{
if
(
diff
<=
EPD_MAX_BIN
)
{
value
=
epd1
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
)
+
value
=
epd1
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
)
+
epd2
->
type
.
value
;
epd2
->
type
.
value
;
}
else
}
else
value
=
epd2
->
type
.
value
;
value
=
epd2
->
type
.
value
;
exponent
=
epd2
->
exponent
;
exponent
=
epd2
->
exponent
;
...
@@ -659,21 +659,21 @@ EpdAdd2(EpDouble *epd1, EpDouble *epd2)
...
@@ -659,21 +659,21 @@ EpdAdd2(EpDouble *epd1, EpDouble *epd2)
void
void
EpdAdd3
(
EpDouble
*
epd1
,
EpDouble
*
epd2
,
EpDouble
*
epd3
)
EpdAdd3
(
EpDouble
*
epd1
,
EpDouble
*
epd2
,
EpDouble
*
epd3
)
{
{
double
value
;
double
value
;
int
exponent
,
diff
;
int
exponent
,
diff
;
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
EpdMakeNan
(
epd3
);
EpdMakeNan
(
epd3
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
int
sign
;
int
sign
;
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
if
(
sign
==
1
)
if
(
sign
==
1
)
EpdMakeNan
(
epd3
);
EpdMakeNan
(
epd3
);
else
else
EpdCopy
(
epd1
,
epd3
);
EpdCopy
(
epd1
,
epd3
);
}
else
if
(
EpdIsInf
(
epd1
))
{
}
else
if
(
EpdIsInf
(
epd1
))
{
EpdCopy
(
epd1
,
epd3
);
EpdCopy
(
epd1
,
epd3
);
}
else
{
}
else
{
...
@@ -689,7 +689,7 @@ EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
...
@@ -689,7 +689,7 @@ EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
diff
=
epd1
->
exponent
-
epd2
->
exponent
;
diff
=
epd1
->
exponent
-
epd2
->
exponent
;
if
(
diff
<=
EPD_MAX_BIN
)
{
if
(
diff
<=
EPD_MAX_BIN
)
{
value
=
epd1
->
type
.
value
+
value
=
epd1
->
type
.
value
+
epd2
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
);
epd2
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
);
}
else
}
else
value
=
epd1
->
type
.
value
;
value
=
epd1
->
type
.
value
;
exponent
=
epd1
->
exponent
;
exponent
=
epd1
->
exponent
;
...
@@ -697,7 +697,7 @@ EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
...
@@ -697,7 +697,7 @@ EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
diff
=
epd2
->
exponent
-
epd1
->
exponent
;
diff
=
epd2
->
exponent
-
epd1
->
exponent
;
if
(
diff
<=
EPD_MAX_BIN
)
{
if
(
diff
<=
EPD_MAX_BIN
)
{
value
=
epd1
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
)
+
value
=
epd1
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
)
+
epd2
->
type
.
value
;
epd2
->
type
.
value
;
}
else
}
else
value
=
epd2
->
type
.
value
;
value
=
epd2
->
type
.
value
;
exponent
=
epd2
->
exponent
;
exponent
=
epd2
->
exponent
;
...
@@ -725,21 +725,21 @@ EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
...
@@ -725,21 +725,21 @@ EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
void
void
EpdSubtract
(
EpDouble
*
epd1
,
double
value
)
EpdSubtract
(
EpDouble
*
epd1
,
double
value
)
{
{
EpDouble
epd2
;
EpDouble
epd2
;
double
tmp
;
double
tmp
;
int
exponent
,
diff
;
int
exponent
,
diff
;
if
(
EpdIsNan
(
epd1
)
||
IsNanDouble
(
value
))
{
if
(
EpdIsNan
(
epd1
)
||
IsNanDouble
(
value
))
{
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
IsInfDouble
(
value
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
IsInfDouble
(
value
))
{
int
sign
;
int
sign
;
EpdConvert
(
value
,
&
epd2
);
EpdConvert
(
value
,
&
epd2
);
if
(
EpdIsInf
(
epd1
)
&&
IsInfDouble
(
value
))
{
if
(
EpdIsInf
(
epd1
)
&&
IsInfDouble
(
value
))
{
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
.
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
.
type
.
bits
.
sign
;
if
(
sign
==
0
)
if
(
sign
==
0
)
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
}
else
if
(
EpdIsInf
(
&
epd2
))
{
}
else
if
(
EpdIsInf
(
&
epd2
))
{
EpdCopy
(
&
epd2
,
epd1
);
EpdCopy
(
&
epd2
,
epd1
);
}
}
...
@@ -787,19 +787,19 @@ EpdSubtract(EpDouble *epd1, double value)
...
@@ -787,19 +787,19 @@ EpdSubtract(EpDouble *epd1, double value)
void
void
EpdSubtract2
(
EpDouble
*
epd1
,
EpDouble
*
epd2
)
EpdSubtract2
(
EpDouble
*
epd1
,
EpDouble
*
epd2
)
{
{
double
value
;
double
value
;
int
exponent
,
diff
;
int
exponent
,
diff
;
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
int
sign
;
int
sign
;
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
if
(
sign
==
0
)
if
(
sign
==
0
)
EpdMakeNan
(
epd1
);
EpdMakeNan
(
epd1
);
}
else
if
(
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd2
))
{
EpdCopy
(
epd2
,
epd1
);
EpdCopy
(
epd2
,
epd1
);
}
}
...
@@ -813,7 +813,7 @@ EpdSubtract2(EpDouble *epd1, EpDouble *epd2)
...
@@ -813,7 +813,7 @@ EpdSubtract2(EpDouble *epd1, EpDouble *epd2)
diff
=
epd1
->
exponent
-
epd2
->
exponent
;
diff
=
epd1
->
exponent
-
epd2
->
exponent
;
if
(
diff
<=
EPD_MAX_BIN
)
{
if
(
diff
<=
EPD_MAX_BIN
)
{
value
=
epd1
->
type
.
value
-
value
=
epd1
->
type
.
value
-
epd2
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
);
epd2
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
);
}
else
}
else
value
=
epd1
->
type
.
value
;
value
=
epd1
->
type
.
value
;
exponent
=
epd1
->
exponent
;
exponent
=
epd1
->
exponent
;
...
@@ -821,7 +821,7 @@ EpdSubtract2(EpDouble *epd1, EpDouble *epd2)
...
@@ -821,7 +821,7 @@ EpdSubtract2(EpDouble *epd1, EpDouble *epd2)
diff
=
epd2
->
exponent
-
epd1
->
exponent
;
diff
=
epd2
->
exponent
-
epd1
->
exponent
;
if
(
diff
<=
EPD_MAX_BIN
)
{
if
(
diff
<=
EPD_MAX_BIN
)
{
value
=
epd1
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
)
-
value
=
epd1
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
)
-
epd2
->
type
.
value
;
epd2
->
type
.
value
;
}
else
}
else
value
=
epd2
->
type
.
value
*
(
double
)(
-
1
.
0
);
value
=
epd2
->
type
.
value
*
(
double
)(
-
1
.
0
);
exponent
=
epd2
->
exponent
;
exponent
=
epd2
->
exponent
;
...
@@ -849,21 +849,21 @@ EpdSubtract2(EpDouble *epd1, EpDouble *epd2)
...
@@ -849,21 +849,21 @@ EpdSubtract2(EpDouble *epd1, EpDouble *epd2)
void
void
EpdSubtract3
(
EpDouble
*
epd1
,
EpDouble
*
epd2
,
EpDouble
*
epd3
)
EpdSubtract3
(
EpDouble
*
epd1
,
EpDouble
*
epd2
,
EpDouble
*
epd3
)
{
{
double
value
;
double
value
;
int
exponent
,
diff
;
int
exponent
,
diff
;
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
if
(
EpdIsNan
(
epd1
)
||
EpdIsNan
(
epd2
))
{
EpdMakeNan
(
epd3
);
EpdMakeNan
(
epd3
);
return
;
return
;
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
}
else
if
(
EpdIsInf
(
epd1
)
||
EpdIsInf
(
epd2
))
{
int
sign
;
int
sign
;
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
if
(
EpdIsInf
(
epd1
)
&&
EpdIsInf
(
epd2
))
{
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
sign
=
epd1
->
type
.
bits
.
sign
^
epd2
->
type
.
bits
.
sign
;
if
(
sign
==
0
)
if
(
sign
==
0
)
EpdCopy
(
epd1
,
epd3
);
EpdCopy
(
epd1
,
epd3
);
else
else
EpdMakeNan
(
epd3
);
EpdMakeNan
(
epd3
);
}
else
if
(
EpdIsInf
(
epd1
))
{
}
else
if
(
EpdIsInf
(
epd1
))
{
EpdCopy
(
epd1
,
epd1
);
EpdCopy
(
epd1
,
epd1
);
}
else
{
}
else
{
...
@@ -880,7 +880,7 @@ EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
...
@@ -880,7 +880,7 @@ EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
diff
=
epd1
->
exponent
-
epd2
->
exponent
;
diff
=
epd1
->
exponent
-
epd2
->
exponent
;
if
(
diff
<=
EPD_MAX_BIN
)
{
if
(
diff
<=
EPD_MAX_BIN
)
{
value
=
epd1
->
type
.
value
-
value
=
epd1
->
type
.
value
-
epd2
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
);
epd2
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
);
}
else
}
else
value
=
epd1
->
type
.
value
;
value
=
epd1
->
type
.
value
;
exponent
=
epd1
->
exponent
;
exponent
=
epd1
->
exponent
;
...
@@ -888,7 +888,7 @@ EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
...
@@ -888,7 +888,7 @@ EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
diff
=
epd2
->
exponent
-
epd1
->
exponent
;
diff
=
epd2
->
exponent
-
epd1
->
exponent
;
if
(
diff
<=
EPD_MAX_BIN
)
{
if
(
diff
<=
EPD_MAX_BIN
)
{
value
=
epd1
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
)
-
value
=
epd1
->
type
.
value
/
pow
((
double
)
2
.
0
,
(
double
)
diff
)
-
epd2
->
type
.
value
;
epd2
->
type
.
value
;
}
else
}
else
value
=
epd2
->
type
.
value
*
(
double
)(
-
1
.
0
);
value
=
epd2
->
type
.
value
*
(
double
)(
-
1
.
0
);
exponent
=
epd2
->
exponent
;
exponent
=
epd2
->
exponent
;
...
@@ -920,7 +920,7 @@ EpdPow2(int n, EpDouble *epd)
...
@@ -920,7 +920,7 @@ EpdPow2(int n, EpDouble *epd)
EpdConvert
(
pow
((
double
)
2
.
0
,
(
double
)
n
),
epd
);
EpdConvert
(
pow
((
double
)
2
.
0
,
(
double
)
n
),
epd
);
}
else
{
}
else
{
EpDouble
epd1
,
epd2
;
EpDouble
epd1
,
epd2
;
int
n1
,
n2
;
int
n1
,
n2
;
n1
=
n
/
2
;
n1
=
n
/
2
;
n2
=
n
-
n1
;
n2
=
n
-
n1
;
...
@@ -951,7 +951,7 @@ EpdPow2Decimal(int n, EpDouble *epd)
...
@@ -951,7 +951,7 @@ EpdPow2Decimal(int n, EpDouble *epd)
EpdNormalizeDecimal
(
epd
);
EpdNormalizeDecimal
(
epd
);
}
else
{
}
else
{
EpDouble
epd1
,
epd2
;
EpDouble
epd1
,
epd2
;
int
n1
,
n2
;
int
n1
,
n2
;
n1
=
n
/
2
;
n1
=
n
/
2
;
n2
=
n
-
n1
;
n2
=
n
-
n1
;
...
@@ -976,7 +976,7 @@ EpdPow2Decimal(int n, EpDouble *epd)
...
@@ -976,7 +976,7 @@ EpdPow2Decimal(int n, EpDouble *epd)
void
void
EpdNormalize
(
EpDouble
*
epd
)
EpdNormalize
(
EpDouble
*
epd
)
{
{
int
exponent
;
int
exponent
;
if
(
IsNanOrInfDouble
(
epd
->
type
.
value
))
{
if
(
IsNanOrInfDouble
(
epd
->
type
.
value
))
{
epd
->
exponent
=
0
;
epd
->
exponent
=
0
;
...
@@ -1006,7 +1006,7 @@ EpdNormalize(EpDouble *epd)
...
@@ -1006,7 +1006,7 @@ EpdNormalize(EpDouble *epd)
void
void
EpdNormalizeDecimal
(
EpDouble
*
epd
)
EpdNormalizeDecimal
(
EpDouble
*
epd
)
{
{
int
exponent
;
int
exponent
;
if
(
IsNanOrInfDouble
(
epd
->
type
.
value
))
{
if
(
IsNanOrInfDouble
(
epd
->
type
.
value
))
{
epd
->
exponent
=
0
;
epd
->
exponent
=
0
;
...
@@ -1033,7 +1033,7 @@ EpdNormalizeDecimal(EpDouble *epd)
...
@@ -1033,7 +1033,7 @@ EpdNormalizeDecimal(EpDouble *epd)
void
void
EpdGetValueAndDecimalExponent
(
EpDouble
*
epd
,
double
*
value
,
int
*
exponent
)
EpdGetValueAndDecimalExponent
(
EpDouble
*
epd
,
double
*
value
,
int
*
exponent
)
{
{
EpDouble
epd1
,
epd2
;
EpDouble
epd1
,
epd2
;
if
(
EpdIsNanOrInf
(
epd
))
if
(
EpdIsNanOrInf
(
epd
))
return
;
return
;
...
@@ -1067,8 +1067,8 @@ EpdGetValueAndDecimalExponent(EpDouble *epd, double *value, int *exponent)
...
@@ -1067,8 +1067,8 @@ EpdGetValueAndDecimalExponent(EpDouble *epd, double *value, int *exponent)
int
int
EpdGetExponent
(
double
value
)
EpdGetExponent
(
double
value
)
{
{
int
exponent
;
int
exponent
;
EpDouble
epd
;
EpDouble
epd
;
epd
.
type
.
value
=
value
;
epd
.
type
.
value
=
value
;
exponent
=
epd
.
type
.
bits
.
exponent
;
exponent
=
epd
.
type
.
bits
.
exponent
;
...
@@ -1090,8 +1090,8 @@ EpdGetExponent(double value)
...
@@ -1090,8 +1090,8 @@ EpdGetExponent(double value)
int
int
EpdGetExponentDecimal
(
double
value
)
EpdGetExponentDecimal
(
double
value
)
{
{
char
*
pos
,
str
[
24
];
char
*
pos
,
str
[
24
];
int
exponent
;
int
exponent
;
sprintf
(
str
,
"%E"
,
value
);
sprintf
(
str
,
"%E"
,
value
);
pos
=
strstr
(
str
,
"E"
);
pos
=
strstr
(
str
,
"E"
);
...
@@ -1304,7 +1304,7 @@ IsInfDouble(double value)
...
@@ -1304,7 +1304,7 @@ IsInfDouble(double value)
int
int
IsNanDouble
(
double
value
)
IsNanDouble
(
double
value
)
{
{
EpType
val
;
EpType
val
;
val
.
value
=
value
;
val
.
value
=
value
;
if
(
val
.
nan
.
exponent
==
EPD_EXP_INF
&&
if
(
val
.
nan
.
exponent
==
EPD_EXP_INF
&&
...
@@ -1332,7 +1332,7 @@ IsNanDouble(double value)
...
@@ -1332,7 +1332,7 @@ IsNanDouble(double value)
int
int
IsNanOrInfDouble
(
double
value
)
IsNanOrInfDouble
(
double
value
)
{
{
EpType
val
;
EpType
val
;
val
.
value
=
value
;
val
.
value
=
value
;
if
(
val
.
nan
.
exponent
==
EPD_EXP_INF
&&
if
(
val
.
nan
.
exponent
==
EPD_EXP_INF
&&
...
...
src/bdd/epd/epd.h
View file @
f2945e12
...
@@ -57,9 +57,9 @@ ABC_NAMESPACE_HEADER_START
...
@@ -57,9 +57,9 @@ ABC_NAMESPACE_HEADER_START
/* Constant declarations */
/* Constant declarations */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
#define
EPD_MAX_BIN
1023
#define
EPD_MAX_BIN
1023
#define
EPD_MAX_DEC
308
#define
EPD_MAX_DEC
308
#define
EPD_EXP_INF
0x7ff
#define
EPD_EXP_INF
0x7ff
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Structure declarations */
/* Structure declarations */
...
@@ -74,15 +74,15 @@ ABC_NAMESPACE_HEADER_START
...
@@ -74,15 +74,15 @@ ABC_NAMESPACE_HEADER_START
SeeAlso []
SeeAlso []
******************************************************************************/
******************************************************************************/
#ifdef
EPD_BIG_ENDIAN
#ifdef EPD_BIG_ENDIAN
struct
IeeeDoubleStruct
{
/* BIG_ENDIAN */
struct
IeeeDoubleStruct
{
/* BIG_ENDIAN */
unsigned
int
sign
:
1
;
unsigned
int
sign
:
1
;
unsigned
int
exponent
:
11
;
unsigned
int
exponent
:
11
;
unsigned
int
mantissa0
:
20
;
unsigned
int
mantissa0
:
20
;
unsigned
int
mantissa1
:
32
;
unsigned
int
mantissa1
:
32
;
};
};
#else
#else
struct
IeeeDoubleStruct
{
/* LITTLE_ENDIAN */
struct
IeeeDoubleStruct
{
/* LITTLE_ENDIAN */
unsigned
int
mantissa1
:
32
;
unsigned
int
mantissa1
:
32
;
unsigned
int
mantissa0
:
20
;
unsigned
int
mantissa0
:
20
;
unsigned
int
exponent
:
11
;
unsigned
int
exponent
:
11
;
...
@@ -99,8 +99,8 @@ struct IeeeDoubleStruct { /* LITTLE_ENDIAN */
...
@@ -99,8 +99,8 @@ struct IeeeDoubleStruct { /* LITTLE_ENDIAN */
SeeAlso []
SeeAlso []
******************************************************************************/
******************************************************************************/
#ifdef
EPD_BIG_ENDIAN
#ifdef EPD_BIG_ENDIAN
struct
IeeeNanStruct
{
/* BIG_ENDIAN */
struct
IeeeNanStruct
{
/* BIG_ENDIAN */
unsigned
int
sign
:
1
;
unsigned
int
sign
:
1
;
unsigned
int
exponent
:
11
;
unsigned
int
exponent
:
11
;
unsigned
int
quiet_bit
:
1
;
unsigned
int
quiet_bit
:
1
;
...
@@ -108,7 +108,7 @@ struct IeeeNanStruct { /* BIG_ENDIAN */
...
@@ -108,7 +108,7 @@ struct IeeeNanStruct { /* BIG_ENDIAN */
unsigned
int
mantissa1
:
32
;
unsigned
int
mantissa1
:
32
;
};
};
#else
#else
struct
IeeeNanStruct
{
/* LITTLE_ENDIAN */
struct
IeeeNanStruct
{
/* LITTLE_ENDIAN */
unsigned
int
mantissa1
:
32
;
unsigned
int
mantissa1
:
32
;
unsigned
int
mantissa0
:
19
;
unsigned
int
mantissa0
:
19
;
unsigned
int
quiet_bit
:
1
;
unsigned
int
quiet_bit
:
1
;
...
@@ -127,14 +127,14 @@ struct IeeeNanStruct { /* LITTLE_ENDIAN */
...
@@ -127,14 +127,14 @@ struct IeeeNanStruct { /* LITTLE_ENDIAN */
******************************************************************************/
******************************************************************************/
union
EpTypeUnion
{
union
EpTypeUnion
{
double
value
;
double
value
;
struct
IeeeDoubleStruct
bits
;
struct
IeeeDoubleStruct
bits
;
struct
IeeeNanStruct
nan
;
struct
IeeeNanStruct
nan
;
};
};
struct
EpDoubleStruct
{
struct
EpDoubleStruct
{
union
EpTypeUnion
type
;
union
EpTypeUnion
type
;
int
exponent
;
int
exponent
;
};
};
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
...
...
src/bdd/mtr/mtr.h
View file @
f2945e12
...
@@ -96,20 +96,20 @@ ABC_NAMESPACE_HEADER_START
...
@@ -96,20 +96,20 @@ ABC_NAMESPACE_HEADER_START
#endif
#endif
/* Flag definitions */
/* Flag definitions */
#define MTR_DEFAULT 0x00000000
#define MTR_DEFAULT
0x00000000
#define MTR_TERMINAL 0x00000001
#define MTR_TERMINAL 0x00000001
#define MTR_SOFT 0x00000002
#define MTR_SOFT
0x00000002
#define MTR_FIXED 0x00000004
#define MTR_FIXED
0x00000004
#define MTR_NEWNODE 0x00000008
#define MTR_NEWNODE
0x00000008
/* MTR_MAXHIGH is defined in such a way that on 32-bit and 64-bit
/* MTR_MAXHIGH is defined in such a way that on 32-bit and 64-bit
** machines one can cast a value to (int) without generating a negative
** machines one can cast a value to (int) without generating a negative
** number.
** number.
*/
*/
#if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
#if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
#define MTR_MAXHIGH (((MtrHalfWord) ~0) >> 1)
#define MTR_MAXHIGH
(((MtrHalfWord) ~0) >> 1)
#else
#else
#define MTR_MAXHIGH ((MtrHalfWord) ~0)
#define MTR_MAXHIGH
((MtrHalfWord) ~0)
#endif
#endif
...
@@ -150,8 +150,8 @@ typedef struct MtrNode {
...
@@ -150,8 +150,8 @@ typedef struct MtrNode {
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Flag manipulation macros */
/* Flag manipulation macros */
#define MTR_SET(node, flag) (node->flags |= (flag))
#define MTR_SET(node, flag)
(node->flags |= (flag))
#define MTR_RESET(node, flag)
(node->flags &= ~ (flag))
#define MTR_RESET(node, flag) (node->flags &= ~ (flag))
#define MTR_TEST(node, flag) (node->flags & (flag))
#define MTR_TEST(node, flag) (node->flags & (flag))
...
...
src/bdd/mtr/mtrBasic.c
View file @
f2945e12
...
@@ -7,20 +7,20 @@
...
@@ -7,20 +7,20 @@
Synopsis [Basic manipulation of multiway branching trees.]
Synopsis [Basic manipulation of multiway branching trees.]
Description [External procedures included in this module:
Description [External procedures included in this module:
<ul>
<ul>
<li> Mtr_AllocNode()
<li> Mtr_AllocNode()
<li> Mtr_DeallocNode()
<li> Mtr_DeallocNode()
<li> Mtr_InitTree()
<li> Mtr_InitTree()
<li> Mtr_FreeTree()
<li> Mtr_FreeTree()
<li> Mtr_CopyTree()
<li> Mtr_CopyTree()
<li> Mtr_MakeFirstChild()
<li> Mtr_MakeFirstChild()
<li> Mtr_MakeLastChild()
<li> Mtr_MakeLastChild()
<li> Mtr_CreateFirstChild()
<li> Mtr_CreateFirstChild()
<li> Mtr_CreateLastChild()
<li> Mtr_CreateLastChild()
<li> Mtr_MakeNextSibling()
<li> Mtr_MakeNextSibling()
<li> Mtr_PrintTree()
<li> Mtr_PrintTree()
</ul>
</ul>
]
]
SeeAlso [cudd package]
SeeAlso [cudd package]
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
******************************************************************************/
******************************************************************************/
#include "util.h"
#include "util
_hack
.h"
#include "mtrInt.h"
#include "mtrInt.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -119,7 +119,7 @@ Mtr_AllocNode(void)
...
@@ -119,7 +119,7 @@ Mtr_AllocNode(void)
{
{
MtrNode
*
node
;
MtrNode
*
node
;
node
=
ALLOC
(
MtrNode
,
1
);
node
=
A
BC_A
LLOC
(
MtrNode
,
1
);
return
node
;
return
node
;
}
/* Mtr_AllocNode */
}
/* Mtr_AllocNode */
...
@@ -140,7 +140,7 @@ void
...
@@ -140,7 +140,7 @@ void
Mtr_DeallocNode
(
Mtr_DeallocNode
(
MtrNode
*
node
/* node to be deallocated */
)
MtrNode
*
node
/* node to be deallocated */
)
{
{
FREE
(
node
);
ABC_
FREE
(
node
);
return
;
return
;
}
/* end of Mtr_DeallocNode */
}
/* end of Mtr_DeallocNode */
...
@@ -224,18 +224,18 @@ Mtr_CopyTree(
...
@@ -224,18 +224,18 @@ Mtr_CopyTree(
if
(
copy
==
NULL
)
return
(
NULL
);
if
(
copy
==
NULL
)
return
(
NULL
);
copy
->
parent
=
copy
->
elder
=
copy
->
child
=
copy
->
younger
=
NULL
;
copy
->
parent
=
copy
->
elder
=
copy
->
child
=
copy
->
younger
=
NULL
;
if
(
node
->
child
!=
NULL
)
{
if
(
node
->
child
!=
NULL
)
{
copy
->
child
=
Mtr_CopyTree
(
node
->
child
,
expansion
);
copy
->
child
=
Mtr_CopyTree
(
node
->
child
,
expansion
);
if
(
copy
->
child
==
NULL
)
{
if
(
copy
->
child
==
NULL
)
{
Mtr_DeallocNode
(
copy
);
Mtr_DeallocNode
(
copy
);
return
(
NULL
);
return
(
NULL
);
}
}
}
}
if
(
node
->
younger
!=
NULL
)
{
if
(
node
->
younger
!=
NULL
)
{
copy
->
younger
=
Mtr_CopyTree
(
node
->
younger
,
expansion
);
copy
->
younger
=
Mtr_CopyTree
(
node
->
younger
,
expansion
);
if
(
copy
->
younger
==
NULL
)
{
if
(
copy
->
younger
==
NULL
)
{
Mtr_FreeTree
(
copy
);
Mtr_FreeTree
(
copy
);
return
(
NULL
);
return
(
NULL
);
}
}
}
}
copy
->
flags
=
node
->
flags
;
copy
->
flags
=
node
->
flags
;
copy
->
low
=
node
->
low
*
expansion
;
copy
->
low
=
node
->
low
*
expansion
;
...
@@ -243,11 +243,11 @@ Mtr_CopyTree(
...
@@ -243,11 +243,11 @@ Mtr_CopyTree(
copy
->
index
=
node
->
index
*
expansion
;
copy
->
index
=
node
->
index
*
expansion
;
if
(
copy
->
younger
)
copy
->
younger
->
elder
=
copy
;
if
(
copy
->
younger
)
copy
->
younger
->
elder
=
copy
;
if
(
copy
->
child
)
{
if
(
copy
->
child
)
{
MtrNode
*
auxnode
=
copy
->
child
;
MtrNode
*
auxnode
=
copy
->
child
;
while
(
auxnode
!=
NULL
)
{
while
(
auxnode
!=
NULL
)
{
auxnode
->
parent
=
copy
;
auxnode
->
parent
=
copy
;
auxnode
=
auxnode
->
younger
;
auxnode
=
auxnode
->
younger
;
}
}
}
}
return
(
copy
);
return
(
copy
);
...
@@ -275,9 +275,9 @@ Mtr_MakeFirstChild(
...
@@ -275,9 +275,9 @@ Mtr_MakeFirstChild(
child
->
elder
=
NULL
;
child
->
elder
=
NULL
;
if
(
parent
->
child
!=
NULL
)
{
if
(
parent
->
child
!=
NULL
)
{
#ifdef MTR_DEBUG
#ifdef MTR_DEBUG
assert
(
parent
->
child
->
elder
==
NULL
);
assert
(
parent
->
child
->
elder
==
NULL
);
#endif
#endif
parent
->
child
->
elder
=
child
;
parent
->
child
->
elder
=
child
;
}
}
parent
->
child
=
child
;
parent
->
child
=
child
;
return
;
return
;
...
@@ -306,14 +306,14 @@ Mtr_MakeLastChild(
...
@@ -306,14 +306,14 @@ Mtr_MakeLastChild(
child
->
younger
=
NULL
;
child
->
younger
=
NULL
;
if
(
parent
->
child
==
NULL
)
{
if
(
parent
->
child
==
NULL
)
{
parent
->
child
=
child
;
parent
->
child
=
child
;
child
->
elder
=
NULL
;
child
->
elder
=
NULL
;
}
else
{
}
else
{
for
(
node
=
parent
->
child
;
for
(
node
=
parent
->
child
;
node
->
younger
!=
NULL
;
node
->
younger
!=
NULL
;
node
=
node
->
younger
);
node
=
node
->
younger
);
node
->
younger
=
child
;
node
->
younger
=
child
;
child
->
elder
=
node
;
child
->
elder
=
node
;
}
}
child
->
parent
=
parent
;
child
->
parent
=
parent
;
return
;
return
;
...
@@ -398,7 +398,7 @@ Mtr_MakeNextSibling(
...
@@ -398,7 +398,7 @@ Mtr_MakeNextSibling(
{
{
second
->
younger
=
first
->
younger
;
second
->
younger
=
first
->
younger
;
if
(
first
->
younger
!=
NULL
)
{
if
(
first
->
younger
!=
NULL
)
{
first
->
younger
->
elder
=
second
;
first
->
younger
->
elder
=
second
;
}
}
second
->
parent
=
first
->
parent
;
second
->
parent
=
first
->
parent
;
first
->
younger
=
second
;
first
->
younger
=
second
;
...
...
src/bdd/mtr/mtrGroup.c
View file @
f2945e12
...
@@ -7,20 +7,20 @@
...
@@ -7,20 +7,20 @@
Synopsis [Functions to support group specification for reordering.]
Synopsis [Functions to support group specification for reordering.]
Description [External procedures included in this module:
Description [External procedures included in this module:
<ul>
<ul>
<li> Mtr_InitGroupTree()
<li> Mtr_InitGroupTree()
<li> Mtr_MakeGroup()
<li> Mtr_MakeGroup()
<li> Mtr_DissolveGroup()
<li> Mtr_DissolveGroup()
<li> Mtr_FindGroup()
<li> Mtr_FindGroup()
<li> Mtr_SwapGroups()
<li> Mtr_SwapGroups()
<li> Mtr_PrintGroups()
<li> Mtr_PrintGroups()
<li> Mtr_ReadGroups()
<li> Mtr_ReadGroups()
</ul>
</ul>
Static procedures included in this module:
Static procedures included in this module:
<ul>
<ul>
<li> mtrShiftHL
<li> mtrShiftHL
</ul>
</ul>
]
]
SeeAlso [cudd package]
SeeAlso [cudd package]
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
******************************************************************************/
******************************************************************************/
#include "util.h"
#include "util
_hack
.h"
#include "mtrInt.h"
#include "mtrInt.h"
ABC_NAMESPACE_IMPL_START
ABC_NAMESPACE_IMPL_START
...
@@ -162,27 +162,27 @@ Mtr_MakeGroup(
...
@@ -162,27 +162,27 @@ Mtr_MakeGroup(
unsigned
int
flags
/* flags for the new group */
)
unsigned
int
flags
/* flags for the new group */
)
{
{
MtrNode
*
node
,
MtrNode
*
node
,
*
first
,
*
first
,
*
last
,
*
last
,
*
previous
,
*
previous
,
*
newn
;
*
newn
;
/* Sanity check. */
/* Sanity check. */
if
(
size
==
0
)
if
(
size
==
0
)
return
(
NULL
);
return
(
NULL
);
/* Check whether current group includes new group. This check is
/* Check whether current group includes new group. This check is
** necessary at the top-level call. In the subsequent calls it is
** necessary at the top-level call. In the subsequent calls it is
** redundant. */
** redundant. */
if
(
low
<
(
unsigned
int
)
root
->
low
||
if
(
low
<
(
unsigned
int
)
root
->
low
||
low
+
size
>
(
unsigned
int
)
(
root
->
low
+
root
->
size
))
low
+
size
>
(
unsigned
int
)
(
root
->
low
+
root
->
size
))
return
(
NULL
);
return
(
NULL
);
/* Trying to create an existing group has the effect of updating
/* Trying to create an existing group has the effect of updating
** the flags. */
** the flags. */
if
(
root
->
size
==
size
&&
root
->
low
==
low
)
{
if
(
root
->
size
==
size
&&
root
->
low
==
low
)
{
root
->
flags
=
flags
;
root
->
flags
=
flags
;
return
(
root
);
return
(
root
);
}
}
/* At this point we know that the new group is properly contained
/* At this point we know that the new group is properly contained
...
@@ -191,15 +191,15 @@ Mtr_MakeGroup(
...
@@ -191,15 +191,15 @@ Mtr_MakeGroup(
/* Root has no children: create a new group. */
/* Root has no children: create a new group. */
if
(
root
->
child
==
NULL
)
{
if
(
root
->
child
==
NULL
)
{
newn
=
Mtr_AllocNode
();
newn
=
Mtr_AllocNode
();
if
(
newn
==
NULL
)
return
(
NULL
);
/* out of memory */
if
(
newn
==
NULL
)
return
(
NULL
);
/* out of memory */
newn
->
low
=
low
;
newn
->
low
=
low
;
newn
->
size
=
size
;
newn
->
size
=
size
;
newn
->
flags
=
flags
;
newn
->
flags
=
flags
;
newn
->
parent
=
root
;
newn
->
parent
=
root
;
newn
->
elder
=
newn
->
younger
=
newn
->
child
=
NULL
;
newn
->
elder
=
newn
->
younger
=
newn
->
child
=
NULL
;
root
->
child
=
newn
;
root
->
child
=
newn
;
return
(
newn
);
return
(
newn
);
}
}
/* Root has children: Find all chidren of root that are included
/* Root has children: Find all chidren of root that are included
...
@@ -208,58 +208,58 @@ Mtr_MakeGroup(
...
@@ -208,58 +208,58 @@ Mtr_MakeGroup(
previous
=
NULL
;
previous
=
NULL
;
first
=
root
->
child
;
/* guaranteed to be non-NULL */
first
=
root
->
child
;
/* guaranteed to be non-NULL */
while
(
first
!=
NULL
&&
low
>=
(
unsigned
int
)
(
first
->
low
+
first
->
size
))
{
while
(
first
!=
NULL
&&
low
>=
(
unsigned
int
)
(
first
->
low
+
first
->
size
))
{
previous
=
first
;
previous
=
first
;
first
=
first
->
younger
;
first
=
first
->
younger
;
}
}
if
(
first
==
NULL
)
{
if
(
first
==
NULL
)
{
/* We have scanned the entire list and we need to append a new
/* We have scanned the entire list and we need to append a new
** child at the end of it. Previous points to the last child
** child at the end of it. Previous points to the last child
** of root. */
** of root. */
newn
=
Mtr_AllocNode
();
newn
=
Mtr_AllocNode
();
if
(
newn
==
NULL
)
return
(
NULL
);
/* out of memory */
if
(
newn
==
NULL
)
return
(
NULL
);
/* out of memory */
newn
->
low
=
low
;
newn
->
low
=
low
;
newn
->
size
=
size
;
newn
->
size
=
size
;
newn
->
flags
=
flags
;
newn
->
flags
=
flags
;
newn
->
parent
=
root
;
newn
->
parent
=
root
;
newn
->
elder
=
previous
;
newn
->
elder
=
previous
;
previous
->
younger
=
newn
;
previous
->
younger
=
newn
;
newn
->
younger
=
newn
->
child
=
NULL
;
newn
->
younger
=
newn
->
child
=
NULL
;
return
(
newn
);
return
(
newn
);
}
}
/* Here first is non-NULL and low < first->low + first->size. */
/* Here first is non-NULL and low < first->low + first->size. */
if
(
low
>=
(
unsigned
int
)
first
->
low
&&
if
(
low
>=
(
unsigned
int
)
first
->
low
&&
low
+
size
<=
(
unsigned
int
)
(
first
->
low
+
first
->
size
))
{
low
+
size
<=
(
unsigned
int
)
(
first
->
low
+
first
->
size
))
{
/* The new group is contained in the group of first. */
/* The new group is contained in the group of first. */
newn
=
Mtr_MakeGroup
(
first
,
low
,
size
,
flags
);
newn
=
Mtr_MakeGroup
(
first
,
low
,
size
,
flags
);
return
(
newn
);
return
(
newn
);
}
else
if
(
low
+
size
<=
first
->
low
)
{
}
else
if
(
low
+
size
<=
first
->
low
)
{
/* The new group is entirely contained in the gap between
/* The new group is entirely contained in the gap between
** previous and first. */
** previous and first. */
newn
=
Mtr_AllocNode
();
newn
=
Mtr_AllocNode
();
if
(
newn
==
NULL
)
return
(
NULL
);
/* out of memory */
if
(
newn
==
NULL
)
return
(
NULL
);
/* out of memory */
newn
->
low
=
low
;
newn
->
low
=
low
;
newn
->
size
=
size
;
newn
->
size
=
size
;
newn
->
flags
=
flags
;
newn
->
flags
=
flags
;
newn
->
child
=
NULL
;
newn
->
child
=
NULL
;
newn
->
parent
=
root
;
newn
->
parent
=
root
;
newn
->
elder
=
previous
;
newn
->
elder
=
previous
;
newn
->
younger
=
first
;
newn
->
younger
=
first
;
first
->
elder
=
newn
;
first
->
elder
=
newn
;
if
(
previous
!=
NULL
)
{
if
(
previous
!=
NULL
)
{
previous
->
younger
=
newn
;
previous
->
younger
=
newn
;
}
else
{
}
else
{
root
->
child
=
newn
;
root
->
child
=
newn
;
}
}
return
(
newn
);
return
(
newn
);
}
else
if
(
low
<
(
unsigned
int
)
first
->
low
&&
}
else
if
(
low
<
(
unsigned
int
)
first
->
low
&&
low
+
size
<
(
unsigned
int
)
(
first
->
low
+
first
->
size
))
{
low
+
size
<
(
unsigned
int
)
(
first
->
low
+
first
->
size
))
{
/* Trying to cut an existing group: not allowed. */
/* Trying to cut an existing group: not allowed. */
return
(
NULL
);
return
(
NULL
);
}
else
if
(
low
>
first
->
low
)
{
}
else
if
(
low
>
first
->
low
)
{
/* The new group neither is contained in the group of first
/* The new group neither is contained in the group of first
** (this was tested above) nor contains it. It is therefore
** (this was tested above) nor contains it. It is therefore
** trying to cut an existing group: not allowed. */
** trying to cut an existing group: not allowed. */
return
(
NULL
);
return
(
NULL
);
}
}
/* First holds the pointer to the first child contained in the new
/* First holds the pointer to the first child contained in the new
...
@@ -267,40 +267,40 @@ Mtr_MakeGroup(
...
@@ -267,40 +267,40 @@ Mtr_MakeGroup(
** first->size. One of the two inequalities is strict. */
** first->size. One of the two inequalities is strict. */
last
=
first
->
younger
;
last
=
first
->
younger
;
while
(
last
!=
NULL
&&
while
(
last
!=
NULL
&&
(
unsigned
int
)
(
last
->
low
+
last
->
size
)
<
low
+
size
)
{
(
unsigned
int
)
(
last
->
low
+
last
->
size
)
<
low
+
size
)
{
last
=
last
->
younger
;
}
if
(
last
==
NULL
)
{
/* All the chilren of root from first onward become children
** of the new group. */
newn
=
Mtr_AllocNode
();
if
(
newn
==
NULL
)
return
(
NULL
);
/* out of memory */
newn
->
low
=
low
;
newn
->
size
=
size
;
newn
->
flags
=
flags
;
newn
->
child
=
first
;
newn
->
parent
=
root
;
newn
->
elder
=
previous
;
newn
->
younger
=
NULL
;
first
->
elder
=
NULL
;
if
(
previous
!=
NULL
)
{
previous
->
younger
=
newn
;
}
else
{
root
->
child
=
newn
;
}
last
=
first
;
while
(
last
!=
NULL
)
{
last
->
parent
=
newn
;
last
=
last
->
younger
;
last
=
last
->
younger
;
}
}
return
(
newn
);
if
(
last
==
NULL
)
{
/* All the chilren of root from first onward become children
** of the new group. */
newn
=
Mtr_AllocNode
();
if
(
newn
==
NULL
)
return
(
NULL
);
/* out of memory */
newn
->
low
=
low
;
newn
->
size
=
size
;
newn
->
flags
=
flags
;
newn
->
child
=
first
;
newn
->
parent
=
root
;
newn
->
elder
=
previous
;
newn
->
younger
=
NULL
;
first
->
elder
=
NULL
;
if
(
previous
!=
NULL
)
{
previous
->
younger
=
newn
;
}
else
{
root
->
child
=
newn
;
}
last
=
first
;
while
(
last
!=
NULL
)
{
last
->
parent
=
newn
;
last
=
last
->
younger
;
}
return
(
newn
);
}
}
/* Here last != NULL and low + size <= last->low + last->size. */
/* Here last != NULL and low + size <= last->low + last->size. */
if
(
low
+
size
-
1
>=
(
unsigned
int
)
last
->
low
&&
if
(
low
+
size
-
1
>=
(
unsigned
int
)
last
->
low
&&
low
+
size
<
(
unsigned
int
)
(
last
->
low
+
last
->
size
))
{
low
+
size
<
(
unsigned
int
)
(
last
->
low
+
last
->
size
))
{
/* Trying to cut an existing group: not allowed. */
/* Trying to cut an existing group: not allowed. */
return
(
NULL
);
return
(
NULL
);
}
}
/* First and last point to the first and last of the children of
/* First and last point to the first and last of the children of
...
@@ -310,26 +310,26 @@ Mtr_MakeGroup(
...
@@ -310,26 +310,26 @@ Mtr_MakeGroup(
** preceeding first. If it is NULL, then first is the first child
** preceeding first. If it is NULL, then first is the first child
** of root. */
** of root. */
newn
=
Mtr_AllocNode
();
newn
=
Mtr_AllocNode
();
if
(
newn
==
NULL
)
return
(
NULL
);
/* out of memory */
if
(
newn
==
NULL
)
return
(
NULL
);
/* out of memory */
newn
->
low
=
low
;
newn
->
low
=
low
;
newn
->
size
=
size
;
newn
->
size
=
size
;
newn
->
flags
=
flags
;
newn
->
flags
=
flags
;
newn
->
child
=
first
;
newn
->
child
=
first
;
newn
->
parent
=
root
;
newn
->
parent
=
root
;
if
(
previous
==
NULL
)
{
if
(
previous
==
NULL
)
{
root
->
child
=
newn
;
root
->
child
=
newn
;
}
else
{
}
else
{
previous
->
younger
=
newn
;
previous
->
younger
=
newn
;
}
}
newn
->
elder
=
previous
;
newn
->
elder
=
previous
;
newn
->
younger
=
last
->
younger
;
newn
->
younger
=
last
->
younger
;
if
(
last
->
younger
!=
NULL
)
{
if
(
last
->
younger
!=
NULL
)
{
last
->
younger
->
elder
=
newn
;
last
->
younger
->
elder
=
newn
;
}
}
last
->
younger
=
NULL
;
last
->
younger
=
NULL
;
first
->
elder
=
NULL
;
first
->
elder
=
NULL
;
for
(
node
=
first
;
node
!=
NULL
;
node
=
node
->
younger
)
{
for
(
node
=
first
;
node
!=
NULL
;
node
=
node
->
younger
)
{
node
->
parent
=
newn
;
node
->
parent
=
newn
;
}
}
return
(
newn
);
return
(
newn
);
...
@@ -368,20 +368,20 @@ Mtr_DissolveGroup(
...
@@ -368,20 +368,20 @@ Mtr_DissolveGroup(
/* Make all children of group children of its parent, and make
/* Make all children of group children of its parent, and make
** last point to the last child of group. */
** last point to the last child of group. */
for
(
last
=
group
->
child
;
last
->
younger
!=
NULL
;
last
=
last
->
younger
)
{
for
(
last
=
group
->
child
;
last
->
younger
!=
NULL
;
last
=
last
->
younger
)
{
last
->
parent
=
parent
;
last
->
parent
=
parent
;
}
}
last
->
parent
=
parent
;
last
->
parent
=
parent
;
last
->
younger
=
group
->
younger
;
last
->
younger
=
group
->
younger
;
if
(
group
->
younger
!=
NULL
)
{
if
(
group
->
younger
!=
NULL
)
{
group
->
younger
->
elder
=
last
;
group
->
younger
->
elder
=
last
;
}
}
group
->
child
->
elder
=
group
->
elder
;
group
->
child
->
elder
=
group
->
elder
;
if
(
group
==
parent
->
child
)
{
if
(
group
==
parent
->
child
)
{
parent
->
child
=
group
->
child
;
parent
->
child
=
group
->
child
;
}
else
{
}
else
{
group
->
elder
->
younger
=
group
->
child
;
group
->
elder
->
younger
=
group
->
child
;
}
}
Mtr_DeallocNode
(
group
);
Mtr_DeallocNode
(
group
);
...
@@ -425,28 +425,28 @@ Mtr_FindGroup(
...
@@ -425,28 +425,28 @@ Mtr_FindGroup(
** check is necessary at the top-level call. In the subsequent
** check is necessary at the top-level call. In the subsequent
** calls it is redundant. */
** calls it is redundant. */
if
(
low
<
(
unsigned
int
)
root
->
low
||
if
(
low
<
(
unsigned
int
)
root
->
low
||
low
+
size
>
(
unsigned
int
)
(
root
->
low
+
root
->
size
))
low
+
size
>
(
unsigned
int
)
(
root
->
low
+
root
->
size
))
return
(
NULL
);
return
(
NULL
);
if
(
root
->
size
==
size
&&
root
->
low
==
low
)
if
(
root
->
size
==
size
&&
root
->
low
==
low
)
return
(
root
);
return
(
root
);
if
(
root
->
child
==
NULL
)
if
(
root
->
child
==
NULL
)
return
(
NULL
);
return
(
NULL
);
/* Find all chidren of root that are included in the new group. If
/* Find all chidren of root that are included in the new group. If
** the group of any child entirely contains the new group, call
** the group of any child entirely contains the new group, call
** Mtr_MakeGroup recursively. */
** Mtr_MakeGroup recursively. */
node
=
root
->
child
;
node
=
root
->
child
;
while
(
low
>=
(
unsigned
int
)
(
node
->
low
+
node
->
size
))
{
while
(
low
>=
(
unsigned
int
)
(
node
->
low
+
node
->
size
))
{
node
=
node
->
younger
;
node
=
node
->
younger
;
}
}
if
(
low
+
size
<=
(
unsigned
int
)
(
node
->
low
+
node
->
size
))
{
if
(
low
+
size
<=
(
unsigned
int
)
(
node
->
low
+
node
->
size
))
{
/* The group is contained in the group of node. */
/* The group is contained in the group of node. */
node
=
Mtr_FindGroup
(
node
,
low
,
size
);
node
=
Mtr_FindGroup
(
node
,
low
,
size
);
return
(
node
);
return
(
node
);
}
else
{
}
else
{
return
(
NULL
);
return
(
NULL
);
}
}
}
/* end of Mtr_FindGroup */
}
/* end of Mtr_FindGroup */
...
@@ -477,11 +477,11 @@ Mtr_SwapGroups(
...
@@ -477,11 +477,11 @@ Mtr_SwapGroups(
int
sizeSecond
;
int
sizeSecond
;
if
(
second
->
younger
==
first
)
{
/* make first first */
if
(
second
->
younger
==
first
)
{
/* make first first */
node
=
first
;
node
=
first
;
first
=
second
;
first
=
second
;
second
=
node
;
second
=
node
;
}
else
if
(
first
->
younger
!=
second
)
{
/* non-adjacent */
}
else
if
(
first
->
younger
!=
second
)
{
/* non-adjacent */
return
(
0
);
return
(
0
);
}
}
sizeFirst
=
first
->
size
;
sizeFirst
=
first
->
size
;
...
@@ -491,12 +491,12 @@ Mtr_SwapGroups(
...
@@ -491,12 +491,12 @@ Mtr_SwapGroups(
parent
=
first
->
parent
;
parent
=
first
->
parent
;
if
(
parent
==
NULL
||
second
->
parent
!=
parent
)
return
(
0
);
if
(
parent
==
NULL
||
second
->
parent
!=
parent
)
return
(
0
);
if
(
parent
->
child
==
first
)
{
if
(
parent
->
child
==
first
)
{
parent
->
child
=
second
;
parent
->
child
=
second
;
}
else
{
/* first->elder != NULL */
}
else
{
/* first->elder != NULL */
first
->
elder
->
younger
=
second
;
first
->
elder
->
younger
=
second
;
}
}
if
(
second
->
younger
!=
NULL
)
{
if
(
second
->
younger
!=
NULL
)
{
second
->
younger
->
elder
=
first
;
second
->
younger
->
elder
=
first
;
}
}
first
->
younger
=
second
->
younger
;
first
->
younger
=
second
->
younger
;
second
->
elder
=
first
->
elder
;
second
->
elder
=
first
->
elder
;
...
@@ -549,30 +549,30 @@ Mtr_PrintGroups(
...
@@ -549,30 +549,30 @@ Mtr_PrintGroups(
if
(
!
silent
)
(
void
)
printf
(
"(%hu"
,
root
->
low
);
if
(
!
silent
)
(
void
)
printf
(
"(%hu"
,
root
->
low
);
#endif
#endif
if
(
MTR_TEST
(
root
,
MTR_TERMINAL
)
||
root
->
child
==
NULL
)
{
if
(
MTR_TEST
(
root
,
MTR_TERMINAL
)
||
root
->
child
==
NULL
)
{
if
(
!
silent
)
(
void
)
printf
(
","
);
if
(
!
silent
)
(
void
)
printf
(
","
);
}
else
{
}
else
{
node
=
root
->
child
;
node
=
root
->
child
;
while
(
node
!=
NULL
)
{
while
(
node
!=
NULL
)
{
assert
(
node
->
low
>=
root
->
low
&&
(
int
)
(
node
->
low
+
node
->
size
)
<=
(
int
)
(
root
->
low
+
root
->
size
));
assert
(
node
->
low
>=
root
->
low
&&
(
int
)
(
node
->
low
+
node
->
size
)
<=
(
int
)
(
root
->
low
+
root
->
size
));
assert
(
node
->
parent
==
root
);
assert
(
node
->
parent
==
root
);
Mtr_PrintGroups
(
node
,
silent
);
Mtr_PrintGroups
(
node
,
silent
);
node
=
node
->
younger
;
node
=
node
->
younger
;
}
}
}
}
if
(
!
silent
)
{
if
(
!
silent
)
{
#if SIZEOF_VOID_P == 8
#if SIZEOF_VOID_P == 8
(
void
)
printf
(
"%u"
,
root
->
low
+
root
->
size
-
1
);
(
void
)
printf
(
"%u"
,
root
->
low
+
root
->
size
-
1
);
#else
#else
(
void
)
printf
(
"%hu"
,
root
->
low
+
root
->
size
-
1
);
(
void
)
printf
(
"%hu"
,
root
->
low
+
root
->
size
-
1
);
#endif
#endif
if
(
root
->
flags
!=
MTR_DEFAULT
)
{
if
(
root
->
flags
!=
MTR_DEFAULT
)
{
(
void
)
printf
(
"|"
);
(
void
)
printf
(
"|"
);
if
(
MTR_TEST
(
root
,
MTR_FIXED
))
(
void
)
printf
(
"F"
);
if
(
MTR_TEST
(
root
,
MTR_FIXED
))
(
void
)
printf
(
"F"
);
if
(
MTR_TEST
(
root
,
MTR_NEWNODE
))
(
void
)
printf
(
"N"
);
if
(
MTR_TEST
(
root
,
MTR_NEWNODE
))
(
void
)
printf
(
"N"
);
if
(
MTR_TEST
(
root
,
MTR_SOFT
))
(
void
)
printf
(
"S"
);
if
(
MTR_TEST
(
root
,
MTR_SOFT
))
(
void
)
printf
(
"S"
);
}
}
(
void
)
printf
(
")"
);
(
void
)
printf
(
")"
);
if
(
root
->
parent
==
NULL
)
(
void
)
printf
(
"
\n
"
);
if
(
root
->
parent
==
NULL
)
(
void
)
printf
(
"
\n
"
);
}
}
assert
((
root
->
flags
&~
(
MTR_TERMINAL
|
MTR_SOFT
|
MTR_FIXED
|
MTR_NEWNODE
))
==
0
);
assert
((
root
->
flags
&~
(
MTR_TERMINAL
|
MTR_SOFT
|
MTR_FIXED
|
MTR_NEWNODE
))
==
0
);
return
;
return
;
...
@@ -625,53 +625,53 @@ Mtr_ReadGroups(
...
@@ -625,53 +625,53 @@ Mtr_ReadGroups(
if
(
root
==
NULL
)
return
NULL
;
if
(
root
==
NULL
)
return
NULL
;
while
(
!
feof
(
fp
))
{
while
(
!
feof
(
fp
))
{
/* Read a triple and check for consistency. */
/* Read a triple and check for consistency. */
err
=
fscanf
(
fp
,
"%d %d %s"
,
&
low
,
&
size
,
attrib
);
err
=
fscanf
(
fp
,
"%d %d %s"
,
&
low
,
&
size
,
attrib
);
if
(
err
==
EOF
)
{
if
(
err
==
EOF
)
{
break
;
break
;
}
else
if
(
err
!=
3
)
{
}
else
if
(
err
!=
3
)
{
Mtr_FreeTree
(
root
);
Mtr_FreeTree
(
root
);
return
(
NULL
);
return
(
NULL
);
}
else
if
(
low
<
0
||
low
+
size
>
nleaves
||
size
<
1
)
{
}
else
if
(
low
<
0
||
low
+
size
>
nleaves
||
size
<
1
)
{
Mtr_FreeTree
(
root
);
Mtr_FreeTree
(
root
);
return
(
NULL
);
return
(
NULL
);
}
else
if
(
strlen
(
attrib
)
>
8
*
sizeof
(
MtrHalfWord
))
{
}
else
if
(
strlen
(
attrib
)
>
8
*
sizeof
(
MtrHalfWord
))
{
/* Not enough bits in the flags word to store these many
/* Not enough bits in the flags word to store these many
** attributes. */
** attributes. */
Mtr_FreeTree
(
root
);
Mtr_FreeTree
(
root
);
return
(
NULL
);
return
(
NULL
);
}
}
/* Parse the flag string. Currently all flags are permitted,
/* Parse the flag string. Currently all flags are permitted,
** to make debugging easier. Normally, specifying NEWNODE
** to make debugging easier. Normally, specifying NEWNODE
** wouldn't be allowed. */
** wouldn't be allowed. */
flags
=
MTR_DEFAULT
;
flags
=
MTR_DEFAULT
;
for
(
c
=
attrib
;
*
c
!=
0
;
c
++
)
{
for
(
c
=
attrib
;
*
c
!=
0
;
c
++
)
{
switch
(
*
c
)
{
switch
(
*
c
)
{
case
'D'
:
case
'D'
:
break
;
break
;
case
'F'
:
case
'F'
:
flags
|=
MTR_FIXED
;
flags
|=
MTR_FIXED
;
break
;
break
;
case
'N'
:
case
'N'
:
flags
|=
MTR_NEWNODE
;
flags
|=
MTR_NEWNODE
;
break
;
break
;
case
'S'
:
case
'S'
:
flags
|=
MTR_SOFT
;
flags
|=
MTR_SOFT
;
break
;
break
;
case
'T'
:
case
'T'
:
flags
|=
MTR_TERMINAL
;
flags
|=
MTR_TERMINAL
;
break
;
break
;
default:
default:
return
NULL
;
return
NULL
;
}
}
node
=
Mtr_MakeGroup
(
root
,
(
MtrHalfWord
)
low
,
(
MtrHalfWord
)
size
,
flags
);
if
(
node
==
NULL
)
{
Mtr_FreeTree
(
root
);
return
(
NULL
);
}
}
}
node
=
Mtr_MakeGroup
(
root
,
(
MtrHalfWord
)
low
,
(
MtrHalfWord
)
size
,
flags
);
if
(
node
==
NULL
)
{
Mtr_FreeTree
(
root
);
return
(
NULL
);
}
}
}
return
(
root
);
return
(
root
);
...
@@ -720,11 +720,11 @@ mtrShiftHL(
...
@@ -720,11 +720,11 @@ mtrShiftHL(
node
->
low
=
(
MtrHalfWord
)
low
;
node
->
low
=
(
MtrHalfWord
)
low
;
if
(
!
MTR_TEST
(
node
,
MTR_TERMINAL
)
&&
node
->
child
!=
NULL
)
{
if
(
!
MTR_TEST
(
node
,
MTR_TERMINAL
)
&&
node
->
child
!=
NULL
)
{
auxnode
=
node
->
child
;
auxnode
=
node
->
child
;
do
{
do
{
if
(
!
mtrShiftHL
(
auxnode
,
shift
))
return
(
0
);
if
(
!
mtrShiftHL
(
auxnode
,
shift
))
return
(
0
);
auxnode
=
auxnode
->
younger
;
auxnode
=
auxnode
->
younger
;
}
while
(
auxnode
!=
NULL
);
}
while
(
auxnode
!=
NULL
);
}
}
return
(
1
);
return
(
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment