root/bdm/math/chmat.cpp @ 76

Revision 76, 1.3 kB (checked in by smidl, 16 years ago)

oprava chol + invqform

  • Property svn:eol-style set to native
Line 
1#include <itpp/itbase.h>
2#include "chmat.h"
3
4using namespace itpp;
5
6//using std::endl;
7
8
9void 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};
19inline mat chmat::to_mat() {mat F=Ch.T() *Ch;return F;};
20void chmat::mult_sym ( const mat &C ) {
21        it_error ( "not implemented" );
22};
23void chmat::mult_sym ( const mat &C , chmat &U ) const {
24        it_error ( "not implemented" );
25};
26void chmat::mult_sym_t ( const mat &C ) {
27        it_error ( "not implemented" );
28};
29void chmat::mult_sym_t ( const mat &C, chmat &U ) const {
30        it_error ( "not implemented" );
31};
32double 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
39inline vec chmat::sqrt_mult ( const vec &v ) const {vec pom; pom = Ch*v; return pom;};
40inline double chmat::qform ( const vec &v ) const {vec pom; pom = Ch*v; return pom*pom;};
41inline double chmat::invqform ( const vec &v ) const {
42        vec pom(v.length());
43        forward_substitution(Ch.T(),v,pom);
44        return pom*pom;
45};
46inline void chmat::clear() {Ch.clear();};
Note: See TracBrowser for help on using the browser.