/**CFile**************************************************************** FileName [extraUtilMisc.c] SystemName [ABC: Logic synthesis and verification system.] PackageName [extra] Synopsis [Misc procedures.] Author [Alan Mishchenko] Affiliation [UC Berkeley] Date [Ver. 1.0. Started - June 20, 2005.] Revision [$Id: extraUtilMisc.c,v 1.0 2003/09/01 00:00:00 alanmi Exp $] ***********************************************************************/ #include "extra.h" /*---------------------------------------------------------------------------*/ /* Constant declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Stucture declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Type declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Variable declarations */ /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* Macro declarations */ /*---------------------------------------------------------------------------*/ /**AutomaticStart*************************************************************/ /*---------------------------------------------------------------------------*/ /* Static function prototypes */ /*---------------------------------------------------------------------------*/ /**AutomaticEnd***************************************************************/ static void Extra_Permutations_rec( char ** pRes, int nFact, int n, char Array[] ); /*---------------------------------------------------------------------------*/ /* Definition of exported functions */ /*---------------------------------------------------------------------------*/ /**Function******************************************************************** Synopsis [Finds the smallest integer larger of equal than the logarithm.] Description [Returns [Log2(Num)].] SideEffects [] SeeAlso [] ******************************************************************************/ int Extra_Base2Log( unsigned Num ) { int Res; assert( Num >= 0 ); if ( Num == 0 ) return 0; if ( Num == 1 ) return 1; for ( Res = 0, Num--; Num; Num >>= 1, Res++ ); return Res; } /* end of Extra_Base2Log */ /**Function******************************************************************** Synopsis [Finds the smallest integer larger of equal than the logarithm.] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Extra_Base2LogDouble( double Num ) { double Res; int ResInt; Res = log(Num)/log(2.0); ResInt = (int)Res; if ( ResInt == Res ) return ResInt; else return ResInt+1; } /**Function******************************************************************** Synopsis [Finds the smallest integer larger of equal than the logarithm.] Description [Returns [Log10(Num)].] SideEffects [] SeeAlso [] ******************************************************************************/ int Extra_Base10Log( unsigned Num ) { int Res; assert( Num >= 0 ); if ( Num == 0 ) return 0; if ( Num == 1 ) return 1; for ( Res = 0, Num--; Num; Num /= 10, Res++ ); return Res; } /* end of Extra_Base2Log */ /**Function******************************************************************** Synopsis [Returns the power of two as a double.] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ double Extra_Power2( int Degree ) { double Res; assert( Degree >= 0 ); if ( Degree < 32 ) return (double)(01<