y=square(x) returns the square of the argument for any numeric type.
More...
y=square(x) returns the square of the argument for any numeric type.
We promise to evaluate x only once. We assume is is acceptable for the result type to be the same as the argument type; if it won't fit caller must cast argument to a wider type first. This is an inline routine which will run as fast as an explicit multiply (x*x) in optimized code, and somewhat faster for complex and conjugate types (5 flops instead of the usual 6).
Squaring a negated number loses the negator at no cost; squaring a conjugate number returns a complex result at no additional cost.
unsigned char SimTK::square |
( |
unsigned char |
u | ) |
|
|
inline |
unsigned short SimTK::square |
( |
unsigned short |
u | ) |
|
|
inline |
unsigned int SimTK::square |
( |
unsigned int |
u | ) |
|
|
inline |
unsigned long SimTK::square |
( |
unsigned long |
u | ) |
|
|
inline |
unsigned long long SimTK::square |
( |
unsigned long long |
u | ) |
|
|
inline |
char SimTK::square |
( |
char |
c | ) |
|
|
inline |
signed char SimTK::square |
( |
signed char |
i | ) |
|
|
inline |
short SimTK::square |
( |
short |
i | ) |
|
|
inline |
int SimTK::square |
( |
int |
i | ) |
|
|
inline |
long SimTK::square |
( |
long |
i | ) |
|
|
inline |
long long SimTK::square |
( |
long long |
i | ) |
|
|
inline |
float SimTK::square |
( |
const float & |
x | ) |
|
|
inline |
double SimTK::square |
( |
const double & |
x | ) |
|
|
inline |
long double SimTK::square |
( |
const long double & |
x | ) |
|
|
inline |
float SimTK::square |
( |
const negator< float > & |
x | ) |
|
|
inline |
double SimTK::square |
( |
const negator< double > & |
x | ) |
|
|
inline |
long double SimTK::square |
( |
const negator< long double > & |
x | ) |
|
|
inline |
template<class P >
std::complex<P> SimTK::square |
( |
const std::complex< P > & |
x | ) |
|
|
inline |
template<class P >
std::complex<P> SimTK::square |
( |
const conjugate< P > & |
x | ) |
|
|
inline |
template<class P >
std::complex<P> SimTK::square |
( |
const negator< std::complex< P > > & |
x | ) |
|
|
inline |
template<class P >
std::complex<P> SimTK::square |
( |
const negator< conjugate< P > > & |
x | ) |
|
|
inline |