1 #ifndef SimTK_SIMMATRIX_NTRAITS_H_
2 #define SimTK_SIMMATRIX_NTRAITS_H_
71 template <
class R>
class conjugate;
76 template <
class T>
class CNT;
79 template <
class N>
class NTraits;
80 template <
class R>
class NTraits< complex<R> >;
81 template <
class R>
class NTraits< conjugate<R> >;
82 template <>
class NTraits<float>;
83 template <>
class NTraits<double>;
84 template <>
class NTraits<long double>;
94 template <
class N>
class negator;
103 template <
class R1,
class R2>
struct Widest {};
112 template <>
struct Widest<long double,long double> {
typedef long double Type;
typedef long double Precision;};
113 template <
class R1,
class R2>
struct Widest< complex<R1>,complex<R2> > {
114 typedef complex< typename Widest<R1,R2>::Type >
Type;
117 template <
class R1,
class R2>
struct Widest< complex<R1>,R2 > {
118 typedef complex< typename Widest<R1,R2>::Type >
Type;
121 template <
class R1,
class R2>
struct Widest< R1,complex<R2> > {
122 typedef complex< typename Widest<R1,R2>::Type >
Type;
145 template <
class R1,
class R2>
struct Narrowest< complex<R1>,complex<R2> > {
146 typedef complex< typename Narrowest<R1,R2>::Type >
Type;
149 template <
class R1,
class R2>
struct Narrowest< complex<R1>,R2 > {
150 typedef complex< typename Narrowest<R1,R2>::Type >
Type;
153 template <
class R1,
class R2>
struct Narrowest< R1,complex<R2> > {
154 typedef complex< typename Narrowest<R1,R2>::Type >
Type;
163 static const float&
getEps() {
static const float c=std::numeric_limits<float>::epsilon();
return c;}
165 static const float&
getSignificant() {
static const float c=std::pow(getEps(), 0.875f);
return c;}
171 static const double&
getEps() {
static const double c=std::numeric_limits<double>::epsilon();
return c;}
172 static const double&
getSignificant() {
static const double c=std::pow(getEps(), 0.875);
return c;}
177 static const long double&
getEps() {
static const long double c=std::numeric_limits<long double>::epsilon();
return c;}
178 static const long double&
getSignificant() {
static const long double c=std::pow(getEps(), 0.875L);
return c;}
200 inline bool isNaN(
const float& x) {
return std::isnan(x);}
201 inline bool isNaN(
const double& x) {
return std::isnan(x);}
202 inline bool isNaN(
const long double& x) {
return std::isnan(x);}
204 template <
class P>
inline bool
208 template <
class P>
inline bool
210 {
return isNaN(x.real()) ||
isNaN(x.negImag());}
227 inline bool isFinite(
const float& x) {
return std::isfinite(x);}
228 inline bool isFinite(
const double& x) {
return std::isfinite(x);}
229 inline bool isFinite(
const long double& x) {
return std::isfinite(x);}
231 template <
class P>
inline bool
235 template <
class P>
inline bool
256 inline bool isInf(
const float& x) {
return std::isinf(x);}
257 inline bool isInf(
const double& x) {
return std::isinf(x);}
258 inline bool isInf(
const long double& x) {
return std::isinf(x);}
260 template <
class P>
inline bool
266 template <
class P>
inline bool
268 return (
isInf(x.real()) && !
isNaN(x.negImag()))
317 return std::abs(a-b) <= scale*(float)tol; }
323 return std::abs(a-b) <= scale*tol; }
329 return std::abs(a-b) <= scale*(
long double)tol; }
384 template <
class P,
class Q>
386 (
const std::complex<P>& a,
const std::complex<Q>& b,
394 template <
class P,
class Q>
404 template <
class P,
class Q>
414 template <
class P,
class Q>
422 template <
class P>
inline bool
427 template <
class P>
inline bool
432 template <
class P>
inline bool
437 template <
class P>
inline bool
442 template <
class P>
inline bool
447 template <
class P>
inline bool
452 template <
class P>
inline bool
457 template <
class P>
inline bool
463 template <
class P>
inline bool
468 template <
class P>
inline bool
473 template <
class P>
inline bool
478 template <
class P>
inline bool
483 template <
class P>
inline bool
488 template <
class P>
inline bool
493 template <
class P>
inline bool
498 template <
class P>
inline bool
506 template <
class N>
class NTraits {
512 template <
class R>
class NTraits< complex<R> > {
513 typedef complex<R> C;
549 template <
class P>
struct Result {
557 template <
class P>
struct Substitute {
570 RealStrideFactor = 2,
577 SignInterpretation = 1
579 static const T*
getData(
const T& t) {
return &t; }
581 static const R&
real(
const T& t) {
return (reinterpret_cast<const R*>(&t))[0]; }
582 static R&
real(T& t) {
return (reinterpret_cast<R*>(&t))[0]; }
583 static const R&
imag(
const T& t) {
return (reinterpret_cast<const R*>(&t))[1]; }
584 static R&
imag(T& t) {
return (reinterpret_cast<R*>(&t))[1]; }
586 static const TNeg&
negate(
const T& t) {
return reinterpret_cast<const TNeg&
>(t);}
587 static TNeg&
negate(T& t) {
return reinterpret_cast<TNeg&
>(t);}
589 static const THerm&
transpose(
const T& t) {
return reinterpret_cast<const THerm&
>(t);}
590 static THerm&
transpose(T& t) {
return reinterpret_cast<THerm&
>(t);}
593 {
return reinterpret_cast<const TPosTrans&
>(t);}
595 {
return reinterpret_cast<TPosTrans&
>(t);}
598 {
return reinterpret_cast<const TWithoutNegator&
>(t);}
600 {
return reinterpret_cast<TWithoutNegator&
>(t);}
603 {
return t.real()*t.real() + t.imag()*t.imag(); }
605 {
return std::sqrt(t); }
606 static TAbs
abs(
const T& t)
610 static TInvert
invert(
const T& t) {
return TReal(1)/t;}
622 static const T c = T(0,1);
682 #define SimTK_BNTCMPLX_SPEC(T1,T2) \
683 template<> template<> struct NTraits< complex<T1> >::Result<T2> { \
684 typedef Widest< complex<T1>,T2 >::Type W; \
685 typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \
687 template<> template<> struct NTraits< complex<T1> >::Result< complex<T2> > { \
688 typedef Widest< complex<T1>,complex<T2> >::Type W; \
689 typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \
691 template<> template<> struct NTraits< complex<T1> >::Result< conjugate<T2> > { \
692 typedef Widest< complex<T1>,complex<T2> >::Type W; \
693 typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \
698 #undef SimTK_BNTCMPLX_SPEC
703 typedef complex<R> C;
737 template <
class P>
struct Result {
745 template <
class P>
struct Substitute {
758 RealStrideFactor = 2,
765 SignInterpretation = 1
768 static const T*
getData(
const T& t) {
return &t; }
770 static const TReal&
real(
const T& t) {
return t.real(); }
771 static TReal&
real(T& t) {
return t.real(); }
772 static const TImag&
imag(
const T& t) {
return t.imag(); }
773 static TImag&
imag(T& t) {
return t.imag(); }
775 static const TNeg&
negate(
const T& t) {
return reinterpret_cast<const TNeg&
>(t);}
776 static TNeg&
negate(T& t) {
return reinterpret_cast<TNeg&
>(t);}
778 static const THerm&
transpose(
const T& t) {
return t.conj();}
782 {
return reinterpret_cast<const TPosTrans&
>(t);}
784 {
return reinterpret_cast<TPosTrans&
>(t);}
787 {
return reinterpret_cast<const TWithoutNegator&
>(t);}
789 {
return reinterpret_cast<TWithoutNegator&
>(t);}
792 {
return t.real()*t.real() + t.negImag()*t.negImag(); }
794 {
return std::sqrt(C(t)); }
795 static TAbs
abs(
const T& t)
798 {
return TStandard(t); }
804 return reinterpret_cast<const TInvert&
>(cmplx); }
821 static const T c = T(0,-1);
894 #define SimTK_NTRAITS_CONJ_SPEC(T1,T2) \
895 template<> template<> struct NTraits< conjugate<T1> >::Result<T2> { \
896 typedef conjugate<Widest<T1,T2>::Type> W; \
897 typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \
899 template<> template<> struct NTraits< conjugate<T1> >::Result<complex<T2> >{\
900 typedef Widest<complex<T1>,complex<T2> >::Type W; \
901 typedef W Mul; typedef W Dvd; typedef W Add; typedef negator<W> Sub; \
903 template<> template<> struct NTraits< conjugate<T1> >::Result<conjugate<T2> >{\
904 typedef Widest<T1,T2>::Type W; typedef complex<W> WC; \
905 typedef negator<WC> Mul; typedef WC Dvd; typedef conjugate<W> Add; typedef WC Sub;\
913 #undef SimTK_NTRAITS_CONJ_SPEC
923 #define SimTK_DEFINE_REAL_NTRAITS(R) \
924 template <> class NTraits<R> { \
927 typedef negator<T> TNeg; \
928 typedef T TWithoutNegator; \
931 typedef complex<T> TComplex; \
933 typedef T TPosTrans; \
934 typedef T TSqHermT; \
935 typedef T TSqTHerm; \
936 typedef T TElement; \
941 typedef T TStandard; \
943 typedef T TNormalize; \
945 typedef T ULessScalar; \
947 typedef T StdNumber; \
948 typedef T Precision; \
949 typedef T ScalarNormSq; \
950 template <class P> struct Result { \
951 typedef typename CNT<P>::template Result<R>::Mul Mul; \
952 typedef typename CNT< typename CNT<P>::THerm >::template Result<R>::Mul Dvd; \
953 typedef typename CNT<P>::template Result<R>::Add Add; \
954 typedef typename CNT< typename CNT<P>::TNeg >::template Result<R>::Add Sub; \
956 template <class P> struct Substitute { \
964 NPackedElements = 1, \
965 NActualElements = 1, \
966 NActualScalars = 1, \
968 RealStrideFactor = 1, \
969 ArgDepth = SCALAR_DEPTH, \
975 SignInterpretation = 1 \
977 static const T* getData(const T& t) { return &t; } \
978 static T* updData(T& t) { return &t; } \
979 static const T& real(const T& t) { return t; } \
980 static T& real(T& t) { return t; } \
981 static const T& imag(const T&) { return getZero(); } \
982 static T& imag(T&) { assert(false); return *reinterpret_cast<T*>(0); } \
983 static const TNeg& negate(const T& t) {return reinterpret_cast<const TNeg&>(t);} \
984 static TNeg& negate(T& t) {return reinterpret_cast<TNeg&>(t);} \
985 static const THerm& transpose(const T& t) {return reinterpret_cast<const THerm&>(t);} \
986 static THerm& transpose(T& t) {return reinterpret_cast<THerm&>(t);} \
987 static const TPosTrans& positionalTranspose(const T& t) \
988 {return reinterpret_cast<const TPosTrans&>(t);} \
989 static TPosTrans& positionalTranspose(T& t) \
990 {return reinterpret_cast<TPosTrans&>(t);} \
991 static const TWithoutNegator& castAwayNegatorIfAny(const T& t) \
992 {return reinterpret_cast<const TWithoutNegator&>(t);} \
993 static TWithoutNegator& updCastAwayNegatorIfAny(T& t) \
994 {return reinterpret_cast<TWithoutNegator&>(t);} \
995 static ScalarNormSq scalarNormSqr(const T& t) {return t*t;} \
996 static TSqrt sqrt(const T& t) {return std::sqrt(t);} \
997 static TAbs abs(const T& t) {return std::abs(t);} \
998 static const TStandard& standardize(const T& t) {return t;} \
999 static TNormalize normalize(const T& t) {return (t>0?T(1):(t<0?T(-1):getNaN()));} \
1000 static TInvert invert(const T& t) {return T(1)/t;} \
1002 static const T& getEps() {return RTraits<T>::getEps();} \
1003 static const T& getSignificant() {return RTraits<T>::getSignificant();} \
1004 static const T& getNaN() {static const T c=std::numeric_limits<T>::quiet_NaN(); return c;} \
1005 static const T& getInfinity() {static const T c=std::numeric_limits<T>::infinity(); return c;} \
1006 static const T& getLeastPositive(){static const T c=std::numeric_limits<T>::min(); return c;} \
1007 static const T& getMostPositive() {static const T c=std::numeric_limits<T>::max(); return c;} \
1008 static const T& getLeastNegative(){static const T c=-std::numeric_limits<T>::min(); return c;} \
1009 static const T& getMostNegative() {static const T c=-std::numeric_limits<T>::max(); return c;} \
1010 static const T& getSqrtEps() {static const T c=std::sqrt(getEps()); return c;} \
1011 static const T& getTiny() {static const T c=std::pow(getEps(), (T)1.25L); return c;} \
1012 static bool isFinite(const T& t) {return SimTK::isFinite(t);} \
1013 static bool isNaN (const T& t) {return SimTK::isNaN(t);} \
1014 static bool isInf (const T& t) {return SimTK::isInf(t);} \
1017 static double getDefaultTolerance() {return RTraits<T>::getDefaultTolerance();} \
1018 static bool isNumericallyEqual(const T& t, const float& f) {return SimTK::isNumericallyEqual(t,f);} \
1019 static bool isNumericallyEqual(const T& t, const double& d) {return SimTK::isNumericallyEqual(t,d);} \
1020 static bool isNumericallyEqual(const T& t, const long double& l) {return SimTK::isNumericallyEqual(t,l);} \
1021 static bool isNumericallyEqual(const T& t, int i) {return SimTK::isNumericallyEqual(t,i);} \
1023 static bool isNumericallyEqual(const T& t, const float& f, double tol){return SimTK::isNumericallyEqual(t,f,tol);} \
1024 static bool isNumericallyEqual(const T& t, const double& d, double tol){return SimTK::isNumericallyEqual(t,d,tol);} \
1025 static bool isNumericallyEqual(const T& t, const long double& l, double tol){return SimTK::isNumericallyEqual(t,l,tol);} \
1026 static bool isNumericallyEqual(const T& t, int i, double tol){return SimTK::isNumericallyEqual(t,i,tol);} \
1028 static const T& getZero() {static const T c=(T)(0); return c;} \
1029 static const T& getOne() {static const T c=(T)(1); return c;} \
1030 static const T& getMinusOne() {static const T c=(T)(-1); return c;} \
1031 static const T& getTwo() {static const T c=(T)(2); return c;} \
1032 static const T& getThree() {static const T c=(T)(3); return c;} \
1033 static const T& getOneHalf() {static const T c=(T)(0.5L); return c;} \
1034 static const T& getOneThird() {static const T c=(T)(1.L/3.L); return c;} \
1035 static const T& getOneFourth() {static const T c=(T)(0.25L); return c;} \
1036 static const T& getOneFifth() {static const T c=(T)(0.2L); return c;} \
1037 static const T& getOneSixth() {static const T c=(T)(1.L/6.L); return c;} \
1038 static const T& getOneSeventh() {static const T c=(T)(1.L/7.L); return c;} \
1039 static const T& getOneEighth() {static const T c=(T)(0.125L); return c;} \
1040 static const T& getOneNinth() {static const T c=(T)(1.L/9.L); return c;} \
1041 static const T& getPi() {static const T c=(T)(SimTK_PI); return c;} \
1042 static const T& getOneOverPi() {static const T c=(T)(1.L/SimTK_PI); return c;} \
1043 static const T& getE() {static const T c=(T)(SimTK_E); return c;} \
1044 static const T& getLog2E() {static const T c=(T)(SimTK_LOG2E); return c;} \
1045 static const T& getLog10E() {static const T c=(T)(SimTK_LOG10E); return c;} \
1046 static const T& getSqrt2() {static const T c=(T)(SimTK_SQRT2); return c;} \
1047 static const T& getOneOverSqrt2() {static const T c=(T)(1.L/SimTK_SQRT2); return c;} \
1048 static const T& getSqrt3() {static const T c=(T)(SimTK_SQRT3); return c;} \
1049 static const T& getOneOverSqrt3() {static const T c=(T)(1.L/SimTK_SQRT3); return c;} \
1050 static const T& getCubeRoot2() {static const T c=(T)(SimTK_CBRT2); return c;} \
1051 static const T& getCubeRoot3() {static const T c=(T)(SimTK_CBRT3); return c;} \
1052 static const T& getLn2() {static const T c=(T)(SimTK_LN2); return c;} \
1053 static const T& getLn10() {static const T c=(T)(SimTK_LN10); return c;} \
1055 static int getNumDigits() {static const int c=(int)(std::log10(1/getEps()) -0.5); return c;} \
1056 static int getLosslessNumDigits() {static const int c=(int)(std::log10(1/getTiny())+0.5); return c;} \
1058 template<> struct NTraits<R>::Result<float> \
1059 {typedef Widest<R,float>::Type Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \
1060 template<> struct NTraits<R>::Result<double> \
1061 {typedef Widest<R,double>::Type Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \
1062 template<> struct NTraits<R>::Result<long double> \
1063 {typedef Widest<R,long double>::Type Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \
1064 template<> struct NTraits<R>::Result<complex<float> > \
1065 {typedef Widest<R,complex<float> >::Type Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \
1066 template<> struct NTraits<R>::Result<complex<double> > \
1067 {typedef Widest<R,complex<double> >::Type Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \
1068 template<> struct NTraits<R>::Result<complex<long double> > \
1069 {typedef Widest<R,complex<long double> >::Type Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \
1070 template<> struct NTraits<R>::Result<conjugate<float> > \
1071 {typedef conjugate<Widest<R,float>::Type> Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \
1072 template<> struct NTraits<R>::Result<conjugate<double> > \
1073 {typedef conjugate<Widest<R,double>::Type> Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \
1074 template<> struct NTraits<R>::Result<conjugate<long double> > \
1075 {typedef conjugate<Widest<R,long double>::Type> Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}
1079 #undef SimTK_DEFINE_REAL_NTRAITS
1082 template <
class R>
class CNT< complex<R> > :
public NTraits< complex<R> > { };
1086 template <>
class CNT<long double> :
public NTraits<long double> { };
1091 #endif //SimTK_SIMMATRIX_NTRAITS_H_
static TNormalize normalize(const T &t)
Definition: NTraits.h:609
static TImag & imag(T &t)
Definition: NTraits.h:773
static bool isNumericallyEqual(const T &a, int b)
Definition: NTraits.h:647
static const T & getOneFourth()
Definition: NTraits.h:857
CNT< P >::template Result< C >::Mul Mul
Definition: NTraits.h:550
C ULessScalar
Definition: NTraits.h:537
C TStandard
Definition: NTraits.h:532
static const T & getInfinity()
Definition: NTraits.h:616
R TReal
Definition: NTraits.h:708
static const T & getOneEighth()
Definition: NTraits.h:662
double Type
Definition: NTraits.h:143
static bool isNumericallyEqual(const T &a, const double &b)
Definition: NTraits.h:643
static const T & getOneOverSqrt3()
Definition: NTraits.h:672
C TInvert
Definition: NTraits.h:533
double Type
Definition: NTraits.h:140
static const T & getLn10()
Definition: NTraits.h:676
static const T & getOne()
Definition: NTraits.h:851
static const T & getMinusOne()
Definition: NTraits.h:653
static const T & getSqrt3()
Definition: NTraits.h:671
static const T & getOneSixth()
Definition: NTraits.h:660
conjugate< R > TCol
Definition: NTraits.h:717
complex< typename Widest< R1, R2 >::Type > Type
Definition: NTraits.h:122
static const T & getLog10E()
Definition: NTraits.h:867
conjugate< R > TComplex
Definition: NTraits.h:710
static bool isNumericallyEqual(const T &a, const double &b, double tol)
Definition: NTraits.h:644
RTraits is a helper class for NTraits.
Definition: NTraits.h:159
SimTK_DEFINE_REAL_NTRAITS(float)
long double Type
Definition: NTraits.h:109
float Precision
Definition: NTraits.h:142
static const T & getOneSeventh()
Definition: NTraits.h:860
R TSqTHerm
Definition: NTraits.h:714
static const T & getThree()
Definition: NTraits.h:854
static bool isNumericallyEqual(const T &a, const long double &b, double tol)
Definition: NTraits.h:845
static TPosTrans & positionalTranspose(T &t)
Definition: NTraits.h:783
complex< R > TSqrt
Definition: NTraits.h:719
P Type
Definition: NTraits.h:558
R ScalarNormSq
Definition: NTraits.h:730
static const T & getCubeRoot3()
Definition: NTraits.h:674
long double Type
Definition: NTraits.h:144
R TReal
Definition: NTraits.h:519
CNT< typename CNT< P >::TNeg >::template Result< C >::Add Sub
Definition: NTraits.h:553
static const T & getZero()
Definition: NTraits.h:651
static bool isFinite(const T &t)
Definition: NTraits.h:626
static const T & getOneThird()
Definition: NTraits.h:856
C TRow
Definition: NTraits.h:527
static const THerm & transpose(const T &t)
Definition: NTraits.h:778
static bool isNumericallyEqual(const T &a, const long double &b, double tol)
Definition: NTraits.h:646
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
static const THerm & transpose(const T &t)
Definition: NTraits.h:589
long double Type
Definition: NTraits.h:106
static bool isNumericallyEqual(const T &a, const float &b)
Definition: NTraits.h:641
static const T & getSqrt2()
Definition: NTraits.h:868
double Type
Definition: NTraits.h:105
static bool isNumericallyEqual(const T &a, const complex< R2 > &b, double tol)
Definition: NTraits.h:837
static const T & getOneSixth()
Definition: NTraits.h:859
float Type
Definition: NTraits.h:142
conjugate< R > TInvert
Definition: NTraits.h:722
static const T & getOneNinth()
Definition: NTraits.h:663
static bool isNaN(const T &t)
Definition: NTraits.h:826
static const double & getSignificant()
Definition: NTraits.h:172
complex< R > THerm
Definition: NTraits.h:711
static const T & getOneFifth()
Definition: NTraits.h:659
static const TPosTrans & positionalTranspose(const T &t)
Definition: NTraits.h:592
static const T & getThree()
Definition: NTraits.h:655
static bool isNaN(const T &t)
Definition: NTraits.h:627
static const T & getSqrt2()
Definition: NTraits.h:669
C TNormalize
Definition: NTraits.h:534
conjugate< R > ULessScalar
Definition: NTraits.h:726
static TInvert invert(const T &t)
Definition: NTraits.h:802
static bool isNumericallyEqual(const T &a, int b, double tol)
Definition: NTraits.h:847
static const T & getOneOverSqrt2()
Definition: NTraits.h:869
static const T & getOneNinth()
Definition: NTraits.h:862
static const T & getMinusOne()
Definition: NTraits.h:852
static const T & getOneOverSqrt2()
Definition: NTraits.h:670
static const T & getLog2E()
Definition: NTraits.h:667
CNT< P >::template Result< T >::Mul Mul
Definition: NTraits.h:738
float Precision
Definition: NTraits.h:138
float Type
Definition: NTraits.h:137
static const TNeg & negate(const T &t)
Definition: NTraits.h:775
static const TPosTrans & positionalTranspose(const T &t)
Definition: NTraits.h:781
static const float & getEps()
Attainable accuracy at this precision.
Definition: NTraits.h:163
static const T & getE()
Definition: NTraits.h:865
conjugate< R > T
Definition: NTraits.h:705
C TWithoutNegator
Definition: NTraits.h:517
C T
Definition: NTraits.h:515
conjugate< R > Number
Definition: NTraits.h:727
Widest< R1, R2 >::Precision Precision
Definition: NTraits.h:123
static const T & getCubeRoot2()
Definition: NTraits.h:673
Widest< R1, R2 >::Precision Precision
Definition: NTraits.h:115
static const T & getNaN()
Definition: NTraits.h:808
CNT< P >::template Result< T >::Add Add
Definition: NTraits.h:740
static const TNeg & negate(const T &t)
Definition: NTraits.h:586
static bool isNumericallyEqual(const T &a, const conjugate< R2 > &b)
Definition: NTraits.h:636
static THerm & transpose(T &t)
Definition: NTraits.h:590
static const T & getLn2()
Definition: NTraits.h:675
static const T & getCubeRoot2()
Definition: NTraits.h:872
C Scalar
Definition: NTraits.h:536
negator< R > TImag
Definition: NTraits.h:709
static TSqrt sqrt(const T &t)
Definition: NTraits.h:793
static const T & getPi()
Definition: NTraits.h:664
static TInvert invert(const T &t)
Definition: NTraits.h:610
static const T & getPi()
Definition: NTraits.h:863
static TReal & real(T &t)
Definition: NTraits.h:771
float Precision
Definition: NTraits.h:136
SimTK_BNTCMPLX_SPEC(float, float)
float Type
Definition: NTraits.h:136
R TImag
Definition: NTraits.h:520
C TComplex
Definition: NTraits.h:521
double Type
Definition: NTraits.h:141
static TAbs abs(const T &t)
Definition: NTraits.h:606
static TNeg & negate(T &t)
Definition: NTraits.h:587
complex< typename Widest< R1, R2 >::Type > Type
Definition: NTraits.h:118
static TSqrt sqrt(const T &t)
Definition: NTraits.h:604
R Precision
Definition: NTraits.h:729
CNT< typename CNT< P >::TNeg >::template Result< T >::Add Sub
Definition: NTraits.h:741
static bool isNumericallyEqual(const T &a, const conjugate< R2 > &b, double tol)
Definition: NTraits.h:833
bool isFinite(const negator< float > &x)
Definition: negator.h:287
R TAbs
Definition: NTraits.h:720
static R & real(T &t)
Definition: NTraits.h:582
conjugate< R > TNormalize
Definition: NTraits.h:723
Definition: CompositeNumericalTypes.h:116
static const R & imag(const T &t)
Definition: NTraits.h:583
static bool isFinite(const T &t)
Definition: NTraits.h:825
Narrowest< R1, R2 >::Precision Precision
Definition: NTraits.h:151
conjugate< R > TWithoutNegator
Definition: NTraits.h:707
CNT< typename CNT< P >::THerm >::template Result< T >::Mul Dvd
Definition: NTraits.h:739
conjugate< R > TPosTrans
Definition: NTraits.h:712
static bool isNumericallyEqual(const T &a, int b)
Definition: NTraits.h:846
static TAbs abs(const T &t)
Definition: NTraits.h:795
float Precision
Definition: NTraits.h:137
double Type
Definition: NTraits.h:107
static TNormalize normalize(const T &t)
Definition: NTraits.h:799
static const T & getTwo()
Definition: NTraits.h:853
static const double & getEps()
Definition: NTraits.h:171
C TCol
Definition: NTraits.h:528
static const TWithoutNegator & castAwayNegatorIfAny(const T &t)
Definition: NTraits.h:786
static TStandard standardize(const T &t)
Definition: NTraits.h:797
static TWithoutNegator & updCastAwayNegatorIfAny(T &t)
Definition: NTraits.h:599
static const T & getTwo()
Definition: NTraits.h:654
float Type
Definition: NTraits.h:139
R TAbs
Definition: NTraits.h:531
This class is specialized for all 36 combinations of standard types (that is, real and complex types ...
Definition: NTraits.h:103
static TWithoutNegator & updCastAwayNegatorIfAny(T &t)
Definition: NTraits.h:788
static bool isNumericallyEqual(const T &a, const conjugate< R2 > &b)
Definition: NTraits.h:831
static double getDefaultTolerance()
Definition: NTraits.h:179
static double getDefaultTolerance()
Definition: NTraits.h:173
High precision mathematical and physical constants.
The purpose of the CNT class is to hide the differences between built-in numerical types and compo...
static ScalarNormSq scalarNormSqr(const T &t)
Definition: NTraits.h:602
static const T & getOneThird()
Definition: NTraits.h:657
static bool isNumericallyEqual(const T &a, const double &b, double tol)
Definition: NTraits.h:843
complex< typename Widest< R1, R2 >::Type > Type
Definition: NTraits.h:114
double Precision
Definition: NTraits.h:140
conjugate< R > TRow
Definition: NTraits.h:716
static const T & getOneSeventh()
Definition: NTraits.h:661
long double Precision
Definition: NTraits.h:110
long double Type
Definition: NTraits.h:111
static bool isNumericallyEqual(const T &a, const float &b, double tol)
Definition: NTraits.h:841
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
long double Precision
Definition: NTraits.h:106
R ScalarNormSq
Definition: NTraits.h:541
static const TReal & real(const T &t)
Definition: NTraits.h:770
conjugate< R > THerm
Definition: NTraits.h:522
static TNeg & negate(T &t)
Definition: NTraits.h:776
static const T & getOne()
Definition: NTraits.h:652
static double getDefaultTolerance()
Definition: NTraits.h:630
static bool isNumericallyEqual(const T &a, int b, double tol)
Definition: NTraits.h:648
double Precision
Definition: NTraits.h:107
static const TImag & imag(const T &t)
Definition: NTraits.h:772
static const T & getInfinity()
Definition: NTraits.h:814
This class is specialized for all 36 combinations of standard types (that is, real and complex types ...
Definition: NTraits.h:135
static const T & getOneHalf()
Definition: NTraits.h:855
Widest< R1, R2 >::Precision Precision
Definition: NTraits.h:119
negator, where N is a number type (real, complex, conjugate), is represented in memory identically...
Definition: String.h:44
static const T & getE()
Definition: NTraits.h:666
static const float & getSignificant()
What multiple of attainable accuracy do we consider significant?
Definition: NTraits.h:165
complex< typename Narrowest< R1, R2 >::Type > Type
Definition: NTraits.h:150
long double Precision
Definition: NTraits.h:112
static const long double & getSignificant()
Definition: NTraits.h:178
static R & imag(T &t)
Definition: NTraits.h:584
RowVectorBase< typename CNT< ELEM >::TAbs > abs(const RowVectorBase< ELEM > &v)
Definition: VectorMath.h:120
bool isNaN(const negator< float > &x)
Definition: negator.h:273
Narrowest< R1, R2 >::Precision Precision
Definition: NTraits.h:147
P Type
Definition: NTraits.h:746
static const T & getOneFourth()
Definition: NTraits.h:658
static T * updData(T &t)
Definition: NTraits.h:769
Specialized information about Composite Numerical Types which allows us to define appropriate templat...
Definition: CompositeNumericalTypes.h:136
static const T & getNaN()
Definition: NTraits.h:612
static const TStandard & standardize(const T &t)
Definition: NTraits.h:608
conjugate< R > TElement
Definition: NTraits.h:715
SimTK_NTRAITS_CONJ_SPEC(float, float)
static bool isInf(const T &t)
Definition: NTraits.h:628
static const T & getCubeRoot3()
Definition: NTraits.h:873
static double getDefaultTolerance()
Definition: NTraits.h:829
bool isInf(const negator< float > &x)
Definition: negator.h:301
double Type
Definition: NTraits.h:108
static ScalarNormSq scalarNormSqr(const T &t)
Definition: NTraits.h:791
static bool isNumericallyEqual(const T &a, const complex< R2 > &b)
Definition: NTraits.h:835
static const T & getSqrt3()
Definition: NTraits.h:870
double Precision
Definition: NTraits.h:143
static const T & getLog10E()
Definition: NTraits.h:668
static const T & getOneEighth()
Definition: NTraits.h:861
static const T & getLog2E()
Definition: NTraits.h:866
Narrowest< R1, R2 >::Precision Precision
Definition: NTraits.h:155
static T * updData(T &t)
Definition: NTraits.h:580
long double Precision
Definition: NTraits.h:111
C StdNumber
Definition: NTraits.h:539
long double Type
Definition: NTraits.h:112
negator< T > TNeg
Definition: NTraits.h:706
complex< typename Narrowest< R1, R2 >::Type > Type
Definition: NTraits.h:154
CNT< typename CNT< P >::THerm >::template Result< C >::Mul Dvd
Definition: NTraits.h:551
static bool isNumericallyEqual(const T &a, const float &b, double tol)
Definition: NTraits.h:642
R Precision
Definition: NTraits.h:540
static bool isInf(const T &t)
Definition: NTraits.h:827
static const T & getOneOverPi()
Definition: NTraits.h:864
double Precision
Definition: NTraits.h:105
static const T & getOneOverPi()
Definition: NTraits.h:665
conjugate< R > Scalar
Definition: NTraits.h:725
long double Type
Definition: NTraits.h:110
C TPosTrans
Definition: NTraits.h:523
static const T * getData(const T &t)
Definition: NTraits.h:579
SimTK::conjugate should be instantiated only for float, double, long double.
Definition: String.h:45
long double Precision
Definition: NTraits.h:109
C TSqrt
Definition: NTraits.h:530
static const T & getI()
Definition: NTraits.h:820
static const T & getOneHalf()
Definition: NTraits.h:656
R TSqTHerm
Definition: NTraits.h:525
R TSqHermT
Definition: NTraits.h:713
static bool isNumericallyEqual(const T &a, const complex< R2 > &b)
Definition: NTraits.h:632
static bool isNumericallyEqual(const T &a, const conjugate< R2 > &b, double tol)
Definition: NTraits.h:638
C TElement
Definition: NTraits.h:526
static const T & getLn10()
Definition: NTraits.h:875
double Precision
Definition: NTraits.h:108
static double getDefaultTolerance()
The default numerical error tolerance is always given in double precision.
Definition: NTraits.h:167
static const T * getData(const T &t)
Definition: NTraits.h:768
complex< typename Narrowest< R1, R2 >::Type > Type
Definition: NTraits.h:146
complex< R > TStandard
Definition: NTraits.h:721
static const T & getZero()
Definition: NTraits.h:850
float Type
Definition: NTraits.h:138
static const long double & getEps()
Definition: NTraits.h:177
static bool isNumericallyEqual(const T &a, const double &b)
Definition: NTraits.h:842
static const TWithoutNegator & castAwayNegatorIfAny(const T &t)
Definition: NTraits.h:597
double Precision
Definition: NTraits.h:141
negator< C > TNeg
Definition: NTraits.h:516
float Precision
Definition: NTraits.h:104
static bool isNumericallyEqual(const T &a, const complex< R2 > &b, double tol)
Definition: NTraits.h:634
static TPosTrans & positionalTranspose(T &t)
Definition: NTraits.h:594
static const T & getOneOverSqrt3()
Definition: NTraits.h:871
R TSqHermT
Definition: NTraits.h:524
static const R & real(const T &t)
Definition: NTraits.h:581
CNT< P >::template Result< C >::Add Add
Definition: NTraits.h:552
long double Precision
Definition: NTraits.h:144
float Type
Definition: NTraits.h:104
complex< R > StdNumber
Definition: NTraits.h:728
static const T & getLn2()
Definition: NTraits.h:874
static bool isNumericallyEqual(const T &a, const long double &b)
Definition: NTraits.h:844
static const T & getOneFifth()
Definition: NTraits.h:858
static const T & getI()
Definition: NTraits.h:621
float Precision
Definition: NTraits.h:139
bool isNumericallyEqual(const float &a, const float &b, double tol=RTraits< float >::getDefaultTolerance())
Compare two floats for approximate equality.
Definition: NTraits.h:313
C Number
Definition: NTraits.h:538
static bool isNumericallyEqual(const T &a, const long double &b)
Definition: NTraits.h:645
static bool isNumericallyEqual(const T &a, const float &b)
Definition: NTraits.h:840
static THerm & transpose(T &t)
Definition: NTraits.h:779