dtaidistance/lib/DTAIDistanceC/DTAIDistanceC/dd_dtw_openmp.c
/*!
Distance matrix for n-dimensional DTW, executed on a 3-dimensional array and in parallel.
 
@see dtw_distances_ndim_matrix
*/
Distance matrix for n-dimensional DTW, executed on a 3-dimensional array and in parallel.
Distance matrix for n - dimensional DTW executed on a 3 - dimensional array and in parallel .
idx_t dtw_distances_ndim_matrix_parallel(seq_t *matrix, idx_t nb_rows, idx_t nb_cols, int ndim, seq_t* output, DTWBlock* block, DTWSettings* settings) {
#if defined(_OPENMP)
    idx_t r, c, r_i, c_i;
    idx_t length;
    idx_t *cbs, *rls;
    if (dtw_distances_prepare(block, nb_rows, &cbs, &rls, &length, settings) != 0) {
        return 0;
    }
    r_i = 0;
    #pragma omp parallel for private(r_i, c_i, r, c) schedule(guided)
    for (r_i=0; r_i < (block->re - block->rb); r_i++) {
         r = block->rb + r_i;
         c_i = 0;
         for (c=cbs[r_i]; c<block->ce; c++) {
             double value = dtw_distance_ndim(&matrix[r*nb_cols*ndim], nb_cols,
                                                      &matrix[c*nb_cols*ndim], nb_cols,
                                                      ndim, settings);
            output[rls[r_i] + c_i] = value;
            c_i++;
         }
    }
    free(cbs);
    free(rls);
    return length;
#else
    printf("ERROR: DTAIDistanceC is compiled without OpenMP support.\n");
    return 0;
#endif
}
idx_t dtw_distances_ndim_matrix_parallel ( seq_t * matrix , idx_t nb_rows , idx_t nb_cols , int ndim , seq_t * output , DTWBlock * block , DTWSettings * settings ) { #if defined ( _OPENMP ) idx_t r , c , r_i , c_i ; idx_t length ; idx_t * cbs , * rls ; if ( dtw_distances_prepare ( block , nb_rows , & cbs , & rls , & length , settings ) != 0 ) { return 0 ; } r_i = 0 ; #pragma  omp parallel for private(r_i, c_i, r, c) schedule(guided) for ( r_i = 0 ; r_i < ( block -> re - block -> rb ) ; r_i ++ ) { r = block -> rb + r_i ; c_i = 0 ; for ( c = cbs [ r_i ] ; c < block -> ce ; c ++ ) { double value = dtw_distance_ndim ( & matrix [ r * nb_cols * ndim ] , nb_cols , & matrix [ c * nb_cols * ndim ] , nb_cols , ndim , settings ) ; output [ rls [ r_i ] + c_i ] = value ; c_i ++ ; } } free ( cbs ) ; free ( rls ) ; return length ; #else printf ( " \n " ) ; return 0 ; #endif }
Distance matrix for n-dimensional DTW, executed on a 3-dimensional array and in parallel.
Distance matrix for n - dimensional DTW executed on a 3 - dimensional array and in parallel .
//        printf("pi=%zu - r=%zu->%zu - c=%zu - value=%.4f\n", pi, r, r*nb_cols, c, value);