Simbody
3.3
|
This file defines the conjugate<R> template class, where R is one of the three built-in real types. More...
#include <complex>
#include <iostream>
#include <limits>
Go to the source code of this file.
Classes | |
class | SimTK::conjugate< R > |
SimTK::conjugate<R> should be instantiated only for float, double, long double. More... | |
class | SimTK::negator< N > |
negator<N>, where N is a number type (real, complex, conjugate), is represented in memory identically to N, but behaves as though multiplied by -1, though at zero cost. More... | |
struct | SimTK::Wider< R1, R2 > |
struct | SimTK::Wider< float, float > |
struct | SimTK::Wider< float, double > |
struct | SimTK::Wider< double, float > |
struct | SimTK::Wider< double, double > |
struct | SimTK::Wider< float, long double > |
struct | SimTK::Wider< double, long double > |
struct | SimTK::Wider< long double, float > |
struct | SimTK::Wider< long double, double > |
struct | SimTK::Wider< long double, long double > |
class | SimTK::conjugate< R > |
SimTK::conjugate<R> should be instantiated only for float, double, long double. More... | |
class | SimTK::conjugate< float > |
class | SimTK::conjugate< double > |
class | SimTK::conjugate< long double > |
Namespaces | |
SimTK | |
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with other symbols. | |
Functions | |
complex< float > | SimTK::operator* (const complex< float > &c, int r) |
complex< float > | SimTK::operator* (int r, const complex< float > &c) |
complex< double > | SimTK::operator* (const complex< float > &c, const double &r) |
complex< double > | SimTK::operator* (const double &r, const complex< float > &c) |
complex< long double > | SimTK::operator* (const complex< float > &c, const long double &r) |
complex< long double > | SimTK::operator* (const long double &r, const complex< float > &c) |
complex< float > | SimTK::operator/ (const complex< float > &c, int r) |
complex< float > | SimTK::operator/ (int r, const complex< float > &c) |
complex< double > | SimTK::operator/ (const complex< float > &c, const double &r) |
complex< double > | SimTK::operator/ (const double &r, const complex< float > &c) |
complex< long double > | SimTK::operator/ (const complex< float > &c, const long double &r) |
complex< long double > | SimTK::operator/ (const long double &r, const complex< float > &c) |
complex< float > | SimTK::operator+ (const complex< float > &c, int r) |
complex< float > | SimTK::operator+ (int r, const complex< float > &c) |
complex< double > | SimTK::operator+ (const complex< float > &c, const double &r) |
complex< double > | SimTK::operator+ (const double &r, const complex< float > &c) |
complex< long double > | SimTK::operator+ (const complex< float > &c, const long double &r) |
complex< long double > | SimTK::operator+ (const long double &r, const complex< float > &c) |
complex< float > | SimTK::operator- (const complex< float > &c, int r) |
complex< float > | SimTK::operator- (int r, const complex< float > &c) |
complex< double > | SimTK::operator- (const complex< float > &c, const double &r) |
complex< double > | SimTK::operator- (const double &r, const complex< float > &c) |
complex< long double > | SimTK::operator- (const complex< float > &c, const long double &r) |
complex< long double > | SimTK::operator- (const long double &r, const complex< float > &c) |
complex< double > | SimTK::operator* (const complex< double > &c, int r) |
complex< double > | SimTK::operator* (int r, const complex< double > &c) |
complex< double > | SimTK::operator* (const complex< double > &c, const float &r) |
complex< double > | SimTK::operator* (const float &r, const complex< double > &c) |
complex< long double > | SimTK::operator* (const complex< double > &c, const long double &r) |
complex< long double > | SimTK::operator* (const long double &r, const complex< double > &c) |
complex< double > | SimTK::operator/ (const complex< double > &c, int r) |
complex< double > | SimTK::operator/ (int r, const complex< double > &c) |
complex< double > | SimTK::operator/ (const complex< double > &c, const float &r) |
complex< double > | SimTK::operator/ (const float &r, const complex< double > &c) |
complex< long double > | SimTK::operator/ (const complex< double > &c, const long double &r) |
complex< long double > | SimTK::operator/ (const long double &r, const complex< double > &c) |
complex< double > | SimTK::operator+ (const complex< double > &c, int r) |
complex< double > | SimTK::operator+ (int r, const complex< double > &c) |
complex< double > | SimTK::operator+ (const complex< double > &c, const float &r) |
complex< double > | SimTK::operator+ (const float &r, const complex< double > &c) |
complex< long double > | SimTK::operator+ (const complex< double > &c, const long double &r) |
complex< long double > | SimTK::operator+ (const long double &r, const complex< double > &c) |
complex< double > | SimTK::operator- (const complex< double > &c, int r) |
complex< double > | SimTK::operator- (int r, const complex< double > &c) |
complex< double > | SimTK::operator- (const complex< double > &c, const float &r) |
complex< double > | SimTK::operator- (const float &r, const complex< double > &c) |
complex< long double > | SimTK::operator- (const complex< double > &c, const long double &r) |
complex< long double > | SimTK::operator- (const long double &r, const complex< double > &c) |
complex< long double > | SimTK::operator* (const complex< long double > &c, int r) |
complex< long double > | SimTK::operator* (int r, const complex< long double > &c) |
complex< long double > | SimTK::operator* (const complex< long double > &c, const float &r) |
complex< long double > | SimTK::operator* (const float &r, const complex< long double > &c) |
complex< long double > | SimTK::operator* (const complex< long double > &c, const double &r) |
complex< long double > | SimTK::operator* (const double &r, const complex< long double > &c) |
complex< long double > | SimTK::operator/ (const complex< long double > &c, int r) |
complex< long double > | SimTK::operator/ (int r, const complex< long double > &c) |
complex< long double > | SimTK::operator/ (const complex< long double > &c, const float &r) |
complex< long double > | SimTK::operator/ (const float &r, const complex< long double > &c) |
complex< long double > | SimTK::operator/ (const complex< long double > &c, const double &r) |
complex< long double > | SimTK::operator/ (const double &r, const complex< long double > &c) |
complex< long double > | SimTK::operator+ (const complex< long double > &c, int r) |
complex< long double > | SimTK::operator+ (int r, const complex< long double > &c) |
complex< long double > | SimTK::operator+ (const complex< long double > &c, const float &r) |
complex< long double > | SimTK::operator+ (const float &r, const complex< long double > &c) |
complex< long double > | SimTK::operator+ (const complex< long double > &c, const double &r) |
complex< long double > | SimTK::operator+ (const double &r, const complex< long double > &c) |
complex< long double > | SimTK::operator- (const complex< long double > &c, int r) |
complex< long double > | SimTK::operator- (int r, const complex< long double > &c) |
complex< long double > | SimTK::operator- (const complex< long double > &c, const float &r) |
complex< long double > | SimTK::operator- (const float &r, const complex< long double > &c) |
complex< long double > | SimTK::operator- (const complex< long double > &c, const double &r) |
complex< long double > | SimTK::operator- (const double &r, const complex< long double > &c) |
const float & | SimTK::real (const conjugate< float > &c) |
const negator< float > & | SimTK::imag (const conjugate< float > &c) |
const complex< float > & | SimTK::conj (const conjugate< float > &c) |
float | SimTK::abs (const conjugate< float > &c) |
float | SimTK::norm (const conjugate< float > &c) |
const double & | SimTK::real (const conjugate< double > &c) |
const negator< double > & | SimTK::imag (const conjugate< double > &c) |
const complex< double > & | SimTK::conj (const conjugate< double > &c) |
double | SimTK::abs (const conjugate< double > &c) |
double | SimTK::norm (const conjugate< double > &c) |
const long double & | SimTK::real (const conjugate< long double > &c) |
const negator< long double > & | SimTK::imag (const conjugate< long double > &c) |
const complex< long double > & | SimTK::conj (const conjugate< long double > &c) |
long double | SimTK::abs (const conjugate< long double > &c) |
long double | SimTK::norm (const conjugate< long double > &c) |
template<class R , class CHAR , class TRAITS > | |
std::basic_istream< CHAR, TRAITS > & | SimTK::operator>> (std::basic_istream< CHAR, TRAITS > &is, conjugate< R > &c) |
template<class R , class CHAR , class TRAITS > | |
std::basic_ostream< CHAR, TRAITS > & | SimTK::operator<< (std::basic_ostream< CHAR, TRAITS > &os, const conjugate< R > &c) |
template<class R > | |
conjugate< R > | SimTK::operator+ (const conjugate< R > &a, const float &b) |
template<class R > | |
conjugate< long double > | SimTK::operator+ (const conjugate< R > &a, const long double &b) |
template<class R > | |
Wider< R, double >::WConj | SimTK::operator+ (const conjugate< R > &a, const double &b) |
template<class R > | |
conjugate< R > | SimTK::operator+ (const float &a, const conjugate< R > &b) |
template<class R > | |
conjugate< long double > | SimTK::operator+ (const long double &a, const conjugate< R > &b) |
template<class R > | |
Wider< R, double >::WConj | SimTK::operator+ (const double &a, const conjugate< R > &b) |
template<class R > | |
conjugate< R > | SimTK::operator* (const conjugate< R > &a, const float &b) |
template<class R > | |
conjugate< long double > | SimTK::operator* (const conjugate< R > &a, const long double &b) |
template<class R > | |
Wider< R, double >::WConj | SimTK::operator* (const conjugate< R > &a, const double &b) |
template<class R > | |
conjugate< R > | SimTK::operator* (const float &a, const conjugate< R > &b) |
template<class R > | |
conjugate< long double > | SimTK::operator* (const long double &a, const conjugate< R > &b) |
template<class R > | |
Wider< R, double >::WConj | SimTK::operator* (const double &a, const conjugate< R > &b) |
template<class R > | |
bool | SimTK::operator== (const conjugate< R > &a, const float &b) |
template<class R > | |
bool | SimTK::operator== (const conjugate< R > &a, const long double &b) |
template<class R > | |
bool | SimTK::operator== (const conjugate< R > &a, const double &b) |
template<class R > | |
bool | SimTK::operator== (const float &a, const conjugate< R > &b) |
template<class R > | |
bool | SimTK::operator== (const long double &a, const conjugate< R > &b) |
template<class R > | |
bool | SimTK::operator== (const double &a, const conjugate< R > &b) |
template<class R > | |
bool | SimTK::operator!= (const conjugate< R > &a, const float &b) |
template<class R > | |
bool | SimTK::operator!= (const conjugate< R > &a, const long double &b) |
template<class R > | |
bool | SimTK::operator!= (const conjugate< R > &a, const double &b) |
template<class R > | |
bool | SimTK::operator!= (const float &a, const conjugate< R > &b) |
template<class R > | |
bool | SimTK::operator!= (const long double &a, const conjugate< R > &b) |
template<class R > | |
bool | SimTK::operator!= (const double &a, const conjugate< R > &b) |
template<class R > | |
conjugate< R > | SimTK::operator- (const conjugate< R > &a, const float &b) |
template<class R > | |
conjugate< long double > | SimTK::operator- (const conjugate< R > &a, const long double &b) |
template<class R > | |
Wider< R, double >::WConj | SimTK::operator- (const conjugate< R > &a, const double &b) |
template<class R > | |
complex< R > | SimTK::operator- (const float &a, const conjugate< R > &b) |
template<class R > | |
complex< long double > | SimTK::operator- (const long double &a, const conjugate< R > &b) |
template<class R > | |
Wider< R, double >::WCplx | SimTK::operator- (const double &a, const conjugate< R > &b) |
template<class R > | |
conjugate< R > | SimTK::operator/ (const conjugate< R > &a, const float &b) |
template<class R > | |
conjugate< long double > | SimTK::operator/ (const conjugate< R > &a, const long double &b) |
template<class R > | |
Wider< R, double >::WConj | SimTK::operator/ (const conjugate< R > &a, const double &b) |
template<class R > | |
complex< R > | SimTK::operator/ (const float &a, const conjugate< R > &b) |
template<class R > | |
complex< long double > | SimTK::operator/ (const long double &a, const conjugate< R > &b) |
template<class R > | |
Wider< R, double >::WCplx | SimTK::operator/ (const double &a, const conjugate< R > &b) |
template<class R , class S > | |
Wider< R, S >::WConj | SimTK::operator+ (const conjugate< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator+ (const conjugate< R > &a, const complex< S > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator+ (const complex< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator- (const conjugate< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
negator< typename Wider< R, S > ::WCplx > | SimTK::operator- (const conjugate< R > &a, const complex< S > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator- (const complex< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
negator< typename Wider< R, S > ::WCplx > | SimTK::operator* (const conjugate< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator* (const conjugate< R > &a, const complex< S > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator* (const complex< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator* (const negator< complex< R > > &a, const conjugate< S > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator* (const conjugate< R > &a, const negator< complex< S > > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator/ (const conjugate< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator/ (const conjugate< R > &a, const complex< S > &r) |
template<class R , class S > | |
Wider< R, S >::WCplx | SimTK::operator/ (const complex< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
bool | SimTK::operator== (const conjugate< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
bool | SimTK::operator== (const conjugate< R > &a, const complex< S > &r) |
template<class R , class S > | |
bool | SimTK::operator== (const complex< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
bool | SimTK::operator!= (const conjugate< R > &a, const conjugate< S > &r) |
template<class R , class S > | |
bool | SimTK::operator!= (const conjugate< R > &a, const complex< S > &r) |
template<class R , class S > | |
bool | SimTK::operator!= (const complex< R > &a, const conjugate< S > &r) |
This file defines the conjugate<R> template class, where R is one of the three built-in real types.
It is exactly like the C++ complex<R> template except that the represented value is the conjugate of the value represented by a complex number containing the same bit pattern. That is, complex and conjugate both contain two real numbers, re and im, with complex(re,im) meaning (re + im*i) while conjugate(re,im) means (re - im*i). It is guaranteed that our conjugate type has the identical size and representation as complex. Together, these definitions and guarantee permit conjugation to be done by reinterpretation (i.e. type casting) rather than by computation.
A caution on implementation of complex numbers: it's not as simple as you might think. A mildly nasty issue is handling mixed precision arguments. More substantial is getting the right complex answer using real arithmetic. For example, if c=a+bi then even a seemingly simple calculation like |c|=sqrt(a*a+b*b) may fail if calculated that way, due to unnecessary overflow. Take a look at a good complex<> implementation or see Press, et al., Numerical Recipes in C++, 2nd ed., 2003, section 5.4, pp 183-4 for a discussion. Consequently, wherever it doesn't matter for performance, conjugate<R> objects are simply converted to complex<R> (which costs one negation) and then the system class is used to do the hard stuff.
References for the complex<> class, which I used as a model for SimTK::conjugate<>: (1) Stroustrup, B., The C++ Programming Language, 3rd ed., 1997, section 22.5, pg 679ff. (2) The C++ Standard Incorporating Technical Corrigendum 1, British Standards Institute ISO/IEC 14882:2003 2nd ed., 2003, section 26.2, pg 592ff.