本文整理汇总了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
}
示例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;
}
}
示例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
}