Simbody
|
This is a user-includable header which includes everything needed to make use of SimMatrix Scalar code. More...
#include "SimTKcommon/internal/common.h"
#include "SimTKcommon/Constants.h"
#include "SimTKcommon/internal/Exception.h"
#include "SimTKcommon/internal/ExceptionMacros.h"
#include "SimTKcommon/internal/String.h"
#include "SimTKcommon/internal/Array.h"
#include "SimTKcommon/internal/conjugate.h"
#include "SimTKcommon/internal/CompositeNumericalTypes.h"
#include "SimTKcommon/internal/NTraits.h"
#include "SimTKcommon/internal/negator.h"
#include <complex>
#include <cmath>
#include <climits>
#include <cassert>
#include <utility>
Go to the source code of this file.
Namespaces | |
namespace | SimTK |
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with other symbols. | |
Typedefs | |
typedef conjugate< Real > | SimTK::Conjugate |
Functions | |
bool | SimTK::atMostOneBitIsSet (unsigned char v) |
bool | SimTK::atMostOneBitIsSet (unsigned short v) |
bool | SimTK::atMostOneBitIsSet (unsigned int v) |
bool | SimTK::atMostOneBitIsSet (unsigned long v) |
bool | SimTK::atMostOneBitIsSet (unsigned long long v) |
bool | SimTK::atMostOneBitIsSet (signed char v) |
bool | SimTK::atMostOneBitIsSet (char v) |
bool | SimTK::atMostOneBitIsSet (short v) |
bool | SimTK::atMostOneBitIsSet (int v) |
bool | SimTK::atMostOneBitIsSet (long v) |
bool | SimTK::atMostOneBitIsSet (long long v) |
bool | SimTK::exactlyOneBitIsSet (unsigned char v) |
bool | SimTK::exactlyOneBitIsSet (unsigned short v) |
bool | SimTK::exactlyOneBitIsSet (unsigned int v) |
bool | SimTK::exactlyOneBitIsSet (unsigned long v) |
bool | SimTK::exactlyOneBitIsSet (unsigned long long v) |
bool | SimTK::exactlyOneBitIsSet (signed char v) |
bool | SimTK::exactlyOneBitIsSet (char v) |
bool | SimTK::exactlyOneBitIsSet (short v) |
bool | SimTK::exactlyOneBitIsSet (int v) |
bool | SimTK::exactlyOneBitIsSet (long v) |
bool | SimTK::exactlyOneBitIsSet (long long v) |
bool | SimTK::signBit (unsigned char i) |
bool | SimTK::signBit (unsigned short i) |
bool | SimTK::signBit (unsigned int i) |
bool | SimTK::signBit (unsigned long i) |
bool | SimTK::signBit (unsigned long long i) |
bool | SimTK::signBit (signed char i) |
bool | SimTK::signBit (short i) |
bool | SimTK::signBit (int i) |
bool | SimTK::signBit (long long i) |
bool | SimTK::signBit (long i) |
bool | SimTK::signBit (const float &f) |
bool | SimTK::signBit (const double &d) |
bool | SimTK::signBit (const negator< float > &nf) |
bool | SimTK::signBit (const negator< double > &nd) |
unsigned int | SimTK::sign (unsigned char u) |
unsigned int | SimTK::sign (unsigned short u) |
unsigned int | SimTK::sign (unsigned int u) |
unsigned int | SimTK::sign (unsigned long u) |
unsigned int | SimTK::sign (unsigned long long u) |
int | SimTK::sign (signed char i) |
int | SimTK::sign (short i) |
int | SimTK::sign (int i) |
int | SimTK::sign (long i) |
int | SimTK::sign (long long i) |
int | SimTK::sign (const float &x) |
int | SimTK::sign (const double &x) |
int | SimTK::sign (const long double &x) |
int | SimTK::sign (const negator< float > &x) |
int | SimTK::sign (const negator< double > &x) |
int | SimTK::sign (const negator< long double > &x) |
unsigned char | SimTK::square (unsigned char u) |
unsigned short | SimTK::square (unsigned short u) |
unsigned int | SimTK::square (unsigned int u) |
unsigned long | SimTK::square (unsigned long u) |
unsigned long long | SimTK::square (unsigned long long u) |
char | SimTK::square (char c) |
signed char | SimTK::square (signed char i) |
short | SimTK::square (short i) |
int | SimTK::square (int i) |
long | SimTK::square (long i) |
long long | SimTK::square (long long i) |
float | SimTK::square (const float &x) |
double | SimTK::square (const double &x) |
long double | SimTK::square (const long double &x) |
float | SimTK::square (const negator< float > &x) |
double | SimTK::square (const negator< double > &x) |
long double | SimTK::square (const negator< long double > &x) |
template<class P > | |
std::complex< P > | SimTK::square (const std::complex< P > &x) |
template<class P > | |
std::complex< P > | SimTK::square (const conjugate< P > &x) |
template<class P > | |
std::complex< P > | SimTK::square (const negator< std::complex< P > > &x) |
template<class P > | |
std::complex< P > | SimTK::square (const negator< conjugate< P > > &x) |
unsigned char | SimTK::cube (unsigned char u) |
unsigned short | SimTK::cube (unsigned short u) |
unsigned int | SimTK::cube (unsigned int u) |
unsigned long | SimTK::cube (unsigned long u) |
unsigned long long | SimTK::cube (unsigned long long u) |
char | SimTK::cube (char c) |
signed char | SimTK::cube (signed char i) |
short | SimTK::cube (short i) |
int | SimTK::cube (int i) |
long | SimTK::cube (long i) |
long long | SimTK::cube (long long i) |
float | SimTK::cube (const float &x) |
double | SimTK::cube (const double &x) |
long double | SimTK::cube (const long double &x) |
negator< float > | SimTK::cube (const negator< float > &x) |
negator< double > | SimTK::cube (const negator< double > &x) |
negator< long double > | SimTK::cube (const negator< long double > &x) |
template<class P > | |
std::complex< P > | SimTK::cube (const std::complex< P > &x) |
template<class P > | |
std::complex< P > | SimTK::cube (const negator< std::complex< P > > &x) |
template<class P > | |
std::complex< P > | SimTK::cube (const conjugate< P > &x) |
template<class P > | |
std::complex< P > | SimTK::cube (const negator< conjugate< P > > &x) |
double & | SimTK::clampInPlace (double low, double &v, double high) |
Check that low <= v <= high and modify v in place if necessary to bring it into that range. | |
float & | SimTK::clampInPlace (float low, float &v, float high) |
long double & | SimTK::clampInPlace (long double low, long double &v, long double high) |
double & | SimTK::clampInPlace (int low, double &v, int high) |
float & | SimTK::clampInPlace (int low, float &v, int high) |
long double & | SimTK::clampInPlace (int low, long double &v, int high) |
double & | SimTK::clampInPlace (int low, double &v, double high) |
float & | SimTK::clampInPlace (int low, float &v, float high) |
long double & | SimTK::clampInPlace (int low, long double &v, long double high) |
double & | SimTK::clampInPlace (double low, double &v, int high) |
float & | SimTK::clampInPlace (float low, float &v, int high) |
long double & | SimTK::clampInPlace (long double low, long double &v, int high) |
unsigned char & | SimTK::clampInPlace (unsigned char low, unsigned char &v, unsigned char high) |
unsigned short & | SimTK::clampInPlace (unsigned short low, unsigned short &v, unsigned short high) |
unsigned int & | SimTK::clampInPlace (unsigned int low, unsigned int &v, unsigned int high) |
unsigned long & | SimTK::clampInPlace (unsigned long low, unsigned long &v, unsigned long high) |
unsigned long long & | SimTK::clampInPlace (unsigned long long low, unsigned long long &v, unsigned long long high) |
char & | SimTK::clampInPlace (char low, char &v, char high) |
signed char & | SimTK::clampInPlace (signed char low, signed char &v, signed char high) |
short & | SimTK::clampInPlace (short low, short &v, short high) |
int & | SimTK::clampInPlace (int low, int &v, int high) |
long & | SimTK::clampInPlace (long low, long &v, long high) |
long long & | SimTK::clampInPlace (long long low, long long &v, long long high) |
negator< float > & | SimTK::clampInPlace (float low, negator< float > &v, float high) |
negator< double > & | SimTK::clampInPlace (double low, negator< double > &v, double high) |
negator< long double > & | SimTK::clampInPlace (long double low, negator< long double > &v, long double high) |
double | SimTK::clamp (double low, double v, double high) |
If v is in range low <= v <= high then return v, otherwise return the nearest bound; this function does not modify the input variable v. | |
float | SimTK::clamp (float low, float v, float high) |
long double | SimTK::clamp (long double low, long double v, long double high) |
double | SimTK::clamp (int low, double v, int high) |
float | SimTK::clamp (int low, float v, int high) |
long double | SimTK::clamp (int low, long double v, int high) |
double | SimTK::clamp (int low, double v, double high) |
float | SimTK::clamp (int low, float v, float high) |
long double | SimTK::clamp (int low, long double v, long double high) |
double | SimTK::clamp (double low, double v, int high) |
float | SimTK::clamp (float low, float v, int high) |
long double | SimTK::clamp (long double low, long double v, int high) |
unsigned char | SimTK::clamp (unsigned char low, unsigned char v, unsigned char high) |
unsigned short | SimTK::clamp (unsigned short low, unsigned short v, unsigned short high) |
unsigned int | SimTK::clamp (unsigned int low, unsigned int v, unsigned int high) |
unsigned long | SimTK::clamp (unsigned long low, unsigned long v, unsigned long high) |
unsigned long long | SimTK::clamp (unsigned long long low, unsigned long long v, unsigned long long high) |
char | SimTK::clamp (char low, char v, char high) |
signed char | SimTK::clamp (signed char low, signed char v, signed char high) |
short | SimTK::clamp (short low, short v, short high) |
int | SimTK::clamp (int low, int v, int high) |
long | SimTK::clamp (long low, long v, long high) |
long long | SimTK::clamp (long long low, long long v, long long high) |
float | SimTK::clamp (float low, negator< float > v, float high) |
double | SimTK::clamp (double low, negator< double > v, double high) |
long double | SimTK::clamp (long double low, negator< long double > v, long double high) |
double | SimTK::stepUp (double x) |
Interpolate smoothly from 0 up to 1 as the input argument goes from 0 to 1, with first and second derivatives zero at either end of the interval. | |
double | SimTK::stepDown (double x) |
Interpolate smoothly from 1 down to 0 as the input argument goes from 0 to 1, with first and second derivatives zero at either end of the interval. | |
double | SimTK::stepAny (double y0, double yRange, double x0, double oneOverXRange, double x) |
Interpolate smoothly from y0 to y1 as the input argument goes from x0 to x1, with first and second derivatives zero at either end of the interval. | |
double | SimTK::dstepUp (double x) |
First derivative of stepUp(): d/dx stepUp(x). | |
double | SimTK::dstepDown (double x) |
First derivative of stepDown(): d/dx stepDown(x). | |
double | SimTK::dstepAny (double yRange, double x0, double oneOverXRange, double x) |
First derivative of stepAny(): d/dx stepAny(x). | |
double | SimTK::d2stepUp (double x) |
Second derivative of stepUp(): d^2/dx^2 stepUp(x). | |
double | SimTK::d2stepDown (double x) |
Second derivative of stepDown(): d^2/dx^2 stepDown(x). | |
double | SimTK::d2stepAny (double yRange, double x0, double oneOverXRange, double x) |
Second derivative of stepAny(): d^2/dx^2 stepAny(x). | |
double | SimTK::d3stepUp (double x) |
Third derivative of stepUp(): d^3/dx^3 stepUp(x). | |
double | SimTK::d3stepDown (double x) |
Third derivative of stepDown(): d^3/dx^3 stepDown(x). | |
double | SimTK::d3stepAny (double yRange, double x0, double oneOverXRange, double x) |
Third derivative of stepAny(): d^3/dx^3 stepAny(x). | |
float | SimTK::stepUp (float x) |
float | SimTK::stepDown (float x) |
float | SimTK::stepAny (float y0, float yRange, float x0, float oneOverXRange, float x) |
float | SimTK::dstepUp (float x) |
float | SimTK::dstepDown (float x) |
float | SimTK::dstepAny (float yRange, float x0, float oneOverXRange, float x) |
float | SimTK::d2stepUp (float x) |
float | SimTK::d2stepDown (float x) |
float | SimTK::d2stepAny (float yRange, float x0, float oneOverXRange, float x) |
float | SimTK::d3stepUp (float x) |
float | SimTK::d3stepDown (float x) |
float | SimTK::d3stepAny (float yRange, float x0, float oneOverXRange, float x) |
long double | SimTK::stepUp (long double x) |
long double | SimTK::stepDown (long double x) |
long double | SimTK::stepAny (long double y0, long double yRange, long double x0, long double oneOverXRange, long double x) |
long double | SimTK::dstepUp (long double x) |
long double | SimTK::dstepDown (long double x) |
long double | SimTK::dstepAny (long double yRange, long double x0, long double oneOverXRange, long double x) |
long double | SimTK::d2stepUp (long double x) |
long double | SimTK::d2stepDown (long double x) |
long double | SimTK::d2stepAny (long double yRange, long double x0, long double oneOverXRange, long double x) |
long double | SimTK::d3stepUp (long double x) |
long double | SimTK::d3stepDown (long double x) |
long double | SimTK::d3stepAny (long double yRange, long double x0, long double oneOverXRange, long double x) |
double | SimTK::stepUp (int x) |
double | SimTK::stepDown (int x) |
std::pair< double, double > | SimTK::approxCompleteEllipticIntegralsKE (double m) |
Given 0<=m<=1, return complete elliptic integrals of the first and second kinds, K(m) and E(m), approximated but with a maximum error of 2e-8 so at least 7 digits are correct (same in float or double precision). See Elliptic integrals for a discussion. | |
std::pair< float, float > | SimTK::approxCompleteEllipticIntegralsKE (float m) |
This is the single precision (float) version of the approximate calculation of elliptic integrals, still yielding about 7 digits of accuracy even though all calculations are done in float precision. | |
std::pair< double, double > | SimTK::approxCompleteEllipticIntegralsKE (int m) |
This integer overload is present to prevent ambiguity; it converts its argument to double precision and then calls approxCompleteEllipticIntegralsKE(double). | |
std::pair< double, double > | SimTK::completeEllipticIntegralsKE (double m) |
Given 0<=m<=1, return complete elliptic integrals of the first and second kinds, K(m) and E(m), calculated to (roughly) machine precision (float or double). See Elliptic integrals for a discussion. | |
std::pair< float, float > | SimTK::completeEllipticIntegralsKE (float m) |
This is the single precision (float) version of the machine-precision calculation of elliptic integrals, providing accuracy to float precision (about 7 digits) which is no better than you'll get with the much faster approximate version, so use that instead! | |
std::pair< double, double > | SimTK::completeEllipticIntegralsKE (int m) |
This integer overload is present to prevent ambiguity; it converts its argument to double precision and then calls completeEllipticIntegralsKE(double). | |
Variables | |
static const 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. | |
static const 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. | |
static const 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. | |
static const 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. | |
static const 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. | |
static const 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. | |
static const 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. | |
static const 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. | |
static const 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. | |
static const 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. | |
static const 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. | |
static const 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. | |
static const Real & | SimTK::Zero = NTraits<Real>::getZero() |
Real(0) | |
static const Real & | SimTK::One = NTraits<Real>::getOne() |
Real(1) | |
static const Real & | SimTK::MinusOne = NTraits<Real>::getMinusOne() |
Real(-1) | |
static const Real & | SimTK::Two = NTraits<Real>::getTwo() |
Real(2) | |
static const Real & | SimTK::Three = NTraits<Real>::getThree() |
Real(3) | |
static const Real & | SimTK::OneHalf = NTraits<Real>::getOneHalf() |
Real(1)/2. | |
static const Real & | SimTK::OneThird = NTraits<Real>::getOneThird() |
Real(1)/3. | |
static const Real & | SimTK::OneFourth = NTraits<Real>::getOneFourth() |
Real(1)/4. | |
static const Real & | SimTK::OneFifth = NTraits<Real>::getOneFifth() |
Real(1)/5. | |
static const Real & | SimTK::OneSixth = NTraits<Real>::getOneSixth() |
Real(1)/6. | |
static const Real & | SimTK::OneSeventh = NTraits<Real>::getOneSeventh() |
Real(1)/7. | |
static const Real & | SimTK::OneEighth = NTraits<Real>::getOneEighth() |
Real(1)/8. | |
static const Real & | SimTK::OneNinth = NTraits<Real>::getOneNinth() |
Real(1)/9. | |
static const Real & | SimTK::Pi = NTraits<Real>::getPi() |
Real(pi) | |
static const Real & | SimTK::OneOverPi = NTraits<Real>::getOneOverPi() |
1/Real(pi) | |
static const Real & | SimTK::E = NTraits<Real>::getE() |
e = Real(exp(1)) | |
static const Real & | SimTK::Log2E = NTraits<Real>::getLog2E() |
Real(log2(e)) (log base 2) | |
static const Real & | SimTK::Log10E = NTraits<Real>::getLog10E() |
Real(log10(e)) (log base 10) | |
static const Real & | SimTK::Sqrt2 = NTraits<Real>::getSqrt2() |
Real(sqrt(2)) | |
static const Real & | SimTK::OneOverSqrt2 = NTraits<Real>::getOneOverSqrt2() |
1/sqrt(2)==sqrt(2)/2 as Real | |
static const Real & | SimTK::Sqrt3 = NTraits<Real>::getSqrt3() |
Real(sqrt(3)) | |
static const Real & | SimTK::OneOverSqrt3 = NTraits<Real>::getOneOverSqrt3() |
Real(1/sqrt(3)) | |
static const Real & | SimTK::CubeRoot2 = NTraits<Real>::getCubeRoot2() |
Real(2^(1/3)) (cube root of 2) | |
static const Real & | SimTK::CubeRoot3 = NTraits<Real>::getCubeRoot3() |
Real(3^(1/3)) (cube root of 3) | |
static const Real & | SimTK::Ln2 = NTraits<Real>::getLn2() |
Real(ln(2)) (natural log of 2) | |
static const Real & | SimTK::Ln10 = NTraits<Real>::getLn10() |
Real(ln(10)) (natural log of 10) | |
static const 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), or if you need an address you can use NTraits<Complex>::getPi(), etc. |
This is a user-includable header which includes everything needed to make use of SimMatrix Scalar code.
More commonly, this will be included from within Matrix code.