⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comparison.ops.template.cpp

📁 神经网络是序列预测,C++实现
💻 CPP
字号:
friend mask operator_OP_(const tseries<DateT>& left, const tseries<DateT>& right) {  // only support equal number of columns for now  if(left.cols!=right.cols) {                           cerr << "tseries comparison: unequal number of cols." << endl;    return mask();  }  // find intersection  RangeSpecifier<DateT> range(left.dates,right.dates,left.rows,right.rows);  // if intersection is empty return empty mask  if(range.size==0) {    return mask();  }  // alloc new mask  bool *ans_data = new bool[range.size*left.cols];  // check memory  if(ans_data==NULL) {    cerr << "tseries comparison: out of memory." << endl;    return mask();  }  // for looping  double *left_col, *right_col;  // loop through cols  for(unsigned int c = 0; c < left.cols; c++) {    left_col = &left.data[c*left.rows];    right_col = &right.data[c*right.rows];    // loop through rows    for(unsigned int r = 0; r < range.size; r++) {      ans_data[r+c*range.size] = (left_col[ range.arg1[r] ] _OP_ right_col[ range.arg2[r] ]) ? true : false;    }  }  // hopefully RVO  return mask(ans_data,range.size*left.cols);}friend mask operator_OP_(const tseries<DateT>& left,const double& right) {  unsigned int len = left.rows*left.cols;  bool* ans = new bool[len];  // check memory  if(ans==NULL) {    cerr << "operator_OP_ out of memory." << endl;    return mask();  }  // loop and do test  for(unsigned int i=0; i < len; i++) {    ans[i] = (left.data[i] _OP_ right) ? true : false;  }  // RVO hopefullly  return mask(ans,len);}friend mask operator_OP_(const double& left, const tseries<DateT>& right) {  unsigned int len = right.rows*right.cols;  bool* ans = new bool[len];  // check memory  if(ans==NULL) {    cerr << "operator_OP_ out of memory." << endl;    return mask();  }  // loop and do test  for(unsigned int i=0; i < len; i++) {    ans[i] = (right.data[i] _OP_ left) ? true : false;  }  // RVO hopefullly  return mask(ans,len);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -