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