Dynamic Time Warping Distance
- RISCV_DSP_ATTRIBUTE riscv_status riscv_dtw_distance_f32 (const riscv_matrix_instance_f32 *pDistance, const riscv_matrix_instance_q7 *pWindow, riscv_matrix_instance_f32 *pDTW, float32_t *distance)
- RISCV_DSP_ATTRIBUTE riscv_status riscv_dtw_init_window_q7 (const riscv_dtw_window windowType, const int32_t windowSize, riscv_matrix_instance_q7 *pWindow)
- RISCV_DSP_ATTRIBUTE void riscv_dtw_path_f32 (const riscv_matrix_instance_f32 *pDTW, int16_t *pPath, uint32_t *pathLength)
- group DTW
Dynamic Time Warping Distance.
This is not really a distance since triangular inequality is not respected.
The step pattern used is symmetric2. Future versions of this function will provide more customization options.
Functions
- RISCV_DSP_ATTRIBUTE riscv_status riscv_dtw_distance_f32 (const riscv_matrix_instance_f32 *pDistance, const riscv_matrix_instance_q7 *pWindow, riscv_matrix_instance_f32 *pDTW, float32_t *distance)
Dynamic Time Warping distance.
The windowing matrix is used to impose some constraints on the search for a path. The algorithm will run faster (smaller search path) but may not be able to find a solution.
- Windowing matrix
The distance matrix must be initialized only where the windowing matrix is containing 1. Thus, use of a window also decreases the number of distances which must be computed.
- Parameters
pDistance – [in] Distance matrix (Query rows * Template columns)
pWindow – [in] Windowing matrix (can be NULL if no windowing used)
pDTW – [out] Temporary cost buffer (same size)
distance – [out] Distance
- Returns
RISCV_MATH_ARGUMENT_ERROR in case no path can be found with window constraint
- RISCV_DSP_ATTRIBUTE riscv_status riscv_dtw_init_window_q7 (const riscv_dtw_window windowType, const int32_t windowSize, riscv_matrix_instance_q7 *pWindow)
Window for dynamic time warping computation.
The input matrix must already contain a buffer and the number of rows (query length) and columns (template length) must be initialized. The function will fill the matrix with 0 and 1.
- Windowing matrix
The window matrix will contain 1 for the position which are accepted and 0 for the positions which are rejected.
- Parameters
windowType – [in] Type of window
windowSize – [in] Window size
pWindow – [inout] Window
- Returns
Error if window type not recognized
- RISCV_DSP_ATTRIBUTE void riscv_dtw_path_f32 (const riscv_matrix_instance_f32 *pDTW, int16_t *pPath, uint32_t *pathLength)
Mapping between query and template.
The warping path has length which is at most 2*(query length + template length) in float. 2 because it is a list of coordinates : (query index, template index) coordinate.
- Warping path
The buffer pPath must be big enough to contain the warping path.
pathLength is the number of points in the returned path. The resturned path may be smaller than query + template.
- Parameters
pDTW – [in] Cost matrix (Query rows * Template columns)
pPath – [out] Warping path in cost matrix 2*(nb rows + nb columns)
pathLength – [out] Length of path in number of points