// ============================================================ // // nttlTraits.h // // Copyright 2002, Dennis Meilicke and Rene Peralta // // ============================================================ // // Description: // // Optimization overrides for NTTL. // // ============================================================ #ifndef __lnv3_nttlTraits__ #define __lnv3_nttlTraits__ #include #include inline ln nttlTraits::Power( ln X, ln e, const ln &m ) { return X.FastExp( e, m ); } inline ln nttlTraits::Random( size_t size ) { ln x; return x.Random( size ); } inline short nttlTraits::Mod8( const ln& x ) { if( x.IsZero( ) ) return 0; return ( x.GetDigit( 0 ) & 7 ); } inline short nttlTraits::Mod4( const ln& x ) { if( x.IsZero( ) ) return 0; return ( x.GetDigit( 0 ) & 3 ); } inline bool nttlTraits::IsOdd( const ln &x ) { return x.IsOdd( ); } inline bool nttlTraits::IsEven( const ln &x ) { return x.IsEven( ); } inline ln nttlTraits::Abs( const ln &X ) { return X.Abs( ); } inline short nttlTraits::ToShort( const ln& X ) { short x; x = X.GetDigit( 0 ) & 0xefff; if( X < 0 ) x = -x; return x; } inline long nttlTraits::ToLong( const ln& X ) { long x; x = X.GetDigit( 0 ); if( X < 0 ) x = -x; return x; } inline unsigned short nttlTraits::ToUnsignedShort( const ln& X ) { unsigned short x; x = X.GetDigit( 0 ) & 0xffff; return x; } inline unsigned long nttlTraits::ToUnsignedLong( const ln& X ) { unsigned long x; x = X.GetDigit( 0 ); return x; } #include #endif