Menu

#6 Saint express crashing

v1.0 (example)
open
nobody
None
5
2015-08-21
2015-08-21
hector
No

I encountered following problem: The variable t is nan

Assume following case, 2000 data rows, one control ip. This means that the inner array tmp can just have one element (because the inner loop runs once).
Assuming the current i is such that the data is missing, i.e., isnan(DATA(i,j)) == TRUE ==> full=false;. Since we just have one control the loop is finished and tmp has ZERO elements. Zero elements are than added to the end of ctrls_with_NA.
Based on (in our case empty) cntrl_with_NA the average is calculated and t set. In our case to -1#IND. This produces later an exception.

vector<Quant_t> ctrls_with_NA;
for(unsigned i=0; i<ctrl_mat_DATA.n_rows;++i){
    bool full=true;
    vector<Quant_t> tmp;
    for(unsigned j=0;j<n_ctrl_ip;++j){
        if(saint::isnan(ctrl_mat_DATA(i,j))) full=false;
        else tmp.push_back(ctrl_mat_DATA(i,j));
    }
    if(!full)
        ctrls_with_NA.insert(ctrls_with_NA.end(),tmp.cbegin(),tmp.cend());
}

best Etienne

PS: I think the bug is obvious form the code, therefore I will not add an example file. If needed, I can generate a simple example...

Discussion


Log in to post a comment.