当前位置: 首页>>代码示例>>C++>>正文


C++ Signal::firstIndex方法代码示例

本文整理汇总了C++中Signal::firstIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Signal::firstIndex方法的具体用法?C++ Signal::firstIndex怎么用?C++ Signal::firstIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Signal的用法示例。


在下文中一共展示了Signal::firstIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addUpsampleAndOperateOn

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
void Filter::addUpsampleAndOperateOn(const Signal &s,Signal &r) const {
//TRACER_CALL(t,"Filter::addUpsampleAndOperateOn");
#ifdef DEBUG
//cout << "\ts = " << s.firstIndex() << " " << s.lastIndex() << endl;
//cout << "\tr = " << r.firstIndex() << " " << r.lastIndex() << endl;
#endif
  int signal_start=s.firstIndex();
  int signal_finish=s.lastIndex();
  int impulse_start=impulse_response->firstIndex();
  int impulse_finish=impulse_response->lastIndex();
  int result_start=impulse_start+2*signal_start;
  int result_finish=impulse_finish+2*signal_finish;
#ifdef DEBUG
//cout << "\timpulse = " << impulse_start << " " << impulse_finish << endl;
//cout << "\tresult = " << result_start << " " << result_finish << endl;
#endif
  CHECK_TEST(result_start>=r.firstIndex());
  CHECK_TEST(result_finish<=r.lastIndex());
#ifdef DEBUG
//for (int n=impulse_response->firstIndex();
//n<=impulse_response->lastIndex();n++) {
//  cout << "\timpulse_response[ " << n << "] = "
//       << impulse_response->value(n) << endl;
//}
//for (int n=s.firstIndex();n<=s.lastIndex();n++) {
//  cout << "\ts[ " << n << "] = " << s.value(n) << endl;
//  cout << "\tn = " << n << endl;
//}
//for (int n=r.firstIndex();n<=r.lastIndex();n++) {
//  cout << "\tr[ " << n << "] = " << r.value(n) << endl;
//}
#endif

  for (int n=result_start;n<=result_finish;n++) {
    double sum=0.;
    int m_start=max(signal_start,(n-impulse_finish)/2);
    if (2*m_start<n-impulse_finish) m_start++;
    int m_finish=min(signal_finish,(n-impulse_start)/2);
    if (2*m_finish>n-impulse_start) m_finish--;
    for (int m=m_start;m<=m_finish;m++) {
      sum+=s.value(m)*impulse_response->value(n-2*m);
    }
    r.value(n)+=sum;
  }
#ifdef DEBUG
//for (int n=r.firstIndex();n<=r.lastIndex();n++) {
//  cout << "\tr[ " << n << "] = " << r.value(n) << endl;
//}
#endif
}
开发者ID:akonneker,项目名称:scicomp,代码行数:51,代码来源:Filter.C

示例2: operateOn

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
void Filter::operateOn(const Signal &s,Signal &r) const {
//TRACER_CALL(t,"Filter::operateOn");
  int signal_start=s.firstIndex();
  int signal_finish=s.lastIndex();
  int impulse_start=impulse_response->firstIndex();
  int impulse_finish=impulse_response->lastIndex();
  int result_start=signal_start+impulse_start;
  int result_finish=signal_finish+impulse_finish;
  CHECK_TEST(result_start>=r.firstIndex());
  CHECK_TEST(result_finish<=r.lastIndex());

  for (int n=result_start;n<=result_finish;n++) {
    double sum=0.;
    int m_start=max(signal_start,n-impulse_finish);
    int m_finish=min(signal_finish,n-impulse_start);
    for (int m=m_start;m<=m_finish;m++) {
      sum+=s.value(m)*impulse_response->value(n-m);
    }
    r.value(n)=sum;
  }
}
开发者ID:akonneker,项目名称:scicomp,代码行数:22,代码来源:Filter.C

示例3: operateOnAndDownsample

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
void Filter::operateOnAndDownsample(const Signal &s,Signal &r) const {
//TRACER_CALL(t,"Filter::operateOnAndDownsample");
  int signal_start=s.firstIndex();
  int signal_finish=s.lastIndex();
  int impulse_start=impulse_response->firstIndex();
  int impulse_finish=impulse_response->lastIndex();
  int result_start=(signal_start+impulse_start)/2;
  int result_finish=(signal_finish+impulse_finish)/2;
  CHECK_TEST(result_start>=r.firstIndex());
  CHECK_TEST(result_finish<=r.lastIndex());
#ifdef DEBUG
//for (int n=impulse_response->firstIndex();
//n<=impulse_response->lastIndex();n++) {
//  cout << "\timpulse_response[ " << n << "] = "
//       << impulse_response->value(n) << endl;
//}
//for (int n=s.firstIndex();n<=s.lastIndex();n++) {
//  cout << "\ts[ " << n << "] = " << s.value(n) << endl;
//}
#endif

  for (int n=result_start;n<=result_finish;n++) {
    double sum=0.;
    int m_start=max(signal_start,2*n-impulse_finish);
    int m_finish=min(signal_finish,2*n-impulse_start);
#ifdef DEBUG
//  cout << "\tn,m_start,m_finish = " << n << " " << m_start << " "
//       << m_finish << endl;
#endif
    for (int m=m_start;m<=m_finish;m++) {
      sum+=s.value(m)*impulse_response->value(2*n-m);
    }
    r.value(n)=sum;
  }
#ifdef DEBUG
//for (int n=r.firstIndex();n<=r.lastIndex();n++) {
//  cout << "\tr[ " << n << "] = " << r.value(n) << endl;
//}
#endif
}
开发者ID:akonneker,项目名称:scicomp,代码行数:41,代码来源:Filter.C


注:本文中的Signal::firstIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。