CompositeNumericalTypes.h
Go to the documentation of this file.00001 #ifndef SimTK_SIMMATRIX_COMPOSITE_NUMERICAL_TYPES_H_
00002 #define SimTK_SIMMATRIX_COMPOSITE_NUMERICAL_TYPES_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00173 #include "SimTKcommon/internal/common.h"
00174
00175 namespace SimTK {
00176
00177
00178
00179
00180
00181
00182 enum {
00183 SCALAR_DEPTH = 0,
00184 SCALAR_COMPOSITE_DEPTH = 1,
00185 COMPOSITE_COMPOSITE_DEPTH = 2,
00186 COMPOSITE_3_DEPTH = 3,
00187 MAX_RESOLVED_DEPTH = COMPOSITE_3_DEPTH
00188 };
00189
00203 template <class K> class CNT : private K {
00204 public:
00205 typedef K T;
00206 typedef typename K::TNeg TNeg;
00207 typedef typename K::TWithoutNegator TWithoutNegator;
00208 typedef typename K::TReal TReal;
00209 typedef typename K::TImag TImag;
00210 typedef typename K::TComplex TComplex;
00211 typedef typename K::THerm THerm;
00212 typedef typename K::TPosTrans TPosTrans;
00213 typedef typename K::TSqHermT TSqHermT;
00214 typedef typename K::TSqTHerm TSqTHerm;
00215 typedef typename K::TElement TElement;
00216 typedef typename K::TRow TRow;
00217 typedef typename K::TCol TCol;
00218
00219
00220
00221 typedef typename K::TAbs TAbs;
00222 typedef typename K::TStandard TStandard;
00223 typedef typename K::TInvert TInvert;
00224 typedef typename K::TNormalize TNormalize;
00225
00226 typedef typename K::Scalar Scalar;
00227 typedef typename K::Number Number;
00228 typedef typename K::StdNumber StdNumber;
00229 typedef typename K::Precision Precision;
00230
00231 typedef typename K::ScalarSq ScalarSq;
00232
00233
00234 template <class P> struct Result {
00235 typedef typename K::template Result<P>::Mul Mul;
00236 typedef typename K::template Result<P>::Dvd Dvd;;
00237 typedef typename K::template Result<P>::Add Add;
00238 typedef typename K::template Result<P>::Sub Sub;
00239 };
00240
00241
00242 template <class P> struct Substitute {
00243 typedef typename K::template Substitute<P>::Type Type;
00244 };
00245
00246 enum {
00247 NRows = K::NRows,
00248 NCols = K::NCols,
00249 RowSpacing = K::RowSpacing,
00250 ColSpacing = K::ColSpacing,
00251 NPackedElements = K::NPackedElements,
00252 NActualElements = K::NActualElements,
00253 NActualScalars = K::NActualScalars,
00254 ImagOffset = K::ImagOffset,
00255 RealStrideFactor = K::RealStrideFactor,
00256 ArgDepth = K::ArgDepth,
00257 IsScalar = K::IsScalar,
00258 IsNumber = K::IsNumber,
00259 IsStdNumber = K::IsStdNumber,
00260 IsPrecision = K::IsPrecision,
00261 SignInterpretation = K::SignInterpretation
00262 };
00263
00264 static const Scalar* getData(const T& t) { return t.getData(); }
00265 static Scalar* updData(T& t) { return t.updData(); }
00266
00267 static const TReal& real(const T& t) { return t.real(); }
00268 static TReal& real(T& t) { return t.real(); }
00269 static const TImag& imag(const T& t) { return t.imag(); }
00270 static TImag& imag(T& t) { return t.imag(); }
00271
00272 static K getInfinity() { return K::getInfinity(); }
00273 static K getNaN() { return K::getNaN(); }
00274
00275
00276
00277
00278 static const TNeg& negate(const T& t)
00279 { return reinterpret_cast<const TNeg&>(t); }
00280 static TNeg& negate(T& t)
00281 { return reinterpret_cast<TNeg&>(t); }
00282
00283 static const THerm& transpose(const K& t)
00284 { return reinterpret_cast<const THerm&>(t); }
00285 static THerm& transpose(K& t)
00286 { return reinterpret_cast<THerm&>(t); }
00287
00288 static const TPosTrans& positionalTranspose(const K& t)
00289 { return reinterpret_cast<const TPosTrans&>(t); }
00290 static TPosTrans& positionalTranspose(K& t)
00291 { return reinterpret_cast<TPosTrans&>(t); }
00292
00293
00294
00295
00296
00297
00298
00299 static const TWithoutNegator& castAwayNegatorIfAny(const T& t)
00300 {return reinterpret_cast<const TWithoutNegator&>(t);}
00301 static TWithoutNegator& updCastAwayNegatorIfAny(T& t)
00302 {return reinterpret_cast<TWithoutNegator&>(t);}
00303
00304 static ScalarSq scalarNormSqr(const K& t) {return t.scalarNormSqr();}
00305 static TAbs abs(const K& t) {return t.abs();}
00306 static TStandard standardize(const K& t) {return t.standardize();}
00307 static TNormalize normalize(const K& t) {return t.normalize();}
00308 static TInvert invert(const K& t) {return t.invert();}
00309 };
00310
00311 }
00312
00313 #endif // SimTK_SIMMATRIX_COMPOSITE_NUMERICAL_TYPES_H_