📄 subscript.cpp
字号:
tseries operator[](mask& m) const { unsigned int mask_size = m.size(); // if mask is not same size as rows of tseries, then we cannot proceed if(mask_size!=rows) { cerr << "tseries& operator[](const mask m): bad mask." << endl; return tseries(); } // init ans to size of elements of mask which are TRUE unsigned int ans_rows = m.total_true(); tseries ans(ans_rows,cols); // loop through mask unsigned int ans_row = 0; double* ans_data = ans.getData(); DateT* ans_dates = ans.getDates(); // loop through mask and set elements of new ans whenever mask is TRUE for(unsigned int i = 0; i < mask_size; i++) { if(m[i]) { ans_dates[ans_row] = dates[i]; for(unsigned int c = 0; c < cols; c++) { ans_data[ans_row + c*ans_rows] = data[i + c*rows]; } ans_row++; } } // set colnames of new answer ans.setColNames(colnames); return ans;}// when [] is used w/ a string it is just an alias for getColTStseries operator[](const string s) const { return getColTS(s);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -