// ============================================================ // // traits.h // // Copyright 2002, Dennis Meilicke and Rene Peralta // // ============================================================ // // Description: // // This includes the two traits class headers. For more // information, see the comments below, and in the other two // headers. // // ============================================================ #ifndef __nttl_traits__ #define __nttl_traits__ // =========================================================== // // Traits class // // OK. I'm not sure if this is a really good name or not. // I've modeled this after the traits classes in the STL, so // I also naturally borrowed the name. // // I the case of nttl, the traits class serves two functions. // First, it should provide some information about the // specialized type. In the case of scalars, this might // include things like the size in bits. A second function // is to contain some common methods that are used by the // nttl algorithms. // // Why put methods in the traits class? Again two reasons. // First, we need to abstract some functions (like Square) // which may simply not exist for a particular type (Square // does not exist for longs). Second, there are some // functions (mod 8) which can be done faster if we know the // underlying structure of the type. A large integer type // would do an '& 7' with the least significant digit, rather // than an expensive division operation. // // =========================================================== // // The methods of the default traits class are intended to be // sufficient for PODs (int, long, etc), but may not be very // good for a proper class. // // The Power method is not as efficient as it could be; the // left to right algorithm is more efficient. Still, for a // POD, you probably won't notice the difference. // // =========================================================== #include #include #endif // __nttl_traits__