y=square(x) returns the square of the argument for any numeric type.
More...
Functions |
unsigned char | square (unsigned char u) |
unsigned short | square (unsigned short u) |
unsigned int | square (unsigned int u) |
unsigned long | square (unsigned long u) |
char | square (char c) |
signed char | square (signed char i) |
short | square (short i) |
int | square (int i) |
long | square (long i) |
float | square (const float &x) |
double | square (const double &x) |
long double | square (const long double &x) |
float | square (const negator< float > &x) |
double | square (const negator< double > &x) |
long double | square (const negator< long double > &x) |
template<class P > |
std::complex< P > | square (const std::complex< P > &x) |
template<class P > |
std::complex< P > | square (const conjugate< P > &x) |
template<class P > |
std::complex< P > | square (const negator< std::complex< P > > &x) |
template<class P > |
std::complex< P > | square (const negator< conjugate< P > > &x) |
Detailed Description
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.
Function Documentation
std::complex<P> SimTK::square |
( |
const negator< conjugate< P > > & |
x |
) |
[inline] |
std::complex<P> SimTK::square |
( |
const negator< std::complex< P > > & |
x |
) |
[inline] |
std::complex<P> SimTK::square |
( |
const conjugate< P > & |
x |
) |
[inline] |
std::complex<P> SimTK::square |
( |
const std::complex< P > & |
x |
) |
[inline] |
long double SimTK::square |
( |
const negator< long double > & |
x |
) |
[inline] |
double SimTK::square |
( |
const negator< double > & |
x |
) |
[inline] |
float SimTK::square |
( |
const negator< float > & |
x |
) |
[inline] |
long double SimTK::square |
( |
const long double & |
x |
) |
[inline] |
double SimTK::square |
( |
const double & |
x |
) |
[inline] |
float SimTK::square |
( |
const float & |
x |
) |
[inline] |
long SimTK::square |
( |
long |
i |
) |
[inline] |
int SimTK::square |
( |
int |
i |
) |
[inline] |
short SimTK::square |
( |
short |
i |
) |
[inline] |
signed char SimTK::square |
( |
signed char |
i |
) |
[inline] |
char SimTK::square |
( |
char |
c |
) |
[inline] |
unsigned long SimTK::square |
( |
unsigned long |
u |
) |
[inline] |
unsigned int SimTK::square |
( |
unsigned int |
u |
) |
[inline] |
unsigned short SimTK::square |
( |
unsigned short |
u |
) |
[inline] |
unsigned char SimTK::square |
( |
unsigned char |
u |
) |
[inline] |