MathTL
|
00001 // -*- c++ -*- 00002 00003 // +--------------------------------------------------------------------+ 00004 // | This file is part of MathTL - the Mathematical Template Library | 00005 // | | 00006 // | Copyright (c) 2002-2009 | 00007 // | Thorsten Raasch, Manuel Werner | 00008 // +--------------------------------------------------------------------+ 00009 00010 #ifndef _MATHTL_MATRIX_DECOMP_H 00011 #define _MATHTL_MATRIX_DECOMP_H 00012 00013 #include <algebra/vector.h> 00014 #include <algebra/matrix.h> 00015 #include <algebra/triangular_matrix.h> 00016 #include <algebra/symmetric_matrix.h> 00017 00018 namespace MathTL 00019 { 00021 00028 template <class C> 00029 bool CholeskyDecomposition(const SymmetricMatrix<C>& A, 00030 LowerTriangularMatrix<C>& L); 00031 00041 template <class C> 00042 class QUDecomposition 00043 { 00044 public: 00046 QUDecomposition(const Matrix<C>& A); 00047 00049 bool hasFullRank() const; 00050 00052 void getU(UpperTriangularMatrix<C>& U) const; 00053 00055 void getQ(Matrix<C>& Q) const; 00056 00062 void solve(const Vector<C>& b, Vector<C>& x) const; 00063 00067 void inverse(Matrix<C>& AInv) const; 00068 00069 protected: 00071 typename Matrix<C>::size_type rowdim_, coldim_; 00073 Matrix<C> QU_; 00075 Vector<C> Udiag_; 00076 }; 00077 00079 00087 template <class C> 00088 class SVD 00089 { 00090 public: 00092 SVD(const Matrix<C>& A); 00093 00095 void getU(Matrix<C>& U) const; 00096 00098 void getUS(Matrix<C>& US) const; 00099 00101 void getS(Vector<C>& S) const { S = Sdiag_; } 00102 00104 void getV(Matrix<C>& V) const; 00105 00106 protected: 00108 typename Matrix<C>::size_type rowdim_, coldim_; 00110 Matrix<C> U_, V_; 00112 Vector<C> Sdiag_; 00113 }; 00114 00120 template <class C> 00121 class Hessenberg 00122 : public Matrix<C> 00123 { 00124 public: 00126 Hessenberg(const Matrix<C>& A); 00127 }; 00128 } 00129 00130 #include <numerics/matrix_decomp.cpp> 00131 00132 #endif