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>;
93 template <
class N>
class negator;
102 template <
class R1,
class R2>
struct Widest {};
107 template <
class R1,
class R2>
struct Widest< complex<R1>,complex<R2> > {
108 typedef complex< typename Widest<R1,R2>::Type >
Type;
111 template <
class R1,
class R2>
struct Widest< complex<R1>,R2 > {
112 typedef complex< typename Widest<R1,R2>::Type >
Type;
115 template <
class R1,
class R2>
struct Widest< R1,complex<R2> > {
116 typedef complex< typename Widest<R1,R2>::Type >
Type;
134 template <
class R1,
class R2>
struct Narrowest< complex<R1>,complex<R2> > {
135 typedef complex< typename Narrowest<R1,R2>::Type >
Type;
138 template <
class R1,
class R2>
struct Narrowest< complex<R1>,R2 > {
139 typedef complex< typename Narrowest<R1,R2>::Type >
Type;
142 template <
class R1,
class R2>
struct Narrowest< R1,complex<R2> > {
143 typedef complex< typename Narrowest<R1,R2>::Type >
Type;
152 static const float&
getEps() {
static const float c=std::numeric_limits<float>::epsilon();
return c;}
154 static const float&
getSignificant() {
static const float c=std::pow(getEps(), 0.875f);
return c;}
160 static const double&
getEps() {
static const double c=std::numeric_limits<double>::epsilon();
return c;}
161 static const double&
getSignificant() {
static const double c=std::pow(getEps(), 0.875);
return c;}
183 inline bool isNaN(
const float& x) {
return std::isnan(x);}
184 inline bool isNaN(
const double& x) {
return std::isnan(x);}
186 template <
class P>
inline bool 190 template <
class P>
inline bool 192 {
return isNaN(x.real()) ||
isNaN(x.negImag());}
209 inline bool isFinite(
const float& x) {
return std::isfinite(x);}
210 inline bool isFinite(
const double& x) {
return std::isfinite(x);}
212 template <
class P>
inline bool 216 template <
class P>
inline bool 237 inline bool isInf(
const float& x) {
return std::isinf(x);}
238 inline bool isInf(
const double& x) {
return std::isinf(x);}
240 template <
class P>
inline bool 246 template <
class P>
inline bool 248 return (
isInf(x.real()) && !
isNaN(x.negImag()))
297 return std::abs(a-b) <= scale*(float)tol; }
303 return std::abs(a-b) <= scale*tol; }
334 template <
class P,
class Q>
336 (
const std::complex<P>& a,
const std::complex<Q>& b,
344 template <
class P,
class Q>
354 template <
class P,
class Q>
364 template <
class P,
class Q>
372 template <
class P>
inline bool 377 template <
class P>
inline bool 382 template <
class P>
inline bool 387 template <
class P>
inline bool 392 template <
class P>
inline bool 397 template <
class P>
inline bool 403 template <
class P>
inline bool 408 template <
class P>
inline bool 413 template <
class P>
inline bool 418 template <
class P>
inline bool 423 template <
class P>
inline bool 428 template <
class P>
inline bool 436 template <
class N>
class NTraits {
442 template <
class R>
class NTraits< complex<R> > {
443 typedef complex<R> C;
479 template <
class P>
struct Result {
487 template <
class P>
struct Substitute {
500 RealStrideFactor = 2,
507 SignInterpretation = 1
511 static const R&
real(
const T& t) {
return (reinterpret_cast<const R*>(&t))[0]; }
512 static R&
real(
T& t) {
return (reinterpret_cast<R*>(&t))[0]; }
513 static const R&
imag(
const T& t) {
return (reinterpret_cast<const R*>(&t))[1]; }
514 static R&
imag(
T& t) {
return (reinterpret_cast<R*>(&t))[1]; }
523 {
return reinterpret_cast<const TPosTrans&
>(t);}
525 {
return reinterpret_cast<TPosTrans&
>(t);}
533 {
return t.real()*t.real() + t.imag()*t.imag(); }
535 {
return std::sqrt(t); }
552 static const T c =
T(0,1);
610 #define SimTK_BNTCMPLX_SPEC(T1,T2) \ 611 template<> template<> struct NTraits< complex<T1> >::Result<T2> { \ 612 typedef Widest< complex<T1>,T2 >::Type W; \ 613 typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \ 615 template<> template<> struct NTraits< complex<T1> >::Result< complex<T2> > { \ 616 typedef Widest< complex<T1>,complex<T2> >::Type W; \ 617 typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \ 619 template<> template<> struct NTraits< complex<T1> >::Result< conjugate<T2> > { \ 620 typedef Widest< complex<T1>,complex<T2> >::Type W; \ 621 typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \ 625 #undef SimTK_BNTCMPLX_SPEC 630 typedef complex<R> C;
664 template <
class P>
struct Result {
672 template <
class P>
struct Substitute {
685 RealStrideFactor = 2,
692 SignInterpretation = 1
709 {
return reinterpret_cast<const TPosTrans&
>(t);}
711 {
return reinterpret_cast<TPosTrans&
>(t);}
719 {
return t.real()*t.real() + t.negImag()*t.negImag(); }
721 {
return std::sqrt(C(t)); }
731 return reinterpret_cast<const TInvert&
>(cmplx); }
748 static const T c =
T(0,-1);
819 #define SimTK_NTRAITS_CONJ_SPEC(T1,T2) \ 820 template<> template<> struct NTraits< conjugate<T1> >::Result<T2> { \ 821 typedef conjugate<Widest<T1,T2>::Type> W; \ 822 typedef W Mul; typedef W Dvd; typedef W Add; typedef W Sub; \ 824 template<> template<> struct NTraits< conjugate<T1> >::Result<complex<T2> >{\ 825 typedef Widest<complex<T1>,complex<T2> >::Type W; \ 826 typedef W Mul; typedef W Dvd; typedef W Add; typedef negator<W> Sub; \ 828 template<> template<> struct NTraits< conjugate<T1> >::Result<conjugate<T2> >{\ 829 typedef Widest<T1,T2>::Type W; typedef complex<W> WC; \ 830 typedef negator<WC> Mul; typedef WC Dvd; typedef conjugate<W> Add; typedef WC Sub;\ 834 #undef SimTK_NTRAITS_CONJ_SPEC 844 #define SimTK_DEFINE_REAL_NTRAITS(R) \ 845 template <> class NTraits<R> { \ 848 typedef negator<T> TNeg; \ 849 typedef T TWithoutNegator; \ 852 typedef complex<T> TComplex; \ 854 typedef T TPosTrans; \ 855 typedef T TSqHermT; \ 856 typedef T TSqTHerm; \ 857 typedef T TElement; \ 862 typedef T TStandard; \ 864 typedef T TNormalize; \ 866 typedef T ULessScalar; \ 868 typedef T StdNumber; \ 869 typedef T Precision; \ 870 typedef T ScalarNormSq; \ 871 template <class P> struct Result { \ 872 typedef typename CNT<P>::template Result<R>::Mul Mul; \ 873 typedef typename CNT< typename CNT<P>::THerm >::template Result<R>::Mul Dvd; \ 874 typedef typename CNT<P>::template Result<R>::Add Add; \ 875 typedef typename CNT< typename CNT<P>::TNeg >::template Result<R>::Add Sub; \ 877 template <class P> struct Substitute { \ 885 NPackedElements = 1, \ 886 NActualElements = 1, \ 887 NActualScalars = 1, \ 889 RealStrideFactor = 1, \ 890 ArgDepth = SCALAR_DEPTH, \ 896 SignInterpretation = 1 \ 898 static const T* getData(const T& t) { return &t; } \ 899 static T* updData(T& t) { return &t; } \ 900 static const T& real(const T& t) { return t; } \ 901 static T& real(T& t) { return t; } \ 902 static const T& imag(const T&) { return getZero(); } \ 903 static T& imag(T&) { assert(false); return *reinterpret_cast<T*>(0); } \ 904 static const TNeg& negate(const T& t) {return reinterpret_cast<const TNeg&>(t);} \ 905 static TNeg& negate(T& t) {return reinterpret_cast<TNeg&>(t);} \ 906 static const THerm& transpose(const T& t) {return reinterpret_cast<const THerm&>(t);} \ 907 static THerm& transpose(T& t) {return reinterpret_cast<THerm&>(t);} \ 908 static const TPosTrans& positionalTranspose(const T& t) \ 909 {return reinterpret_cast<const TPosTrans&>(t);} \ 910 static TPosTrans& positionalTranspose(T& t) \ 911 {return reinterpret_cast<TPosTrans&>(t);} \ 912 static const TWithoutNegator& castAwayNegatorIfAny(const T& t) \ 913 {return reinterpret_cast<const TWithoutNegator&>(t);} \ 914 static TWithoutNegator& updCastAwayNegatorIfAny(T& t) \ 915 {return reinterpret_cast<TWithoutNegator&>(t);} \ 916 static ScalarNormSq scalarNormSqr(const T& t) {return t*t;} \ 917 static TSqrt sqrt(const T& t) {return std::sqrt(t);} \ 918 static TAbs abs(const T& t) {return std::abs(t);} \ 919 static const TStandard& standardize(const T& t) {return t;} \ 920 static TNormalize normalize(const T& t) {return (t>0?T(1):(t<0?T(-1):getNaN()));} \ 921 static TInvert invert(const T& t) {return T(1)/t;} \ 923 static const T& getEps() {return RTraits<T>::getEps();} \ 924 static const T& getSignificant() {return RTraits<T>::getSignificant();} \ 925 static const T& getNaN() {static const T c=std::numeric_limits<T>::quiet_NaN(); return c;} \ 926 static const T& getInfinity() {static const T c=std::numeric_limits<T>::infinity(); return c;} \ 927 static const T& getLeastPositive(){static const T c=std::numeric_limits<T>::min(); return c;} \ 928 static const T& getMostPositive() {static const T c=std::numeric_limits<T>::max(); return c;} \ 929 static const T& getLeastNegative(){static const T c=-std::numeric_limits<T>::min(); return c;} \ 930 static const T& getMostNegative() {static const T c=-std::numeric_limits<T>::max(); return c;} \ 931 static const T& getSqrtEps() {static const T c=std::sqrt(getEps()); return c;} \ 932 static const T& getTiny() {static const T c=std::pow(getEps(), (T)1.25L); return c;} \ 933 static bool isFinite(const T& t) {return SimTK::isFinite(t);} \ 934 static bool isNaN (const T& t) {return SimTK::isNaN(t);} \ 935 static bool isInf (const T& t) {return SimTK::isInf(t);} \ 938 static double getDefaultTolerance() {return RTraits<T>::getDefaultTolerance();} \ 939 static bool isNumericallyEqual(const T& t, const float& f) {return SimTK::isNumericallyEqual(t,f);} \ 940 static bool isNumericallyEqual(const T& t, const double& d) {return SimTK::isNumericallyEqual(t,d);} \ 941 static bool isNumericallyEqual(const T& t, int i) {return SimTK::isNumericallyEqual(t,i);} \ 943 static bool isNumericallyEqual(const T& t, const float& f, double tol){return SimTK::isNumericallyEqual(t,f,tol);} \ 944 static bool isNumericallyEqual(const T& t, const double& d, double tol){return SimTK::isNumericallyEqual(t,d,tol);} \ 945 static bool isNumericallyEqual(const T& t, int i, double tol){return SimTK::isNumericallyEqual(t,i,tol);} \ 947 static const T& getZero() {static const T c=(T)(0); return c;} \ 948 static const T& getOne() {static const T c=(T)(1); return c;} \ 949 static const T& getMinusOne() {static const T c=(T)(-1); return c;} \ 950 static const T& getTwo() {static const T c=(T)(2); return c;} \ 951 static const T& getThree() {static const T c=(T)(3); return c;} \ 952 static const T& getOneHalf() {static const T c=(T)(0.5L); return c;} \ 953 static const T& getOneThird() {static const T c=(T)(1.L/3.L); return c;} \ 954 static const T& getOneFourth() {static const T c=(T)(0.25L); return c;} \ 955 static const T& getOneFifth() {static const T c=(T)(0.2L); return c;} \ 956 static const T& getOneSixth() {static const T c=(T)(1.L/6.L); return c;} \ 957 static const T& getOneSeventh() {static const T c=(T)(1.L/7.L); return c;} \ 958 static const T& getOneEighth() {static const T c=(T)(0.125L); return c;} \ 959 static const T& getOneNinth() {static const T c=(T)(1.L/9.L); return c;} \ 960 static const T& getPi() {static const T c=(T)(SimTK_PI); return c;} \ 961 static const T& getOneOverPi() {static const T c=(T)(1.L/SimTK_PI); return c;} \ 962 static const T& getE() {static const T c=(T)(SimTK_E); return c;} \ 963 static const T& getLog2E() {static const T c=(T)(SimTK_LOG2E); return c;} \ 964 static const T& getLog10E() {static const T c=(T)(SimTK_LOG10E); return c;} \ 965 static const T& getSqrt2() {static const T c=(T)(SimTK_SQRT2); return c;} \ 966 static const T& getOneOverSqrt2() {static const T c=(T)(1.L/SimTK_SQRT2); return c;} \ 967 static const T& getSqrt3() {static const T c=(T)(SimTK_SQRT3); return c;} \ 968 static const T& getOneOverSqrt3() {static const T c=(T)(1.L/SimTK_SQRT3); return c;} \ 969 static const T& getCubeRoot2() {static const T c=(T)(SimTK_CBRT2); return c;} \ 970 static const T& getCubeRoot3() {static const T c=(T)(SimTK_CBRT3); return c;} \ 971 static const T& getLn2() {static const T c=(T)(SimTK_LN2); return c;} \ 972 static const T& getLn10() {static const T c=(T)(SimTK_LN10); return c;} \ 974 static int getNumDigits() {static const int c=(int)(std::log10(1/getEps()) -0.5); return c;} \ 975 static int getLosslessNumDigits() {static const int c=(int)(std::log10(1/getTiny())+0.5); return c;} \ 977 template<> struct NTraits<R>::Result<float> \ 978 {typedef Widest<R,float>::Type Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \ 979 template<> struct NTraits<R>::Result<double> \ 980 {typedef Widest<R,double>::Type Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \ 981 template<> struct NTraits<R>::Result<complex<float> > \ 982 {typedef Widest<R,complex<float> >::Type Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \ 983 template<> struct NTraits<R>::Result<complex<double> > \ 984 {typedef Widest<R,complex<double> >::Type Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \ 985 template<> struct NTraits<R>::Result<conjugate<float> > \ 986 {typedef conjugate<Widest<R,float>::Type> Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;}; \ 987 template<> struct NTraits<R>::Result<conjugate<double> > \ 988 {typedef conjugate<Widest<R,double>::Type> Mul;typedef Mul Dvd;typedef Mul Add;typedef Mul Sub;} 990 #if defined(__clang__) 991 #pragma clang diagnostic push 993 #pragma clang diagnostic ignored "-Wnull-dereference" 997 #if defined(__clang__) 998 #pragma clang diagnostic pop 1001 #undef SimTK_DEFINE_REAL_NTRAITS 1004 template <
class R>
class CNT< complex<R> > :
public NTraits< complex<R> > { };
1012 #endif //SimTK_SIMMATRIX_NTRAITS_H_ static TNormalize normalize(const T &t)
Definition: NTraits.h:539
static TImag & imag(T &t)
Definition: NTraits.h:700
static bool isNumericallyEqual(const T &a, int b)
Definition: NTraits.h:575
static const T & getOneFourth()
Definition: NTraits.h:782
CNT< P >::template Result< C >::Mul Mul
Definition: NTraits.h:480
C ULessScalar
Definition: NTraits.h:467
C TStandard
Definition: NTraits.h:462
static const T & getInfinity()
Definition: NTraits.h:546
R TReal
Definition: NTraits.h:635
static const T & getOneEighth()
Definition: NTraits.h:590
static bool isNumericallyEqual(const T &a, const double &b)
Definition: NTraits.h:573
static const T & getOneOverSqrt3()
Definition: NTraits.h:600
C TInvert
Definition: NTraits.h:463
double Type
Definition: NTraits.h:133
static const T & getLn10()
Definition: NTraits.h:604
static const T & getOne()
Definition: NTraits.h:776
static const T & getMinusOne()
Definition: NTraits.h:581
static const T & getSqrt3()
Definition: NTraits.h:599
static const T & getOneSixth()
Definition: NTraits.h:588
conjugate< R > TCol
Definition: NTraits.h:644
complex< typename Widest< R1, R2 >::Type > Type
Definition: NTraits.h:116
static const T & getLog10E()
Definition: NTraits.h:792
conjugate< R > TComplex
Definition: NTraits.h:637
static bool isNumericallyEqual(const T &a, const double &b, double tol)
Definition: NTraits.h:574
RTraits is a helper class for NTraits.
Definition: NTraits.h:148
SimTK_DEFINE_REAL_NTRAITS(float)
static const T & getOneSeventh()
Definition: NTraits.h:785
R TSqTHerm
Definition: NTraits.h:641
static const T & getThree()
Definition: NTraits.h:779
static TPosTrans & positionalTranspose(T &t)
Definition: NTraits.h:710
complex< R > TSqrt
Definition: NTraits.h:646
P Type
Definition: NTraits.h:488
R ScalarNormSq
Definition: NTraits.h:657
static const T & getCubeRoot3()
Definition: NTraits.h:602
R TReal
Definition: NTraits.h:449
CNT< typename CNT< P >::TNeg >::template Result< C >::Add Sub
Definition: NTraits.h:483
static const T & getZero()
Definition: NTraits.h:579
static bool isFinite(const T &t)
Definition: NTraits.h:556
static const T & getOneThird()
Definition: NTraits.h:781
C TRow
Definition: NTraits.h:457
static const THerm & transpose(const T &t)
Definition: NTraits.h:705
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
SimTK::conjugate<R> should be instantiated only for float, double.
Definition: String.h:45
static const THerm & transpose(const T &t)
Definition: NTraits.h:519
static bool isNumericallyEqual(const T &a, const float &b)
Definition: NTraits.h:571
static const T & getSqrt2()
Definition: NTraits.h:793
double Type
Definition: NTraits.h:104
static bool isNumericallyEqual(const T &a, const complex< R2 > &b, double tol)
Definition: NTraits.h:764
static const T & getOneSixth()
Definition: NTraits.h:784
conjugate< R > TInvert
Definition: NTraits.h:649
static const T & getOneNinth()
Definition: NTraits.h:591
static bool isNaN(const T &t)
Definition: NTraits.h:753
static const double & getSignificant()
Definition: NTraits.h:161
complex< R > THerm
Definition: NTraits.h:638
static const T & getOneFifth()
Definition: NTraits.h:587
static const TPosTrans & positionalTranspose(const T &t)
Definition: NTraits.h:522
static const T & getThree()
Definition: NTraits.h:583
static bool isNaN(const T &t)
Definition: NTraits.h:557
static const T & getSqrt2()
Definition: NTraits.h:597
C TNormalize
Definition: NTraits.h:464
conjugate< R > ULessScalar
Definition: NTraits.h:653
static TInvert invert(const T &t)
Definition: NTraits.h:729
static bool isNumericallyEqual(const T &a, int b, double tol)
Definition: NTraits.h:772
static const T & getOneOverSqrt2()
Definition: NTraits.h:794
static const T & getOneNinth()
Definition: NTraits.h:787
static const T & getMinusOne()
Definition: NTraits.h:777
static const T & getOneOverSqrt2()
Definition: NTraits.h:598
static const T & getLog2E()
Definition: NTraits.h:595
CNT< P >::template Result< T >::Mul Mul
Definition: NTraits.h:665
float Type
Definition: NTraits.h:131
static const TNeg & negate(const T &t)
Definition: NTraits.h:702
static const TPosTrans & positionalTranspose(const T &t)
Definition: NTraits.h:708
static const float & getEps()
Attainable accuracy at this precision.
Definition: NTraits.h:152
static const T & getE()
Definition: NTraits.h:790
conjugate< R > T
Definition: NTraits.h:632
C TWithoutNegator
Definition: NTraits.h:447
negator<N>, where N is a number type (real, complex, conjugate), is represented in memory identically...
Definition: String.h:44
C T
Definition: NTraits.h:445
conjugate< R > Number
Definition: NTraits.h:654
Widest< R1, R2 >::Precision Precision
Definition: NTraits.h:117
static const T & getCubeRoot2()
Definition: NTraits.h:601
Widest< R1, R2 >::Precision Precision
Definition: NTraits.h:109
static const T & getNaN()
Definition: NTraits.h:735
CNT< P >::template Result< T >::Add Add
Definition: NTraits.h:667
static const TNeg & negate(const T &t)
Definition: NTraits.h:516
static bool isNumericallyEqual(const T &a, const conjugate< R2 > &b)
Definition: NTraits.h:566
static THerm & transpose(T &t)
Definition: NTraits.h:520
static const T & getLn2()
Definition: NTraits.h:603
static const T & getCubeRoot2()
Definition: NTraits.h:797
C Scalar
Definition: NTraits.h:466
negator< R > TImag
Definition: NTraits.h:636
static TSqrt sqrt(const T &t)
Definition: NTraits.h:720
static const T & getPi()
Definition: NTraits.h:592
static TInvert invert(const T &t)
Definition: NTraits.h:540
static const T & getPi()
Definition: NTraits.h:788
static TReal & real(T &t)
Definition: NTraits.h:698
float Precision
Definition: NTraits.h:130
SimTK_BNTCMPLX_SPEC(float, float)
float Type
Definition: NTraits.h:130
R TImag
Definition: NTraits.h:450
C TComplex
Definition: NTraits.h:451
static TAbs abs(const T &t)
Definition: NTraits.h:536
static TNeg & negate(T &t)
Definition: NTraits.h:517
complex< typename Widest< R1, R2 >::Type > Type
Definition: NTraits.h:112
static TSqrt sqrt(const T &t)
Definition: NTraits.h:534
R Precision
Definition: NTraits.h:656
CNT< typename CNT< P >::TNeg >::template Result< T >::Add Sub
Definition: NTraits.h:668
static bool isNumericallyEqual(const T &a, const conjugate< R2 > &b, double tol)
Definition: NTraits.h:760
bool isFinite(const negator< float > &x)
Definition: negator.h:285
R TAbs
Definition: NTraits.h:647
static R & real(T &t)
Definition: NTraits.h:512
conjugate< R > TNormalize
Definition: NTraits.h:650
Definition: CompositeNumericalTypes.h:116
static const R & imag(const T &t)
Definition: NTraits.h:513
static bool isFinite(const T &t)
Definition: NTraits.h:752
Narrowest< R1, R2 >::Precision Precision
Definition: NTraits.h:140
conjugate< R > TWithoutNegator
Definition: NTraits.h:634
CNT< typename CNT< P >::THerm >::template Result< T >::Mul Dvd
Definition: NTraits.h:666
conjugate< R > TPosTrans
Definition: NTraits.h:639
static bool isNumericallyEqual(const T &a, int b)
Definition: NTraits.h:771
static TAbs abs(const T &t)
Definition: NTraits.h:722
float Precision
Definition: NTraits.h:131
double Type
Definition: NTraits.h:105
static TNormalize normalize(const T &t)
Definition: NTraits.h:726
static const T & getTwo()
Definition: NTraits.h:778
static const double & getEps()
Definition: NTraits.h:160
C TCol
Definition: NTraits.h:458
static const TWithoutNegator & castAwayNegatorIfAny(const T &t)
Definition: NTraits.h:713
static TStandard standardize(const T &t)
Definition: NTraits.h:724
static TWithoutNegator & updCastAwayNegatorIfAny(T &t)
Definition: NTraits.h:529
static const T & getTwo()
Definition: NTraits.h:582
float Type
Definition: NTraits.h:132
R TAbs
Definition: NTraits.h:461
This class is specialized for all 16 combinations of standard types (that is, real and complex types ...
Definition: NTraits.h:102
static TWithoutNegator & updCastAwayNegatorIfAny(T &t)
Definition: NTraits.h:715
static bool isNumericallyEqual(const T &a, const conjugate< R2 > &b)
Definition: NTraits.h:758
static double getDefaultTolerance()
Definition: NTraits.h:162
High precision mathematical and physical constants.
The purpose of the CNT<T> class is to hide the differences between built-in numerical types and compo...
static ScalarNormSq scalarNormSqr(const T &t)
Definition: NTraits.h:532
static const T & getOneThird()
Definition: NTraits.h:585
static bool isNumericallyEqual(const T &a, const double &b, double tol)
Definition: NTraits.h:770
complex< typename Widest< R1, R2 >::Type > Type
Definition: NTraits.h:108
double Precision
Definition: NTraits.h:133
conjugate< R > TRow
Definition: NTraits.h:643
static const T & getOneSeventh()
Definition: NTraits.h:589
static bool isNumericallyEqual(const T &a, const float &b, double tol)
Definition: NTraits.h:768
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
R ScalarNormSq
Definition: NTraits.h:471
static const TReal & real(const T &t)
Definition: NTraits.h:697
conjugate< R > THerm
Definition: NTraits.h:452
static TNeg & negate(T &t)
Definition: NTraits.h:703
static const T & getOne()
Definition: NTraits.h:580
static double getDefaultTolerance()
Definition: NTraits.h:560
static bool isNumericallyEqual(const T &a, int b, double tol)
Definition: NTraits.h:576
double Precision
Definition: NTraits.h:105
static const TImag & imag(const T &t)
Definition: NTraits.h:699
static const T & getInfinity()
Definition: NTraits.h:741
This class is specialized for all 16 combinations of standard types (that is, real and complex types ...
Definition: NTraits.h:129
static const T & getOneHalf()
Definition: NTraits.h:780
Widest< R1, R2 >::Precision Precision
Definition: NTraits.h:113
static const T & getE()
Definition: NTraits.h:594
static const float & getSignificant()
What multiple of attainable accuracy do we consider significant?
Definition: NTraits.h:154
complex< typename Narrowest< R1, R2 >::Type > Type
Definition: NTraits.h:139
static R & imag(T &t)
Definition: NTraits.h:514
RowVectorBase< typename CNT< ELEM >::TAbs > abs(const RowVectorBase< ELEM > &v)
Definition: VectorMath.h:120
bool isNaN(const negator< float > &x)
Definition: negator.h:272
Narrowest< R1, R2 >::Precision Precision
Definition: NTraits.h:136
P Type
Definition: NTraits.h:673
static const T & getOneFourth()
Definition: NTraits.h:586
static T * updData(T &t)
Definition: NTraits.h:696
Specialized information about Composite Numerical Types which allows us to define appropriate templat...
Definition: CompositeNumericalTypes.h:136
static const T & getNaN()
Definition: NTraits.h:542
static const TStandard & standardize(const T &t)
Definition: NTraits.h:538
conjugate< R > TElement
Definition: NTraits.h:642
SimTK_NTRAITS_CONJ_SPEC(float, float)
static bool isInf(const T &t)
Definition: NTraits.h:558
static const T & getCubeRoot3()
Definition: NTraits.h:798
static double getDefaultTolerance()
Definition: NTraits.h:756
bool isInf(const negator< float > &x)
Definition: negator.h:298
double Type
Definition: NTraits.h:106
static ScalarNormSq scalarNormSqr(const T &t)
Definition: NTraits.h:718
static bool isNumericallyEqual(const T &a, const complex< R2 > &b)
Definition: NTraits.h:762
static const T & getSqrt3()
Definition: NTraits.h:795
static const T & getLog10E()
Definition: NTraits.h:596
static const T & getOneEighth()
Definition: NTraits.h:786
static const T & getLog2E()
Definition: NTraits.h:791
Narrowest< R1, R2 >::Precision Precision
Definition: NTraits.h:144
static T * updData(T &t)
Definition: NTraits.h:510
C StdNumber
Definition: NTraits.h:469
negator< T > TNeg
Definition: NTraits.h:633
complex< typename Narrowest< R1, R2 >::Type > Type
Definition: NTraits.h:143
CNT< typename CNT< P >::THerm >::template Result< C >::Mul Dvd
Definition: NTraits.h:481
static bool isNumericallyEqual(const T &a, const float &b, double tol)
Definition: NTraits.h:572
R Precision
Definition: NTraits.h:470
static bool isInf(const T &t)
Definition: NTraits.h:754
static const T & getOneOverPi()
Definition: NTraits.h:789
double Precision
Definition: NTraits.h:104
static const T & getOneOverPi()
Definition: NTraits.h:593
conjugate< R > Scalar
Definition: NTraits.h:652
C TPosTrans
Definition: NTraits.h:453
static const T * getData(const T &t)
Definition: NTraits.h:509
C TSqrt
Definition: NTraits.h:460
static const T & getI()
Definition: NTraits.h:747
static const T & getOneHalf()
Definition: NTraits.h:584
R TSqTHerm
Definition: NTraits.h:455
R TSqHermT
Definition: NTraits.h:640
static bool isNumericallyEqual(const T &a, const complex< R2 > &b)
Definition: NTraits.h:562
static bool isNumericallyEqual(const T &a, const conjugate< R2 > &b, double tol)
Definition: NTraits.h:568
C TElement
Definition: NTraits.h:456
static const T & getLn10()
Definition: NTraits.h:800
double Precision
Definition: NTraits.h:106
static double getDefaultTolerance()
The default numerical error tolerance is always given in double precision.
Definition: NTraits.h:156
static const T * getData(const T &t)
Definition: NTraits.h:695
complex< typename Narrowest< R1, R2 >::Type > Type
Definition: NTraits.h:135
complex< R > TStandard
Definition: NTraits.h:648
static const T & getZero()
Definition: NTraits.h:775
static bool isNumericallyEqual(const T &a, const double &b)
Definition: NTraits.h:769
static const TWithoutNegator & castAwayNegatorIfAny(const T &t)
Definition: NTraits.h:527
negator< C > TNeg
Definition: NTraits.h:446
float Precision
Definition: NTraits.h:103
static bool isNumericallyEqual(const T &a, const complex< R2 > &b, double tol)
Definition: NTraits.h:564
static TPosTrans & positionalTranspose(T &t)
Definition: NTraits.h:524
static const T & getOneOverSqrt3()
Definition: NTraits.h:796
R TSqHermT
Definition: NTraits.h:454
static const R & real(const T &t)
Definition: NTraits.h:511
CNT< P >::template Result< C >::Add Add
Definition: NTraits.h:482
float Type
Definition: NTraits.h:103
complex< R > StdNumber
Definition: NTraits.h:655
static const T & getLn2()
Definition: NTraits.h:799
static const T & getOneFifth()
Definition: NTraits.h:783
static const T & getI()
Definition: NTraits.h:551
float Precision
Definition: NTraits.h:132
bool isNumericallyEqual(const float &a, const float &b, double tol=RTraits< float >::getDefaultTolerance())
Compare two floats for approximate equality.
Definition: NTraits.h:293
C Number
Definition: NTraits.h:468
static bool isNumericallyEqual(const T &a, const float &b)
Definition: NTraits.h:767
static THerm & transpose(T &t)
Definition: NTraits.h:706