41 const int nSig =
static_cast<int>(matData.rows());
42 const int nSamples =
static_cast<int>(matData.cols());
44 MatrixXd aec = MatrixXd::Identity(nSig, nSig);
46 if (nSig < 2 || nSamples < 2)
50 MatrixXd envs(nSig, nSamples);
51 for (
int i = 0; i < nSig; ++i) {
56 for (
int i = 0; i < nSig; ++i) {
57 for (
int j = i + 1; j < nSig; ++j) {
71 const int nSig =
static_cast<int>(matData.rows());
72 const int nSamples =
static_cast<int>(matData.cols());
74 MatrixXd aec = MatrixXd::Identity(nSig, nSig);
76 if (nSig < 2 || nSamples < 2)
80 for (
int i = 0; i < nSig; ++i) {
81 VectorXd si = matData.row(i).transpose();
84 for (
int j = i + 1; j < nSig; ++j) {
85 VectorXd sj = matData.row(j).transpose();
88 double siNorm2 = si.squaredNorm();
91 sjOrth_ij = sj - (sj.dot(si) / siNorm2) * si;
99 double sjNorm2 = sj.squaredNorm();
102 siOrth_ji = si - (si.dot(sj) / sjNorm2) * sj;
111 double r = (r_ij + r_ji) / 2.0;
124 const Index n = signal.size();
125 const Index nPad = std::max<Index>(nFft, n);
129 VectorXd padded = VectorXd::Zero(nPad);
130 padded.head(n) = signal;
133 fft.SetFlag(FFT<double>::HalfSpectrum);
135 fft.fwd(half, padded);
138 VectorXcd spec = VectorXcd::Zero(nPad);
139 spec.head(half.size()) = half;
140 spec.segment(1, (nPad - 1) / 2) *= 2.0;
142 fft.ClearFlag(FFT<double>::HalfSpectrum);
144 fft.inv(analytic, spec);
145 return analytic.head(n).cwiseAbs();
152 const int n =
static_cast<int>(a.size());
153 if (n < 2 || b.size() != n)
156 double meanA = a.mean();
157 double meanB = b.mean();
159 VectorXd ac = a.array() - meanA;
160 VectorXd bc = b.array() - meanB;
162 double stdA = std::sqrt(ac.squaredNorm() /
static_cast<double>(n - 1));
163 double stdB = std::sqrt(bc.squaredNorm() /
static_cast<double>(n - 1));
165 if (stdA < 1e-15 || stdB < 1e-15)
168 return ac.dot(bc) / (
static_cast<double>(n - 1) * stdA * stdB);