/** * Dynamic time warping between two feature sequences (or a precomputed * cost matrix). * * @param {Array|Float32Array|Float64Array>|null} X * Feature matrix, shape (d, N) — rows are features, columns are frames. * Pass null when supplying `options.C`. * @param {Array|Float32Array|Float64Array>|null} Y * Feature matrix, shape (d, M). Pass null when supplying `options.C`. * @param {Object} [options] * @param {Array>} [options.C=null] - precomputed cost matrix (N, M). * Mutually exclusive with X/Y. * @param {string} [options.metric='euclidean'] * @param {Array>} [options.stepSizesSigma=null] - custom steps, * APPENDED to the defaults. * @param {Array} [options.weightsAdd=null] - additive step weights. * @param {Array} [options.weightsMul=null] - multiplicative step weights. * @param {boolean} [options.subseq=false] - subsequence DTW. * @param {boolean} [options.backtrack=true] - also return the warping path. * @param {boolean} [options.globalConstraints=false] - Sakoe-Chiba band. * @param {number} [options.bandRad=0.25] - band radius as a fraction of min(N, M). * @param {boolean} [options.returnSteps=false] - also return the step matrix. * @returns {{D: Float64Array[], wp?: number[][], steps?: Int32Array[]}} * `D` is the (N, M) accumulated cost matrix (`D[N-1][M-1]` is the total * alignment cost). `wp` (when backtrack) is the warping path from the end * of the alignment down to its start. */ export function dtw(X?: Array | Float32Array | Float64Array> | null, Y?: Array | Float32Array | Float64Array> | null, options?: { C?: Array>; metric?: string; stepSizesSigma?: Array>; weightsAdd?: Array; weightsMul?: Array; subseq?: boolean; backtrack?: boolean; globalConstraints?: boolean; bandRad?: number; returnSteps?: boolean; }): { D: Float64Array[]; wp?: number[][]; steps?: Int32Array[]; }; /** * Backtrack a warping path from a recorded step matrix. * * @param {Int32Array[]|Array>} steps - step matrix from `dtw` * (`returnSteps: true`). * @param {Object} [options] * @param {Array>} [options.stepSizesSigma=null] - the SAME * custom steps passed to `dtw` (they are appended to the defaults here * too, so index bookkeeping matches the forward pass). * @param {boolean} [options.subseq=false] * @param {number|null} [options.start=null] - start column (subseq only). * @returns {number[][]} warping path, end-to-start. */ export function dtwBacktracking(steps: Int32Array[] | Array>, options?: { stepSizesSigma?: Array>; subseq?: boolean; start?: number | null; }): number[][];