Simbody  3.6

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)
 
float SimTK::square (const negator< float > &x)
 
double SimTK::square (const negator< 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)
 

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

◆ square() [1/19]

unsigned char SimTK::square ( unsigned char  u)
inline

◆ square() [2/19]

unsigned short SimTK::square ( unsigned short  u)
inline

◆ square() [3/19]

unsigned int SimTK::square ( unsigned int  u)
inline

◆ square() [4/19]

unsigned long SimTK::square ( unsigned long  u)
inline

◆ square() [5/19]

unsigned long long SimTK::square ( unsigned long long  u)
inline

◆ square() [6/19]

char SimTK::square ( char  c)
inline

◆ square() [7/19]

signed char SimTK::square ( signed char  i)
inline

◆ square() [8/19]

short SimTK::square ( short  i)
inline

◆ square() [9/19]

int SimTK::square ( int  i)
inline

◆ square() [10/19]

long SimTK::square ( long  i)
inline

◆ square() [11/19]

long long SimTK::square ( long long  i)
inline

◆ square() [12/19]

float SimTK::square ( const float &  x)
inline

◆ square() [13/19]

double SimTK::square ( const double &  x)
inline

◆ square() [14/19]

float SimTK::square ( const negator< float > &  x)
inline

◆ square() [15/19]

double SimTK::square ( const negator< double > &  x)
inline

◆ square() [16/19]

template<class P >
std::complex<P> SimTK::square ( const std::complex< P > &  x)
inline

◆ square() [17/19]

template<class P >
std::complex<P> SimTK::square ( const conjugate< P > &  x)
inline

◆ square() [18/19]

template<class P >
std::complex<P> SimTK::square ( const negator< std::complex< P > > &  x)
inline

◆ square() [19/19]

template<class P >
std::complex<P> SimTK::square ( const negator< conjugate< P > > &  x)
inline