]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/choleski.hh
f4b5e2981499438255bd4b0cd5613ff82bfdd012
[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   /// diagonal 
20   Vector D;
21
22   /** Create decomposition of P. 
23     PRE
24     P needs to be symmetric positive definite
25     */
26     
27   Choleski_decomposition (Matrix const &P);
28
29   /**
30     solve Px = rhs
31     */
32   Vector solve (Vector rhs) const;
33   void solve (Vector &dest, Vector const &rhs) const;
34   Vector operator * (Vector rhs) const { return solve (rhs); }
35   /**
36     return the inverse of the matrix P.
37     */
38   Matrix inverse() const;
39   /**
40     return P,  calc'ed from L and D
41     */
42   Matrix original() const;
43 private:
44   void full_matrix_solve (Vector &,Vector const&) const;
45   void band_matrix_solve (Vector &, Vector const&) const;
46   void full_matrix_decompose (Matrix const & P);
47   void band_matrix_decompose (Matrix const &P);
48          
49 };
50 #endif