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.
◆ square() [1/21]
unsigned char SimTK::square |
( |
unsigned char |
u | ) |
|
|
inline |
◆ square() [2/21]
unsigned short SimTK::square |
( |
unsigned short |
u | ) |
|
|
inline |
◆ square() [3/21]
unsigned int SimTK::square |
( |
unsigned int |
u | ) |
|
|
inline |
◆ square() [4/21]
unsigned long SimTK::square |
( |
unsigned long |
u | ) |
|
|
inline |
◆ square() [5/21]
unsigned long long SimTK::square |
( |
unsigned long long |
u | ) |
|
|
inline |
◆ square() [6/21]
char SimTK::square |
( |
char |
c | ) |
|
|
inline |
◆ square() [7/21]
signed char SimTK::square |
( |
signed char |
i | ) |
|
|
inline |
◆ square() [8/21]
short SimTK::square |
( |
short |
i | ) |
|
|
inline |
◆ square() [9/21]
int SimTK::square |
( |
int |
i | ) |
|
|
inline |
◆ square() [10/21]
long SimTK::square |
( |
long |
i | ) |
|
|
inline |
◆ square() [11/21]
long long SimTK::square |
( |
long long |
i | ) |
|
|
inline |
◆ square() [12/21]
float SimTK::square |
( |
const float & |
x | ) |
|
|
inline |
◆ square() [13/21]
double SimTK::square |
( |
const double & |
x | ) |
|
|
inline |
◆ square() [14/21]
long double SimTK::square |
( |
const long double & |
x | ) |
|
|
inline |
◆ square() [15/21]
float SimTK::square |
( |
const negator< float > & |
x | ) |
|
|
inline |
◆ square() [16/21]
double SimTK::square |
( |
const negator< double > & |
x | ) |
|
|
inline |
◆ square() [17/21]
long double SimTK::square |
( |
const negator< long double > & |
x | ) |
|
|
inline |
◆ square() [18/21]
template<class P >
std::complex<P> SimTK::square |
( |
const std::complex< P > & |
x | ) |
|
|
inline |
◆ square() [19/21]
template<class P >
std::complex<P> SimTK::square |
( |
const conjugate< P > & |
x | ) |
|
|
inline |
◆ square() [20/21]
template<class P >
std::complex<P> SimTK::square |
( |
const negator< std::complex< P > > & |
x | ) |
|
|
inline |
◆ square() [21/21]