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 Q; |
---|
14 | Z = concat_vertical ( Ch,mat(w*v) ); |
---|
15 | qr ( Z,Q,R ); |
---|
16 | Ch = R ( 0, Ch.rows()-1, 0, Ch.cols()-1 ); |
---|
17 | }; |
---|
18 | inline mat chmat::to_mat(){mat F=Ch.T()*Ch;return F;}; |
---|
19 | void chmat::mult_sym ( const mat &C ) { |
---|
20 | it_error("not implemented"); |
---|
21 | }; |
---|
22 | void chmat::mult_sym ( const mat &C , chmat &U) const { |
---|
23 | it_error("not implemented"); |
---|
24 | }; |
---|
25 | void chmat::mult_sym_t ( const mat &C ) { |
---|
26 | it_error("not implemented"); |
---|
27 | }; |
---|
28 | void chmat::mult_sym_t ( const mat &C, chmat &U ) const { |
---|
29 | it_error("not implemented"); |
---|
30 | }; |
---|
31 | double chmat::logdet() const { |
---|
32 | double ldet=0.0; int i; |
---|
33 | //sum of logs of (possibly negative!) diagonal entries |
---|
34 | for (i=0;i<Ch.rows();i++ ) {ldet+=log ( std::fabs(Ch ( i,i )) );} |
---|
35 | return 2*ldet; //compensate for Ch being sqrt() |
---|
36 | }; |
---|
37 | //TODO can be done more efficiently using BLAS, see triangular matrices |
---|
38 | inline vec chmat::sqrt_mult ( const vec &v ) const {vec pom; pom = Ch*v; return pom;}; |
---|
39 | inline double chmat::qform ( const vec &v ) const {vec pom; pom = Ch*v; return pom*pom;}; |
---|
40 | inline void chmat::clear() {Ch.clear();}; |
---|