Changeset 76 for bdm/math/chmat.cpp

Show
Ignore:
Timestamp:
04/18/08 14:01:20 (16 years ago)
Author:
smidl
Message:

oprava chol + invqform

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/math/chmat.cpp

    r39 r76  
    1111        mat Z; 
    1212        mat R; 
    13         mat Q; 
    14         Z = concat_vertical ( Ch,mat(w*v) ); 
    15          qr ( Z,Q,R ); 
     13        mat V(1,v.length()); 
     14        V.set_row(0,v*w); 
     15        Z = concat_vertical ( Ch,V ); 
     16        qr ( Z,R ); 
    1617        Ch = R ( 0, Ch.rows()-1, 0, Ch.cols()-1 ); 
    1718}; 
    18 inline mat chmat::to_mat(){mat F=Ch.T()*Ch;return F;}; 
     19inline mat chmat::to_mat() {mat F=Ch.T() *Ch;return F;}; 
    1920void chmat::mult_sym ( const mat &C ) { 
    20 it_error("not implemented"); 
     21        it_error ( "not implemented" ); 
    2122}; 
    22 void chmat::mult_sym ( const mat &C , chmat &U) const { 
    23 it_error("not implemented"); 
     23void chmat::mult_sym ( const mat &C , chmat &U ) const { 
     24        it_error ( "not implemented" ); 
    2425}; 
    2526void chmat::mult_sym_t ( const mat &C ) { 
    26 it_error("not implemented"); 
     27        it_error ( "not implemented" ); 
    2728}; 
    2829void chmat::mult_sym_t ( const mat &C, chmat &U ) const { 
    29 it_error("not implemented"); 
     30        it_error ( "not implemented" ); 
    3031}; 
    3132double chmat::logdet() const { 
    3233        double ldet=0.0; int i; 
    3334        //sum of logs of (possibly negative!) diagonal entries 
    34         for (i=0;i<Ch.rows();i++ ) {ldet+=log ( std::fabs(Ch ( i,i )) );} 
     35        for ( i=0;i<Ch.rows();i++ ) {ldet+=log ( std::fabs ( Ch ( i,i ) ) );} 
    3536        return 2*ldet; //compensate for Ch being sqrt() 
    3637}; 
     
    3839inline vec chmat::sqrt_mult ( const vec &v ) const {vec pom; pom = Ch*v; return pom;}; 
    3940inline 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}; 
    4046inline void chmat::clear() {Ch.clear();};