1 | #include <itpp/itbase.h> |
---|
2 | #include "chmat.h" |
---|
3 | |
---|
4 | using namespace itpp; |
---|
5 | |
---|
6 | //using std::endl; |
---|
7 | |
---|
8 | |
---|
9 | void chmat::opupdt ( const vec &v, double w ) { |
---|
10 | //TODO see cholupdt in lhotse |
---|
11 | mat Z; |
---|
12 | mat R; |
---|
13 | mat V(1,v.length()); |
---|
14 | V.set_row(0,v*w); |
---|
15 | Z = concat_vertical ( Ch,V ); |
---|
16 | qr ( Z,R ); |
---|
17 | Ch = R ( 0, Ch.rows()-1, 0, Ch.cols()-1 ); |
---|
18 | }; |
---|
19 | inline mat chmat::to_mat() {mat F=Ch.T() *Ch;return F;}; |
---|
20 | void chmat::mult_sym ( const mat &C ) { |
---|
21 | it_error ( "not implemented" ); |
---|
22 | }; |
---|
23 | void chmat::mult_sym ( const mat &C , chmat &U ) const { |
---|
24 | it_error ( "not implemented" ); |
---|
25 | }; |
---|
26 | void chmat::mult_sym_t ( const mat &C ) { |
---|
27 | it_error ( "not implemented" ); |
---|
28 | }; |
---|
29 | void chmat::mult_sym_t ( const mat &C, chmat &U ) const { |
---|
30 | it_error ( "not implemented" ); |
---|
31 | }; |
---|
32 | double chmat::logdet() const { |
---|
33 | double ldet=0.0; int i; |
---|
34 | //sum of logs of (possibly negative!) diagonal entries |
---|
35 | for ( i=0;i<Ch.rows();i++ ) {ldet+=log ( std::fabs ( Ch ( i,i ) ) );} |
---|
36 | return 2*ldet; //compensate for Ch being sqrt() |
---|
37 | }; |
---|
38 | //TODO can be done more efficiently using BLAS, see triangular matrices |
---|
39 | inline vec chmat::sqrt_mult ( const vec &v ) const {vec pom; pom = Ch*v; return pom;}; |
---|
40 | inline double chmat::qform ( const vec &v ) const {vec pom; pom = Ch*v; return pom*pom;}; |
---|
41 | inline double chmat::invqform ( const vec &v ) const { |
---|
42 | vec pom(v.length()); |
---|
43 | forward_substitution(Ch.T(),v,pom); |
---|
44 | return pom*pom; |
---|
45 | }; |
---|
46 | inline void chmat::clear() {Ch.clear();}; |
---|