subscript.cpp

来自「神经网络是序列预测,C++实现」· C++ 代码 · 共 42 行

CPP
42
字号
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 + =
减小字号Ctrl + -
显示快捷键?