|
Simbody 3.9
|
This is a set of predefined constants in the form of Real (SimTK default precision) symbols that are important for writing precision-independent numerical algorithms. More...
Variables | |
| constexpr Real | SimTK::NaN = NTraits<Real>::getNaN() |
| This is the IEEE "not a number" constant for this implementation of the default-precision Real type; be very careful using this because it has many strange properties such as not comparing equal to itself. | |
| constexpr Real | SimTK::Infinity = NTraits<Real>::getInfinity() |
| This is the IEEE positive infinity constant for this implementation of the default-precision Real type; -Infinity will produce the negative infinity constant. | |
| constexpr Real | SimTK::Eps = NTraits<Real>::getEps() |
| Epsilon is the size of roundoff noise; it is the smallest positive number of default-precision type Real such that 1+Eps != 1. | |
| constexpr Real | SimTK::SqrtEps = NTraits<Real>::getSqrtEps() |
| This is the square root of Eps, ~1e-8 if Real is double, ~3e-4 if Real is float. | |
| constexpr Real | SimTK::TinyReal = NTraits<Real>::getTiny() |
| TinyReal is a floating point value smaller than the floating point precision; it is defined as Eps^(5/4) which is ~1e-20 for Real==double and ~1e-9 for float. | |
| constexpr Real | SimTK::SignificantReal = NTraits<Real>::getSignificant() |
| SignificantReal is the smallest value that we consider to be clearly distinct from roundoff error when it is the result of a computation; it is defined as Eps^(7/8) which is ~1e-14 when Real==double, ~1e-6 when Real==float. | |
| constexpr Real | SimTK::LeastPositiveReal = NTraits<Real>::getLeastPositive() |
| This is the smallest positive real number that can be expressed in the type Real; it is ~1e-308 when Real==double, ~1e-38 when Real==float. | |
| constexpr Real | SimTK::MostPositiveReal = NTraits<Real>::getMostPositive() |
| This is the largest finite positive real number that can be expressed in the Real type; ~1e+308 when Real==double, ~1e+38 when Real==float. Note that there is also a value Infinity that will test larger than this one. | |
| constexpr Real | SimTK::LeastNegativeReal = NTraits<Real>::getLeastNegative() |
| This is the largest negative real number (that is, closest to zero) that can be expressed in values of type Real. | |
| constexpr Real | SimTK::MostNegativeReal = NTraits<Real>::getMostNegative() |
| This is the smallest finite negative real number that can be expressed in values of type Real. Note that -Infinity is a value that will still test smaller than this one. | |
| constexpr int | SimTK::NumDigitsReal = NTraits<Real>::getNumDigits() |
| This is the number of decimal digits that can be reliably stored and retrieved in the default Real precision (typically log10(1/eps)-1), that is, about 15 digits when Real==double and 6 digits when Real==float. | |
| constexpr int | SimTK::LosslessNumDigitsReal = NTraits<Real>::getLosslessNumDigits() |
| This is the smallest number of decimal digits you should store in a text file if you want to be able to get exactly the same bit pattern back when you read it back in and convert the text to a Real value. | |
| constexpr Real | SimTK::Zero = NTraits<Real>::getZero() |
| Real(0) | |
| constexpr Real | SimTK::One = NTraits<Real>::getOne() |
| Real(1) | |
| constexpr Real | SimTK::MinusOne = NTraits<Real>::getMinusOne() |
| Real(-1) | |
| constexpr Real | SimTK::Two = NTraits<Real>::getTwo() |
| Real(2) | |
| constexpr Real | SimTK::Three = NTraits<Real>::getThree() |
| Real(3) | |
| constexpr Real | SimTK::OneHalf = NTraits<Real>::getOneHalf() |
| Real(1)/2. | |
| constexpr Real | SimTK::OneThird = NTraits<Real>::getOneThird() |
| Real(1)/3. | |
| constexpr Real | SimTK::OneFourth = NTraits<Real>::getOneFourth() |
| Real(1)/4. | |
| constexpr Real | SimTK::OneFifth = NTraits<Real>::getOneFifth() |
| Real(1)/5. | |
| constexpr Real | SimTK::OneSixth = NTraits<Real>::getOneSixth() |
| Real(1)/6. | |
| constexpr Real | SimTK::OneSeventh = NTraits<Real>::getOneSeventh() |
| Real(1)/7. | |
| constexpr Real | SimTK::OneEighth = NTraits<Real>::getOneEighth() |
| Real(1)/8. | |
| constexpr Real | SimTK::OneNinth = NTraits<Real>::getOneNinth() |
| Real(1)/9. | |
| constexpr Real | SimTK::Pi = NTraits<Real>::getPi() |
| Real(pi) | |
| constexpr Real | SimTK::OneOverPi = NTraits<Real>::getOneOverPi() |
| 1/Real(pi) | |
| constexpr Real | SimTK::E = NTraits<Real>::getE() |
| e = Real(exp(1)) | |
| constexpr Real | SimTK::Log2E = NTraits<Real>::getLog2E() |
| Real(log2(e)) (log base 2) | |
| constexpr Real | SimTK::Log10E = NTraits<Real>::getLog10E() |
| Real(log10(e)) (log base 10) | |
| constexpr Real | SimTK::Sqrt2 = NTraits<Real>::getSqrt2() |
| Real(sqrt(2)) | |
| constexpr Real | SimTK::OneOverSqrt2 = NTraits<Real>::getOneOverSqrt2() |
| 1/sqrt(2)==sqrt(2)/2 as Real | |
| constexpr Real | SimTK::Sqrt3 = NTraits<Real>::getSqrt3() |
| Real(sqrt(3)) | |
| constexpr Real | SimTK::OneOverSqrt3 = NTraits<Real>::getOneOverSqrt3() |
| Real(1/sqrt(3)) | |
| constexpr Real | SimTK::CubeRoot2 = NTraits<Real>::getCubeRoot2() |
| Real(2^(1/3)) (cube root of 2) | |
| constexpr Real | SimTK::CubeRoot3 = NTraits<Real>::getCubeRoot3() |
| Real(3^(1/3)) (cube root of 3) | |
| constexpr Real | SimTK::Ln2 = NTraits<Real>::getLn2() |
| Real(ln(2)) (natural log of 2) | |
| constexpr Real | SimTK::Ln10 = NTraits<Real>::getLn10() |
| Real(ln(10)) (natural log of 10) | |
| constexpr Complex | SimTK::I = NTraits<Complex>::getI() |
| We only need one complex constant, i = sqrt(-1). For the rest just multiply the real constant by i, or convert with Complex(the Real constant). | |
This is a set of predefined constants in the form of Real (SimTK default precision) symbols that are important for writing precision-independent numerical algorithms.
Constants defined here include common mathematical values like pi, e, and sqrt(2) and also numerical constants related to the floating point implementation of the Real type, such as NaN, Infinity, and the machine precision Epsilon. For convenience we also provide several common numerical values for which it is useful to have a precision-independent representation (mostly to avoid warnings or casts to avoid them). These include small integers and common small fractions like 1/2 and 1/3.
Note that the Simbody convention for typed constants is to name them like ordinary variables except with an initial capital letter (like a class name). Typed constants are processed by the compiler rather than the preprocessor and do not require any special treatment when used; they behave just like variables of the same type and value would behave. So we don't feel the need to draw attention to them with ALL_CAPS like we do with preprocessor symbols.
This is the IEEE "not a number" constant for this implementation of the default-precision Real type; be very careful using this because it has many strange properties such as not comparing equal to itself.
You must use the SimTK::isNaN() function instead to determine whether something contains a NaN value.
This is the IEEE positive infinity constant for this implementation of the default-precision Real type; -Infinity will produce the negative infinity constant.
Infinity tests larger than any other Real value.
Epsilon is the size of roundoff noise; it is the smallest positive number of default-precision type Real such that 1+Eps != 1.
If Real is double (the normal case) then Eps ~= 1e-16; if Real is float then Eps ~= 1e-7.
This is the square root of Eps, ~1e-8 if Real is double, ~3e-4 if Real is float.
Many numerical algorithms are limited to accuracy of sqrt(Eps) so this constant is useful in checking for termination of them.
TinyReal is a floating point value smaller than the floating point precision; it is defined as Eps^(5/4) which is ~1e-20 for Real==double and ~1e-9 for float.
This is commonly used as a number to add to a computation in a denominator (such as a vector length) that might come out zero, just for the purpose of avoiding a divide by zero.
SignificantReal is the smallest value that we consider to be clearly distinct from roundoff error when it is the result of a computation; it is defined as Eps^(7/8) which is ~1e-14 when Real==double, ~1e-6 when Real==float.
This is the smallest positive real number that can be expressed in the type Real; it is ~1e-308 when Real==double, ~1e-38 when Real==float.
This is the largest finite positive real number that can be expressed in the Real type; ~1e+308 when Real==double, ~1e+38 when Real==float. Note that there is also a value Infinity that will test larger than this one.
This is the largest negative real number (that is, closest to zero) that can be expressed in values of type Real.
This is the smallest finite negative real number that can be expressed in values of type Real. Note that -Infinity is a value that will still test smaller than this one.
This is the number of decimal digits that can be reliably stored and retrieved in the default Real precision (typically log10(1/eps)-1), that is, about 15 digits when Real==double and 6 digits when Real==float.
This is the smallest number of decimal digits you should store in a text file if you want to be able to get exactly the same bit pattern back when you read it back in and convert the text to a Real value.
Typically, this is about log10(1/tiny), which is about 20 digits when Real==double and 9 digits when Real==float.
e = Real(exp(1))
Real(log10(e)) (log base 10)
1/sqrt(2)==sqrt(2)/2 as Real
Real(1/sqrt(3))
Real(2^(1/3)) (cube root of 2)
Real(3^(1/3)) (cube root of 3)
Real(ln(2)) (natural log of 2)
Real(ln(10)) (natural log of 10)
We only need one complex constant, i = sqrt(-1). For the rest just multiply the real constant by i, or convert with Complex(the Real constant).