dtaidistance/lib/DTAIDistanceC/DTAIDistanceC/dd_dtw_openmp.c
/*!
 Distance matrix for n-dimensional DTW, executed on a list of pointers to arrays and in parallel.
 
@see dtw_distances_ndim_ptrs
 */
Distance matrix for n-dimensional DTW, executed on a list of pointers to arrays and in parallel.
Distance matrix for n - dimensional DTW executed on a list of pointers to arrays and in parallel .
idx_t dtw_distances_ndim_ptrs_parallel(seq_t **ptrs, idx_t nb_ptrs, idx_t* lengths, 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_ptrs, &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(ptrs[r], lengths[r],
                          ptrs[c], lengths[c],
                          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_ptrs_parallel ( seq_t * * ptrs , idx_t nb_ptrs , idx_t * lengths , 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_ptrs , & 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 ( ptrs [ r ] , lengths [ r ] , ptrs [ c ] , lengths [ c ] , 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 list of pointers to arrays and in parallel.
Distance matrix for n - dimensional DTW executed on a list of pointers to arrays and in parallel .
//        printf("pi=%zu - r=%zu - c=%zu - value=%.4f\n", pi, r, c, value);