Rcpp matrix entrywise exponential calculation using omp parallelization

36 views Asked by At

I want to calculate the entrywise exponential of a large matrix X and store the resule in another matrix Y using omp parallelization in Rcpp (or maybe RcppArmadillo).

Using regular omp parallelization method such as the following Rcpp code:

double X[row][col], Y[row][col];
#pragma omp parallel for shared(X,Y)
for(i=0; i<row; i++){    
    for(j=0; j<col; j++){        
        X[i][j] = 0.0;        
        Y[i][j] = exp(X[i][j]);    
    } 
}

will fail since google searching tells me that exp() function is not thread safe. Is there any way to fix it?

0

There are 0 answers