        if (idx_cluster[off_i + k] != idx_cluster[off_j + k]) {
            return;
        }
    }
    atomicAdd(&cp_out[dt], 1);
}

__global__ void ion_pair_corr_ani(const unsigned int* idx_pair,
                                  const unsigned int* idx_cluster,
                                  int n_frames,
                                  int n_ani,
                                  int max_cluster,
                                  unsigned int* ip_out,
                                  unsigned int* cp_out) {
    int j = blockIdx.x * blockDim.x + threadIdx.x;
    int i = blockIdx.y;
    int ani = blockIdx.z;
    if (i >= n_frames || j >= n_frames || ani >= n_ani) return;
    if (j < i) return;
    int dt = j - i;
    unsigned int a = idx_pair[i * n_ani + ani];
    unsigned int b = idx_pair[j * n_ani + ani];
    if (a == b) {
        atomicAdd(&ip_out[dt], 1);
    }
    int off_i = (i * n_ani + ani) * max_cluster;
    int off_j = (j * n_ani + ani) * max_cluster;
    for (int k = 0; k < max_cluster; k++) {
        if (idx_cluster[off_i + k] != idx_cluster[off_j + k]) {
            return;
        }
    }
    atomicAdd(&cp_out[dt], 1);
}
