wccCalcBatch: Batched Windowed Cross Correlation

View source: R/wccCalcBatch.R

wccCalcBatchR Documentation

Batched Windowed Cross Correlation

Description

Computes the Windowed Cross Correlation grid for a list of series pairs in one call, reusing per-series prefix sums across pairs. Real dyads and surrogate pairings drawn from the same series pool can therefore be evaluated together cheaply.

Usage

wccCalcBatch(seriesArray1, seriesArray2, pairs=NULL,
             wMax=50, tMax=50, wInc=1, tInc=1, method=c("cumc"))

Arguments

seriesArray1

A D1 x n numeric matrix; each row is one series. When pairs is not supplied, seriesArray1 and seriesArray2 must have the same number of rows.

seriesArray2

A D2 x n numeric matrix; each row is one series. Must have the same number of columns as seriesArray1.

pairs

A P x 2 integer matrix; row p selects the pair (seriesArray1[pairs[p,1],], seriesArray2[pairs[p,2],]). When NULL (default), it is set to cbind(1:D, 1:D), i.e. the real dyads.

wMax

Window size in samples (default=50). Must be at least 5.

tMax

Maximum lag in samples (default=50).

wInc

Window increment in samples (default=1).

tInc

Lag increment in samples (default=1).

method

Backend for the batched computation. Currently only "cumc" (batched cumulative-sum C backend) is available on the CPU-only build.

Details

Missing data is not supported: any NA in seriesArray1 or seriesArray2 raises an error.

The C backend computes per-series prefix sums once and reuses them across all pairs, so the batched call scales with the number of unique series rather than the number of pairs. This makes the function particularly efficient when many surrogate pairings are drawn from a small pool of series, as in wccSurrogateDyads and wccFindDyadParam.

Value

An nRow x nCol x P numeric array. Slab [,,p] equals wccCalc(seriesArray1[pairs[p,1],], seriesArray2[pairs[p,2],], wMax=wMax, tMax=tMax, wInc=wInc, tInc=tInc, method="cumc").

See Also

wccCalc for the single-dyad interface and the definition of the returned grid.

Examples

D <- 3
n <- 500
arr1 <- t(sapply(1:D, function(i) sin(c(1:n)/10) + rnorm(n, sd=.5)))
arr2 <- t(sapply(1:D, function(i) sin(c(1:n)/12) + rnorm(n, sd=.5)))
grids <- wccCalcBatch(arr1, arr2, wMax=50, tMax=50)
dim(grids)

wcc documentation built on July 14, 2026, 5:07 p.m.