LinearAlgebra.h
Go to the documentation of this file.00001 #ifndef SimTK_LINEAR_ALGEBRA_H_
00002 #define SimTK_LINEAR_ALGEBRA_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
00043 #include <limits.h>
00044 #include "SimTKcommon.h"
00045 #include "SimTKmath.h"
00046 #include "SimTKcommon/internal/BigMatrix.h"
00047 #include "internal/common.h"
00048
00049 namespace SimTK {
00050
00051
00052
00053
00054
00055
00056 static const double DefaultRecpCondition = 1e-12;
00060 class SimTK_SIMMATH_EXPORT Factor {
00061 public:
00062
00063 Factor() {}
00065 template <class ELT> Factor( Matrix_<ELT> m );
00067 template <class ELT> void solve( const Vector_<ELT>& b, Vector_<ELT>& x ) const;
00069 template <class ELT> void solve( const Matrix_<ELT>& b, Matrix_<ELT>& x ) const;
00070
00071 };
00072
00073 class FactorLURepBase;
00074
00078 class SimTK_SIMMATH_EXPORT FactorLU: public Factor {
00079 public:
00080
00081 ~FactorLU();
00082
00083 FactorLU();
00084 FactorLU( const FactorLU& c );
00085 FactorLU& operator=(const FactorLU& rhs);
00086
00087 template <class ELT> FactorLU( const Matrix_<ELT>& m );
00089 template <class ELT> void factor( const Matrix_<ELT>& m );
00091 template <class ELT> void solve( const Vector_<ELT>& b, Vector_<ELT>& x ) const;
00093 template <class ELT> void solve( const Matrix_<ELT>& b, Matrix_<ELT>& x ) const;
00094
00096 template <class ELT> void getL( Matrix_<ELT>& l ) const;
00098 template <class ELT> void getU( Matrix_<ELT>& u ) const;
00100 template < class ELT > void inverse( Matrix_<ELT>& m ) const;
00101
00103 bool isSingular() const;
00105 int getSingularIndex() const;
00106
00107
00108 protected:
00109 class FactorLURepBase *rep;
00110
00111 };
00112
00113
00114 class FactorQTZRepBase;
00118 class SimTK_SIMMATH_EXPORT FactorQTZ: public Factor {
00119 public:
00120
00121 ~FactorQTZ();
00122
00123 FactorQTZ();
00124 FactorQTZ( const FactorQTZ& c );
00125 FactorQTZ& operator=(const FactorQTZ& rhs);
00127 template <typename ELT> FactorQTZ( const Matrix_<ELT>& m);
00129 template <typename ELT> FactorQTZ( const Matrix_<ELT>& m, double rcond );
00131 template <typename ELT> FactorQTZ( const Matrix_<ELT>& m, float rcond );
00133 template <typename ELT> void factor( const Matrix_<ELT>& m);
00135 template <typename ELT> void factor( const Matrix_<ELT>& m, float rcond );
00137 template <typename ELT> void factor( const Matrix_<ELT>& m, double rcond );
00139 template <typename ELT> void solve( const Vector_<ELT>& b, Vector_<ELT>& x ) const;
00141 template <typename ELT> void solve( const Matrix_<ELT>& b, Matrix_<ELT>& x ) const;
00142
00143 template < class ELT > void inverse( Matrix_<ELT>& m ) const;
00144
00146 int getRank() const;
00148 double getRCondEstimate() const;
00149
00150
00151 protected:
00152 class FactorQTZRepBase *rep;
00153 };
00157 class SimTK_SIMMATH_EXPORT Eigen {
00158 public:
00159
00160 ~Eigen();
00161
00162 Eigen();
00163 Eigen( const Eigen& c );
00164 Eigen& operator=(const Eigen& rhs);
00165
00167 template <class ELT> Eigen( const Matrix_<ELT>& m );
00169 template <class ELT> void factor( const Matrix_<ELT>& m );
00171 template <class VAL, class VEC> void getAllEigenValuesAndVectors( Vector_<VAL>& values, Matrix_<VEC>& vectors);
00173 template <class T> void getAllEigenValues( Vector_<T>& values);
00174
00176 template <class VAL, class VEC> void getFewEigenValuesAndVectors( Vector_<VAL>& values, Matrix_<VEC>& vectors, int ilow, int ihi);
00178 template <class T> void getFewEigenVectors( Matrix_<T>& vectors, int ilow, int ihi );
00180 template <class T> void getFewEigenValues( Vector_<T>& values, int ilow, int ihi );
00181
00183 template <class VAL, class VEC> void getFewEigenValuesAndVectors( Vector_<VAL>& values, Matrix_<VEC>& vectors, typename CNT<VAL>::TReal rlow, typename CNT<VAL>::TReal rhi);
00185 template <class T> void getFewEigenVectors( Matrix_<T>& vectors, typename CNT<T>::TReal rlow, typename CNT<T>::TReal rhi );
00187 template <class T> void getFewEigenValues( Vector_<T>& values, typename CNT<T>::TReal rlow, typename CNT<T>::TReal rhi );
00188
00189
00190 protected:
00191 class EigenRepBase *rep;
00192
00193 };
00197 class SimTK_SIMMATH_EXPORT FactorSVD: public Factor {
00198 public:
00199
00200 ~FactorSVD();
00202 FactorSVD();
00204 FactorSVD( const FactorSVD& c );
00206 FactorSVD& operator=(const FactorSVD& rhs);
00207
00209 template < class ELT > FactorSVD( const Matrix_<ELT>& m );
00212 template < class ELT > FactorSVD( const Matrix_<ELT>& m, float rcond );
00215 template < class ELT > FactorSVD( const Matrix_<ELT>& m, double rcond );
00217 template < class ELT > void factor( const Matrix_<ELT>& m );
00220 template < class ELT > void factor( const Matrix_<ELT>& m, float rcond );
00223 template < class ELT > void factor( const Matrix_<ELT>& m, double rcond );
00224
00226 template < class T > void getSingularValuesAndVectors( Vector_<typename CNT<T>::TReal>& values,
00227 Matrix_<T>& leftVectors, Matrix_<T>& rightVectors );
00229 template < class T > void getSingularValues( Vector_<T>& values);
00230
00232 int getRank();
00234 template < class ELT > void inverse( Matrix_<ELT>& m );
00236 template <class ELT> void solve( const Vector_<ELT>& b, Vector_<ELT>& x );
00239 template <class ELT> void solve( const Matrix_<ELT>& b, Matrix_<ELT>& x );
00240
00241 protected:
00242 class FactorSVDRepBase *rep;
00243
00244 };
00245
00246 }
00247
00248 #endif //SimTK_LINEAR_ALGEBRA_H_