There are three numeric classes: real, complex, conjugate and each comes in float, double, and long double precision. Each of these may be modified by a negator, which does not change the in-memory *representation* but negates the *interpretation*. Thus there are 18 distinct scalar types: 3 precisions each of real, complex, and conjugate and their negators.
The Scalar Types ---------------- Here is a complete taxonomy of the scalar types we support.
<scalar> ::= <number> | negator< <number> > <number> ::= <standard> | <conjugate> <standard> ::= <real> | <complex>
<real> ::= float | double | long double <complex> ::= complex< <real> > <conjugate> ::= conjugate< <real> >
#include <cstddef>
#include <cassert>
#include <complex>
#include <iostream>
#include <limits>
Go to the source code of this file.
#define SimTK_BNTCMPLX_SPEC | ( | T1, | |||
T2 | ) |
Value:
template<> template<> struct NTraits< complex<T1> >::Result<T2> { \ typedef Widest< complex<T1>,T2 >::Type W; \ typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \ }; \ template<> template<> struct NTraits< complex<T1> >::Result< complex<T2> > { \ typedef Widest< complex<T1>,complex<T2> >::Type W; \ typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \ }; \ template<> template<> struct NTraits< complex<T1> >::Result< conjugate<T2> > { \ typedef Widest< complex<T1>,complex<T2> >::Type W; \ typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \ }
#define SimTK_DEFINE_REAL_NTRAITS | ( | R | ) |
#define SimTK_NTRAITS_CONJ_SPEC | ( | T1, | |||
T2 | ) |
Value:
template<> template<> struct NTraits< conjugate<T1> >::Result<T2> { \ typedef conjugate<Widest<T1,T2>::Type> W; \ typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \ }; \ template<> template<> struct NTraits< conjugate<T1> >::Result<complex<T2> >{\ typedef Widest<complex<T1>,complex<T2> >::Type W; \ typedef W Mul; typedef W Dvd; typedef W Add; typedef negator<W> Sub; \ }; \ template<> template<> struct NTraits< conjugate<T1> >::Result<conjugate<T2> >{\ typedef Widest<T1,T2>::Type W; typedef complex<W> WC; \ typedef negator<WC> Mul; typedef WC Dvd; typedef conjugate<W> Add; typedef WC Sub;\ }