Show
Ignore:
Timestamp:
08/05/09 14:40:03 (15 years ago)
Author:
mido
Message:

panove, vite, jak jsem peclivej na upravu kodu.. snad se vam bude libit:) konfigurace je v souboru /system/astylerc

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/math/chmat.cpp

    r455 r477  
    99        mat Z; 
    1010        mat R; 
    11         mat V(1,v.length()); 
    12         V.set_row(0,v*sqrt(w)); 
    13         Z = concat_vertical ( Ch,V ); 
    14         qr ( Z,R ); 
    15         Ch = R ( 0, Ch.rows()-1, 0, Ch.cols()-1 ); 
     11        mat V ( 1, v.length() ); 
     12        V.set_row ( 0, v*sqrt ( w ) ); 
     13        Z = concat_vertical ( Ch, V ); 
     14        qr ( Z, R ); 
     15        Ch = R ( 0, Ch.rows() - 1, 0, Ch.cols() - 1 ); 
    1616}; 
    17 mat chmat::to_mat() const {mat F=Ch.T() *Ch;return F;}; 
     17mat chmat::to_mat() const { 
     18        mat F = Ch.T() * Ch; 
     19        return F; 
     20}; 
    1821void chmat::mult_sym ( const mat &C ) { 
    19         it_assert_debug(C.rows()==dim, "Wrong dimension of U"); 
    20         if(!qr(Ch*C.T(), Ch)) {it_warning("QR unstable in chmat mult_sym");} 
     22        it_assert_debug ( C.rows() == dim, "Wrong dimension of U" ); 
     23        if ( !qr ( Ch*C.T(), Ch ) ) { 
     24                it_warning ( "QR unstable in chmat mult_sym" ); 
     25        } 
    2126}; 
    2227void chmat::mult_sym ( const mat &C , chmat &U ) const { 
    23         it_assert_debug(C.rows()==U.dim, "Wrong dimension of U"); 
    24         if(!qr(Ch*C.T(), U.Ch)) {it_warning("QR unstable in chmat mult_sym");} 
     28        it_assert_debug ( C.rows() == U.dim, "Wrong dimension of U" ); 
     29        if ( !qr ( Ch*C.T(), U.Ch ) ) { 
     30                it_warning ( "QR unstable in chmat mult_sym" ); 
     31        } 
    2532}; 
    2633void chmat::mult_sym_t ( const mat &C ) { 
    27         it_assert_debug(C.cols()==dim, "Wrong dimension of U"); 
    28         if(!qr(Ch*C, Ch)) {it_warning("QR unstable in chmat mult_sym");} 
     34        it_assert_debug ( C.cols() == dim, "Wrong dimension of U" ); 
     35        if ( !qr ( Ch*C, Ch ) ) { 
     36                it_warning ( "QR unstable in chmat mult_sym" ); 
     37        } 
    2938}; 
    3039void chmat::mult_sym_t ( const mat &C, chmat &U ) const { 
    31         it_assert_debug(C.cols()==U.dim, "Wrong dimension of U"); 
    32         if(!qr(Ch*C, U.Ch)) {it_warning("QR unstable in chmat mult_sym");} 
     40        it_assert_debug ( C.cols() == U.dim, "Wrong dimension of U" ); 
     41        if ( !qr ( Ch*C, U.Ch ) ) { 
     42                it_warning ( "QR unstable in chmat mult_sym" ); 
     43        } 
    3344}; 
    3445double chmat::logdet() const { 
    35         double ldet=0.0; int i; 
     46        double ldet = 0.0; 
     47        int i; 
    3648        //sum of logs of (possibly negative!) diagonal entries 
    37         for ( i=0;i<Ch.rows();i++ ) {ldet+=log ( std::fabs ( Ch ( i,i ) ) );} 
     49        for ( i = 0; i < Ch.rows(); i++ ) { 
     50                ldet += log ( std::fabs ( Ch ( i, i ) ) ); 
     51        } 
    3852        return 2*ldet; //compensate for Ch being sqrt() 
    3953}; 
    4054//TODO can be done more efficiently using BLAS, see triangular matrices 
    41 vec chmat::sqrt_mult ( const vec &v ) const {vec pom; pom = Ch*v; return pom;}; 
    42 double chmat::qform ( const vec &v ) const {vec pom; pom = Ch*v; return pom*pom;}; 
    43 double chmat::invqform ( const vec &v ) const { 
    44         vec pom(v.length()); 
    45         forward_substitution(Ch.T(),v,pom); 
     55vec chmat::sqrt_mult ( const vec &v ) const { 
     56        vec pom; 
     57        pom = Ch * v; 
     58        return pom; 
     59}; 
     60double chmat::qform ( const vec &v ) const { 
     61        vec pom; 
     62        pom = Ch * v; 
    4663        return pom*pom; 
    4764}; 
    48 void chmat::clear() {Ch.clear();}; 
     65double chmat::invqform ( const vec &v ) const { 
     66        vec pom ( v.length() ); 
     67        forward_substitution ( Ch.T(), v, pom ); 
     68        return pom*pom; 
     69}; 
     70void chmat::clear() { 
     71        Ch.clear(); 
     72};