//* 不同采样率的道互相关函数
02.void DisDtCorrelativity(float &_af, float *_TracePick, float *_Trace, int _Len,
03. int _Dt, int _Index)
04.//** _af :互相关函数
05.//** _TracePick : trace one 错动道
06.//** _Trace : 相关参考道
07.//** _Index : 错动样点个数
08.//** _Len : 相关段长度
09.//** _Dt : 采样率差别倍数
10.{
11. double sum11 = 0.0;
12. double sum22 = 0.0;
13. double sum1 = 0.0;
14. double sum2 = 0.0;
15. double sum12 = 0.0;
16.
17. for (int i=0; i<_Len; i++)
18. {
19. int k = _Dt * i + _Index;
20. sum1 = sum1 + _Trace[i];
21. sum2 = sum2 + _TracePick[k];
22. sum12 = sum12 + _Trace[i] * _TracePick[k];
23. sum11 = sum11 + _Trace[i] * _Trace[i];
24. sum22 = sum22 + _TracePick[k] * _TracePick[k];
25. }
26. double aa = (sum11*_Len-sum1*sum1) * (sum22*_Len-sum2*sum2);
27. if (aa <= 0)
28. {
29. _af = 0.0;
30. return;
31. }
32. double a = sqrt(aa);
33. double b = (sum12*_Len - sum1*sum2);
34. _af = b/a;
35.}
转载于:https://my.oschina.net/u/582827/blog/1499074