diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2015-03-23 18:40:38 +0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2015-03-23 18:40:38 +0700 |
commit | efdd26f86d3dbbde1626fe6a84304bc700b97479 (patch) | |
tree | da4ebd027e5e8de8a03a4a0cb15fa72a31d2ca74 /src/misc | |
parent | 5f77e7ae8fb6ed29812aa67514109d961a61c112 (diff) | |
download | abc-efdd26f86d3dbbde1626fe6a84304bc700b97479.tar.gz abc-efdd26f86d3dbbde1626fe6a84304bc700b97479.tar.bz2 abc-efdd26f86d3dbbde1626fe6a84304bc700b97479.zip |
Scalable SOP manipulation package.
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/vec/vecBit.h | 2 | ||||
-rw-r--r-- | src/misc/vec/vecFlt.h | 12 | ||||
-rw-r--r-- | src/misc/vec/vecInt.h | 47 | ||||
-rw-r--r-- | src/misc/vec/vecWrd.h | 19 |
4 files changed, 79 insertions, 1 deletions
diff --git a/src/misc/vec/vecBit.h b/src/misc/vec/vecBit.h index cb89e982..543a1258 100644 --- a/src/misc/vec/vecBit.h +++ b/src/misc/vec/vecBit.h @@ -124,7 +124,7 @@ static inline Vec_Bit_t * Vec_BitStartFull( int nSize ) { Vec_Bit_t * p; nSize = (nSize >> 5) + ((nSize & 31) > 0); - p = Vec_BitAlloc( nSize ); + p = Vec_BitAlloc( nSize * 32 ); p->nSize = nSize * 32; memset( p->pArray, 0xff, sizeof(int) * nSize ); return p; diff --git a/src/misc/vec/vecFlt.h b/src/misc/vec/vecFlt.h index 482973f7..9988deae 100644 --- a/src/misc/vec/vecFlt.h +++ b/src/misc/vec/vecFlt.h @@ -225,6 +225,18 @@ static inline Vec_Flt_t * Vec_FltDupArray( Vec_Flt_t * pVec ) SeeAlso [] ***********************************************************************/ +static inline void Vec_FltZero( Vec_Flt_t * p ) +{ + p->pArray = NULL; + p->nSize = 0; + p->nCap = 0; +} +static inline void Vec_FltErase( Vec_Flt_t * p ) +{ + ABC_FREE( p->pArray ); + p->nSize = 0; + p->nCap = 0; +} static inline void Vec_FltFree( Vec_Flt_t * p ) { ABC_FREE( p->pArray ); diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index 6d3ea8f6..e18b4616 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -1338,6 +1338,16 @@ static inline void Vec_IntSort( Vec_Int_t * p, int fReverse ) qsort( (void *)p->pArray, p->nSize, sizeof(int), (int (*)(const void *, const void *)) Vec_IntSortCompare1 ); } +static inline void Vec_IntSortPairs( Vec_Int_t * p, int fReverse ) +{ + assert( Vec_IntSize(p) % 2 == 0 ); + if ( fReverse ) + qsort( (void *)p->pArray, p->nSize/2, 2*sizeof(int), + (int (*)(const void *, const void *)) Vec_IntSortCompare2 ); + else + qsort( (void *)p->pArray, p->nSize/2, 2*sizeof(int), + (int (*)(const void *, const void *)) Vec_IntSortCompare1 ); +} /**Function************************************************************* @@ -1394,6 +1404,36 @@ static inline int Vec_IntCountUnique( Vec_Int_t * p ) /**Function************************************************************* + Synopsis [Counts the number of unique pairs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_IntUniqifyPairs( Vec_Int_t * p ) +{ + int i, k, RetValue; + assert( p->nSize % 2 == 0 ); + if ( p->nSize < 4 ) + return 0; + Vec_IntSortPairs( p, 0 ); + for ( i = k = 1; i < p->nSize/2; i++ ) + if ( p->pArray[2*i] != p->pArray[2*(i-1)] || p->pArray[2*i+1] != p->pArray[2*(i-1)+1] ) + { + p->pArray[2*k] = p->pArray[2*i]; + p->pArray[2*k+1] = p->pArray[2*i+1]; + k++; + } + RetValue = p->nSize/2 - k; + p->nSize = 2*k; + return RetValue; +} + +/**Function************************************************************* + Synopsis [Counts the number of unique entries.] Description [] @@ -1891,6 +1931,13 @@ static inline void Vec_IntAppend( Vec_Int_t * vVec1, Vec_Int_t * vVec2 ) Vec_IntForEachEntry( vVec2, Entry, i ) Vec_IntPush( vVec1, Entry ); } +static inline void Vec_IntAppendSkip( Vec_Int_t * vVec1, Vec_Int_t * vVec2, int iVar ) +{ + int Entry, i; + Vec_IntForEachEntry( vVec2, Entry, i ) + if ( i != iVar ) + Vec_IntPush( vVec1, Entry ); +} ABC_NAMESPACE_HEADER_END diff --git a/src/misc/vec/vecWrd.h b/src/misc/vec/vecWrd.h index 5227fec5..d286baf3 100644 --- a/src/misc/vec/vecWrd.h +++ b/src/misc/vec/vecWrd.h @@ -961,6 +961,25 @@ static inline word Vec_WrdSum( Vec_Wrd_t * p ) /**Function************************************************************* + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_WrdCountZero( Vec_Wrd_t * p ) +{ + int i, Counter = 0; + for ( i = 0; i < p->nSize; i++ ) + Counter += (p->pArray[i] == 0); + return Counter; +} + +/**Function************************************************************* + Synopsis [Checks if two vectors are equal.] Description [] |