Skip to content

CODE

ITD Implementation — NExT Cross-Correlation → Per-Pair AR(4) → Eigenvalues → Clustering

int tiny_sysid_itd(const float *data, int n_ch, int n, float fs,
                   int n_modes, tiny_sysid_result_t *result)
{
    // Step 1: NExT cross-correlation R[lag][i][j]
    float *R = calloc((L+1) * n_ch * n_ch, sizeof(float));
    for (int i = 0; i < n_ch; i++)
        for (int j = 0; j < n_ch; j++)
            for (int lag = 0; lag <= L; lag++)
                for (int t = 0; t < n - lag; t++)
                    R[lag * n_ch * n_ch + i * n_ch + j] +=
                        data[i * n + t] * data[j * n + t + lag];

    // Step 2: Per-pair AR(4) system matrix
    // M1[4][nc], M2[4][nc] → A = M2·M1⁺ → eig(A) → 4 candidates

    // Step 3: Cluster (10% freq tolerance, min 2 votes)

    // Step 4: CPSD-based mode shapes via Welch SVD
}

Design: sn=4, 5ch → 10 pairs × 4 = 40 raw candidates, 10% tolerance, min 2 votes.