]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/choleski.hh
release: 0.1.59
[lilypond.git] / flower / include / choleski.hh
1 #ifndef CHOLESKI_HH
2 #define CHOLESKI_HH
3
4 #include "matrix.hh"
5
6 /**
7   Choleski decomposition of a matrix
8     structure for using the LU decomposition of a positive definite matrix.
9
10     #P# is split  into
11
12     LD transpose (L)
13     */
14 struct Choleski_decomposition {
15
16   /// lower triangle of Choleski decomposition
17   Matrix L;
18
19   bool band_b_;
20
21   /// diagonal 
22   Vector D;
23
24   /** Create decomposition of P. 
25     PRE
26     P needs to be symmetric positive definite
27     */
28     
29   Choleski_decomposition (Matrix const &P);
30
31   /**
32     solve Px = rhs
33     */
34   Vector solve (Vector rhs) const;
35   void solve (Vector &dest, Vector const &rhs) const;
36   Vector operator * (Vector rhs) const { return solve (rhs); }
37   /**
38     return the inverse of the matrix P.
39     */
40   Matrix inverse() const;
41   /**
42     return P,  calc'ed from L and D
43     */
44   Matrix original() const;
45 private:
46   void full_matrix_solve (Vector &,Vector const&) const;
47   void band_matrix_solve (Vector &, Vector const&) const;
48   void full_matrix_decompose (Matrix const & P);
49   void band_matrix_decompose (Matrix const &P);
50          
51 };
52 #endif