Since squaring can often be done much faster than regular multiplication, it would be nice to be able to take advantage of this in algorithms that do a lot of squaring (e.g. fast exponentiation). But there is no standard C++ operator for squaring. This method provides a way to supply a squaring operation for the type T. The default implementation for this method is regular multiplication, of course.
Name | Type | Description |
---|---|---|
x | T | Some number. |
#include <nttl/nttlTraits.h> ... nttlTraits<int> tr; ... int x = 123; int s = tr.Square( x ); |