Changeset 1030

Show
Ignore:
Timestamp:
06/02/10 13:53:29 (14 years ago)
Author:
prikryl
Message:

Corrected win32-specific error: pow(2,n) calls on these systems are ambiguous (there are three variants of pow() with different double/float/long double parameters). Replaced pow() with left shift and reorganised some parts of the code.

Location:
library/bdm/estim
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/estim/arx.cpp

    r1025 r1030  
    299299    int dimV = est._V().cols(); 
    300300    int nparams = dimV - 1;                 // number of parameters 
    301     int nalternatives = pow(2, nparams);    // number of alternatives 
    302      
     301    //kamil: int nalternatives = pow(2, nparams);    // number of alternatives 
     302    int nalternatives = 1 << nparams;    // number of alternatives 
     303 
    303304    // Permutation matrix 
    304305    mat perm_matrix = ones(nalternatives, nparams); 
    305306    int i, j, period, idx_from, idx_to, start, end; 
    306307    for(i = 0; i < nparams; i++) { 
    307         idx_from = pow(2, i); 
    308         idx_to = 2 * pow(2, i) - 1; 
    309         period = pow(2, i+1); 
    310         j = 0; 
     308        // kamil: idx_from = pow(2, i); 
     309                // kamil: idx_to = 2 * pow(2, i) - 1; 
     310                // kamil: period = pow(2, i+1); 
     311        // jp: what about this? 
     312                idx_from = 1 << i; 
     313                period   = ( idx_from << 1 ); 
     314        idx_to   = period - 1; 
     315        // end:jp 
     316                j = 0; 
    311317        start = idx_from; 
    312318        end = idx_to; 
    313         while(start < pow(2, nparams)) { 
     319        // kamil: while(start < pow(2, nparams)) { 
     320                while ( start < nalternatives ) { 
    314321            perm_matrix.set_submatrix(start, end, i, i, 0); 
    315322            j++; 
     
    337344        } 
    338345 
    339         nalternatives_cond = sum(vec_alt) + 1; 
     346        // kamil: nalternatives_cond = sum(vec_alt) + 1; 
     347        nalternatives_cond = (int) sum(vec_alt) + 1; 
    340348        ivec vec_perm(0);                   // permutation vector 
    341349 
  • library/bdm/estim/arx.h

    r1025 r1030  
    263263        void validate() { 
    264264                ARX::validate(); 
    265                 int philen = pow(2, est._V().cols() - 1); 
     265                // kamil: int philen = pow(2, est._V().cols() - 1); 
     266                // but under win32 this call is ambiguous, and moreover it uses 
     267                // floats to compute 2^n ... 
     268                int philen = 1 << (est._V().cols() - 1); 
    266269                rvc.add ( RV ( "{phi }", vec_1(philen) ) ); // pocet 2^parametru 
    267270                dimc += philen;